Package moves, new fn in Rect, new bound adapters

v5stable
Ondřej Hruška 10 years ago
parent fa8792a904
commit 0236e779c3
  1. 2
      src/mightypork/gamecore/audio/DeferredAudio.java
  2. 4
      src/mightypork/gamecore/audio/SoundSystem.java
  3. 2
      src/mightypork/gamecore/audio/players/EffectPlayer.java
  4. 2
      src/mightypork/gamecore/control/bus/events/MouseButtonEvent.java
  5. 4
      src/mightypork/gamecore/control/bus/events/MouseMotionEvent.java
  6. 2
      src/mightypork/gamecore/control/bus/events/ScreenChangeEvent.java
  7. 4
      src/mightypork/gamecore/gui/components/AbstractComponent.java
  8. 4
      src/mightypork/gamecore/gui/components/PluggableRenderable.java
  9. 2
      src/mightypork/gamecore/gui/components/layout/AbstractLayout.java
  10. 2
      src/mightypork/gamecore/gui/components/layout/ColumnHolder.java
  11. 2
      src/mightypork/gamecore/gui/components/layout/RowHolder.java
  12. 8
      src/mightypork/gamecore/gui/components/painters/AbstractPainter.java
  13. 6
      src/mightypork/gamecore/gui/components/painters/TextPainter.java
  14. 2
      src/mightypork/gamecore/gui/screens/LayeredScreen.java
  15. 4
      src/mightypork/gamecore/gui/screens/Screen.java
  16. 4
      src/mightypork/gamecore/gui/screens/ScreenLayer.java
  17. 4
      src/mightypork/gamecore/input/InputSystem.java
  18. 4
      src/mightypork/gamecore/render/DisplaySystem.java
  19. 6
      src/mightypork/gamecore/render/Render.java
  20. 6
      src/mightypork/gamecore/render/fonts/FontRenderer.java
  21. 2
      src/mightypork/gamecore/render/fonts/GLFont.java
  22. 2
      src/mightypork/gamecore/render/fonts/impl/CachedFont.java
  23. 2
      src/mightypork/gamecore/render/fonts/impl/DeferredFont.java
  24. 2
      src/mightypork/gamecore/render/fonts/impl/NullFont.java
  25. 2
      src/mightypork/gamecore/render/textures/DeferredTexture.java
  26. 2
      src/mightypork/gamecore/render/textures/TextureBank.java
  27. 4
      src/mightypork/gamecore/render/textures/TxQuad.java
  28. 4
      src/mightypork/rogue/screens/LayerFps.java
  29. 2
      src/mightypork/rogue/screens/test_bouncyboxes/BouncyBox.java
  30. 2
      src/mightypork/rogue/screens/test_bouncyboxes/LayerBouncyBoxes.java
  31. 14
      src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java
  32. 6
      src/mightypork/rogue/screens/test_font/ScreenTestFont.java
  33. 14
      src/mightypork/test/TestConstr.java
  34. 8
      src/mightypork/test/TestCoords.java
  35. 6
      src/mightypork/test/TestVec.java
  36. 4
      src/mightypork/utils/config/PropertyManager.java
  37. 2
      src/mightypork/utils/math/Calc.java
  38. 2
      src/mightypork/utils/math/Polar.java
  39. 2
      src/mightypork/utils/math/animation/AnimDouble.java
  40. 970
      src/mightypork/utils/math/constraints/ConstraintFactory.java
  41. 19
      src/mightypork/utils/math/constraints/PluggableNumBound.java
  42. 4
      src/mightypork/utils/math/constraints/PluggableRectBound.java
  43. 16
      src/mightypork/utils/math/constraints/PluggableVectBound.java
  44. 2
      src/mightypork/utils/math/constraints/RectBound.java
  45. 57
      src/mightypork/utils/math/constraints/RectCache.java
  46. 2
      src/mightypork/utils/math/constraints/VectBound.java
  47. 3
      src/mightypork/utils/math/constraints/num/Num.java
  48. 2
      src/mightypork/utils/math/constraints/num/NumAdapter.java
  49. 5
      src/mightypork/utils/math/constraints/num/NumBound.java
  50. 25
      src/mightypork/utils/math/constraints/num/NumBoundAdapter.java
  51. 8
      src/mightypork/utils/math/constraints/num/NumConst.java
  52. 2
      src/mightypork/utils/math/constraints/num/NumDigest.java
  53. 2
      src/mightypork/utils/math/constraints/num/NumMutable.java
  54. 2
      src/mightypork/utils/math/constraints/num/NumVar.java
  55. 106
      src/mightypork/utils/math/constraints/rect/Rect.java
  56. 6
      src/mightypork/utils/math/constraints/rect/RectAdapter.java
  57. 8
      src/mightypork/utils/math/constraints/rect/RectBoundAdapter.java
  58. 136
      src/mightypork/utils/math/constraints/rect/RectConst.java
  59. 4
      src/mightypork/utils/math/constraints/rect/RectDigest.java
  60. 4
      src/mightypork/utils/math/constraints/rect/RectMutable.java
  61. 6
      src/mightypork/utils/math/constraints/rect/RectVar.java
  62. 4
      src/mightypork/utils/math/constraints/rect/RectVectAdapter.java
  63. 12
      src/mightypork/utils/math/constraints/vect/Vect.java
  64. 2
      src/mightypork/utils/math/constraints/vect/VectAdapter.java
  65. 2
      src/mightypork/utils/math/constraints/vect/VectAnimated.java
  66. 26
      src/mightypork/utils/math/constraints/vect/VectBoundAdapter.java
  67. 14
      src/mightypork/utils/math/constraints/vect/VectConst.java
  68. 2
      src/mightypork/utils/math/constraints/vect/VectDigest.java
  69. 2
      src/mightypork/utils/math/constraints/vect/VectMutable.java
  70. 6
      src/mightypork/utils/math/constraints/vect/VectNumAdapter.java
  71. 2
      src/mightypork/utils/math/constraints/vect/VectVar.java
  72. 4
      src/mightypork/utils/objects/Convert.java

