From 0236e779c3a4b5cee1c4bebcb6254de7ee469066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Mon, 14 Apr 2014 21:58:43 +0200 Subject: [PATCH] Package moves, new fn in Rect, new bound adapters --- .../gamecore/audio/DeferredAudio.java | 2 +- .../gamecore/audio/SoundSystem.java | 4 +- .../gamecore/audio/players/EffectPlayer.java | 2 +- .../control/bus/events/MouseButtonEvent.java | 2 +- .../control/bus/events/MouseMotionEvent.java | 4 +- .../control/bus/events/ScreenChangeEvent.java | 2 +- .../gui/components/AbstractComponent.java | 4 +- .../gui/components/PluggableRenderable.java | 4 +- .../gui/components/layout/AbstractLayout.java | 2 +- .../gui/components/layout/ColumnHolder.java | 2 +- .../gui/components/layout/RowHolder.java | 2 +- .../components/painters/AbstractPainter.java | 8 +- .../gui/components/painters/TextPainter.java | 6 +- .../gamecore/gui/screens/LayeredScreen.java | 2 +- .../gamecore/gui/screens/Screen.java | 4 +- .../gamecore/gui/screens/ScreenLayer.java | 4 +- .../gamecore/input/InputSystem.java | 4 +- .../gamecore/render/DisplaySystem.java | 4 +- src/mightypork/gamecore/render/Render.java | 6 +- .../gamecore/render/fonts/FontRenderer.java | 6 +- .../gamecore/render/fonts/GLFont.java | 2 +- .../render/fonts/impl/CachedFont.java | 2 +- .../render/fonts/impl/DeferredFont.java | 2 +- .../gamecore/render/fonts/impl/NullFont.java | 2 +- .../render/textures/DeferredTexture.java | 2 +- .../gamecore/render/textures/TextureBank.java | 2 +- .../gamecore/render/textures/TxQuad.java | 4 +- src/mightypork/rogue/screens/LayerFps.java | 4 +- .../screens/test_bouncyboxes/BouncyBox.java | 2 +- .../test_bouncyboxes/LayerBouncyBoxes.java | 2 +- .../test_cat_sound/LayerFlyingCat.java | 14 +- .../screens/test_font/ScreenTestFont.java | 6 +- src/mightypork/test/TestConstr.java | 14 +- src/mightypork/test/TestCoords.java | 8 +- src/mightypork/test/TestVec.java | 6 +- .../utils/config/PropertyManager.java | 4 +- src/mightypork/utils/math/Calc.java | 2 +- src/mightypork/utils/math/Polar.java | 2 +- .../utils/math/animation/AnimDouble.java | 2 +- .../math/constraints/ConstraintFactory.java | 970 ------------------ .../math/constraints/PluggableNumBound.java | 19 + .../math/constraints/PluggableRectBound.java | 4 +- .../math/constraints/PluggableVectBound.java | 16 + .../utils/math/constraints/RectBound.java | 2 +- .../utils/math/constraints/RectCache.java | 57 - .../utils/math/constraints/VectBound.java | 2 +- .../utils/math/{ => constraints}/num/Num.java | 3 +- .../{ => constraints}/num/NumAdapter.java | 2 +- .../math/constraints/{ => num}/NumBound.java | 5 +- .../math/constraints/num/NumBoundAdapter.java | 25 + .../math/{ => constraints}/num/NumConst.java | 8 +- .../math/{ => constraints}/num/NumDigest.java | 2 +- .../{ => constraints}/num/NumMutable.java | 2 +- .../math/{ => constraints}/num/NumVar.java | 2 +- .../math/{ => constraints}/rect/Rect.java | 106 +- .../{ => constraints}/rect/RectAdapter.java | 6 +- .../{ => rect}/RectBoundAdapter.java | 8 +- .../{ => constraints}/rect/RectConst.java | 136 ++- .../{ => constraints}/rect/RectDigest.java | 4 +- .../{ => constraints}/rect/RectMutable.java | 4 +- .../math/{ => constraints}/rect/RectVar.java | 6 +- .../rect/RectVectAdapter.java | 4 +- .../math/{ => constraints}/vect/Vect.java | 12 +- .../{ => constraints}/vect/VectAdapter.java | 2 +- .../{ => constraints}/vect/VectAnimated.java | 2 +- .../constraints/vect/VectBoundAdapter.java | 26 + .../{ => constraints}/vect/VectConst.java | 14 +- .../{ => constraints}/vect/VectDigest.java | 2 +- .../{ => constraints}/vect/VectMutable.java | 2 +- .../vect/VectNumAdapter.java | 6 +- .../math/{ => constraints}/vect/VectVar.java | 2 +- src/mightypork/utils/objects/Convert.java | 4 +- 72 files changed, 441 insertions(+), 1180 deletions(-) delete mode 100644 src/mightypork/utils/math/constraints/ConstraintFactory.java create mode 100644 src/mightypork/utils/math/constraints/PluggableNumBound.java create mode 100644 src/mightypork/utils/math/constraints/PluggableVectBound.java delete mode 100644 src/mightypork/utils/math/constraints/RectCache.java rename src/mightypork/utils/math/{ => constraints}/num/Num.java (99%) rename src/mightypork/utils/math/{ => constraints}/num/NumAdapter.java (77%) rename src/mightypork/utils/math/constraints/{ => num}/NumBound.java (63%) create mode 100644 src/mightypork/utils/math/constraints/num/NumBoundAdapter.java rename src/mightypork/utils/math/{ => constraints}/num/NumConst.java (95%) rename src/mightypork/utils/math/{ => constraints}/num/NumDigest.java (79%) rename src/mightypork/utils/math/{ => constraints}/num/NumMutable.java (89%) rename src/mightypork/utils/math/{ => constraints}/num/NumVar.java (89%) rename src/mightypork/utils/math/{ => constraints}/rect/Rect.java (85%) rename src/mightypork/utils/math/{ => constraints}/rect/RectAdapter.java (84%) rename src/mightypork/utils/math/constraints/{ => rect}/RectBoundAdapter.java (61%) rename src/mightypork/utils/math/{ => constraints}/rect/RectConst.java (71%) rename src/mightypork/utils/math/{ => constraints}/rect/RectDigest.java (88%) rename src/mightypork/utils/math/{ => constraints}/rect/RectMutable.java (92%) rename src/mightypork/utils/math/{ => constraints}/rect/RectVar.java (80%) rename src/mightypork/utils/math/{ => constraints}/rect/RectVectAdapter.java (79%) rename src/mightypork/utils/math/{ => constraints}/vect/Vect.java (98%) rename src/mightypork/utils/math/{ => constraints}/vect/VectAdapter.java (90%) rename src/mightypork/utils/math/{ => constraints}/vect/VectAnimated.java (99%) create mode 100644 src/mightypork/utils/math/constraints/vect/VectBoundAdapter.java rename src/mightypork/utils/math/{ => constraints}/vect/VectConst.java (93%) rename src/mightypork/utils/math/{ => constraints}/vect/VectDigest.java (85%) rename src/mightypork/utils/math/{ => constraints}/vect/VectMutable.java (95%) rename src/mightypork/utils/math/{ => constraints}/vect/VectNumAdapter.java (81%) rename src/mightypork/utils/math/{ => constraints}/vect/VectVar.java (94%) diff --git a/src/mightypork/gamecore/audio/DeferredAudio.java b/src/mightypork/gamecore/audio/DeferredAudio.java index 125df9b..0d32b27 100644 --- a/src/mightypork/gamecore/audio/DeferredAudio.java +++ b/src/mightypork/gamecore/audio/DeferredAudio.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; diff --git a/src/mightypork/gamecore/audio/SoundSystem.java b/src/mightypork/gamecore/audio/SoundSystem.java index 479d880..a30fb05 100644 --- a/src/mightypork/gamecore/audio/SoundSystem.java +++ b/src/mightypork/gamecore/audio/SoundSystem.java @@ -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; diff --git a/src/mightypork/gamecore/audio/players/EffectPlayer.java b/src/mightypork/gamecore/audio/players/EffectPlayer.java index df4cc59..8f4f955 100644 --- a/src/mightypork/gamecore/audio/players/EffectPlayer.java +++ b/src/mightypork/gamecore/audio/players/EffectPlayer.java @@ -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; /** diff --git a/src/mightypork/gamecore/control/bus/events/MouseButtonEvent.java b/src/mightypork/gamecore/control/bus/events/MouseButtonEvent.java index 6cc9493..e6cfd0a 100644 --- a/src/mightypork/gamecore/control/bus/events/MouseButtonEvent.java +++ b/src/mightypork/gamecore/control/bus/events/MouseButtonEvent.java @@ -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; /** diff --git a/src/mightypork/gamecore/control/bus/events/MouseMotionEvent.java b/src/mightypork/gamecore/control/bus/events/MouseMotionEvent.java index a1e230f..5be202a 100644 --- a/src/mightypork/gamecore/control/bus/events/MouseMotionEvent.java +++ b/src/mightypork/gamecore/control/bus/events/MouseMotionEvent.java @@ -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; /** diff --git a/src/mightypork/gamecore/control/bus/events/ScreenChangeEvent.java b/src/mightypork/gamecore/control/bus/events/ScreenChangeEvent.java index c41aa36..f7be505 100644 --- a/src/mightypork/gamecore/control/bus/events/ScreenChangeEvent.java +++ b/src/mightypork/gamecore/control/bus/events/ScreenChangeEvent.java @@ -1,7 +1,7 @@ package mightypork.gamecore.control.bus.events; -import mightypork.utils.math.vect.Vect; +import mightypork.utils.math.constraints.vect.Vect; /** diff --git a/src/mightypork/gamecore/gui/components/AbstractComponent.java b/src/mightypork/gamecore/gui/components/AbstractComponent.java index 6d04520..250fabe 100644 --- a/src/mightypork/gamecore/gui/components/AbstractComponent.java +++ b/src/mightypork/gamecore/gui/components/AbstractComponent.java @@ -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; } diff --git a/src/mightypork/gamecore/gui/components/PluggableRenderable.java b/src/mightypork/gamecore/gui/components/PluggableRenderable.java index e9558ac..90274b9 100644 --- a/src/mightypork/gamecore/gui/components/PluggableRenderable.java +++ b/src/mightypork/gamecore/gui/components/PluggableRenderable.java @@ -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); } diff --git a/src/mightypork/gamecore/gui/components/layout/AbstractLayout.java b/src/mightypork/gamecore/gui/components/layout/AbstractLayout.java index cf5db55..b2e6b35 100644 --- a/src/mightypork/gamecore/gui/components/layout/AbstractLayout.java +++ b/src/mightypork/gamecore/gui/components/layout/AbstractLayout.java @@ -37,7 +37,7 @@ public abstract class AbstractLayout extends AbstractComponent { */ public AbstractLayout(AppAccess app, RectBound context) { super(app); - setContext(context); + setRect(context); } diff --git a/src/mightypork/gamecore/gui/components/layout/ColumnHolder.java b/src/mightypork/gamecore/gui/components/layout/ColumnHolder.java index 3ba8ce2..ab4cbcb 100644 --- a/src/mightypork/gamecore/gui/components/layout/ColumnHolder.java +++ b/src/mightypork/gamecore/gui/components/layout/ColumnHolder.java @@ -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); } diff --git a/src/mightypork/gamecore/gui/components/layout/RowHolder.java b/src/mightypork/gamecore/gui/components/layout/RowHolder.java index 1f38ee9..2a6692d 100644 --- a/src/mightypork/gamecore/gui/components/layout/RowHolder.java +++ b/src/mightypork/gamecore/gui/components/layout/RowHolder.java @@ -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); } diff --git a/src/mightypork/gamecore/gui/components/painters/AbstractPainter.java b/src/mightypork/gamecore/gui/components/painters/AbstractPainter.java index 83226b2..a3dae4a 100644 --- a/src/mightypork/gamecore/gui/components/painters/AbstractPainter.java +++ b/src/mightypork/gamecore/gui/components/painters/AbstractPainter.java @@ -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); } } diff --git a/src/mightypork/gamecore/gui/components/painters/TextPainter.java b/src/mightypork/gamecore/gui/components/painters/TextPainter.java index 331f57d..4f32e7b 100644 --- a/src/mightypork/gamecore/gui/components/painters/TextPainter.java +++ b/src/mightypork/gamecore/gui/components/painters/TextPainter.java @@ -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; diff --git a/src/mightypork/gamecore/gui/screens/LayeredScreen.java b/src/mightypork/gamecore/gui/screens/LayeredScreen.java index fe5e309..35cca7f 100644 --- a/src/mightypork/gamecore/gui/screens/LayeredScreen.java +++ b/src/mightypork/gamecore/gui/screens/LayeredScreen.java @@ -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; /** diff --git a/src/mightypork/gamecore/gui/screens/Screen.java b/src/mightypork/gamecore/gui/screens/Screen.java index 94f0e45..32dd613 100644 --- a/src/mightypork/gamecore/gui/screens/Screen.java +++ b/src/mightypork/gamecore/gui/screens/Screen.java @@ -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; /** diff --git a/src/mightypork/gamecore/gui/screens/ScreenLayer.java b/src/mightypork/gamecore/gui/screens/ScreenLayer.java index 9dd468b..dfd7081 100644 --- a/src/mightypork/gamecore/gui/screens/ScreenLayer.java +++ b/src/mightypork/gamecore/gui/screens/ScreenLayer.java @@ -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; /** diff --git a/src/mightypork/gamecore/input/InputSystem.java b/src/mightypork/gamecore/input/InputSystem.java index 80b7ca9..37f0614 100644 --- a/src/mightypork/gamecore/input/InputSystem.java +++ b/src/mightypork/gamecore/input/InputSystem.java @@ -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; diff --git a/src/mightypork/gamecore/render/DisplaySystem.java b/src/mightypork/gamecore/render/DisplaySystem.java index ff052b3..5bf9b61 100644 --- a/src/mightypork/gamecore/render/DisplaySystem.java +++ b/src/mightypork/gamecore/render/DisplaySystem.java @@ -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; diff --git a/src/mightypork/gamecore/render/Render.java b/src/mightypork/gamecore/render/Render.java index 3852bc5..a70a2dd 100644 --- a/src/mightypork/gamecore/render/Render.java +++ b/src/mightypork/gamecore/render/Render.java @@ -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; diff --git a/src/mightypork/gamecore/render/fonts/FontRenderer.java b/src/mightypork/gamecore/render/fonts/FontRenderer.java index 6169e15..80d0cf3 100644 --- a/src/mightypork/gamecore/render/fonts/FontRenderer.java +++ b/src/mightypork/gamecore/render/fonts/FontRenderer.java @@ -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; /** diff --git a/src/mightypork/gamecore/render/fonts/GLFont.java b/src/mightypork/gamecore/render/fonts/GLFont.java index 41f1303..97c4b3a 100644 --- a/src/mightypork/gamecore/render/fonts/GLFont.java +++ b/src/mightypork/gamecore/render/fonts/GLFont.java @@ -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; /** diff --git a/src/mightypork/gamecore/render/fonts/impl/CachedFont.java b/src/mightypork/gamecore/render/fonts/impl/CachedFont.java index 0908260..ec5de26 100644 --- a/src/mightypork/gamecore/render/fonts/impl/CachedFont.java +++ b/src/mightypork/gamecore/render/fonts/impl/CachedFont.java @@ -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; diff --git a/src/mightypork/gamecore/render/fonts/impl/DeferredFont.java b/src/mightypork/gamecore/render/fonts/impl/DeferredFont.java index d8aaade..e2b90dd 100644 --- a/src/mightypork/gamecore/render/fonts/impl/DeferredFont.java +++ b/src/mightypork/gamecore/render/fonts/impl/DeferredFont.java @@ -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; /** diff --git a/src/mightypork/gamecore/render/fonts/impl/NullFont.java b/src/mightypork/gamecore/render/fonts/impl/NullFont.java index 901c10f..692d3df 100644 --- a/src/mightypork/gamecore/render/fonts/impl/NullFont.java +++ b/src/mightypork/gamecore/render/fonts/impl/NullFont.java @@ -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; /** diff --git a/src/mightypork/gamecore/render/textures/DeferredTexture.java b/src/mightypork/gamecore/render/textures/DeferredTexture.java index ed09a4a..2f3da12 100644 --- a/src/mightypork/gamecore/render/textures/DeferredTexture.java +++ b/src/mightypork/gamecore/render/textures/DeferredTexture.java @@ -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; diff --git a/src/mightypork/gamecore/render/textures/TextureBank.java b/src/mightypork/gamecore/render/textures/TextureBank.java index c3fccba..d667fd3 100644 --- a/src/mightypork/gamecore/render/textures/TextureBank.java +++ b/src/mightypork/gamecore/render/textures/TextureBank.java @@ -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; diff --git a/src/mightypork/gamecore/render/textures/TxQuad.java b/src/mightypork/gamecore/render/textures/TxQuad.java index e2eb628..27e858f 100644 --- a/src/mightypork/gamecore/render/textures/TxQuad.java +++ b/src/mightypork/gamecore/render/textures/TxQuad.java @@ -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; diff --git a/src/mightypork/rogue/screens/LayerFps.java b/src/mightypork/rogue/screens/LayerFps.java index 5f13de1..36aca1a 100644 --- a/src/mightypork/rogue/screens/LayerFps.java +++ b/src/mightypork/rogue/screens/LayerFps.java @@ -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); } diff --git a/src/mightypork/rogue/screens/test_bouncyboxes/BouncyBox.java b/src/mightypork/rogue/screens/test_bouncyboxes/BouncyBox.java index 15669ee..c1c1623 100644 --- a/src/mightypork/rogue/screens/test_bouncyboxes/BouncyBox.java +++ b/src/mightypork/rogue/screens/test_bouncyboxes/BouncyBox.java @@ -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 { diff --git a/src/mightypork/rogue/screens/test_bouncyboxes/LayerBouncyBoxes.java b/src/mightypork/rogue/screens/test_bouncyboxes/LayerBouncyBoxes.java index b36a87b..de0aeaf 100644 --- a/src/mightypork/rogue/screens/test_bouncyboxes/LayerBouncyBoxes.java +++ b/src/mightypork/rogue/screens/test_bouncyboxes/LayerBouncyBoxes.java @@ -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 { diff --git a/src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java b/src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java index 5978928..584e0f4 100644 --- a/src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java +++ b/src/mightypork/rogue/screens/test_cat_sound/LayerFlyingCat.java @@ -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 diff --git a/src/mightypork/rogue/screens/test_font/ScreenTestFont.java b/src/mightypork/rogue/screens/test_font/ScreenTestFont.java index ed26b6f..e60ba8e 100644 --- a/src/mightypork/rogue/screens/test_font/ScreenTestFont.java +++ b/src/mightypork/rogue/screens/test_font/ScreenTestFont.java @@ -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); } diff --git a/src/mightypork/test/TestConstr.java b/src/mightypork/test/TestConstr.java index 33ee2e6..a013725 100644 --- a/src/mightypork/test/TestConstr.java +++ b/src/mightypork/test/TestConstr.java @@ -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 { diff --git a/src/mightypork/test/TestCoords.java b/src/mightypork/test/TestCoords.java index a3ebcb1..6e163c1 100644 --- a/src/mightypork/test/TestCoords.java +++ b/src/mightypork/test/TestCoords.java @@ -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 { diff --git a/src/mightypork/test/TestVec.java b/src/mightypork/test/TestVec.java index 5bc28bf..436092b 100644 --- a/src/mightypork/test/TestVec.java +++ b/src/mightypork/test/TestVec.java @@ -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 { diff --git a/src/mightypork/utils/config/PropertyManager.java b/src/mightypork/utils/config/PropertyManager.java index 9e642ae..0a67876 100644 --- a/src/mightypork/utils/config/PropertyManager.java +++ b/src/mightypork/utils/config/PropertyManager.java @@ -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; diff --git a/src/mightypork/utils/math/Calc.java b/src/mightypork/utils/math/Calc.java index dda717f..17d4bfe 100644 --- a/src/mightypork/utils/math/Calc.java +++ b/src/mightypork/utils/math/Calc.java @@ -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; diff --git a/src/mightypork/utils/math/Polar.java b/src/mightypork/utils/math/Polar.java index 620a110..801b3fb 100644 --- a/src/mightypork/utils/math/Polar.java +++ b/src/mightypork/utils/math/Polar.java @@ -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; /** diff --git a/src/mightypork/utils/math/animation/AnimDouble.java b/src/mightypork/utils/math/animation/AnimDouble.java index c193ba8..bb679e1 100644 --- a/src/mightypork/utils/math/animation/AnimDouble.java +++ b/src/mightypork/utils/math/animation/AnimDouble.java @@ -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; /** diff --git a/src/mightypork/utils/math/constraints/ConstraintFactory.java b/src/mightypork/utils/math/constraints/ConstraintFactory.java deleted file mode 100644 index 72cb853..0000000 --- a/src/mightypork/utils/math/constraints/ConstraintFactory.java +++ /dev/null @@ -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.
- * 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); - } - }; - } - -} diff --git a/src/mightypork/utils/math/constraints/PluggableNumBound.java b/src/mightypork/utils/math/constraints/PluggableNumBound.java new file mode 100644 index 0000000..f96fca8 --- /dev/null +++ b/src/mightypork/utils/math/constraints/PluggableNumBound.java @@ -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); + +} diff --git a/src/mightypork/utils/math/constraints/PluggableRectBound.java b/src/mightypork/utils/math/constraints/PluggableRectBound.java index bce7532..faec1bb 100644 --- a/src/mightypork/utils/math/constraints/PluggableRectBound.java +++ b/src/mightypork/utils/math/constraints/PluggableRectBound.java @@ -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); } diff --git a/src/mightypork/utils/math/constraints/PluggableVectBound.java b/src/mightypork/utils/math/constraints/PluggableVectBound.java new file mode 100644 index 0000000..22e1457 --- /dev/null +++ b/src/mightypork/utils/math/constraints/PluggableVectBound.java @@ -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); + +} diff --git a/src/mightypork/utils/math/constraints/RectBound.java b/src/mightypork/utils/math/constraints/RectBound.java index 0398593..5789f1e 100644 --- a/src/mightypork/utils/math/constraints/RectBound.java +++ b/src/mightypork/utils/math/constraints/RectBound.java @@ -1,7 +1,7 @@ package mightypork.utils.math.constraints; -import mightypork.utils.math.rect.Rect; +import mightypork.utils.math.constraints.rect.Rect; /** diff --git a/src/mightypork/utils/math/constraints/RectCache.java b/src/mightypork/utils/math/constraints/RectCache.java deleted file mode 100644 index b07a2de..0000000 --- a/src/mightypork/utils/math/constraints/RectCache.java +++ /dev/null @@ -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}.
- * 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()); - } - -} diff --git a/src/mightypork/utils/math/constraints/VectBound.java b/src/mightypork/utils/math/constraints/VectBound.java index c74c569..86f07b7 100644 --- a/src/mightypork/utils/math/constraints/VectBound.java +++ b/src/mightypork/utils/math/constraints/VectBound.java @@ -1,7 +1,7 @@ package mightypork.utils.math.constraints; -import mightypork.utils.math.vect.Vect; +import mightypork.utils.math.constraints.vect.Vect; /** diff --git a/src/mightypork/utils/math/num/Num.java b/src/mightypork/utils/math/constraints/num/Num.java similarity index 99% rename from src/mightypork/utils/math/num/Num.java rename to src/mightypork/utils/math/constraints/num/Num.java index 56d96ce..ec33a94 100644 --- a/src/mightypork/utils/math/num/Num.java +++ b/src/mightypork/utils/math/constraints/num/Num.java @@ -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 { diff --git a/src/mightypork/utils/math/num/NumAdapter.java b/src/mightypork/utils/math/constraints/num/NumAdapter.java similarity index 77% rename from src/mightypork/utils/math/num/NumAdapter.java rename to src/mightypork/utils/math/constraints/num/NumAdapter.java index f2a1cc2..c941647 100644 --- a/src/mightypork/utils/math/num/NumAdapter.java +++ b/src/mightypork/utils/math/constraints/num/NumAdapter.java @@ -1,4 +1,4 @@ -package mightypork.utils.math.num; +package mightypork.utils.math.constraints.num; public abstract class NumAdapter extends Num { diff --git a/src/mightypork/utils/math/constraints/NumBound.java b/src/mightypork/utils/math/constraints/num/NumBound.java similarity index 63% rename from src/mightypork/utils/math/constraints/NumBound.java rename to src/mightypork/utils/math/constraints/num/NumBound.java index a7338db..911fd0b 100644 --- a/src/mightypork/utils/math/constraints/NumBound.java +++ b/src/mightypork/utils/math/constraints/num/NumBound.java @@ -1,7 +1,4 @@ -package mightypork.utils.math.constraints; - - -import mightypork.utils.math.num.Num; +package mightypork.utils.math.constraints.num; /** diff --git a/src/mightypork/utils/math/constraints/num/NumBoundAdapter.java b/src/mightypork/utils/math/constraints/num/NumBoundAdapter.java new file mode 100644 index 0000000..d1f6729 --- /dev/null +++ b/src/mightypork/utils/math/constraints/num/NumBoundAdapter.java @@ -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(); + } + +} diff --git a/src/mightypork/utils/math/num/NumConst.java b/src/mightypork/utils/math/constraints/num/NumConst.java similarity index 95% rename from src/mightypork/utils/math/num/NumConst.java rename to src/mightypork/utils/math/constraints/num/NumConst.java index 3204280..4a2d940 100644 --- a/src/mightypork/utils/math/num/NumConst.java +++ b/src/mightypork/utils/math/constraints/num/NumConst.java @@ -1,8 +1,10 @@ -package mightypork.utils.math.num; +package mightypork.utils.math.constraints.num; /** - * Constant number + * Constant number.
+ * 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) { diff --git a/src/mightypork/utils/math/num/NumDigest.java b/src/mightypork/utils/math/constraints/num/NumDigest.java similarity index 79% rename from src/mightypork/utils/math/num/NumDigest.java rename to src/mightypork/utils/math/constraints/num/NumDigest.java index e9677d0..9fb1213 100644 --- a/src/mightypork/utils/math/num/NumDigest.java +++ b/src/mightypork/utils/math/constraints/num/NumDigest.java @@ -1,4 +1,4 @@ -package mightypork.utils.math.num; +package mightypork.utils.math.constraints.num; public class NumDigest { diff --git a/src/mightypork/utils/math/num/NumMutable.java b/src/mightypork/utils/math/constraints/num/NumMutable.java similarity index 89% rename from src/mightypork/utils/math/num/NumMutable.java rename to src/mightypork/utils/math/constraints/num/NumMutable.java index b0b1e9d..857945a 100644 --- a/src/mightypork/utils/math/num/NumMutable.java +++ b/src/mightypork/utils/math/constraints/num/NumMutable.java @@ -1,4 +1,4 @@ -package mightypork.utils.math.num; +package mightypork.utils.math.constraints.num; /** diff --git a/src/mightypork/utils/math/num/NumVar.java b/src/mightypork/utils/math/constraints/num/NumVar.java similarity index 89% rename from src/mightypork/utils/math/num/NumVar.java rename to src/mightypork/utils/math/constraints/num/NumVar.java index 3219f7f..12a0b94 100644 --- a/src/mightypork/utils/math/num/NumVar.java +++ b/src/mightypork/utils/math/constraints/num/NumVar.java @@ -1,4 +1,4 @@ -package mightypork.utils.math.num; +package mightypork.utils.math.constraints.num; /** diff --git a/src/mightypork/utils/math/rect/Rect.java b/src/mightypork/utils/math/constraints/rect/Rect.java similarity index 85% rename from src/mightypork/utils/math/rect/Rect.java rename to src/mightypork/utils/math/constraints/rect/Rect.java index ec6186a..989b28d 100644 --- a/src/mightypork/utils/math/rect/Rect.java +++ b/src/mightypork/utils/math/constraints/rect/Rect.java @@ -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 * diff --git a/src/mightypork/utils/math/rect/RectAdapter.java b/src/mightypork/utils/math/constraints/rect/RectAdapter.java similarity index 84% rename from src/mightypork/utils/math/rect/RectAdapter.java rename to src/mightypork/utils/math/constraints/rect/RectAdapter.java index 3a495d5..6f3e883 100644 --- a/src/mightypork/utils/math/rect/RectAdapter.java +++ b/src/mightypork/utils/math/constraints/rect/RectAdapter.java @@ -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; /** diff --git a/src/mightypork/utils/math/constraints/RectBoundAdapter.java b/src/mightypork/utils/math/constraints/rect/RectBoundAdapter.java similarity index 61% rename from src/mightypork/utils/math/constraints/RectBoundAdapter.java rename to src/mightypork/utils/math/constraints/rect/RectBoundAdapter.java index 3c32b2a..6d2a911 100644 --- a/src/mightypork/utils/math/constraints/RectBoundAdapter.java +++ b/src/mightypork/utils/math/constraints/rect/RectBoundAdapter.java @@ -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; } diff --git a/src/mightypork/utils/math/rect/RectConst.java b/src/mightypork/utils/math/constraints/rect/RectConst.java similarity index 71% rename from src/mightypork/utils/math/rect/RectConst.java rename to src/mightypork/utils/math/constraints/rect/RectConst.java index 87dbefb..61458a2 100644 --- a/src/mightypork/utils/math/rect/RectConst.java +++ b/src/mightypork/utils/math/constraints/rect/RectConst.java @@ -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.
+ * 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(); diff --git a/src/mightypork/utils/math/rect/RectDigest.java b/src/mightypork/utils/math/constraints/rect/RectDigest.java similarity index 88% rename from src/mightypork/utils/math/rect/RectDigest.java rename to src/mightypork/utils/math/constraints/rect/RectDigest.java index 1d369c6..24d2332 100644 --- a/src/mightypork/utils/math/rect/RectDigest.java +++ b/src/mightypork/utils/math/constraints/rect/RectDigest.java @@ -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 { diff --git a/src/mightypork/utils/math/rect/RectMutable.java b/src/mightypork/utils/math/constraints/rect/RectMutable.java similarity index 92% rename from src/mightypork/utils/math/rect/RectMutable.java rename to src/mightypork/utils/math/constraints/rect/RectMutable.java index 764bc44..efacde6 100644 --- a/src/mightypork/utils/math/rect/RectMutable.java +++ b/src/mightypork/utils/math/constraints/rect/RectMutable.java @@ -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; /** diff --git a/src/mightypork/utils/math/rect/RectVar.java b/src/mightypork/utils/math/constraints/rect/RectVar.java similarity index 80% rename from src/mightypork/utils/math/rect/RectVar.java rename to src/mightypork/utils/math/constraints/rect/RectVar.java index 568881c..78b5c8e 100644 --- a/src/mightypork/utils/math/rect/RectVar.java +++ b/src/mightypork/utils/math/constraints/rect/RectVar.java @@ -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 { diff --git a/src/mightypork/utils/math/rect/RectVectAdapter.java b/src/mightypork/utils/math/constraints/rect/RectVectAdapter.java similarity index 79% rename from src/mightypork/utils/math/rect/RectVectAdapter.java rename to src/mightypork/utils/math/constraints/rect/RectVectAdapter.java index fa8cce9..bb375f6 100644 --- a/src/mightypork/utils/math/rect/RectVectAdapter.java +++ b/src/mightypork/utils/math/constraints/rect/RectVectAdapter.java @@ -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; /** diff --git a/src/mightypork/utils/math/vect/Vect.java b/src/mightypork/utils/math/constraints/vect/Vect.java similarity index 98% rename from src/mightypork/utils/math/vect/Vect.java rename to src/mightypork/utils/math/constraints/vect/Vect.java index 4b377cf..0954a6b 100644 --- a/src/mightypork/utils/math/vect/Vect.java +++ b/src/mightypork/utils/math/constraints/vect/Vect.java @@ -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); } diff --git a/src/mightypork/utils/math/vect/VectAdapter.java b/src/mightypork/utils/math/constraints/vect/VectAdapter.java similarity index 90% rename from src/mightypork/utils/math/vect/VectAdapter.java rename to src/mightypork/utils/math/constraints/vect/VectAdapter.java index 39777a0..3d91450 100644 --- a/src/mightypork/utils/math/vect/VectAdapter.java +++ b/src/mightypork/utils/math/constraints/vect/VectAdapter.java @@ -1,4 +1,4 @@ -package mightypork.utils.math.vect; +package mightypork.utils.math.constraints.vect; /** diff --git a/src/mightypork/utils/math/vect/VectAnimated.java b/src/mightypork/utils/math/constraints/vect/VectAnimated.java similarity index 99% rename from src/mightypork/utils/math/vect/VectAnimated.java rename to src/mightypork/utils/math/constraints/vect/VectAnimated.java index 253e737..562cb42 100644 --- a/src/mightypork/utils/math/vect/VectAnimated.java +++ b/src/mightypork/utils/math/constraints/vect/VectAnimated.java @@ -1,4 +1,4 @@ -package mightypork.utils.math.vect; +package mightypork.utils.math.constraints.vect; import mightypork.gamecore.control.timing.Pauseable; diff --git a/src/mightypork/utils/math/constraints/vect/VectBoundAdapter.java b/src/mightypork/utils/math/constraints/vect/VectBoundAdapter.java new file mode 100644 index 0000000..cf394b1 --- /dev/null +++ b/src/mightypork/utils/math/constraints/vect/VectBoundAdapter.java @@ -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(); + } + +} diff --git a/src/mightypork/utils/math/vect/VectConst.java b/src/mightypork/utils/math/constraints/vect/VectConst.java similarity index 93% rename from src/mightypork/utils/math/vect/VectConst.java rename to src/mightypork/utils/math/constraints/vect/VectConst.java index 5bbb696..2e5b758 100644 --- a/src/mightypork/utils/math/vect/VectConst.java +++ b/src/mightypork/utils/math/constraints/vect/VectConst.java @@ -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.
- * This coordinate is guaranteed to never change, as opposed to view. + * This coordinate is guaranteed to never change, as opposed to view.
+ * 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(); } diff --git a/src/mightypork/utils/math/vect/VectDigest.java b/src/mightypork/utils/math/constraints/vect/VectDigest.java similarity index 85% rename from src/mightypork/utils/math/vect/VectDigest.java rename to src/mightypork/utils/math/constraints/vect/VectDigest.java index 21d1774..ca2a9d3 100644 --- a/src/mightypork/utils/math/vect/VectDigest.java +++ b/src/mightypork/utils/math/constraints/vect/VectDigest.java @@ -1,4 +1,4 @@ -package mightypork.utils.math.vect; +package mightypork.utils.math.constraints.vect; public class VectDigest { diff --git a/src/mightypork/utils/math/vect/VectMutable.java b/src/mightypork/utils/math/constraints/vect/VectMutable.java similarity index 95% rename from src/mightypork/utils/math/vect/VectMutable.java rename to src/mightypork/utils/math/constraints/vect/VectMutable.java index 2400fcd..6d89eac 100644 --- a/src/mightypork/utils/math/vect/VectMutable.java +++ b/src/mightypork/utils/math/constraints/vect/VectMutable.java @@ -1,4 +1,4 @@ -package mightypork.utils.math.vect; +package mightypork.utils.math.constraints.vect; /** diff --git a/src/mightypork/utils/math/vect/VectNumAdapter.java b/src/mightypork/utils/math/constraints/vect/VectNumAdapter.java similarity index 81% rename from src/mightypork/utils/math/vect/VectNumAdapter.java rename to src/mightypork/utils/math/constraints/vect/VectNumAdapter.java index 7ef43fb..695a7b2 100644 --- a/src/mightypork/utils/math/vect/VectNumAdapter.java +++ b/src/mightypork/utils/math/constraints/vect/VectNumAdapter.java @@ -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; /** diff --git a/src/mightypork/utils/math/vect/VectVar.java b/src/mightypork/utils/math/constraints/vect/VectVar.java similarity index 94% rename from src/mightypork/utils/math/vect/VectVar.java rename to src/mightypork/utils/math/constraints/vect/VectVar.java index e085bca..b3f5d74 100644 --- a/src/mightypork/utils/math/vect/VectVar.java +++ b/src/mightypork/utils/math/constraints/vect/VectVar.java @@ -1,4 +1,4 @@ -package mightypork.utils.math.vect; +package mightypork.utils.math.constraints.vect; /** diff --git a/src/mightypork/utils/objects/Convert.java b/src/mightypork/utils/objects/Convert.java index 4557a54..6d58288 100644 --- a/src/mightypork/utils/objects/Convert.java +++ b/src/mightypork/utils/objects/Convert.java @@ -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; /**