From 65bfbbd16ae5f6470e21e86dd17a9dccebb5a252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 12 Apr 2014 07:02:03 +0200 Subject: [PATCH] Removed trash, improved constraint system (nicer names) --- .gitignore | 3 +- README.md | 23 +- .../gui/components/layout/ColumnHolder.java | 2 +- .../gui/components/layout/RowHolder.java | 2 +- .../gui/components/painters/QuadPainter.java | 15 +- .../gamecore/gui/screens/LayeredScreen.java | 2 +- .../gamecore/gui/screens/Screen.java | 2 +- .../gamecore/gui/screens/ScreenLayer.java | 18 + .../gamecore/input/InputSystem.java | 48 +- .../gamecore/render/DisplaySystem.java | 71 +- src/mightypork/gamecore/render/Render.java | 9 +- .../gamecore/render/fonts/FontRenderer.java | 7 +- src/mightypork/rogue/App.java | 2 +- src/mightypork/rogue/screens/LayerFps.java | 26 +- .../screens/test_bouncyboxes/BouncyBox.java | 12 +- .../test_bouncyboxes/LayerBouncyBoxes.java | 17 +- .../test_cat_sound/LayerFlyingCat.java | 17 +- .../screens/test_font/ScreenTestFont.java | 5 +- .../test_render/LayerTestGradient.java | 4 +- src/mightypork/test/TestConstr.java | 30 + .../utils/math/constraints/CReverseProxy.java | 36 + .../utils/math/constraints/Constraints.java | 830 +++++----------- .../utils/math/constraints/VecConstraint.java | 9 + .../math/constraints/VecConstraintSynth.java | 33 + .../utils/math/constraints/VecWrapper.java | 23 - src/mightypork/utils/math/coord/Vec.java | 6 +- .../utils/math/coord/VecMathImpl.java | 11 +- .../utils/math/rect/MutableRect.java | 8 +- src/mightypork/utils/math/rect/Rect.java | 45 +- src/mightypork/utils/math/rect/RectImpl.java | 100 +- src/mightypork/utils/math/rect/RectMath.java | 8 +- .../utils/math/rect/RectMutable.java | 2 +- src/mightypork/utils/math/rect/RectView.java | 4 +- .../utils/math/rect/xx/RectCalc.java | 279 ------ src/mightypork/utils/math/rect/xx/Rectd.java | 909 ------------------ 35 files changed, 640 insertions(+), 1978 deletions(-) create mode 100644 src/mightypork/test/TestConstr.java create mode 100644 src/mightypork/utils/math/constraints/CReverseProxy.java create mode 100644 src/mightypork/utils/math/constraints/VecConstraintSynth.java delete mode 100644 src/mightypork/utils/math/constraints/VecWrapper.java delete mode 100644 src/mightypork/utils/math/rect/xx/RectCalc.java delete mode 100644 src/mightypork/utils/math/rect/xx/Rectd.java diff --git a/.gitignore b/.gitignore index 97adb72..23984b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /bin/ /target/ -*.log \ No newline at end of file +*.log +.attach_pid* \ No newline at end of file diff --git a/README.md b/README.md index d736bc7..82e523a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ Goals ----- - Simple retro-themed dungeon crawler -- Multiplayer support +- (Multiplayer support) <- maybe +- Threads for resource loading and event handling Features @@ -14,23 +15,21 @@ Features - Full OOP design - Event driven - OpenGL 2D rendering - -- Random floors -- Real-time gameplay -- Monsters with AI (-> combat system) +- Screen / layer based graphics with Constraint System. -Possibly added +Gameplay -------------- -- Stats and leveling -- Collectable items -- Potions, food -- Simple inventory system +- Random floors +- Turn-based +- Monsters with AI (-> combat system) +- Collectable items, armor upgrades etc. +- Health, Hunger, Level Used libraries -------------- -- Slick2D -- LWJGL \ No newline at end of file +- LWJGL (OpenGL & OpenAL support) +- SlickUtil (texture loader, audio system) \ No newline at end of file diff --git a/src/mightypork/gamecore/gui/components/layout/ColumnHolder.java b/src/mightypork/gamecore/gui/components/layout/ColumnHolder.java index b3897df..996533c 100644 --- a/src/mightypork/gamecore/gui/components/layout/ColumnHolder.java +++ b/src/mightypork/gamecore/gui/components/layout/ColumnHolder.java @@ -52,7 +52,7 @@ public class ColumnHolder extends ElementHolder { { if (elem == null) return; - elem.setContext(_column(this, cols, col++)); + elem.setContext(cColumn(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 5a548ed..ff8f1a8 100644 --- a/src/mightypork/gamecore/gui/components/layout/RowHolder.java +++ b/src/mightypork/gamecore/gui/components/layout/RowHolder.java @@ -52,7 +52,7 @@ public class RowHolder extends ElementHolder { { if (elem == null) return; - elem.setContext(_row(this, rows, row++)); + elem.setContext(cRow(this, rows, row++)); attach(elem); } diff --git a/src/mightypork/gamecore/gui/components/painters/QuadPainter.java b/src/mightypork/gamecore/gui/components/painters/QuadPainter.java index 0a8599b..4c6db88 100644 --- a/src/mightypork/gamecore/gui/components/painters/QuadPainter.java +++ b/src/mightypork/gamecore/gui/components/painters/QuadPainter.java @@ -20,7 +20,20 @@ public class QuadPainter extends PluggableRenderer { /** - * Painter with cokloured vertices. + * Painter with solid color + * + * @param color + */ + public QuadPainter(RGB color) { + this.colorHMinVMin = color; + this.colorHMaxVMin = color; + this.colorHMaxVMax = color; + this.colorHMinVMax = color; + } + + + /** + * Painter with coloured vertices. * * @param colorHMinVMin * @param colorHMaxVMin diff --git a/src/mightypork/gamecore/gui/screens/LayeredScreen.java b/src/mightypork/gamecore/gui/screens/LayeredScreen.java index faacf70..ee3520b 100644 --- a/src/mightypork/gamecore/gui/screens/LayeredScreen.java +++ b/src/mightypork/gamecore/gui/screens/LayeredScreen.java @@ -30,7 +30,7 @@ public abstract class LayeredScreen extends Screen { protected void renderScreen() { for (final ScreenLayer layer : layers) { - layer.render(); + if (layer.isVisible()) layer.render(); } } diff --git a/src/mightypork/gamecore/gui/screens/Screen.java b/src/mightypork/gamecore/gui/screens/Screen.java index ed7a3e2..d5f26ca 100644 --- a/src/mightypork/gamecore/gui/screens/Screen.java +++ b/src/mightypork/gamecore/gui/screens/Screen.java @@ -116,7 +116,7 @@ public abstract class Screen extends AppSubModule implements Renderable, KeyBind if (!isActive()) return; if (needSetupViewport) { - Render.setupOrtho(); + Render.setupOrtho(getDisplay().getSize()); } Render.pushState(); diff --git a/src/mightypork/gamecore/gui/screens/ScreenLayer.java b/src/mightypork/gamecore/gui/screens/ScreenLayer.java index 39d3028..05b84a2 100644 --- a/src/mightypork/gamecore/gui/screens/ScreenLayer.java +++ b/src/mightypork/gamecore/gui/screens/ScreenLayer.java @@ -9,6 +9,7 @@ import mightypork.gamecore.input.KeyBindingPool; import mightypork.gamecore.input.KeyStroke; import mightypork.utils.math.constraints.RectConstraint; import mightypork.utils.math.coord.Vec; +import mightypork.utils.math.coord.VecView; import mightypork.utils.math.rect.RectView; @@ -21,8 +22,13 @@ public abstract class ScreenLayer extends AppSubModule implements Comparable implements VecMath { } + @Override + public VecView getVec() + { + return this.view(); + } + + /** *

* Some operation was performed and this result was obtained. @@ -212,7 +219,7 @@ abstract class VecMathImpl implements VecMath { @Override public V add(double x, double y, double z) { - return result(x, y, z); + return result(x() + x, y() + y, z() + z); } @@ -386,6 +393,6 @@ abstract class VecMathImpl implements VecMath { @Override public String toString() { - return String.format("[ %.2f ; %.2f ; %.2f ]", x(), y(), z()); + return String.format("(%.1f %.1f %.1f)", x(), y(), z()); } } diff --git a/src/mightypork/utils/math/rect/MutableRect.java b/src/mightypork/utils/math/rect/MutableRect.java index ff3112b..b8928b1 100644 --- a/src/mightypork/utils/math/rect/MutableRect.java +++ b/src/mightypork/utils/math/rect/MutableRect.java @@ -165,13 +165,13 @@ public class MutableRect extends RectImpl implements RectMutable { * Shrink the rect * * @param left shrink - * @param top shrink * @param right shrink + * @param top shrink * @param bottom shrink * @return result */ @Override - public RectMutable shrink(double left, double top, double right, double bottom) + public RectMutable shrink(double left, double right, double top, double bottom) { pos.add(left, top); size.sub(left + right, top + bottom).abs(); @@ -183,13 +183,13 @@ public class MutableRect extends RectImpl implements RectMutable { * Grow the rect * * @param left growth - * @param top growth * @param right growth + * @param top growth * @param bottom growth * @return result */ @Override - public RectMutable grow(double left, double top, double right, double bottom) + public RectMutable grow(double left, double right, double top, double bottom) { pos.sub(left, top); size.add(left + right, top + bottom).abs(); diff --git a/src/mightypork/utils/math/rect/Rect.java b/src/mightypork/utils/math/rect/Rect.java index 7420b66..d6c6dfe 100644 --- a/src/mightypork/utils/math/rect/Rect.java +++ b/src/mightypork/utils/math/rect/Rect.java @@ -1,6 +1,7 @@ package mightypork.utils.math.rect; +import mightypork.utils.math.constraints.RectConstraint; import mightypork.utils.math.coord.VecView; @@ -9,7 +10,7 @@ import mightypork.utils.math.coord.VecView; * * @author MightyPork */ -public interface Rect { +public interface Rect extends RectConstraint { RectView ONE = new FixedRect(0, 0, 1, 1); RectView ZERO = new FixedRect(0, 0, 0, 0); @@ -37,30 +38,42 @@ public interface Rect { VecView getOrigin(); - /** - * @return center - */ - VecView getCenter(); - - - /** - * @return rect size - */ VecView getSize(); - /** - * @return rect width - */ double getWidth(); - /** - * @return rect height - */ double getHeight(); + VecView getTopLeft(); + + + VecView getTopCenter(); + + + VecView getTopRight(); + + + VecView getCenterLeft(); + + + VecView getCenter(); + + + VecView getCenterRight(); + + + VecView getBottomLeft(); + + + VecView getBottomCenter(); + + + VecView getBottomRight(); + + double xMin(); diff --git a/src/mightypork/utils/math/rect/RectImpl.java b/src/mightypork/utils/math/rect/RectImpl.java index 880ecf7..bac64fd 100644 --- a/src/mightypork/utils/math/rect/RectImpl.java +++ b/src/mightypork/utils/math/rect/RectImpl.java @@ -1,16 +1,101 @@ package mightypork.utils.math.rect; +import static mightypork.utils.math.constraints.Constraints.*; +import mightypork.utils.math.constraints.VecConstraint; import mightypork.utils.math.coord.Vec; import mightypork.utils.math.coord.VecView; public abstract class RectImpl implements RectMath { + private VecConstraint tl, tc, tr, cl, c, cr, bl, bc, br; + + + @Override + public RectView getRect() + { + return this.view(); + } + + + @Override + public abstract VecView getOrigin(); + + + @Override + public abstract VecView getSize(); + + + @Override + public VecView getTopLeft() + { + if (tl == null) tl = cTopLeft(this); + return tl.getVec(); + } + + + @Override + public VecView getTopCenter() + { + if (tc == null) tc = cTopCenter(this); + return tc.getVec(); + } + + + @Override + public VecView getTopRight() + { + if (tr == null) tr = cTopRight(this); + return tr.getVec(); + } + + + @Override + public VecView getCenterLeft() + { + if (cl == null) cl = cCenterLeft(this); + return cl.getVec(); + } + + @Override public final VecView getCenter() { - return getOrigin().add(getSize().half()); + if (c == null) c = cCenter(this); + return c.getVec(); + } + + + @Override + public VecView getCenterRight() + { + if (cr == null) cr = cCenterRight(this); + return cr.getVec(); + } + + + @Override + public VecView getBottomLeft() + { + if (bl == null) bl = cBottomLeft(this); + return bl.getVec(); + } + + + @Override + public VecView getBottomCenter() + { + if (bc == null) bc = cBottomCenter(this); + return bc.getVec(); + } + + + @Override + public VecView getBottomRight() + { + if (br == null) br = cBottomRight(this); + return br.getVec(); } @@ -73,7 +158,7 @@ public abstract class RectImpl implements RectMath { @Override public final T shrink(double x, double y) { - return shrink(x, y, x, y); + return shrink(x, x, y, y); } @@ -87,7 +172,7 @@ public abstract class RectImpl implements RectMath { @Override public final T grow(double x, double y) { - return grow(x, y, x, y); + return grow(x, x, y, y); } @@ -98,6 +183,13 @@ public abstract class RectImpl implements RectMath { } + @Override + public RectMutable copy() + { + return new MutableRect(this); + } + + @Override public final boolean contains(Vec point) { @@ -116,6 +208,6 @@ public abstract class RectImpl implements RectMath { @Override public String toString() { - return String.format("Rect[ %s - %s ]", getOrigin().toString(), getOrigin().add(getSize())); + return String.format("Rect { %s - %s }", getOrigin().toString(), getOrigin().add(getSize())); } } diff --git a/src/mightypork/utils/math/rect/RectMath.java b/src/mightypork/utils/math/rect/RectMath.java index bf8cace..1004879 100644 --- a/src/mightypork/utils/math/rect/RectMath.java +++ b/src/mightypork/utils/math/rect/RectMath.java @@ -53,12 +53,12 @@ interface RectMath extends Rect { * Shrink the rect * * @param left shrink - * @param top shrink * @param right shrink + * @param top shrink * @param bottom shrink * @return result */ - T shrink(double left, double top, double right, double bottom); + T shrink(double left, double right, double top, double bottom); /** @@ -84,12 +84,12 @@ interface RectMath extends Rect { * Grow the rect * * @param left growth - * @param top growth * @param right growth + * @param top growth * @param bottom growth * @return result */ - T grow(double left, double top, double right, double bottom); + T grow(double left, double right, double top, double bottom); /** diff --git a/src/mightypork/utils/math/rect/RectMutable.java b/src/mightypork/utils/math/rect/RectMutable.java index adc1220..7a3ddd5 100644 --- a/src/mightypork/utils/math/rect/RectMutable.java +++ b/src/mightypork/utils/math/rect/RectMutable.java @@ -4,7 +4,7 @@ package mightypork.utils.math.rect; import mightypork.utils.math.coord.Vec; -public interface RectMutable extends Rect { +public interface RectMutable extends RectMath { /** * Set to other rect's coordinates diff --git a/src/mightypork/utils/math/rect/RectView.java b/src/mightypork/utils/math/rect/RectView.java index f2d5536..a9df140 100644 --- a/src/mightypork/utils/math/rect/RectView.java +++ b/src/mightypork/utils/math/rect/RectView.java @@ -25,14 +25,14 @@ public abstract class RectView extends RectImpl { @Override - public RectView shrink(double left, double top, double right, double bottom) + public RectView shrink(double left, double right, double top, double bottom) { return result(getOrigin().add(left, top), getSize().sub(left + right, top + bottom)); } @Override - public RectView grow(double left, double top, double right, double bottom) + public RectView grow(double left, double right, double top, double bottom) { return result(getOrigin().sub(left, top), getSize().add(left + right, top + bottom)); } diff --git a/src/mightypork/utils/math/rect/xx/RectCalc.java b/src/mightypork/utils/math/rect/xx/RectCalc.java deleted file mode 100644 index 1550c85..0000000 --- a/src/mightypork/utils/math/rect/xx/RectCalc.java +++ /dev/null @@ -1,279 +0,0 @@ -package mightypork.utils.math.rect.xx; - - -//package mightypork.utils.math.rect; -// -//import mightypork.utils.math.constraints.NumberConstraint; -//import mightypork.utils.math.coord.VecValue; -//import mightypork.utils.math.coord.VecView; -//import mightypork.utils.math.coord.SynthCoord3D; -// -// -//public class RectCalc { -// /* ================= Coords ================= */ -// -// public static NumberConstraint _x(final VecValue c) -// { -// return c.xc(); -// } -// -// -// public static NumberConstraint _y(final VecValue c) -// { -// return c.yc(); -// } -// -// -// public static NumberConstraint _z(final VecValue c) -// { -// return c.zc(); -// } -// -// -// public static VecView _neg(final VecValue c) -// { -// return _mul(c, -1); -// } -// -// -// public static VecView _half(final VecValue c) -// { -// return _mul(c, 0.5); -// } -// -// -// // --- add --- -// -// public static VecView _add(final VecValue c1, final VecValue c2) -// { -// return new SynthCoord3D() { -// -// @Override -// public double x() -// { -// return c1.x() + c2.x(); -// } -// -// -// @Override -// public double y() -// { -// return c1.y() + c2.y(); -// } -// -// -// @Override -// public double z() -// { -// return c1.z() + c2.z(); -// } -// -// }; -// } -// -// -// public static VecView _add(final VecValue c, final Object x, final Object y) -// { -// return _add(c, x, y, 0); -// } -// -// -// public static VecView _add(final VecValue c, final Object x, final Object y, final Object z) -// { -// return new SynthCoord3D() { -// -// @Override -// public double x() -// { -// return c.x() + num(x); -// } -// -// -// @Override -// public double y() -// { -// return c.y() + num(y); -// } -// -// -// @Override -// public double z() -// { -// return c.z() + num(z); -// } -// -// }; -// } -// -// -// // --- sub --- -// -// public static VecView _sub(final VecValue c1, final VecValue c2) -// { -// return new SynthCoord3D() { -// -// @Override -// public double x() -// { -// return c1.x() - c2.x(); -// } -// -// -// @Override -// public double y() -// { -// return c1.y() - c2.y(); -// } -// -// -// @Override -// public double z() -// { -// return c1.z() - c2.z(); -// } -// -// }; -// } -// -// -// public static VecView _sub(final VecValue c, final Object x, final Object y) -// { -// return _add(c, x, y, 0); -// } -// -// -// public static VecView _sub(final VecValue c, final Object x, final Object y, final Object z) -// { -// return new SynthCoord3D() { -// -// @Override -// public double x() -// { -// return c.x() - num(x); -// } -// -// -// @Override -// public double y() -// { -// return c.y() - num(y); -// } -// -// -// @Override -// public double z() -// { -// return c.z() - num(z); -// } -// -// }; -// } -// -// -// // --- mul --- -// -// public static VecView _mul(final VecValue c, final Object mul) -// { -// return new SynthCoord3D() { -// -// @Override -// public double x() -// { -// return c.x() * num(mul); -// } -// -// -// @Override -// public double y() -// { -// return c.y() * num(mul); -// } -// -// -// @Override -// public double z() -// { -// return c.z() * num(mul); -// } -// -// }; -// } -// -// public static VecView _origin(final Rect r) -// { -// return r.getOrigin().view(); -// } -// -// -// public static VecView _size(final Rect r) -// { -// return r.getSize().view(); -// } -// -// -// public static NumberConstraint _width(final Rect r) -// { -// return _x(_size(r)); -// } -// -// -// public static NumberConstraint _height(final Rect r) -// { -// return _y(_size(r)); -// } -// -// -// public static VecView _center(final Rect r) -// { -// return _add(_origin(r), _half(_size(r))); -// } -// -// -// public static VecView _top_left(final Rect r) -// { -// return _origin(r); -// } -// -// -// public static VecView _top_right(final Rect r) -// { -// return _add(_origin(r), _width(r), 0); -// } -// -// -// public static VecView _bottom_left(final Rect r) -// { -// return _add(_origin(r), 0, _height(r)); -// } -// -// -// public static VecView _bottom_right(final Rect r) -// { -// return _add(_origin(r), _size(r)); -// } -// -// -// public static VecView _center_top(final Rect r) -// { -// return _add(_origin(r), _half(_width(r)), 0); -// } -// -// -// public static VecView _center_bottom(final Rect r) -// { -// return _add(_origin(r), _half(_width(r)), _height(r)); -// } -// -// -// public static VecView _center_left(final Rect r) -// { -// return _add(_origin(r), 0, _half(_height(r))); -// } -// -// -// public static VecView _center_right(final Rect r) -// { -// return _add(_origin(r), _width(r), _half(_height(r))); -// } -// -//} diff --git a/src/mightypork/utils/math/rect/xx/Rectd.java b/src/mightypork/utils/math/rect/xx/Rectd.java deleted file mode 100644 index fc022de..0000000 --- a/src/mightypork/utils/math/rect/xx/Rectd.java +++ /dev/null @@ -1,909 +0,0 @@ -package mightypork.utils.math.rect.xx; - - -//package mightypork.utils.math.rect; -// -// -//import mightypork.utils.math.Calc; -//import mightypork.utils.math.constraints.NumberConstraint; -//import mightypork.utils.math.constraints.RectConstraint; -//import mightypork.utils.math.coord.ConstrCoord; -//import mightypork.utils.math.coord.VecValue; -//import mightypork.utils.math.coord.VecArith; -//import mightypork.utils.math.coord.VecMutable; -// -// -///** -// * Rectangle determined by two coordinates - min and max. -// * -// * @author MightyPork -// */ -//public class Rectd implements RectConstraint, IRect { -// -// public static final IRect ZERO = new FixedRect(0, 0, 0, 0).freeze(); -// public static final Rect ONE = new FixedRect(0, 0, 1, 1).freeze(); -// -// -// /** -// * Rectangle from size; coords are copied. -// * -// * @param min min coord -// * @param size rect size -// * @return the rect -// */ -// public static Rect fromSize(VecArith min, VecValue size) -// { -// return fromSize(min, size.xi(), size.yi()); -// } -// -// -// /** -// * Make rect from min coord and size; coords are copied. -// * -// * @param min min coord -// * @param width size x -// * @param height size y -// * @return the new rect -// */ -// public static Rect fromSize(VecArith min, double width, double height) -// { -// return new FixedRect(min.copy(), min.add(width, height)); -// } -// -// -// /** -// * Rectangle from size -// * -// * @param sizeX size x -// * @param sizeY size y -// * @return rect -// */ -// public static IRect fromSize(double sizeX, double sizeY) -// { -// return fromSize(0, 0, sizeX, sizeY); -// } -// -// -// /** -// * Get rect from size -// * -// * @param size size -// * @return rect -// */ -// public static IRect fromSize(VecValue size) -// { -// return fromSize(0, 0, size.x(), size.y()); -// } -// -// -// /** -// * Make rect from min coord and size -// * -// * @param xmin min x -// * @param ymin min y -// * @param width size x -// * @param height size y -// * @return the new rect -// */ -// public static Rect fromSize(double xmin, double ymin, double width, double height) -// { -// return new FixedRect(xmin, ymin, xmin + width, ymin + height); -// } -// -// /** Lowest coordinates xy */ -// protected final VecArith min; -// -// /** Highest coordinates xy */ -// protected final VecArith max; -// -// // view of secondary corners. -// -// //@formatter:off -// private final ConstrCoord HMinVMax = new ConstrCoord( -// new NumberConstraint() { -// @Override -// public double getValue() -// { -// return min.x(); -// } -// }, -// new NumberConstraint() { -// @Override -// public double getValue() -// { -// return max.y(); -// } -// }, -// null -// ); -// -// -// private final ConstrCoord HMaxVMin = new ConstrCoord( -// new NumberConstraint() { -// @Override -// public double getValue() { -// return max.x(); -// } -// }, -// new NumberConstraint() { -// @Override -// public double getValue() -// { -// return min.y(); -// } -// }, -// null -// ); -// //@formatter:on -// -// private boolean frozen; -// -// -// public boolean isWritable() -// { -// return !frozen && !isView(); -// } -// -// -// public boolean isView() -// { -// return false; -// } -// -// -// public Rect freeze() -// { -// min.copy(); -// max.copy(); -// frozen = true; -// return this; -// } -// -// -// /** -// * Get a readonly view -// * -// * @return view -// */ -// public RectView view() -// { -// return new RectView(this); -// } -// -// -// protected void assertWritable() -// { -// if (!isWritable()) { -// throw new UnsupportedOperationException("This Rect is not writable."); -// } -// } -// -// -// /** -// * New Rect [0, 0, 0, 0] -// */ -// public Rect() { -// this(0, 0, 0, 0); -// } -// -// -// /** -// * Rect [0, 0, size.x, size.y] -// * -// * @param size size coord -// */ -// public Rect(VecValue size) { -// this(0, 0, size.x(), size.y()); -// } -// -// -// /** -// * New rect of two coords; Coords are plugged in directly (ie. views can be -// * used for frozen rect representing another) -// * -// * @param min coord 1 -// * @param max coord 2 -// */ -// public Rect(VecValue min, VecValue max) { -// this.min = min; // must not copy -// this.max = max; // must not copy -// } -// -// -// /** -// * New Rect -// * -// * @param xmin lower x -// * @param ymin lower y -// * @param xmax upper x -// * @param ymax upper y -// */ -// public Rect(double xmin, double ymin, double xmax, double ymax) { -// min = new VecArith(xmin, ymin); -// max = new VecArith(xmax, ymax); -// } -// -// -// /** -// * Rect [0, 0, x, y] -// * -// * @param x width -// * @param y height -// */ -// public Rect(double x, double y) { -// this(0, 0, x, y); -// } -// -// -// /** -// * New rect as a copy of other rect -// * -// * @param r other rect -// */ -// public Rect(Rect r) { -// this(r.min.copy(), r.max.copy()); -// } -// -// -// /** -// * Get offset copy (add) -// * -// * @param move offset vector -// * @return offset copy -// */ -// @Override -// public Rect move(VecMutable move) -// { -// return copy().add_ip(move); -// } -// -// -// /** -// * Add X and Y to all coordinates in a copy -// * -// * @param x x to add -// * @param y y to add -// * @return copy changed -// */ -// @Override -// public Rect move(double x, double y) -// { -// return move(new VecArith(x, y)); -// } -// -// -// /** -// * Offset in place (add) -// * -// * @param move offset vector -// * @return this -// */ -// public Rect add_ip(VecMutable move) -// { -// min.add_ip(move); -// max.add_ip(move); -// return this; -// } -// -// -// /** -// * Add X and Y to all coordinates in place -// * -// * @param x x to add -// * @param y y to add -// * @return this -// */ -// public IRect add_ip(double x, double y) -// { -// return add_ip(new VecArith(x, y)); -// } -// -// -// /** -// * Get a copy -// * -// * @return copy -// */ -// @Override -// public Rect copy() -// { -// return new FixedRect(this); -// } -// -// -// /** -// * Get rect center -// * -// * @return center -// */ -// @Override -// public VecValue getCenter() -// { -// return min.midTo(max).copy(); -// } -// -// -// /** -// * Get center of the lower edge. -// * -// * @return center -// */ -// @Override -// public VecValue getCenterVMin() -// { -// return new VecArith((max.x() + min.x()) / 2D, min.y()).copy(); -// } -// -// -// /** -// * Get center of the left edge. -// * -// * @return center -// */ -// @Override -// public VecValue getCenterHMin() -// { -// return new VecArith(min.x(), (max.y() + min.y()) / 2D).copy(); -// } -// -// -// /** -// * Get center of the right edge. -// * -// * @return center -// */ -// @Override -// public VecValue getCenterHMax() -// { -// return new VecArith(max.x(), (max.y() + min.y()) / 2D).copy(); -// } -// -// -// /** -// * Get center of the top edge. -// * -// * @return center -// */ -// @Override -// public VecValue getCenterVMax() -// { -// return new VecArith((max.x() + min.x()) / 2D, max.y()).copy(); -// } -// -// -// /** -// * Get left bottom -// * -// * @return center -// */ -// @Override -// public VecArith getHMinVMin() -// { -// return min.view(); -// } -// -// -// /** -// * Get left top -// * -// * @return center -// */ -// @Override -// public VecValue getHMinVMax() -// { -// return HMinVMax; -// } -// -// -// /** -// * Get right bottom -// * -// * @return center -// */ -// @Override -// public VecValue getHMaxVMin() -// { -// return HMaxVMin; -// } -// -// -// /** -// * Get right top -// * -// * @return center -// */ -// @Override -// public VecArith getHMaxVMax() -// { -// return max.view(); -// } -// -// -// /** -// * Alias for getX2Y2 -// * -// * @return highest coordinates xy -// */ -// @Override -// public VecMutable getMax() -// { -// return getHMaxVMax(); -// } -// -// -// /** -// * Alias for getX1Y1 -// * -// * @return lowest coordinates xy -// */ -// @Override -// public VecMutable getMin() -// { -// return getHMinVMin(); -// } -// -// -// /** -// * Alias for getX1Y1 -// * -// * @return lowest coordinates xy -// */ -// public VecValue getOrigin() -// { -// return getHMinVMin(); -// } -// -// -// /** -// * Shrink to sides in copy -// * -// * @param shrink shrink size (added to each side) -// * @return shrinkn copy -// */ -// @Override -// public IRect shrink(VecValue shrink) -// { -// return copy().shrink_ip(shrink); -// } -// -// -// /** -// * Shrink to sides in copy -// * -// * @param x x to add -// * @param y y to add -// * @return changed copy -// */ -// @Override -// public IRect shrink(double x, double y) -// { -// return copy().shrink_ip(x, y); -// } -// -// -// /** -// * Shrink to sides in place -// * -// * @param shrink shrink size (added to each side) -// * @return this -// */ -// public IRect shrink_ip(VecValue shrink) -// { -// shrink_ip(shrink.x(), shrink.y()); -// return this; -// } -// -// -// /** -// * Shrink to sides in place -// * -// * @param x horizontal shrink -// * @param y vertical shrink -// * @return this -// */ -// public IRect shrink_ip(double x, double y) -// { -// min.sub_ip(x, y); -// max.add_ip(-x, -y); -// return this; -// } -// -// -// /** -// * Shrink the rect -// * -// * @param xmin shrink -// * @param ymin shrink -// * @param xmax shrink -// * @param ymax shrink -// * @return changed copy -// */ -// @Override -// public Rect shrink(double xmin, double ymin, double xmax, double ymax) -// { -// return copy().shrink_ip(xmin, ymin, xmax, ymax); -// } -// -// -// /** -// * Shrink the rect in place -// * -// * @param xmin shrink -// * @param ymin shrink -// * @param xmax shrink -// * @param ymax shrink -// * @return this -// */ -// public Rect shrink_ip(double xmin, double ymin, double xmax, double ymax) -// { -// min.add_ip(xmin, ymin); -// max.add_ip(-xmax, -ymax); -// return this; -// } -// -// -// /** -// * Grow to sides in copy -// * -// * @param grow grow size (added to each side) -// * @return grown copy -// */ -// @Override -// public IRect grow(VecValue grow) -// { -// return copy().grow_ip(grow); -// } -// -// -// /** -// * Grow to sides in copy -// * -// * @param x horizontal grow -// * @param y vertical grow -// * @return changed copy -// */ -// @Override -// public IRect grow(double x, double y) -// { -// return copy().grow_ip(x, y); -// } -// -// -// /** -// * Grow to sides in place -// * -// * @param grow grow size (added to each side) -// * @return this -// */ -// public IRect grow_ip(VecValue grow) -// { -// grow_ip(grow.x(), grow.y()); -// return this; -// } -// -// -// /** -// * Grow to sides in place -// * -// * @param x horizontal grow -// * @param y vertical grow -// * @return this -// */ -// public IRect grow_ip(double x, double y) -// { -// min.sub_ip(x, y); -// max.add_ip(x, y); -// return this; -// } -// -// -// /** -// * Grow the rect -// * -// * @param xmin growth -// * @param ymin growth -// * @param xmax growth -// * @param ymax growth -// * @return changed copy -// */ -// @Override -// public Rect grow(double xmin, double ymin, double xmax, double ymax) -// { -// return copy().grow_ip(xmin, ymin, xmax, ymax); -// } -// -// -// /** -// * Grow the rect in place -// * -// * @param xmin growth -// * @param ymin growth -// * @param xmax growth -// * @param ymax growth -// * @return this -// */ -// public Rect grow_ip(double xmin, double ymin, double xmax, double ymax) -// { -// min.add_ip(-xmin, -ymin); -// max.add_ip(xmax, ymax); -// return this; -// } -// -// -// /** -// * Check if point is inside this rectangle -// * -// * @param point point to test -// * @return is inside -// */ -// @Override -// public boolean isInside(VecValue point) -// { -// return Calc.inRange(point.x(), min.x(), max.x()) && Calc.inRange(point.y(), min.y(), max.y()); -// } -// -// -// /** -// * Multiply in copy -// * -// * @param factor multiplier -// * @return offset copy -// */ -// @Override -// public IRect mul(double factor) -// { -// return copy().mul_ip(factor); -// } -// -// -// /** -// * Multiply by number (useful for centered rects) -// * -// * @param x x multiplier -// * @param y y multiplier -// * @return copy multiplied -// */ -// @Override -// public IRect mul(double x, double y) -// { -// return copy().mul_ip(x, y); -// } -// -// -// /** -// * Multiply coord in place -// * -// * @param factor multiplier -// * @return this -// */ -// public IRect mul_ip(double factor) -// { -// min.mul_ip(factor); -// max.mul_ip(factor); -// return this; -// } -// -// -// /** -// * Multiply coord in place -// * -// * @param x multiplier x -// * @param y multiplier y -// * @return this -// */ -// public IRect mul_ip(double x, double y) -// { -// min.mul_ip(x, y, 1); -// max.mul_ip(x, y, 1); -// return this; -// } -// -// -// /** -// * Round coords in copy -// * -// * @return copy, rounded -// */ -// @Override -// public Rect round() -// { -// return new FixedRect(min.round(), max.round()); -// } -// -// -// /** -// * Round this in place -// * -// * @return this -// */ -// public IRect round_ip() -// { -// min.round_ip(); -// max.round_ip(); -// return this; -// } -// -// -// /** -// * Set to coordinates -// * -// * @param xmin lower x -// * @param ymin lower y -// * @param xmax upper x -// * @param ymax upper y -// */ -// @Override -// public void setTo(double xmin, double ymin, double xmax, double ymax) -// { -// min.setTo(Math.min(xmin, xmax), Math.min(ymin, ymax)); -// max.setTo(Math.max(xmin, xmax), Math.max(ymin, ymax)); -// } -// -// -// /** -// * Set to other rect's coordinates -// * -// * @param r other rect -// */ -// @Override -// public void setTo(Rect r) -// { -// min.setTo(r.min); -// max.setTo(r.max); -// } -// -// -// /** -// * Subtract X and Y from all coordinates in a copy -// * -// * @param x x to subtract -// * @param y y to subtract -// * @return copy changed -// */ -// @Override -// public IRect sub(double x, double y) -// { -// return sub(new VecArith(x, y)); -// } -// -// -// /** -// * Get offset copy (subtract) -// * -// * @param move offset vector -// * @return offset copy -// */ -// @Override -// public IRect sub(VecMutable move) -// { -// return copy().sub_ip(move); -// } -// -// -// /** -// * Subtract X and Y from all coordinates in place -// * -// * @param x x to subtract -// * @param y y to subtract -// * @return this -// */ -// public IRect sub_ip(double x, double y) -// { -// return sub_ip(new VecArith(x, y)); -// } -// -// -// /** -// * Offset in place (subtract) -// * -// * @param move offset vector -// * @return this -// */ -// public IRect sub_ip(VecMutable move) -// { -// min.sub_ip(move); -// max.sub_ip(move); -// return this; -// } -// -// -// @Override -// public String toString() -// { -// return String.format("[%s-%s]", min.toString(), max.toString()); -// } -// -// -// /** -// * @return lower x -// */ -// @Override -// public double xMin() -// { -// return min.x(); -// } -// -// -// /** -// * @return upper x -// */ -// @Override -// public double xMax() -// { -// return max.x(); -// } -// -// -// /** -// * @return lower y -// */ -// @Override -// public double yMin() -// { -// return min.y(); -// } -// -// -// /** -// * @return upper y -// */ -// @Override -// public double yMax() -// { -// return max.y(); -// } -// -// -// @Override -// public double getHeight() -// { -// return max.y() - min.y(); -// } -// -// -// @Override -// public double getWidth() -// { -// return max.x() - min.x(); -// } -// -// -// /** -// * Get size (width, height) as (x,y) -// * -// * @return coord of width,height -// */ -// public VecValue getSize() -// { -// return new VecArith(max.x() - min.x(), max.y() - min.y()); -// } -// -// -// @Override -// public RectView getRect() -// { -// return this; -// } -// -// -// /** -// * Generate zero rect -// * -// * @return zero -// */ -// public static IRect zero() -// { -// return ZERO.copy(); -// } -// -// -// /** -// * Generate 0,0-1,1 rect -// * -// * @return one -// */ -// public static IRect one() -// { -// return ZERO.copy(); -// } -//}