@ -6,7 +6,7 @@ import java.io.IOException;
import mightypork.gamecore.loading.DeferredResource;
import mightypork.utils.annotations.Alias;
import mightypork.utils.files.FileUtils;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
import org.newdawn.slick.openal.Audio;
import org.newdawn.slick.openal.SoundStore;

@ -12,8 +12,8 @@ import mightypork.gamecore.control.bus.clients.RootBusNode;
import mightypork.gamecore.control.bus.events.ResourceLoadRequest;
import mightypork.gamecore.control.timing.Updateable;
import mightypork.utils.math.Calc.Buffers;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectVar;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectVar;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.AL10;

@ -3,7 +3,7 @@ package mightypork.gamecore.audio.players;
import mightypork.gamecore.audio.DeferredAudio;
import mightypork.gamecore.audio.Volume;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -2,7 +2,7 @@ package mightypork.gamecore.control.bus.events;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -2,8 +2,8 @@ package mightypork.gamecore.control.bus.events;
import mightypork.gamecore.control.bus.events.types.UnloggedEvent;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectConst;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectConst;
/**

@ -1,7 +1,7 @@
package mightypork.gamecore.control.bus.events;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -4,7 +4,7 @@ package mightypork.gamecore.gui.components;
import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.control.AppSubModule;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.constraints.rect.Rect;
public abstract class AbstractComponent extends AppSubModule implements PluggableRenderable {
@ -18,7 +18,7 @@ public abstract class AbstractComponent extends AppSubModule implements Pluggabl
@Override
public void setContext(RectBound context)
public void setRect(RectBound context)
{
this.context = context;
}

@ -3,7 +3,7 @@ package mightypork.gamecore.gui.components;
import mightypork.utils.math.constraints.PluggableRectBound;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.constraints.rect.Rect;
/**
@ -22,6 +22,6 @@ public interface PluggableRenderable extends Renderable, PluggableRectBound {
@Override
void setContext(RectBound rect);
void setRect(RectBound rect);
}

@ -37,7 +37,7 @@ public abstract class AbstractLayout extends AbstractComponent {
*/
public AbstractLayout(AppAccess app, RectBound context) {
super(app);
setContext(context);
setRect(context);
}

@ -51,7 +51,7 @@ public class ColumnHolder extends AbstractLayout {
{
if (elem == null) return;
elem.setContext(column(this, cols, col++));
elem.setRect(column(this, cols, col++));
attach(elem);
}

@ -51,7 +51,7 @@ public class RowHolder extends AbstractLayout {
{
if (elem == null) return;
elem.setContext(row(this, rows, row++));
elem.setRect(row(this, rows, row++));
attach(elem);
}

@ -4,8 +4,8 @@ package mightypork.gamecore.gui.components.painters;
import mightypork.gamecore.gui.components.PluggableRenderable;
import mightypork.gamecore.gui.components.Renderable;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.RectBoundAdapter;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.RectBoundAdapter;
/**
@ -27,8 +27,8 @@ public abstract class AbstractPainter extends RectBoundAdapter implements Plugga
@Override
public void setContext(RectBound rect)
public void setRect(RectBound rect)
{
super.setContext(rect);
super.setRect(rect);
}
}

@ -5,9 +5,9 @@ import mightypork.gamecore.render.fonts.FontRenderer;
import mightypork.gamecore.render.fonts.FontRenderer.Align;
import mightypork.gamecore.render.fonts.GLFont;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectVar;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectVar;
import mightypork.utils.string.StringProvider;
import mightypork.utils.string.StringProvider.StringWrapper;

@ -5,7 +5,7 @@ import java.util.Collection;
import java.util.TreeSet;
import mightypork.gamecore.control.AppAccess;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -11,8 +11,8 @@ import mightypork.gamecore.input.KeyStroke;
import mightypork.gamecore.render.Render;
import mightypork.utils.annotations.DefaultImpl;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -8,8 +8,8 @@ import mightypork.gamecore.input.KeyBindingPool;
import mightypork.gamecore.input.KeyStroke;
import mightypork.utils.annotations.DefaultImpl;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -9,8 +9,8 @@ import mightypork.gamecore.control.bus.events.MouseMotionEvent;
import mightypork.gamecore.control.timing.Updateable;
import mightypork.rogue.events.ActionRequest;
import mightypork.rogue.events.ActionRequest.RequestType;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectVar;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectVar;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;

@ -11,8 +11,8 @@ import mightypork.gamecore.control.bus.events.ScreenChangeEvent;
import mightypork.gamecore.control.timing.FpsMeter;
import mightypork.utils.logging.Log;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.vect.Vect;
import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;

@ -9,9 +9,9 @@ import mightypork.gamecore.render.textures.TxQuad;
import mightypork.utils.files.FileUtils;
import mightypork.utils.logging.Log;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectConst;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectConst;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.opengl.Texture;

@ -3,9 +3,9 @@ package mightypork.gamecore.render.fonts;
import mightypork.gamecore.render.Render;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectVar;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectVar;
/**

@ -2,7 +2,7 @@ package mightypork.gamecore.render.fonts;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -23,7 +23,7 @@ import mightypork.gamecore.render.fonts.GLFont;
import mightypork.gamecore.render.textures.FilterMode;
import mightypork.utils.logging.Log;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.vect.VectConst;
import mightypork.utils.math.constraints.vect.VectConst;
import org.lwjgl.BufferUtils;
import org.lwjgl.util.glu.GLU;

@ -13,7 +13,7 @@ import mightypork.gamecore.render.textures.FilterMode;
import mightypork.utils.annotations.Alias;
import mightypork.utils.files.FileUtils;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -4,7 +4,7 @@ package mightypork.gamecore.render.fonts.impl;
import mightypork.gamecore.render.fonts.GLFont;
import mightypork.utils.logging.Log;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -5,7 +5,7 @@ import mightypork.gamecore.loading.DeferredResource;
import mightypork.gamecore.loading.MustLoadInMainThread;
import mightypork.gamecore.render.Render;
import mightypork.utils.annotations.Alias;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.constraints.rect.Rect;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.opengl.Texture;

@ -6,7 +6,7 @@ import java.util.HashMap;
import mightypork.gamecore.control.AppAccess;
import mightypork.gamecore.control.AppAdapter;
import mightypork.gamecore.control.bus.events.ResourceLoadRequest;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.constraints.rect.Rect;
import org.newdawn.slick.opengl.Texture;

@ -1,8 +1,8 @@
package mightypork.gamecore.render.textures;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.rect.RectConst;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.RectConst;
import org.newdawn.slick.opengl.Texture;

@ -12,7 +12,7 @@ import mightypork.gamecore.render.fonts.GLFont;
import mightypork.rogue.Res;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.string.StringProvider;
@ -49,7 +49,7 @@ public class LayerFps extends ScreenLayer {
}
});
tp.setContext(constraint);
tp.setRect(constraint);
tp.setShadow(RGB.BLACK, Vect.ONE);
}

@ -9,8 +9,8 @@ import mightypork.gamecore.render.Render;
import mightypork.utils.math.animation.AnimDouble;
import mightypork.utils.math.animation.Easing;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.NumBound;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.constraints.num.NumBound;
public class BouncyBox extends AbstractPainter implements Updateable {

@ -14,7 +14,7 @@ import mightypork.gamecore.render.fonts.FontRenderer.Align;
import mightypork.rogue.Res;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.vect.VectConst;
import mightypork.utils.math.constraints.vect.VectConst;
public class LayerBouncyBoxes extends ScreenLayer {

@ -17,10 +17,10 @@ import mightypork.rogue.Res;
import mightypork.utils.math.animation.AnimDouble;
import mightypork.utils.math.animation.Easing;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.num.Num;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectAnimated;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectAnimated;
public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButtonEvent.Listener {
@ -43,7 +43,7 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
cat = new ImagePainter(Res.getTxQuad("test.kitten"));
cat.setContext(Rect.make(size, size).centerTo(pos));
cat.setRect(Rect.make(size, size).centerTo(pos));
tp = new TextPainter(Res.getFont("default"));
tp.setAlign(Align.CENTER);
@ -51,11 +51,11 @@ public class LayerFlyingCat extends ScreenLayer implements Updateable, MouseButt
tp.setText("Meow!");
tp.setShadow(RGB.dark(0.8), Vect.make(2, 2));
tp.setContext(Rect.make(64, 64).centerTo(mouse()));
tp.setRect(Rect.make(64, 64).centerTo(mouse()));
qp = QuadPainter.gradV(RGB.YELLOW, RGB.RED);
qp.setContext(cat.getRect().bottomLeft().expand(size.half(), Num.ZERO, Num.ZERO, size.half()));
qp.setRect(cat.getRect().bottomLeft().expand(size.half(), Num.ZERO, Num.ZERO, size.half()));
/*
* Register keys

@ -7,8 +7,8 @@ import mightypork.gamecore.gui.screens.Screen;
import mightypork.gamecore.render.fonts.FontRenderer.Align;
import mightypork.rogue.Res;
import mightypork.utils.math.color.RGB;
import mightypork.utils.math.num.Num;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.rect.Rect;
public class ScreenTestFont extends Screen {
@ -25,7 +25,7 @@ public class ScreenTestFont extends Screen {
final Num h = bounds().height().mul(0.1);
final Rect strbox = Rect.make(Num.ZERO, h).centerTo(bounds());
tp.setContext(strbox);
tp.setRect(strbox);
}

@ -3,13 +3,13 @@ package mightypork.test;
import java.util.Locale;
import mightypork.utils.math.num.Num;
import mightypork.utils.math.num.NumVar;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.rect.RectConst;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectConst;
import mightypork.utils.math.vect.VectVar;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.num.NumVar;
import mightypork.utils.math.constraints.rect.Rect;
import mightypork.utils.math.constraints.rect.RectConst;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectConst;
import mightypork.utils.math.constraints.vect.VectVar;
public class TestConstr {

@ -1,10 +1,10 @@
package mightypork.test;
import mightypork.utils.math.num.Num;
import mightypork.utils.math.num.NumVar;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectVar;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.num.NumVar;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectVar;
public class TestCoords {

@ -1,9 +1,9 @@
package mightypork.test;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectConst;
import mightypork.utils.math.vect.VectVar;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectConst;
import mightypork.utils.math.constraints.vect.VectVar;
public class TestVec {

@ -10,8 +10,8 @@ import java.util.Map.Entry;
import java.util.TreeMap;
import mightypork.utils.math.Range;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectConst;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectConst;
import mightypork.utils.objects.Convert;

@ -7,7 +7,7 @@ import java.util.List;
import java.util.Random;
import mightypork.utils.math.animation.Easing;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
import org.lwjgl.BufferUtils;

@ -3,7 +3,7 @@ package mightypork.utils.math;
import mightypork.utils.math.Calc.Deg;
import mightypork.utils.math.Calc.Rad;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -4,7 +4,7 @@ package mightypork.utils.math.animation;
import mightypork.gamecore.control.timing.Pauseable;
import mightypork.gamecore.control.timing.Updateable;
import mightypork.utils.math.Calc;
import mightypork.utils.math.num.NumMutable;
import mightypork.utils.math.constraints.num.NumMutable;
/**

@ -1,970 +0,0 @@
package mightypork.utils.math.constraints;
import mightypork.gamecore.control.timing.Poller;
import mightypork.utils.math.num.Num;
import mightypork.utils.math.num.Num;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.rect.RectVal;
import mightypork.utils.math.rect.RectView;
import mightypork.utils.math.rect.RectView;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectAdapter;
import mightypork.utils.math.vect.VectVal;
import mightypork.utils.math.vect.Vect;
/**
* Constraint factory.<br>
* Import statically for best experience.
*
* @author MightyPork
*/
public class ConstraintFactory {
public static RectCache cached(final Poller poller, final RectBound rc)
{
return new RectCache(poller, rc);
}
/**
* Convert {@link Number} to {@link NumBound} if needed
*
* @param o unknown numeric value
* @return converted
*/
private static NumBound toNumberBound(final Object o)
{
if (o instanceof NumBound) return (NumBound) o;
if (o instanceof Number) return new Num() {
@Override
public double value()
{
return ((Number) o).doubleValue();
}
};
throw new IllegalArgumentException("Invalid numeric type.");
}
/**
* Convert {@link Number} or {@link NumBound} to double (current value)
*
* @param o unknown numeric value
* @return double value
*/
private static double eval(final Object o)
{
return o == null ? 0 : toNumberBound(o).getNum().value();
}
/**
* Convert as {@link VectBound} to a {@link Vect}
*
* @param vectBound vect bound
* @return contained vect
*/
private static Vect eval(final VectBound vectBound)
{
return vectBound == null ? Vect.ZERO : vectBound.getVect();
}
/**
* Convert a {@link RectBound} to a {@link Rect}
*
* @param rectBound rect bound
* @return contained rect
*/
private static RectView eval(final RectBound rectBound)
{
return rectBound == null ? Rect.ZERO : rectBound.getRect();
}
public static Num min(final Object a, final Object b)
{
return new Num() {
@Override
public double value()
{
return Math.min(eval(a), eval(b));
}
};
}
public static Num max(final Object a, final Object b)
{
return new Num() {
@Override
public double value()
{
return Math.max(eval(a), eval(b));
}
};
}
public static Num abs(final NumBound a)
{
return new Num() {
@Override
public double value()
{
return Math.abs(a.value());
}
};
}
public static Num half(final NumBound a)
{
return new Num() {
@Override
public double value()
{
return a.value() / 2;
}
};
}
public static Num round(final NumBound a)
{
return new Num() {
@Override
public double value()
{
return Math.round(a.value());
}
};
}
public static RectBound round(final RectBound r)
{
return new RectBound() {
@Override
public RectView getRect()
{
return eval(r).round();
}
};
}
public static Num ceil(final NumBound a)
{
return new Num() {
@Override
public double value()
{
return Math.ceil(a.value());
}
};
}
public static Num floor(final NumBound a)
{
return new Num() {
@Override
public double value()
{
return Math.floor(a.value());
}
};
}
public static Num neg(final NumBound a)
{
return new Num() {
@Override
public double value()
{
return -a.value();
}
};
}
public static Num add(final Object a, final Object b)
{
return new Num() {
@Override
public double value()
{
return eval(a) + eval(b);
}
};
}
public static Num sub(final Object a, final Object b)
{
return new Num() {
@Override
public double value()
{
return eval(a) - eval(b);
}
};
}
public static Num mul(final Object a, final Object b)
{
return new Num() {
@Override
public double value()
{
return eval(a) * eval(b);
}
};
}
public static Num half(final Object a)
{
return mul(a, 0.5);
}
public static Num div(final Object a, final Object b)
{
return new Num() {
@Override
public double value()
{
return eval(a) / eval(b);
}
};
}
public static Num perc(final Object whole, final Object percent)
{
return new Num() {
@Override
public double value()
{
return eval(whole) * (eval(percent) / 100);
}
};
}
public static RectBound row(final RectBound r, final int rows, final int index)
{
return new RectBound() {
@Override
public RectView getRect()
{
RectView rv = eval(r);
final double height = rv.height();
final double perRow = height / rows;
final VectVal origin = rv.origin().add(0, perRow * index);
final VectVal size = rv.size().setY(perRow);
return RectVal.make(origin, size);
}
};
}
public static RectBound column(final RectBound r, final int columns, final int index)
{
return new RectBound() {
@Override
public RectView getRect()
{
RectView rv = eval(r);
final double width = rv.width();
final double perCol = width / columns;
final VectVal origin = rv.origin().add(perCol * index, 0);
final VectVal size = rv.size().setX(perCol);
return RectVal.make(origin, size);
}
};
}
public static RectBound tile(final RectBound r, final int rows, final int cols, final int left, final int top)
{
return new RectBound() {
@Override
public RectView getRect()
{
RectView rv = eval(r);
final double height = rv.height();
final double width = rv.height();
final double perRow = height / rows;
final double perCol = width / cols;
final VectVal origin = rv.origin().add(perCol * left, perRow * (rows - top - 1));
return RectVal.make(origin, perCol, perRow);
}
};
}
public static RectBound shrink(RectBound r, Object shrink)
{
return shrink(r, shrink, shrink, shrink, shrink);
}
public static RectBound shrink(RectBound context, Object horiz, Object vert)
{
return shrink(context, horiz, vert, horiz, vert);
}
public static RectBound shrink(final RectBound r, final Object left, final Object top, final Object right, final Object bottom)
{
return new RectBound() {
@Override
public RectView getRect()
{
return eval(r).shrink(eval(left), eval(top), eval(right), eval(bottom));
}
};
}
public static RectBound shrinkTop(final RectBound r, final Object shrink)
{
return new RectBound() {
@Override
public RectView getRect()
{
return eval(r).shrink(0, eval(shrink), 0, 0);
}
};
}
public static RectBound shrinkBottom(final RectBound r, final Object shrink)
{
return new RectBound() {
@Override
public RectView getRect()
{
return eval(r).shrink(0, 0, 0, eval(shrink));
}
};
}
public static RectBound shrinkLeft(final RectBound r, final Object shrink)
{
return new RectBound() {
@Override
public RectView getRect()
{
return eval(r).shrink(eval(shrink), 0, 0, 0);
}
};
}
public static RectBound shrinkRight(final RectBound r, final Object shrink)
{
return new RectBound() {
@Override
public RectView getRect()
{
return eval(r).shrink(0, 0, eval(shrink), 0);
}
};
}
public static RectBound grow(RectBound r, Object grow)
{
return grow(r, grow, grow, grow, grow);
}
public static RectBound grow(RectBound r, Object horiz, Object vert)
{
return grow(r, horiz, vert, horiz, vert);
}
public static RectBound grow(final RectBound r, final Object left, final Object right, final Object top, final Object bottom)
{
return new RectBound() {
@Override
public RectView getRect()
{
return eval(r).grow(eval(left), eval(right), eval(top), eval(bottom));
}
};
}
public static RectBound growUp(final RectBound r, final Object grow)
{
return new RectBound() {
@Override
public RectView getRect()
{
return eval(r).grow(0, eval(grow), 0, 0);
}
};
}
public static RectBound growDown(final RectBound r, final Object grow)
{
return new RectBound() {
@Override
public RectView getRect()
{
return eval(r).grow(0, 0, 0, eval(grow));
}
};
}
public static RectBound growLeft(final RectBound r, final Object grow)
{
return new RectBound() {
@Override
public RectView getRect()
{
return eval(r).grow(eval(grow), 0, 0, 0);
}
};
}
public static RectBound growRight(final RectBound r, final Object grow)
{
return new RectBound() {
@Override
public RectView getRect()
{
return eval(r).grow(0, 0, eval(grow), 0);
}
};
}
public static RectBound box(final Object side)
{
return box(side, side);
}
public static RectBound box(final VectBound origin, final Object width, final Object height)
{
return new RectBound() {
@Override
public RectView getRect()
{
return RectVal.make(eval(origin), eval(width), eval(height));
}
};
}
public static RectBound box(final Object width, final Object height)
{
return box(Vect.ZERO, width, height);
}
public static RectBound box(final RectBound r, final Object width, final Object height)
{
return new RectBound() {
@Override
public RectView getRect()
{
final RectView origin = eval(r);
return RectVal.make(origin.x(), origin.y(), eval(width), eval(height));
}
};
}
public static RectBound box(final RectBound r, final Object x, final Object y, final Object width, final Object height)
{
return new RectBound() {
@Override
public RectView getRect()
{
final VectVal origin = eval(r).origin();
return RectVal.make(origin.x() + eval(x), origin.y() + eval(y), eval(width), eval(height));
}
};
}
public static RectBound centerTo(final RectBound r, final RectBound centerTo)
{
return new RectBound() {
@Override
public RectView getRect()
{
final VectVal size = eval(r).size();
final VectVal center = eval(centerTo).center();
return RectVal.make(center.sub(size.half()), size);
}
};
}
public static RectBound centerTo(final RectBound r, final VectBound centerTo)
{
return new RectBound() {
@Override
public RectView getRect()
{
final VectVal size = eval(r).size();
return RectVal.make(eval(centerTo).sub(size.half()), size);
}
};
}
public static RectBound centerTo(final RectBound r, final Object x, final Object y)
{
return new RectBound() {
@Override
public RectView getRect()
{
final VectVal size = eval(r).size();
final VectVal v = VectVal.make(eval(x), eval(y));
return RectVal.make(v.sub(size.half()), size);
}
};
}
public static RectBound move(final RectBound r, final VectBound move)
{
return new RectBound() {
@Override
public RectView getRect()
{
return eval(r).move(eval(move));
}
};
}
public static RectBound move(final RectBound r, final Object x, final Object y)
{
return new RectBound() {
@Override
public RectView getRect()
{
return eval(r).move(eval(x), eval(y));
}
};
}
/**
* Make a rect around coord
*
* @param c coord
* @param allSides size to grow on all sides
* @return rect constraint
*/
public static RectBound expand(final VectBound c, final Object allSides)
{
return expand(c, allSides, allSides, allSides, allSides);
}
/**
* Make a rect around coord
*
* @param c coord
* @param horizontal horisontal grow (left, right)
* @param vertical vertical grow (top, bottom)
* @return rect constraint
*/
public static RectBound expand(final VectBound c, final Object horizontal, final Object vertical)
{
return expand(c, horizontal, vertical, horizontal, vertical);
}
/**
* Make a rect around coord, growing by given amounts
*
* @param c coord
* @param top
* @param right
* @param bottom
* @param left
* @return rect constraint
*/
public static RectBound expand(final VectBound c, final Object top, final Object right, final Object bottom, final Object left)
{
return new RectBound() {
@Override
public RectView getRect()
{
final double t = eval(top);
final double r = eval(right);
final double b = eval(bottom);
final double l = eval(left);
final Vect v = eval(c);
return RectVal.make(v.x() - l, v.y() - t, l + r, t + b);
}
};
}
public static RectBound edgeLeft(final RectBound r)
{
return new RectBound() {
@Override
public RectView getRect()
{
RectView v = eval(r);
return v.shrink(NumBound.ZERO, NumBound.ZERO, v.width(), NumBound.ZERO);
}
};
}
public static RectBound edgeTop(final RectBound r)
{
return new RectBound() {
@Override
public RectView getRect()
{
RectView rv = eval(r);
return rv.shrink(NumBound.ZERO,NumBound.ZERO, NumBound.ZERO, rv.height());
}
};
}
public static RectBound edgeRight(final RectBound r)
{
return new RectBound() {
@Override
public RectView getRect()
{
RectView rv = eval(r);
return rv.shrink(rv.width(), NumBound.ZERO, NumBound.ZERO, NumBound.ZERO);
}
};
}
public static RectBound edgeBottom(final RectBound r)
{
return new RectBound() {
@Override
public RectView getRect()
{
RectView rv = eval(r);
return rv.shrink(NumBound.ZERO, rv.height(), NumBound.ZERO, NumBound.ZERO);
}
};
}
public static Vect neg(final VectBound c)
{
return mul(c, -1);
}
public static Vect half(final VectBound c)
{
return mul(c, 0.5);
}
public static Vect add(final VectBound c1, final VectBound c2)
{
return new VectAdapter() {
@Override
public Vect getSource()
{
return eval(c1).add(eval(c2));
}
};
}
public static Vect add(final VectBound c, final Object x, final Object y)
{
return add(c, x, y, 0);
}
public static Vect add(final VectBound c, final Object x, final Object y, final Object z)
{
return new VectAdapter() {
@Override
public Vect getSource()
{
return eval(c).add(eval(x), eval(y), eval(z));
}
};
}
public static Vect sub(final VectBound c1, final VectBound c2)
{
return new VectAdapter() {
@Override
public Vect getSource()
{
return eval(c1).sub(eval(c2));
}
};
}
public static Vect sub(final VectBound c, final Object x, final Object y)
{
return sub(c, x, y, 0);
}
public static Vect sub(final VectBound c, final Object x, final Object y, final Object z)
{
return new VectAdapter() {
@Override
public Vect getSource()
{
return eval(c).sub(eval(x), eval(y), eval(z));
}
};
}
public static Vect mul(final VectBound c, final Object mul)
{
return new VectAdapter() {
@Override
public Vect getSource()
{
return eval(c).mul(eval(mul));
}
};
}
public static Vect norm(final VectBound c, final Object norm)
{
return new VectAdapter() {
@Override
public Vect getSource()
{
return eval(c).norm(eval(norm));
}
};
}
public static Vect origin(final RectBound r)
{
return new VectAdapter() {
@Override
public Vect getSource()
{
return eval(r).origin();
}
};
}
public static Vect size(final RectBound r)
{
return new VectAdapter() {
@Override
public Vect getSource()
{
return eval(r).size();
}
};
}
public static Num height(final RectBound r)
{
return size(r).yC();
}
public static Num width(final RectBound r)
{
return size(r).xC();
}
public static Vect center(final RectBound r)
{
return add(origin(r), half(size(r)));
}
public static Vect topLeft(final RectBound r)
{
return origin(r);
}
public static Vect topRight(final RectBound r)
{
return add(origin(r), width(r), 0);
}
public static Vect bottomLeft(final RectBound r)
{
return add(origin(r), 0, width(r));
}
public static Vect bottomRight(final RectBound r)
{
return add(origin(r), size(r));
}
public static Vect topCenter(final RectBound r)
{
return add(origin(r), half(width(r)), 0);
}
public static Vect bottomCenter(final RectBound r)
{
return add(origin(r), half(width(r)), width(r));
}
public static Vect centerLeft(final RectBound r)
{
return add(origin(r), 0, half(width(r)));
}
public static Vect centerRight(final RectBound r)
{
return add(origin(r), width(r), half(width(r)));
}
/**
* Zero-sized RectView at given coord
*
* @param c coord
* @return rect
*/
public static RectBound zeroRect(final VectBound c)
{
return new RectBound() {
@Override
public RectView getRect()
{
Vect cv = eval(c);
return new RectView() {
@Override
public Vect size()
{
return Vect.ZERO;
}
@Override
public Vect origin()
{
return null;
}
};RectVal.make.make(cv.x(), cv.y(), 0, 0);
}
};
}
}

@ -0,0 +1,19 @@
package mightypork.utils.math.constraints;
import mightypork.utils.math.constraints.num.NumBound;
/**
* Pluggable numeric constraint
*
* @author MightyPork
*/
public interface PluggableNumBound extends NumBound {
/**
* @param num bound to set
*/
abstract void setNum(NumBound num);
}

@ -2,7 +2,7 @@ package mightypork.utils.math.constraints;
/**
* Interface for constraints that can be assigned context
* Pluggable rect bound
*
* @author MightyPork
*/
@ -11,6 +11,6 @@ public interface PluggableRectBound extends RectBound {
/**
* @param rect context to set
*/
abstract void setContext(RectBound rect);
abstract void setRect(RectBound rect);
}

@ -0,0 +1,16 @@
package mightypork.utils.math.constraints;
/**
* Pluggable vector constraint
*
* @author MightyPork
*/
public interface PluggableVectBound extends VectBound {
/**
* @param num bound to set
*/
abstract void setVect(VectBound num);
}

@ -1,7 +1,7 @@
package mightypork.utils.math.constraints;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.constraints.rect.Rect;
/**

@ -1,57 +0,0 @@
package mightypork.utils.math.constraints;
import mightypork.gamecore.control.timing.Pollable;
import mightypork.gamecore.control.timing.Poller;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.rect.RectMutable;
/**
* {@link RectBound} cache, used for caching computed Rect from a complex
* {@link RectBound}.<br>
* Calculates only when polled.
*
* @author MightyPork
*/
public class RectCache implements RectBound, Pollable {
private final RectBound observed;
private final RectMutable cached = Rect.makeVar();
/**
* @param observed cached constraint
*/
public RectCache(RectBound observed) {
this.observed = observed;
poll();
}
/**
* Create and join a poller
*
* @param poller poller to join
* @param rc observed constraint
*/
public RectCache(Poller poller, RectBound rc) {
this(rc);
poller.add(this);
}
@Override
public Rect getRect()
{
return cached;
}
@Override
public void poll()
{
cached.setTo(observed.getRect());
}
}

@ -1,7 +1,7 @@
package mightypork.utils.math.constraints;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -1,9 +1,8 @@
package mightypork.utils.math.num;
package mightypork.utils.math.constraints.num;
import mightypork.utils.annotations.FactoryMethod;
import mightypork.utils.math.Calc;
import mightypork.utils.math.constraints.NumBound;
public abstract class Num implements NumBound {

@ -1,4 +1,4 @@
package mightypork.utils.math.num;
package mightypork.utils.math.constraints.num;
public abstract class NumAdapter extends Num {

@ -1,7 +1,4 @@
package mightypork.utils.math.constraints;
import mightypork.utils.math.num.Num;
package mightypork.utils.math.constraints.num;
/**

@ -0,0 +1,25 @@
package mightypork.utils.math.constraints.num;
import mightypork.utils.math.constraints.PluggableNumBound;
public class NumBoundAdapter extends NumAdapter implements PluggableNumBound {
private NumBound backing = null;
@Override
public void setNum(NumBound rect)
{
this.backing = rect;
}
@Override
protected Num getSource()
{
return backing.getNum();
}
}

@ -1,8 +1,10 @@
package mightypork.utils.math.num;
package mightypork.utils.math.constraints.num;
/**
* Constant number
* Constant number.<br>
* It's arranged so that operations with constant arguments yield constant
* results.
*
* @author MightyPork
*/
@ -39,12 +41,14 @@ public class NumConst extends Num {
return this;
}
@Override
public NumDigest digest()
{
return (digest != null) ? digest : (digest = super.digest());
}
@Override
public NumConst add(double addend)
{

@ -1,4 +1,4 @@
package mightypork.utils.math.num;
package mightypork.utils.math.constraints.num;
public class NumDigest {

@ -1,4 +1,4 @@
package mightypork.utils.math.num;
package mightypork.utils.math.constraints.num;
/**

@ -1,4 +1,4 @@
package mightypork.utils.math.num;
package mightypork.utils.math.constraints.num;
/**

@ -1,12 +1,12 @@
package mightypork.utils.math.rect;
package mightypork.utils.math.constraints.rect;
import mightypork.utils.annotations.FactoryMethod;
import mightypork.utils.math.constraints.RectBound;
import mightypork.utils.math.num.Num;
import mightypork.utils.math.num.NumConst;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectConst;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.num.NumConst;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectConst;
/**
@ -332,6 +332,102 @@ public abstract class Rect implements RectBound {
}
public Rect shrinkLeft(final double shrink)
{
return growLeft(-shrink);
}
public Rect shrinkRight(final double shrink)
{
return growLeft(-shrink);
}
public Rect shrinkTop(final double shrink)
{
return growTop(-shrink);
}
public Rect shrinkBottom(final double shrink)
{
return growBottom(-shrink);
}
public Rect growLeft(final double shrink)
{
return grow(shrink, 0, 0, 0);
}
public Rect growRight(final double shrink)
{
return grow(0, shrink, 0, 0);
}
public Rect growTop(final double shrink)
{
return grow(0, 0, shrink, 0);
}
public Rect growBottom(final double shrink)
{
return grow(0, 0, 0, shrink);
}
public Rect shrinkLeft(final Num shrink)
{
return shrink(shrink, Num.ZERO, Num.ZERO, Num.ZERO);
}
public Rect shrinkRight(final Num shrink)
{
return shrink(Num.ZERO, shrink, Num.ZERO, Num.ZERO);
}
public Rect shrinkTop(final Num shrink)
{
return shrink(Num.ZERO, Num.ZERO, shrink, Num.ZERO);
}
public Rect shrinkBottom(final Num shrink)
{
return shrink(Num.ZERO, Num.ZERO, Num.ZERO, shrink);
}
public Rect growLeft(final Num shrink)
{
return grow(shrink, Num.ZERO, Num.ZERO, Num.ZERO);
}
public Rect growRight(final Num shrink)
{
return grow(Num.ZERO, shrink, Num.ZERO, Num.ZERO);
}
public Rect growTop(final Num shrink)
{
return grow(Num.ZERO, Num.ZERO, shrink, Num.ZERO);
}
public Rect growBottom(final Num shrink)
{
return grow(Num.ZERO, Num.ZERO, Num.ZERO, shrink);
}
/**
* Grow to sides
*

@ -1,8 +1,8 @@
package mightypork.utils.math.rect;
package mightypork.utils.math.constraints.rect;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectAdapter;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectAdapter;
/**

@ -1,8 +1,8 @@
package mightypork.utils.math.constraints;
package mightypork.utils.math.constraints.rect;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.rect.RectAdapter;
import mightypork.utils.math.constraints.PluggableRectBound;
import mightypork.utils.math.constraints.RectBound;
/**
@ -16,7 +16,7 @@ public abstract class RectBoundAdapter extends RectAdapter implements PluggableR
@Override
public void setContext(RectBound rect)
public void setRect(RectBound rect)
{
this.backing = rect;
}

@ -1,13 +1,15 @@
package mightypork.utils.math.rect;
package mightypork.utils.math.constraints.rect;
import mightypork.utils.math.num.NumConst;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectConst;
import mightypork.utils.math.constraints.num.NumConst;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectConst;
/**
* Rectangle with constant bounds, that can never change.
* Rectangle with constant bounds, that can never change.<br>
* It's arranged so that operations with constant arguments yield constant
* results.
*
* @author MightyPork
*/
@ -81,7 +83,7 @@ public class RectConst extends Rect {
{
return this; // already constant
}
@Override
public RectDigest digest()
@ -89,6 +91,7 @@ public class RectConst extends Rect {
return (digest != null) ? digest : (digest = super.digest());
}
@Override
public VectConst origin()
{
@ -115,8 +118,8 @@ public class RectConst extends Rect {
{
return Rect.make(pos.add(x, y), size);
}
public RectConst move(NumConst x, NumConst y)
{
return super.move(x, y).freeze();
@ -264,28 +267,27 @@ public class RectConst extends Rect {
}
@Override
public RectConst leftEdge()
{
return (v_edge_l != null) ? v_edge_l : (v_edge_l = super.leftEdge().freeze());
}
@Override
public RectConst rightEdge()
{
return (v_edge_r != null) ? v_edge_r : (v_edge_r = super.rightEdge().freeze());
}
@Override
public RectConst topEdge()
{
return (v_edge_t != null) ? v_edge_t : (v_edge_t = super.topEdge().freeze());
}
@Override
public RectConst bottomEdge()
{
@ -319,6 +321,110 @@ public class RectConst extends Rect {
}
@Override
public RectConst shrinkLeft(double shrink)
{
return super.shrinkLeft(shrink).freeze();
}
@Override
public RectConst shrinkRight(double shrink)
{
return super.shrinkRight(shrink).freeze();
}
@Override
public RectConst shrinkTop(double shrink)
{
return super.shrinkTop(shrink).freeze();
}
@Override
public RectConst shrinkBottom(double shrink)
{
return super.shrinkBottom(shrink).freeze();
}
@Override
public RectConst growLeft(double shrink)
{
return super.growLeft(shrink).freeze();
}
@Override
public RectConst growRight(double shrink)
{
return super.growRight(shrink).freeze();
}
@Override
public RectConst growTop(double shrink)
{
return super.growTop(shrink).freeze();
}
@Override
public RectConst growBottom(double shrink)
{
return super.growBottom(shrink).freeze();
}
public RectConst shrinkLeft(NumConst shrink)
{
return super.shrinkLeft(shrink).freeze();
}
public RectConst shrinkRight(NumConst shrink)
{
return super.shrinkRight(shrink).freeze();
}
public RectConst shrinkTop(NumConst shrink)
{
return super.shrinkTop(shrink).freeze();
}
public RectConst shrinkBottom(NumConst shrink)
{
return super.shrinkBottom(shrink).freeze();
}
public RectConst growLeft(NumConst shrink)
{
return super.growLeft(shrink).freeze();
}
public RectConst growRight(NumConst shrink)
{
return super.growRight(shrink).freeze();
}
public RectConst growTop(NumConst shrink)
{
return super.growTop(shrink).freeze();
}
public RectConst growBottom(NumConst shrink)
{
return super.growBottom(shrink).freeze();
}
public RectConst centerTo(VectConst point)
{
return super.centerTo(point).freeze();

@ -1,7 +1,7 @@
package mightypork.utils.math.rect;
package mightypork.utils.math.constraints.rect;
import mightypork.utils.math.vect.VectConst;
import mightypork.utils.math.constraints.vect.VectConst;
public class RectDigest {

@ -1,7 +1,7 @@
package mightypork.utils.math.rect;
package mightypork.utils.math.constraints.rect;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -1,8 +1,8 @@
package mightypork.utils.math.rect;
package mightypork.utils.math.constraints.rect;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectVar;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectVar;
public class RectVar extends RectMutable {

@ -1,7 +1,7 @@
package mightypork.utils.math.rect;
package mightypork.utils.math.constraints.rect;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.constraints.vect.Vect;
/**

@ -1,14 +1,13 @@
package mightypork.utils.math.vect;
package mightypork.utils.math.constraints.vect;
import mightypork.utils.annotations.DefaultImpl;
import mightypork.utils.annotations.FactoryMethod;
import mightypork.utils.math.Calc;
import mightypork.utils.math.constraints.VectBound;
import mightypork.utils.math.num.Num;
import mightypork.utils.math.num.NumConst;
import mightypork.utils.math.rect.Rect;
import mightypork.utils.math.rect.RectDigest;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.num.NumConst;
import mightypork.utils.math.constraints.rect.Rect;
/**
@ -236,7 +235,6 @@ public abstract class Vect implements VectBound {
{
return new VectConst(this);
}
/**
@ -1127,7 +1125,7 @@ public abstract class Vect implements VectBound {
* @param bottom
* @return the rect
*/
public Rect expand(int left, int right, int top, int bottom)
public Rect expand(double left, double right, double top, double bottom)
{
return Rect.make(this, Vect.ZERO).grow(left, right, top, bottom);
}

@ -1,4 +1,4 @@
package mightypork.utils.math.vect;
package mightypork.utils.math.constraints.vect;
/**

@ -1,4 +1,4 @@
package mightypork.utils.math.vect;
package mightypork.utils.math.constraints.vect;
import mightypork.gamecore.control.timing.Pauseable;

@ -0,0 +1,26 @@
package mightypork.utils.math.constraints.vect;
import mightypork.utils.math.constraints.PluggableVectBound;
import mightypork.utils.math.constraints.VectBound;
public class VectBoundAdapter extends VectAdapter implements PluggableVectBound {
private VectBound backing = null;
@Override
public void setVect(VectBound rect)
{
this.backing = rect;
}
@Override
protected Vect getSource()
{
return backing.getVect();
}
}

@ -1,14 +1,16 @@
package mightypork.utils.math.vect;
package mightypork.utils.math.constraints.vect;
import mightypork.utils.math.num.Num;
import mightypork.utils.math.num.NumConst;
import mightypork.utils.math.rect.RectConst;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.num.NumConst;
import mightypork.utils.math.constraints.rect.RectConst;
/**
* Coordinate with immutable numeric values.<br>
* This coordinate is guaranteed to never change, as opposed to view.
* This coordinate is guaranteed to never change, as opposed to view.<br>
* It's arranged so that operations with constant arguments yield constant
* results.
*
* @author MightyPork
*/
@ -350,7 +352,7 @@ public final class VectConst extends Vect {
@Override
public RectConst expand(int left, int right, int top, int bottom)
public RectConst expand(double left, double right, double top, double bottom)
{
return super.expand(left, right, top, bottom).freeze();
}

@ -1,4 +1,4 @@
package mightypork.utils.math.vect;
package mightypork.utils.math.constraints.vect;
public class VectDigest {

@ -1,4 +1,4 @@
package mightypork.utils.math.vect;
package mightypork.utils.math.constraints.vect;
/**

@ -1,8 +1,8 @@
package mightypork.utils.math.vect;
package mightypork.utils.math.constraints.vect;
import mightypork.utils.math.constraints.NumBound;
import mightypork.utils.math.num.Num;
import mightypork.utils.math.constraints.num.Num;
import mightypork.utils.math.constraints.num.NumBound;
/**

@ -1,4 +1,4 @@
package mightypork.utils.math.vect;
package mightypork.utils.math.constraints.vect;
/**

@ -4,8 +4,8 @@ package mightypork.utils.objects;
import mightypork.utils.logging.Log;
import mightypork.utils.math.Calc;
import mightypork.utils.math.Range;
import mightypork.utils.math.vect.Vect;
import mightypork.utils.math.vect.VectConst;
import mightypork.utils.math.constraints.vect.Vect;
import mightypork.utils.math.constraints.vect.VectConst;
/**

Loading…
Cancel
Save