diff --git a/src/main/java/pythagoras/f/AbstractArc.java b/src/main/java/pythagoras/f/AbstractArc.java index f6efee0..b8dbd2d 100644 --- a/src/main/java/pythagoras/f/AbstractArc.java +++ b/src/main/java/pythagoras/f/AbstractArc.java @@ -13,37 +13,37 @@ import java.util.NoSuchElementException; public abstract class AbstractArc extends RectangularShape implements IArc { @Override // from interface IArc - public Point getStartPoint () { - return getStartPoint(new Point()); + public Point startPoint () { + return startPoint(new Point()); } @Override // from interface IArc - public Point getStartPoint (Point target) { - float a = FloatMath.toRadians(getAngleStart()); - return target.set(getX() + (1f + FloatMath.cos(a)) * getWidth() / 2f, - getY() + (1f - FloatMath.sin(a)) * getHeight() / 2f); + public Point startPoint (Point target) { + float a = FloatMath.toRadians(angleStart()); + return target.set(x() + (1f + FloatMath.cos(a)) * width() / 2f, + y() + (1f - FloatMath.sin(a)) * height() / 2f); } @Override // from interface IArc - public Point getEndPoint () { - return getEndPoint(new Point()); + public Point endPoint () { + return endPoint(new Point()); } @Override // from interface IArc - public Point getEndPoint (Point target) { - float a = FloatMath.toRadians(getAngleStart() + getAngleExtent()); - return target.set(getX() + (1f + FloatMath.cos(a)) * getWidth() / 2f, - getY() + (1f - FloatMath.sin(a)) * getHeight() / 2f); + public Point endPoint (Point target) { + float a = FloatMath.toRadians(angleStart() + angleExtent()); + return target.set(x() + (1f + FloatMath.cos(a)) * width() / 2f, + y() + (1f - FloatMath.sin(a)) * height() / 2f); } @Override // from interface IArc public boolean containsAngle (float angle) { - float extent = getAngleExtent(); + float extent = angleExtent(); if (extent >= 360f) { return true; } - angle = getNormAngle(angle); - float a1 = getNormAngle(getAngleStart()); + angle = normAngle(angle); + float a1 = normAngle(angleStart()); float a2 = a1 + extent; if (a2 > 360f) { return angle >= a1 || angle <= a2 - 360f; @@ -56,41 +56,41 @@ public abstract class AbstractArc extends RectangularShape implements IArc @Override // from interface IArc public Arc clone () { - return new Arc(getX(), getY(), getWidth(), getHeight(), getAngleStart(), getAngleExtent(), - getArcType()); + return new Arc(x(), y(), width(), height(), angleStart(), angleExtent(), + arcType()); } @Override // from RectangularShape public boolean isEmpty () { - return getArcType() == OPEN || super.isEmpty(); + return arcType() == OPEN || super.isEmpty(); } @Override // from RectangularShape public boolean contains (float px, float py) { // normalize point - float nx = (px - getX()) / getWidth() - 0.5f; - float ny = (py - getY()) / getHeight() - 0.5f; + float nx = (px - x()) / width() - 0.5f; + float ny = (py - y()) / height() - 0.5f; if ((nx * nx + ny * ny) > 0.25) { return false; } - float extent = getAngleExtent(); + float extent = angleExtent(); float absExtent = Math.abs(extent); if (absExtent >= 360f) { return true; } boolean containsAngle = containsAngle(FloatMath.toDegrees(-FloatMath.atan2(ny, nx))); - if (getArcType() == PIE) { + if (arcType() == PIE) { return containsAngle; } if (absExtent <= 180f && !containsAngle) { return false; } - Line l = new Line(getStartPoint(), getEndPoint()); + Line l = new Line(startPoint(), endPoint()); int ccw1 = l.relativeCCW(px, py); - int ccw2 = l.relativeCCW(getCenterX(), getCenterY()); + int ccw2 = l.relativeCCW(centerX(), centerY()); return ccw1 == 0 || ccw2 == 0 || ((ccw1 + ccw2) == 0 ^ absExtent > 180f); } @@ -101,20 +101,20 @@ public abstract class AbstractArc extends RectangularShape implements IArc return false; } - float absExtent = Math.abs(getAngleExtent()); - if (getArcType() != PIE || absExtent <= 180f || absExtent >= 360f) { + float absExtent = Math.abs(angleExtent()); + if (arcType() != PIE || absExtent <= 180f || absExtent >= 360f) { return true; } Rectangle r = new Rectangle(rx, ry, rw, rh); - float cx = getCenterX(), cy = getCenterY(); + float cx = centerX(), cy = centerY(); if (r.contains(cx, cy)) { return false; } - Point p1 = getStartPoint(), p2 = getEndPoint(); - return !r.intersectsLine(cx, cy, p1.getX(), p1.getY()) && - !r.intersectsLine(cx, cy, p2.getX(), p2.getY()); + Point p1 = startPoint(), p2 = endPoint(); + return !r.intersectsLine(cx, cy, p1.x(), p1.y()) && + !r.intersectsLine(cx, cy, p2.x(), p2.y()); } @Override // from RectangularShape @@ -129,22 +129,22 @@ public abstract class AbstractArc extends RectangularShape implements IArc return true; } - float cx = getCenterX(), cy = getCenterY(); - Point p1 = getStartPoint(), p2 = getEndPoint(); + float cx = centerX(), cy = centerY(); + Point p1 = startPoint(), p2 = endPoint(); // check: does rectangle contain arc's points Rectangle r = new Rectangle(rx, ry, rw, rh); - if (r.contains(p1) || r.contains(p2) || (getArcType() == PIE && r.contains(cx, cy))) { + if (r.contains(p1) || r.contains(p2) || (arcType() == PIE && r.contains(cx, cy))) { return true; } - if (getArcType() == PIE) { - if (r.intersectsLine(p1.getX(), p1.getY(), cx, cy) || - r.intersectsLine(p2.getX(), p2.getY(), cx, cy)) { + if (arcType() == PIE) { + if (r.intersectsLine(p1.x(), p1.y(), cx, cy) || + r.intersectsLine(p2.x(), p2.y(), cx, cy)) { return true; } } else { - if (r.intersectsLine(p1.getX(), p1.getY(), p2.getX(), p2.getY())) { + if (r.intersectsLine(p1.x(), p1.y(), p2.x(), p2.y())) { return true; } } @@ -156,27 +156,27 @@ public abstract class AbstractArc extends RectangularShape implements IArc } @Override // from RectangularShape - public Rectangle getBounds (Rectangle target) { + public Rectangle bounds (Rectangle target) { if (isEmpty()) { - target.setBounds(getX(), getY(), getWidth(), getHeight()); + target.setBounds(x(), y(), width(), height()); return target; } - float rx1 = getX(); - float ry1 = getY(); - float rx2 = rx1 + getWidth(); - float ry2 = ry1 + getHeight(); + float rx1 = x(); + float ry1 = y(); + float rx2 = rx1 + width(); + float ry2 = ry1 + height(); - Point p1 = getStartPoint(), p2 = getEndPoint(); + Point p1 = startPoint(), p2 = endPoint(); - float bx1 = containsAngle(180f) ? rx1 : Math.min(p1.getX(), p2.getX()); - float by1 = containsAngle(90f) ? ry1 : Math.min(p1.getY(), p2.getY()); - float bx2 = containsAngle(0f) ? rx2 : Math.max(p1.getX(), p2.getX()); - float by2 = containsAngle(270f) ? ry2 : Math.max(p1.getY(), p2.getY()); + float bx1 = containsAngle(180f) ? rx1 : Math.min(p1.x(), p2.x()); + float by1 = containsAngle(90f) ? ry1 : Math.min(p1.y(), p2.y()); + float bx2 = containsAngle(0f) ? rx2 : Math.max(p1.x(), p2.x()); + float by2 = containsAngle(270f) ? ry2 : Math.max(p1.y(), p2.y()); - if (getArcType() == PIE) { - float cx = getCenterX(); - float cy = getCenterY(); + if (arcType() == PIE) { + float cx = centerX(); + float cy = centerY(); bx1 = Math.min(bx1, cx); by1 = Math.min(by1, cy); bx2 = Math.max(bx2, cx); @@ -187,12 +187,12 @@ public abstract class AbstractArc extends RectangularShape implements IArc } @Override // from interface IShape - public PathIterator getPathIterator (Transform at) { + public PathIterator pathIterator (Transform at) { return new Iterator(this, at); } /** Returns a normalized angle (bound between 0 and 360 degrees). */ - protected float getNormAngle (float angle) { + protected float normAngle (float angle) { return angle - FloatMath.floor(angle / 360f) * 360f; } @@ -258,13 +258,13 @@ public abstract class AbstractArc extends RectangularShape implements IArc private float my; Iterator (IArc a, Transform t) { - this.width = a.getWidth() / 2f; - this.height = a.getHeight() / 2f; - this.x = a.getX() + width; - this.y = a.getY() + height; - this.angle = -FloatMath.toRadians(a.getAngleStart()); - this.extent = -a.getAngleExtent(); - this.type = a.getArcType(); + this.width = a.width() / 2f; + this.height = a.height() / 2f; + this.x = a.x() + width; + this.y = a.y() + height; + this.angle = -FloatMath.toRadians(a.angleStart()); + this.extent = -a.angleExtent(); + this.type = a.arcType(); this.t = t; if (width < 0 || height < 0) { @@ -296,7 +296,7 @@ public abstract class AbstractArc extends RectangularShape implements IArc } } - @Override public int getWindingRule () { + @Override public int windingRule () { return WIND_NON_ZERO; } diff --git a/src/main/java/pythagoras/f/AbstractCubicCurve.java b/src/main/java/pythagoras/f/AbstractCubicCurve.java index c9c870f..7b841d7 100644 --- a/src/main/java/pythagoras/f/AbstractCubicCurve.java +++ b/src/main/java/pythagoras/f/AbstractCubicCurve.java @@ -13,35 +13,35 @@ import java.util.NoSuchElementException; public abstract class AbstractCubicCurve implements ICubicCurve { @Override // from interface ICubicCurve - public Point getP1 () { - return new Point(getX1(), getY1()); + public Point p1 () { + return new Point(x1(), y1()); } @Override // from interface ICubicCurve - public Point getCtrlP1 () { - return new Point(getCtrlX1(), getCtrlY1()); + public Point ctrlP1 () { + return new Point(ctrlX1(), ctrlY1()); } @Override // from interface ICubicCurve - public Point getCtrlP2 () { - return new Point(getCtrlX2(), getCtrlY2()); + public Point ctrlP2 () { + return new Point(ctrlX2(), ctrlY2()); } @Override // from interface ICubicCurve - public Point getP2 () { - return new Point(getX2(), getY2()); + public Point p2 () { + return new Point(x2(), y2()); } @Override // from interface ICubicCurve - public float getFlatnessSq () { - return CubicCurves.getFlatnessSq(getX1(), getY1(), getCtrlX1(), getCtrlY1(), - getCtrlX2(), getCtrlY2(), getX2(), getY2()); + public float flatnessSq () { + return CubicCurves.flatnessSq(x1(), y1(), ctrlX1(), ctrlY1(), + ctrlX2(), ctrlY2(), x2(), y2()); } @Override // from interface ICubicCurve - public float getFlatness () { - return CubicCurves.getFlatness(getX1(), getY1(), getCtrlX1(), getCtrlY1(), - getCtrlX2(), getCtrlY2(), getX2(), getY2()); + public float flatness () { + return CubicCurves.flatness(x1(), y1(), ctrlX1(), ctrlY1(), + ctrlX2(), ctrlY2(), x2(), y2()); } @Override // from interface ICubicCurve @@ -51,8 +51,8 @@ public abstract class AbstractCubicCurve implements ICubicCurve @Override // from interface ICubicCurve public CubicCurve clone () { - return new CubicCurve(getX1(), getY1(), getCtrlX1(), getCtrlY1(), - getCtrlX2(), getCtrlY2(), getX2(), getY2()); + return new CubicCurve(x1(), y1(), ctrlX1(), ctrlY1(), + ctrlX2(), ctrlY2(), x2(), y2()); } @Override // from interface IShape @@ -73,12 +73,12 @@ public abstract class AbstractCubicCurve implements ICubicCurve @Override // from interface IShape public boolean contains (IPoint p) { - return contains(p.getX(), p.getY()); + return contains(p.x(), p.y()); } @Override // from interface IShape public boolean contains (IRectangle r) { - return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + return contains(r.x(), r.y(), r.width(), r.height()); } @Override // from interface IShape @@ -89,19 +89,19 @@ public abstract class AbstractCubicCurve implements ICubicCurve @Override // from interface IShape public boolean intersects (IRectangle r) { - return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + return intersects(r.x(), r.y(), r.width(), r.height()); } @Override // from interface IShape - public Rectangle getBounds () { - return getBounds(new Rectangle()); + public Rectangle bounds () { + return bounds(new Rectangle()); } @Override // from interface IShape - public Rectangle getBounds (Rectangle target) { - float x1 = getX1(), y1 = getY1(), x2 = getX2(), y2 = getY2(); - float ctrlx1 = getCtrlX1(), ctrly1 = getCtrlY1(); - float ctrlx2 = getCtrlX2(), ctrly2 = getCtrlY2(); + public Rectangle bounds (Rectangle target) { + float x1 = x1(), y1 = y1(), x2 = x2(), y2 = y2(); + float ctrlx1 = ctrlX1(), ctrly1 = ctrlY1(); + float ctrlx2 = ctrlX2(), ctrly2 = ctrlY2(); float rx1 = Math.min(Math.min(x1, x2), Math.min(ctrlx1, ctrlx2)); float ry1 = Math.min(Math.min(y1, y2), Math.min(ctrly1, ctrly2)); float rx2 = Math.max(Math.max(x1, x2), Math.max(ctrlx1, ctrlx2)); @@ -111,13 +111,13 @@ public abstract class AbstractCubicCurve implements ICubicCurve } @Override // from interface IShape - public PathIterator getPathIterator (Transform t) { + public PathIterator pathIterator (Transform t) { return new Iterator(this, t); } @Override // from interface IShape - public PathIterator getPathIterator (Transform at, float flatness) { - return new FlatteningPathIterator(getPathIterator(at), flatness); + public PathIterator pathIterator (Transform at, float flatness) { + return new FlatteningPathIterator(pathIterator(at), flatness); } /** An iterator over an {@link ICubicCurve}. */ @@ -132,7 +132,7 @@ public abstract class AbstractCubicCurve implements ICubicCurve this.t = t; } - @Override public int getWindingRule () { + @Override public int windingRule () { return WIND_NON_ZERO; } @@ -152,17 +152,17 @@ public abstract class AbstractCubicCurve implements ICubicCurve int count; if (index == 0) { type = SEG_MOVETO; - coords[0] = c.getX1(); - coords[1] = c.getY1(); + coords[0] = c.x1(); + coords[1] = c.y1(); count = 1; } else { type = SEG_CUBICTO; - coords[0] = c.getCtrlX1(); - coords[1] = c.getCtrlY1(); - coords[2] = c.getCtrlX2(); - coords[3] = c.getCtrlY2(); - coords[4] = c.getX2(); - coords[5] = c.getY2(); + coords[0] = c.ctrlX1(); + coords[1] = c.ctrlY1(); + coords[2] = c.ctrlX2(); + coords[3] = c.ctrlY2(); + coords[4] = c.x2(); + coords[5] = c.y2(); count = 3; } if (t != null) { diff --git a/src/main/java/pythagoras/f/AbstractDimension.java b/src/main/java/pythagoras/f/AbstractDimension.java index f089519..f38da64 100644 --- a/src/main/java/pythagoras/f/AbstractDimension.java +++ b/src/main/java/pythagoras/f/AbstractDimension.java @@ -19,7 +19,7 @@ public abstract class AbstractDimension implements IDimension @Override public int hashCode () { - return Platform.hashCode(getWidth()) ^ Platform.hashCode(getHeight()); + return Platform.hashCode(width()) ^ Platform.hashCode(height()); } @Override @@ -29,13 +29,13 @@ public abstract class AbstractDimension implements IDimension } if (obj instanceof AbstractDimension) { AbstractDimension d = (AbstractDimension)obj; - return (d.getWidth() == getWidth() && d.getHeight() == getHeight()); + return (d.width() == width() && d.height() == height()); } return false; } @Override public String toString () { - return Dimensions.dimenToString(getWidth(), getHeight()); + return Dimensions.dimenToString(width(), height()); } } diff --git a/src/main/java/pythagoras/f/AbstractEllipse.java b/src/main/java/pythagoras/f/AbstractEllipse.java index 070a0e7..7c4cef7 100644 --- a/src/main/java/pythagoras/f/AbstractEllipse.java +++ b/src/main/java/pythagoras/f/AbstractEllipse.java @@ -14,14 +14,14 @@ public abstract class AbstractEllipse extends RectangularShape implements IEllip { @Override // from IEllipse public Ellipse clone () { - return new Ellipse(getX(), getY(), getWidth(), getHeight()); + return new Ellipse(x(), y(), width(), height()); } @Override // from interface IShape public boolean contains (float px, float py) { if (isEmpty()) return false; - float a = (px - getX()) / getWidth() - 0.5f; - float b = (py - getY()) / getHeight() - 0.5f; + float a = (px - x()) / width() - 0.5f; + float b = (py - y()) / height() - 0.5f; return a * a + b * b < 0.25f; } @@ -35,8 +35,8 @@ public abstract class AbstractEllipse extends RectangularShape implements IEllip @Override // from interface IShape public boolean intersects (float rx, float ry, float rw, float rh) { if (isEmpty() || rw <= 0f || rh <= 0f) return false; - float cx = getX() + getWidth() / 2f; - float cy = getY() + getHeight() / 2f; + float cx = x() + width() / 2f; + float cy = y() + height() / 2f; float rx1 = rx, ry1 = ry, rx2 = rx + rw, ry2 = ry + rh; float nx = cx < rx1 ? rx1 : (cx > rx2 ? rx2 : cx); float ny = cy < ry1 ? ry1 : (cy > ry2 ? ry2 : cy); @@ -44,7 +44,7 @@ public abstract class AbstractEllipse extends RectangularShape implements IEllip } @Override // from interface IShape - public PathIterator getPathIterator (Transform at) { + public PathIterator pathIterator (Transform at) { return new Iterator(this, at); } @@ -56,17 +56,17 @@ public abstract class AbstractEllipse extends RectangularShape implements IEllip private int index; Iterator (IEllipse e, Transform t) { - this.x = e.getX(); - this.y = e.getY(); - this.width = e.getWidth(); - this.height = e.getHeight(); + this.x = e.x(); + this.y = e.y(); + this.width = e.width(); + this.height = e.height(); this.t = t; if (width < 0f || height < 0f) { index = 6; } } - @Override public int getWindingRule () { + @Override public int windingRule () { return WIND_NON_ZERO; } diff --git a/src/main/java/pythagoras/f/AbstractLine.java b/src/main/java/pythagoras/f/AbstractLine.java index 6a9fbbb..75d8977 100644 --- a/src/main/java/pythagoras/f/AbstractLine.java +++ b/src/main/java/pythagoras/f/AbstractLine.java @@ -13,78 +13,78 @@ import java.util.NoSuchElementException; public abstract class AbstractLine implements ILine { @Override // from interface ILine - public Point getP1 () { - return getP1(new Point()); + public Point p1 () { + return p1(new Point()); } @Override // from interface ILine - public Point getP1 (Point target) { - return target.set(getX1(), getY1()); + public Point p1 (Point target) { + return target.set(x1(), y1()); } @Override // from interface ILine - public Point getP2 () { - return getP2(new Point()); + public Point p2 () { + return p2(new Point()); } @Override // from interface ILine - public Point getP2 (Point target) { - return target.set(getX2(), getY2()); + public Point p2 (Point target) { + return target.set(x2(), y2()); } @Override // from interface ILine public float pointLineDistSq (float px, float py) { - return Lines.pointLineDistSq(px, py, getX1(), getY1(), getX2(), getY2()); + return Lines.pointLineDistSq(px, py, x1(), y1(), x2(), y2()); } @Override // from interface ILine public float pointLineDistSq (IPoint p) { - return Lines.pointLineDistSq(p.getX(), p.getY(), getX1(), getY1(), getX2(), getY2()); + return Lines.pointLineDistSq(p.x(), p.y(), x1(), y1(), x2(), y2()); } @Override // from interface ILine public float pointLineDist (float px, float py) { - return Lines.pointLineDist(px, py, getX1(), getY1(), getX2(), getY2()); + return Lines.pointLineDist(px, py, x1(), y1(), x2(), y2()); } @Override // from interface ILine public float pointLineDist (IPoint p) { - return Lines.pointLineDist(p.getX(), p.getY(), getX1(), getY1(), getX2(), getY2()); + return Lines.pointLineDist(p.x(), p.y(), x1(), y1(), x2(), y2()); } @Override // from interface ILine public float pointSegDistSq (float px, float py) { - return Lines.pointSegDistSq(px, py, getX1(), getY1(), getX2(), getY2()); + return Lines.pointSegDistSq(px, py, x1(), y1(), x2(), y2()); } @Override // from interface ILine public float pointSegDistSq (IPoint p) { - return Lines.pointSegDistSq(p.getX(), p.getY(), getX1(), getY1(), getX2(), getY2()); + return Lines.pointSegDistSq(p.x(), p.y(), x1(), y1(), x2(), y2()); } @Override // from interface ILine public float pointSegDist (float px, float py) { - return Lines.pointSegDist(px, py, getX1(), getY1(), getX2(), getY2()); + return Lines.pointSegDist(px, py, x1(), y1(), x2(), y2()); } @Override // from interface ILine public float pointSegDist (IPoint p) { - return Lines.pointSegDist(p.getX(), p.getY(), getX1(), getY1(), getX2(), getY2()); + return Lines.pointSegDist(p.x(), p.y(), x1(), y1(), x2(), y2()); } @Override // from interface ILine public int relativeCCW (float px, float py) { - return Lines.relativeCCW(px, py, getX1(), getY1(), getX2(), getY2()); + return Lines.relativeCCW(px, py, x1(), y1(), x2(), y2()); } @Override // from interface ILine public int relativeCCW (IPoint p) { - return Lines.relativeCCW(p.getX(), p.getY(), getX1(), getY1(), getX2(), getY2()); + return Lines.relativeCCW(p.x(), p.y(), x1(), y1(), x2(), y2()); } @Override // from interface ILine public Line clone () { - return new Line(getX1(), getY1(), getX2(), getY2()); + return new Line(x1(), y1(), x2(), y2()); } @Override // from interface IShape @@ -114,7 +114,7 @@ public abstract class AbstractLine implements ILine @Override // from interface IShape public boolean intersects (float rx, float ry, float rw, float rh) { - return Lines.lineIntersectsRect(getX1(), getY1(), getX2(), getY2(), rx, ry, rw, rh); + return Lines.lineIntersectsRect(x1(), y1(), x2(), y2(), rx, ry, rw, rh); } @Override // from interface IShape @@ -123,13 +123,13 @@ public abstract class AbstractLine implements ILine } @Override // from interface IShape - public Rectangle getBounds () { - return getBounds(new Rectangle()); + public Rectangle bounds () { + return bounds(new Rectangle()); } @Override // from interface IShape - public Rectangle getBounds (Rectangle target) { - float x1 = getX1(), x2 = getX2(), y1 = getY1(), y2 = getY2(); + public Rectangle bounds (Rectangle target) { + float x1 = x1(), x2 = x2(), y1 = y1(), y2 = y2(); float rx, ry, rw, rh; if (x1 < x2) { rx = x1; @@ -150,12 +150,12 @@ public abstract class AbstractLine implements ILine } @Override // from interface IShape - public PathIterator getPathIterator (Transform at) { + public PathIterator pathIterator (Transform at) { return new Iterator(this, at); } @Override // from interface IShape - public PathIterator getPathIterator (Transform at, float flatness) { + public PathIterator pathIterator (Transform at, float flatness) { return new Iterator(this, at); } @@ -167,14 +167,14 @@ public abstract class AbstractLine implements ILine private int index; Iterator (ILine l, Transform at) { - this.x1 = l.getX1(); - this.y1 = l.getY1(); - this.x2 = l.getX2(); - this.y2 = l.getY2(); + this.x1 = l.x1(); + this.y1 = l.y1(); + this.x2 = l.x2(); + this.y2 = l.y2(); this.t = at; } - @Override public int getWindingRule () { + @Override public int windingRule () { return WIND_NON_ZERO; } diff --git a/src/main/java/pythagoras/f/AbstractPoint.java b/src/main/java/pythagoras/f/AbstractPoint.java index f18a4fa..2b914b7 100644 --- a/src/main/java/pythagoras/f/AbstractPoint.java +++ b/src/main/java/pythagoras/f/AbstractPoint.java @@ -14,22 +14,22 @@ public abstract class AbstractPoint implements IPoint { @Override // from IPoint public float distanceSq (float px, float py) { - return Points.distanceSq(getX(), getY(), px, py); + return Points.distanceSq(x(), y(), px, py); } @Override // from IPoint public float distanceSq (IPoint p) { - return Points.distanceSq(getX(), getY(), p.getX(), p.getY()); + return Points.distanceSq(x(), y(), p.x(), p.y()); } @Override // from IPoint public float distance (float px, float py) { - return Points.distance(getX(), getY(), px, py); + return Points.distance(x(), y(), px, py); } @Override // from IPoint public float distance (IPoint p) { - return Points.distance(getX(), getY(), p.getX(), p.getY()); + return Points.distance(x(), y(), p.x(), p.y()); } @Override // from IPoint @@ -39,17 +39,17 @@ public abstract class AbstractPoint implements IPoint @Override // from IPoint public Point mult (float s, Point result) { - return result.set(getX() * s, getY() * s); + return result.set(x() * s, y() * s); } @Override // from IPoint public Point add (float x, float y) { - return new Point(getX() + x, getY() + y); + return new Point(x() + x, y() + y); } @Override // from IPoint public Point add (float x, float y, Point result) { - return result.set(getX() + x, getY() + y); + return result.set(x() + x, y() + y); } @Override // from IPoint @@ -59,7 +59,7 @@ public abstract class AbstractPoint implements IPoint @Override // from IPoint public Point rotate (float angle, Point result) { - float x = getX(), y = getY(); + float x = x(), y = y(); float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); return result.set(x*cosa - y*sina, x*sina + y*cosa); } @@ -76,18 +76,18 @@ public abstract class AbstractPoint implements IPoint } if (obj instanceof AbstractPoint) { AbstractPoint p = (AbstractPoint)obj; - return getX() == p.getX() && getY() == p.getY(); + return x() == p.x() && y() == p.y(); } return false; } @Override public int hashCode () { - return Platform.hashCode(getX()) ^ Platform.hashCode(getY()); + return Platform.hashCode(x()) ^ Platform.hashCode(y()); } @Override public String toString () { - return Points.pointToString(getX(), getY()); + return Points.pointToString(x(), y()); } } diff --git a/src/main/java/pythagoras/f/AbstractQuadCurve.java b/src/main/java/pythagoras/f/AbstractQuadCurve.java index 865da78..9ab0011 100644 --- a/src/main/java/pythagoras/f/AbstractQuadCurve.java +++ b/src/main/java/pythagoras/f/AbstractQuadCurve.java @@ -13,28 +13,28 @@ import java.util.NoSuchElementException; public abstract class AbstractQuadCurve implements IQuadCurve { @Override // from interface IQuadCurve - public Point getP1 () { - return new Point(getX1(), getY1()); + public Point p1 () { + return new Point(x1(), y1()); } @Override // from interface IQuadCurve - public Point getCtrlP () { - return new Point(getCtrlX(), getCtrlY()); + public Point ctrlP () { + return new Point(ctrlX(), ctrlY()); } @Override // from interface IQuadCurve - public Point getP2 () { - return new Point(getX2(), getY2()); + public Point p2 () { + return new Point(x2(), y2()); } @Override // from interface IQuadCurve - public float getFlatnessSq () { - return Lines.pointSegDistSq(getCtrlX(), getCtrlY(), getX1(), getY1(), getX2(), getY2()); + public float flatnessSq () { + return Lines.pointSegDistSq(ctrlX(), ctrlY(), x1(), y1(), x2(), y2()); } @Override // from interface IQuadCurve - public float getFlatness () { - return Lines.pointSegDist(getCtrlX(), getCtrlY(), getX1(), getY1(), getX2(), getY2()); + public float flatness () { + return Lines.pointSegDist(ctrlX(), ctrlY(), x1(), y1(), x2(), y2()); } @Override // from interface IQuadCurve @@ -44,7 +44,7 @@ public abstract class AbstractQuadCurve implements IQuadCurve @Override // from interface IQuadCurve public QuadCurve clone () { - return new QuadCurve(getX1(), getY1(), getCtrlX(), getCtrlY(), getX2(), getY2()); + return new QuadCurve(x1(), y1(), ctrlX(), ctrlY(), x2(), y2()); } @Override // from interface IShape @@ -65,12 +65,12 @@ public abstract class AbstractQuadCurve implements IQuadCurve @Override // from interface IShape public boolean contains (IPoint p) { - return contains(p.getX(), p.getY()); + return contains(p.x(), p.y()); } @Override // from interface IShape public boolean contains (IRectangle r) { - return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + return contains(r.x(), r.y(), r.width(), r.height()); } @Override // from interface IShape @@ -81,18 +81,18 @@ public abstract class AbstractQuadCurve implements IQuadCurve @Override // from interface IShape public boolean intersects (IRectangle r) { - return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + return intersects(r.x(), r.y(), r.width(), r.height()); } @Override // from interface IShape - public Rectangle getBounds () { - return getBounds(new Rectangle()); + public Rectangle bounds () { + return bounds(new Rectangle()); } @Override // from interface IShape - public Rectangle getBounds (Rectangle target) { - float x1 = getX1(), y1 = getY1(), x2 = getX2(), y2 = getY2(); - float ctrlx = getCtrlX(), ctrly = getCtrlY(); + public Rectangle bounds (Rectangle target) { + float x1 = x1(), y1 = y1(), x2 = x2(), y2 = y2(); + float ctrlx = ctrlX(), ctrly = ctrlY(); float rx0 = Math.min(Math.min(x1, x2), ctrlx); float ry0 = Math.min(Math.min(y1, y2), ctrly); float rx1 = Math.max(Math.max(x1, x2), ctrlx); @@ -102,13 +102,13 @@ public abstract class AbstractQuadCurve implements IQuadCurve } @Override // from interface IShape - public PathIterator getPathIterator (Transform t) { + public PathIterator pathIterator (Transform t) { return new Iterator(this, t); } @Override // from interface IShape - public PathIterator getPathIterator (Transform t, float flatness) { - return new FlatteningPathIterator(getPathIterator(t), flatness); + public PathIterator pathIterator (Transform t, float flatness) { + return new FlatteningPathIterator(pathIterator(t), flatness); } /** An iterator over an {@link IQuadCurve}. */ @@ -123,7 +123,7 @@ public abstract class AbstractQuadCurve implements IQuadCurve this.t = t; } - @Override public int getWindingRule () { + @Override public int windingRule () { return WIND_NON_ZERO; } @@ -143,15 +143,15 @@ public abstract class AbstractQuadCurve implements IQuadCurve int count; if (index == 0) { type = SEG_MOVETO; - coords[0] = c.getX1(); - coords[1] = c.getY1(); + coords[0] = c.x1(); + coords[1] = c.y1(); count = 1; } else { type = SEG_QUADTO; - coords[0] = c.getCtrlX(); - coords[1] = c.getCtrlY(); - coords[2] = c.getX2(); - coords[3] = c.getY2(); + coords[0] = c.ctrlX(); + coords[1] = c.ctrlY(); + coords[2] = c.x2(); + coords[3] = c.y2(); count = 2; } if (t != null) { diff --git a/src/main/java/pythagoras/f/AbstractRectangle.java b/src/main/java/pythagoras/f/AbstractRectangle.java index 3cf4c40..c62c440 100644 --- a/src/main/java/pythagoras/f/AbstractRectangle.java +++ b/src/main/java/pythagoras/f/AbstractRectangle.java @@ -15,38 +15,38 @@ import pythagoras.util.Platform; public abstract class AbstractRectangle extends RectangularShape implements IRectangle { @Override // from interface IRectangle - public Point getLocation () { - return getLocation(new Point()); + public Point location () { + return location(new Point()); } @Override // from interface IRectangle - public Point getLocation (Point target) { - return target.set(getX(), getY()); + public Point location (Point target) { + return target.set(x(), y()); } @Override // from interface IRectangle - public Dimension getSize () { - return getSize(new Dimension()); + public Dimension size () { + return size(new Dimension()); } @Override // from interface IRectangle - public Dimension getSize (Dimension target) { - target.setSize(getWidth(), getHeight()); + public Dimension size (Dimension target) { + target.setSize(width(), height()); return target; } @Override // from interface IRectangle public Rectangle intersection (float rx, float ry, float rw, float rh) { - float x1 = Math.max(getX(), rx); - float y1 = Math.max(getY(), ry); - float x2 = Math.min(getMaxX(), rx + rw); - float y2 = Math.min(getMaxY(), ry + rh); + float x1 = Math.max(x(), rx); + float y1 = Math.max(y(), ry); + float x2 = Math.min(maxX(), rx + rw); + float y2 = Math.min(maxY(), ry + rh); return new Rectangle(x1, y1, x2 - x1, y2 - y1); } @Override // from interface IRectangle public Rectangle intersection (IRectangle r) { - return intersection(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + return intersection(r.x(), r.y(), r.width(), r.height()); } @Override // from interface IRectangle @@ -58,31 +58,31 @@ public abstract class AbstractRectangle extends RectangularShape implements IRec @Override // from interface IRectangle public boolean intersectsLine (float x1, float y1, float x2, float y2) { - return Lines.lineIntersectsRect(x1, y1, x2, y2, getX(), getY(), getWidth(), getHeight()); + return Lines.lineIntersectsRect(x1, y1, x2, y2, x(), y(), width(), height()); } @Override // from interface IRectangle public boolean intersectsLine (ILine l) { - return intersectsLine(l.getX1(), l.getY1(), l.getX2(), l.getY2()); + return intersectsLine(l.x1(), l.y1(), l.x2(), l.y2()); } @Override // from interface IRectangle public int outcode (float px, float py) { int code = 0; - if (getWidth() <= 0) { + if (width() <= 0) { code |= OUT_LEFT | OUT_RIGHT; - } else if (px < getX()) { + } else if (px < x()) { code |= OUT_LEFT; - } else if (px > getMaxX()) { + } else if (px > maxX()) { code |= OUT_RIGHT; } - if (getHeight() <= 0) { + if (height() <= 0) { code |= OUT_TOP | OUT_BOTTOM; - } else if (py < getY()) { + } else if (py < y()) { code |= OUT_TOP; - } else if (py > getMaxY()) { + } else if (py > maxY()) { code |= OUT_BOTTOM; } @@ -91,7 +91,7 @@ public abstract class AbstractRectangle extends RectangularShape implements IRec @Override // from interface IRectangle public int outcode (IPoint p) { - return outcode(p.getX(), p.getY()); + return outcode(p.x(), p.y()); } @Override // from interface IRectangle @@ -103,19 +103,19 @@ public abstract class AbstractRectangle extends RectangularShape implements IRec public boolean contains (float px, float py) { if (isEmpty()) return false; - float x = getX(), y = getY(); + float x = x(), y = y(); if (px < x || py < y) return false; px -= x; py -= y; - return px < getWidth() && py < getHeight(); + return px < width() && py < height(); } @Override // from interface IShape public boolean contains (float rx, float ry, float rw, float rh) { if (isEmpty()) return false; - float x1 = getX(), y1 = getY(), x2 = x1 + getWidth(), y2 = y1 + getHeight(); + float x1 = x(), y1 = y(), x2 = x1 + width(), y2 = y1 + height(); return (x1 <= rx) && (rx + rw <= x2) && (y1 <= ry) && (ry + rh <= y2); } @@ -123,17 +123,17 @@ public abstract class AbstractRectangle extends RectangularShape implements IRec public boolean intersects (float rx, float ry, float rw, float rh) { if (isEmpty()) return false; - float x1 = getX(), y1 = getY(), x2 = x1 + getWidth(), y2 = y1 + getHeight(); + float x1 = x(), y1 = y(), x2 = x1 + width(), y2 = y1 + height(); return (rx + rw > x1) && (rx < x2) && (ry + rh > y1) && (ry < y2); } @Override // from interface IShape - public PathIterator getPathIterator (Transform t) { + public PathIterator pathIterator (Transform t) { return new Iterator(this, t); } @Override // from interface IShape - public PathIterator getPathIterator (Transform t, float flatness) { + public PathIterator pathIterator (Transform t, float flatness) { return new Iterator(this, t); } @@ -144,22 +144,22 @@ public abstract class AbstractRectangle extends RectangularShape implements IRec } if (obj instanceof AbstractRectangle) { AbstractRectangle r = (AbstractRectangle)obj; - return r.getX() == getX() && r.getY() == getY() && - r.getWidth() == getWidth() && r.getHeight() == getHeight(); + return r.x() == x() && r.y() == y() && + r.width() == width() && r.height() == height(); } return false; } @Override // from Object public int hashCode () { - return Platform.hashCode(getX()) ^ Platform.hashCode(getY()) ^ - Platform.hashCode(getWidth()) ^ Platform.hashCode(getHeight()); + return Platform.hashCode(x()) ^ Platform.hashCode(y()) ^ + Platform.hashCode(width()) ^ Platform.hashCode(height()); } @Override // from Object public String toString () { - return Dimensions.dimenToString(getWidth(), getHeight()) + - Points.pointToString(getX(), getY()); + return Dimensions.dimenToString(width(), height()) + + Points.pointToString(x(), y()); } /** An iterator over an {@link IRectangle}. */ @@ -172,17 +172,17 @@ public abstract class AbstractRectangle extends RectangularShape implements IRec private int index; Iterator (IRectangle r, Transform at) { - this.x = r.getX(); - this.y = r.getY(); - this.width = r.getWidth(); - this.height = r.getHeight(); + this.x = r.x(); + this.y = r.y(); + this.width = r.width(); + this.height = r.height(); this.t = at; if (width < 0f || height < 0f) { index = 6; } } - @Override public int getWindingRule () { + @Override public int windingRule () { return WIND_NON_ZERO; } diff --git a/src/main/java/pythagoras/f/AbstractRoundRectangle.java b/src/main/java/pythagoras/f/AbstractRoundRectangle.java index 0e534c5..354788b 100644 --- a/src/main/java/pythagoras/f/AbstractRoundRectangle.java +++ b/src/main/java/pythagoras/f/AbstractRoundRectangle.java @@ -14,21 +14,21 @@ public abstract class AbstractRoundRectangle extends RectangularShape implements { @Override // from interface IRoundRectangle public RoundRectangle clone () { - return new RoundRectangle(getX(), getY(), getWidth(), getHeight(), - getArcWidth(), getArcHeight()); + return new RoundRectangle(x(), y(), width(), height(), + arcWidth(), arcHeight()); } @Override // from interface IShape public boolean contains (float px, float py) { if (isEmpty()) return false; - float rx1 = getX(), ry1 = getY(); - float rx2 = rx1 + getWidth(), ry2 = ry1 + getHeight(); + float rx1 = x(), ry1 = y(); + float rx2 = rx1 + width(), ry2 = ry1 + height(); if (px < rx1 || px >= rx2 || py < ry1 || py >= ry2) { return false; } - float aw = getArcWidth() / 2f, ah = getArcHeight() / 2f; + float aw = arcWidth() / 2f, ah = arcHeight() / 2f; float cx, cy; if (px < rx1 + aw) { cx = rx1 + aw; @@ -62,7 +62,7 @@ public abstract class AbstractRoundRectangle extends RectangularShape implements public boolean intersects (float rx, float ry, float rw, float rh) { if (isEmpty() || rw <= 0f || rh <= 0f) return false; - float x1 = getX(), y1 = getY(), x2 = x1 + getWidth(), y2 = y1 + getHeight(); + float x1 = x(), y1 = y(), x2 = x1 + width(), y2 = y1 + height(); float rx1 = rx, ry1 = ry, rx2 = rx + rw, ry2 = ry + rh; if (rx2 < x1 || x2 < rx1 || ry2 < y1 || y2 < ry1) { return false; @@ -75,7 +75,7 @@ public abstract class AbstractRoundRectangle extends RectangularShape implements } @Override // from interface IShape - public PathIterator getPathIterator (Transform at) { + public PathIterator pathIterator (Transform at) { return new Iterator(this, at); } @@ -87,19 +87,19 @@ public abstract class AbstractRoundRectangle extends RectangularShape implements private int index; Iterator (IRoundRectangle rr, Transform at) { - this.x = rr.getX(); - this.y = rr.getY(); - this.width = rr.getWidth(); - this.height = rr.getHeight(); - this.aw = Math.min(width, rr.getArcWidth()); - this.ah = Math.min(height, rr.getArcHeight()); + this.x = rr.x(); + this.y = rr.y(); + this.width = rr.width(); + this.height = rr.height(); + this.aw = Math.min(width, rr.arcWidth()); + this.ah = Math.min(height, rr.arcHeight()); this.t = at; if (width < 0f || height < 0f || aw < 0f || ah < 0f) { index = POINTS.length; } } - @Override public int getWindingRule () { + @Override public int windingRule () { return WIND_NON_ZERO; } diff --git a/src/main/java/pythagoras/f/AbstractTransform.java b/src/main/java/pythagoras/f/AbstractTransform.java index 2f2f4ee..305e985 100644 --- a/src/main/java/pythagoras/f/AbstractTransform.java +++ b/src/main/java/pythagoras/f/AbstractTransform.java @@ -10,13 +10,13 @@ package pythagoras.f; public abstract class AbstractTransform implements Transform { @Override // from Transform - public Vector getScale () { - return new Vector(getScaleX(), getScaleY()); + public Vector scale () { + return new Vector(scaleX(), scaleY()); } @Override // from Transform - public Vector getTranslation () { - return new Vector(getTx(), getTy()); + public Vector translation () { + return new Vector(tx(), ty()); } @Override // from Transform diff --git a/src/main/java/pythagoras/f/AbstractVector.java b/src/main/java/pythagoras/f/AbstractVector.java index e12f97a..ad03d3d 100644 --- a/src/main/java/pythagoras/f/AbstractVector.java +++ b/src/main/java/pythagoras/f/AbstractVector.java @@ -14,7 +14,7 @@ public abstract class AbstractVector implements IVector { @Override // from interface IVector public float dot (IVector other) { - return getX()*other.getX() + getY()*other.getY(); + return x()*other.x() + y()*other.y(); } @Override // from interface IVector @@ -24,7 +24,7 @@ public abstract class AbstractVector implements IVector @Override // from interface IVector public Vector negate (Vector result) { - return result.set(-getX(), -getY()); + return result.set(-x(), -y()); } @Override // from interface IVector @@ -45,7 +45,7 @@ public abstract class AbstractVector implements IVector @Override // from interface IVector public float direction (IVector other) { - return FloatMath.atan2(other.getY() - getY(), other.getX() - getX()); + return FloatMath.atan2(other.y() - y(), other.x() - x()); } @Override // from interface IVector @@ -55,7 +55,7 @@ public abstract class AbstractVector implements IVector @Override // from interface IVector public float lengthSq () { - float x = getX(), y = getY(); + float x = x(), y = y(); return (x*x + y*y); } @@ -66,7 +66,7 @@ public abstract class AbstractVector implements IVector @Override // from interface IVector public float distanceSq (IVector other) { - float dx = getX() - other.getX(), dy = getY() - other.getY(); + float dx = x() - other.x(), dy = y() - other.y(); return dx*dx + dy*dy; } @@ -77,7 +77,7 @@ public abstract class AbstractVector implements IVector @Override // from interface IVector public Vector mult (float v, Vector result) { - return result.set(getX()*v, getY()*v); + return result.set(x()*v, y()*v); } @Override // from interface IVector @@ -87,7 +87,7 @@ public abstract class AbstractVector implements IVector @Override // from interface IVector public Vector mult (IVector other, Vector result) { - return result.set(getX()*other.getX(), getY()*other.getY()); + return result.set(x()*other.x(), y()*other.y()); } @Override // from interface IVector @@ -97,7 +97,7 @@ public abstract class AbstractVector implements IVector @Override // from interface IVector public Vector add (IVector other, Vector result) { - return add(other.getX(), other.getY(), result); + return add(other.x(), other.y(), result); } @Override // from interface IVector @@ -107,7 +107,7 @@ public abstract class AbstractVector implements IVector @Override // from interface IVector public Vector subtract (IVector other, Vector result) { - return add(-other.getX(), -other.getY(), result); + return add(-other.x(), -other.y(), result); } @Override // from interface IVector @@ -117,7 +117,7 @@ public abstract class AbstractVector implements IVector @Override // from interface IVector public Vector add (float x, float y, Vector result) { - return result.set(getX() + x, getY() + y); + return result.set(x() + x, y() + y); } @Override // from interface IVector @@ -127,7 +127,7 @@ public abstract class AbstractVector implements IVector @Override // from interface IVector public Vector addScaled (IVector other, float v, Vector result) { - return result.set(getX() + other.getX()*v, getY() + other.getY()*v); + return result.set(x() + other.x()*v, y() + other.y()*v); } @Override // from interface IVector @@ -137,24 +137,24 @@ public abstract class AbstractVector implements IVector @Override // from interface IVector public Vector rotate (float angle, Vector result) { - float x = getX(), y = getY(); + float x = x(), y = y(); float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); return result.set(x*cosa - y*sina, x*sina + y*cosa); } @Override // from interface IVector public Vector rotateAndAdd (float angle, IVector add, Vector result) { - float x = getX(), y = getY(); + float x = x(), y = y(); float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); - return result.set(x*cosa - y*sina + add.getX(), x*sina + y*cosa + add.getY()); + return result.set(x*cosa - y*sina + add.x(), x*sina + y*cosa + add.y()); } @Override // from interface IVector public Vector rotateScaleAndAdd (float angle, float scale, IVector add, Vector result) { - float x = getX(), y = getY(); + float x = x(), y = y(); float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); - return result.set((x*cosa - y*sina)*scale + add.getX(), - (x*sina + y*cosa)*scale + add.getY()); + return result.set((x*cosa - y*sina)*scale + add.x(), + (x*sina + y*cosa)*scale + add.y()); } @Override // from interface IVector @@ -164,8 +164,8 @@ public abstract class AbstractVector implements IVector @Override // from interface IVector public Vector lerp (IVector other, float t, Vector result) { - float x = getX(), y = getY(); - float dx = other.getX() - x, dy = other.getY() - y; + float x = x(), y = y(); + float dx = other.x() - x, dy = other.y() - y; return result.set(x + t*dx, y + t*dy); } @@ -181,18 +181,18 @@ public abstract class AbstractVector implements IVector } if (obj instanceof AbstractVector) { AbstractVector p = (AbstractVector)obj; - return getX() == p.getX() && getY() == p.getY(); + return x() == p.x() && y() == p.y(); } return false; } @Override public int hashCode () { - return Platform.hashCode(getX()) ^ Platform.hashCode(getY()); + return Platform.hashCode(x()) ^ Platform.hashCode(y()); } @Override public String toString () { - return Vectors.vectorToString(getX(), getY()); + return Vectors.vectorToString(x(), y()); } } diff --git a/src/main/java/pythagoras/f/AffineTransform.java b/src/main/java/pythagoras/f/AffineTransform.java index fd7fd8f..5357087 100644 --- a/src/main/java/pythagoras/f/AffineTransform.java +++ b/src/main/java/pythagoras/f/AffineTransform.java @@ -51,24 +51,24 @@ public class AffineTransform extends AbstractTransform } @Override // from Transform - public float getUniformScale () { + public float uniformScale () { // the square root of the signed area of the parallelogram spanned by the axis vectors float cp = m00*m11 - m01*m10; return (cp < 0f) ? -FloatMath.sqrt(-cp) : FloatMath.sqrt(cp); } @Override // from Transform - public float getScaleX () { + public float scaleX () { return FloatMath.sqrt(m00*m00 + m01*m01); } @Override // from Transform - public float getScaleY () { + public float scaleY () { return FloatMath.sqrt(m10*m10 + m11*m11); } @Override // from Transform - public float getRotation () { + public float rotation () { // use the iterative polar decomposition algorithm described by Ken Shoemake: // http://www.cs.wisc.edu/graphics/Courses/838-s2002/Papers/polar-decomp.pdf @@ -105,12 +105,12 @@ public class AffineTransform extends AbstractTransform } @Override // from Transform - public float getTx () { + public float tx () { return this.tx; } @Override // from Transform - public float getTy () { + public float ty () { return this.ty; } @@ -122,7 +122,7 @@ public class AffineTransform extends AbstractTransform @Override // from Transform public Transform setScaleX (float scaleX) { // normalize the scale to 1, then re-apply - float osx = getScaleX(); + float osx = scaleX(); m00 /= osx; m01 /= osx; m00 *= scaleX; m01 *= scaleX; return this; @@ -131,7 +131,7 @@ public class AffineTransform extends AbstractTransform @Override // from Transform public Transform setScaleY (float scaleY) { // normalize the scale to 1, then re-apply - float osy = getScaleY(); + float osy = scaleY(); m10 /= osy; m11 /= osy; m10 *= scaleY; m11 *= scaleY; return this; @@ -140,7 +140,7 @@ public class AffineTransform extends AbstractTransform @Override // from Transform public Transform setRotation (float angle) { // extract the scale, then reapply rotation and scale together - float sx = getScaleX(), sy = getScaleY(); + float sx = scaleX(), sy = scaleY(); float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle); m00 = cosa * sx; m01 = sina * sx; m10 = -sina * sy; m11 = cosa * sy; @@ -276,7 +276,7 @@ public class AffineTransform extends AbstractTransform @Override // from Transform public Point transform (IPoint p, Point into) { - float x = p.getX(), y = p.getY(); + float x = p.x(), y = p.y(); return into.set(m00*x + m10*y + tx, m01*x + m11*y + ty); } @@ -298,7 +298,7 @@ public class AffineTransform extends AbstractTransform @Override // from Transform public Point inverseTransform (IPoint p, Point into) { - float x = p.getX() - tx, y = p.getY() - ty; + float x = p.x() - tx, y = p.y() - ty; float det = m00 * m11 - m01 * m10; if (Math.abs(det) == 0f) { // determinant is zero; matrix is not invertible @@ -311,13 +311,13 @@ public class AffineTransform extends AbstractTransform @Override // from Transform public Vector transform (IVector v, Vector into) { - float x = v.getX(), y = v.getY(); + float x = v.x(), y = v.y(); return into.set(m00*x + m10*y, m01*x + m11*y); } @Override // from Transform public Vector inverseTransform (IVector v, Vector into) { - float x = v.getX(), y = v.getY(); + float x = v.x(), y = v.y(); float det = m00 * m11 - m01 * m10; if (Math.abs(det) == 0f) { // determinant is zero; matrix is not invertible @@ -341,13 +341,13 @@ public class AffineTransform extends AbstractTransform @Override public String toString () { return "affine [" + FloatMath.toString(m00) + " " + FloatMath.toString(m01) + " " + - FloatMath.toString(m10) + " " + FloatMath.toString(m11) + " " + getTranslation() + "]"; + FloatMath.toString(m10) + " " + FloatMath.toString(m11) + " " + translation() + "]"; } // we don't publicize this because it might encourage someone to do something stupid like // create a new AffineTransform from another AffineTransform using this instead of clone() protected AffineTransform (Transform other) { - this(other.getScaleX(), other.getScaleY(), other.getRotation(), - other.getTx(), other.getTy()); + this(other.scaleX(), other.scaleY(), other.rotation(), + other.tx(), other.ty()); } } diff --git a/src/main/java/pythagoras/f/Arc.java b/src/main/java/pythagoras/f/Arc.java index 89636ac..603008b 100644 --- a/src/main/java/pythagoras/f/Arc.java +++ b/src/main/java/pythagoras/f/Arc.java @@ -56,42 +56,42 @@ public class Arc extends AbstractArc implements Serializable * angular extent. */ public Arc (IRectangle bounds, float start, float extent, int type) { - setArc(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight(), + setArc(bounds.x(), bounds.y(), bounds.width(), bounds.height(), start, extent, type); } @Override // from interface IArc - public int getArcType () { + public int arcType () { return type; } @Override // from interface IArc - public float getX () { + public float x () { return x; } @Override // from interface IArc - public float getY () { + public float y () { return y; } @Override // from interface IArc - public float getWidth () { + public float width () { return width; } @Override // from interface IArc - public float getHeight () { + public float height () { return height; } @Override // from interface IArc - public float getAngleStart () { + public float angleStart () { return start; } @Override // from interface IArc - public float getAngleExtent () { + public float angleExtent () { return extent; } @@ -139,7 +139,7 @@ public class Arc extends AbstractArc implements Serializable * values. */ public void setArc (IPoint point, IDimension size, float start, float extent, int type) { - setArc(point.getX(), point.getY(), size.getWidth(), size.getHeight(), start, extent, type); + setArc(point.x(), point.y(), size.width(), size.height(), start, extent, type); } /** @@ -147,7 +147,7 @@ public class Arc extends AbstractArc implements Serializable * values. */ public void setArc (IRectangle rect, float start, float extent, int type) { - setArc(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight(), start, extent, type); + setArc(rect.x(), rect.y(), rect.width(), rect.height(), start, extent, type); } /** @@ -155,8 +155,8 @@ public class Arc extends AbstractArc implements Serializable * the supplied arc. */ public void setArc (IArc arc) { - setArc(arc.getX(), arc.getY(), arc.getWidth(), arc.getHeight(), arc.getAngleStart(), - arc.getAngleExtent(), arc.getArcType()); + setArc(arc.x(), arc.y(), arc.width(), arc.height(), arc.angleStart(), + arc.angleExtent(), arc.arcType()); } /** @@ -174,16 +174,16 @@ public class Arc extends AbstractArc implements Serializable */ public void setArcByTangent (IPoint p1, IPoint p2, IPoint p3, float radius) { // use simple geometric calculations of arc center, radius and angles by tangents - float a1 = -FloatMath.atan2(p1.getY() - p2.getY(), p1.getX() - p2.getX()); - float a2 = -FloatMath.atan2(p3.getY() - p2.getY(), p3.getX() - p2.getX()); + float a1 = -FloatMath.atan2(p1.y() - p2.y(), p1.x() - p2.x()); + float a2 = -FloatMath.atan2(p3.y() - p2.y(), p3.x() - p2.x()); float am = (a1 + a2) / 2f; float ah = a1 - am; float d = radius / Math.abs(FloatMath.sin(ah)); - float x = p2.getX() + d * FloatMath.cos(am); - float y = p2.getY() - d * FloatMath.sin(am); + float x = p2.x() + d * FloatMath.cos(am); + float y = p2.y() - d * FloatMath.sin(am); ah = ah >= 0f ? FloatMath.PI * 1.5f - ah : FloatMath.PI * 0.5f - ah; - a1 = getNormAngle(FloatMath.toDegrees(am - ah)); - a2 = getNormAngle(FloatMath.toDegrees(am + ah)); + a1 = normAngle(FloatMath.toDegrees(am - ah)); + a2 = normAngle(FloatMath.toDegrees(am + ah)); float delta = a2 - a1; if (delta <= 0f) { delta += 360f; @@ -196,8 +196,8 @@ public class Arc extends AbstractArc implements Serializable * the center of this arc. */ public void setAngleStart (IPoint point) { - float angle = FloatMath.atan2(point.getY() - getCenterY(), point.getX() - getCenterX()); - setAngleStart(getNormAngle(-FloatMath.toDegrees(angle))); + float angle = FloatMath.atan2(point.y() - centerY(), point.x() - centerX()); + setAngleStart(normAngle(-FloatMath.toDegrees(angle))); } /** @@ -208,10 +208,10 @@ public class Arc extends AbstractArc implements Serializable * counterclockwise from the first point around to the second point. */ public void setAngles (float x1, float y1, float x2, float y2) { - float cx = getCenterX(); - float cy = getCenterY(); - float a1 = getNormAngle(-FloatMath.toDegrees(FloatMath.atan2(y1 - cy, x1 - cx))); - float a2 = getNormAngle(-FloatMath.toDegrees(FloatMath.atan2(y2 - cy, x2 - cx))); + float cx = centerX(); + float cy = centerY(); + float a1 = normAngle(-FloatMath.toDegrees(FloatMath.atan2(y1 - cy, x1 - cx))); + float a2 = normAngle(-FloatMath.toDegrees(FloatMath.atan2(y2 - cy, x2 - cx))); a2 -= a1; if (a2 <= 0f) { a2 += 360f; @@ -228,12 +228,12 @@ public class Arc extends AbstractArc implements Serializable * counterclockwise from the first point around to the second point. */ public void setAngles (IPoint p1, IPoint p2) { - setAngles(p1.getX(), p1.getY(), p2.getX(), p2.getY()); + setAngles(p1.x(), p1.y(), p2.x(), p2.y()); } @Override // from RectangularShape public void setFrame (float x, float y, float width, float height) { - setArc(x, y, width, height, getAngleStart(), getAngleExtent(), type); + setArc(x, y, width, height, angleStart(), angleExtent(), type); } private int type; diff --git a/src/main/java/pythagoras/f/Area.java b/src/main/java/pythagoras/f/Area.java index 6b751a9..f485001 100644 --- a/src/main/java/pythagoras/f/Area.java +++ b/src/main/java/pythagoras/f/Area.java @@ -30,7 +30,7 @@ public class Area implements IShape, Cloneable int rulesIndex = 0; int coordsIndex = 0; - for (PathIterator pi = s.getPathIterator(null); !pi.isDone(); pi.next()) { + for (PathIterator pi = s.pathIterator(null); !pi.isDone(); pi.next()) { coords = adjustSize(coords, coordsIndex + 6); rules = adjustSize(rules, rulesIndex + 1); offsets = adjustSize(offsets, rulesIndex + 1); @@ -140,7 +140,7 @@ public class Area implements IShape, Cloneable addCurvePolygon(area); } - if (getAreaBoundsSquare() < GeometryUtil.EPSILON) { + if (areaBoundsSquare() < GeometryUtil.EPSILON) { reset(); } } @@ -162,7 +162,7 @@ public class Area implements IShape, Cloneable intersectCurvePolygon(area); } - if (getAreaBoundsSquare() < GeometryUtil.EPSILON) { + if (areaBoundsSquare() < GeometryUtil.EPSILON) { reset(); } } @@ -181,7 +181,7 @@ public class Area implements IShape, Cloneable subtractCurvePolygon(area); } - if (getAreaBoundsSquare() < GeometryUtil.EPSILON) { + if (areaBoundsSquare() < GeometryUtil.EPSILON) { reset(); } } @@ -209,25 +209,25 @@ public class Area implements IShape, Cloneable @Override // from interface IShape public boolean contains (float x, float y, float width, float height) { - int crossCount = Crossing.intersectPath(getPathIterator(null), x, y, width, height); + int crossCount = Crossing.intersectPath(pathIterator(null), x, y, width, height); return crossCount != Crossing.CROSSING && Crossing.isInsideEvenOdd(crossCount); } @Override // from interface IShape public boolean contains (IPoint p) { - return contains(p.getX(), p.getY()); + return contains(p.x(), p.y()); } @Override // from interface IShape public boolean contains (IRectangle r) { - return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + return contains(r.x(), r.y(), r.width(), r.height()); } @Override // from interface IShape public boolean intersects (float x, float y, float width, float height) { if ((width <= 0f) || (height <= 0f)) { return false; - } else if (!getBounds().intersects(x, y, width, height)) { + } else if (!bounds().intersects(x, y, width, height)) { return false; } int crossCount = Crossing.intersectShape(this, x, y, width, height); @@ -236,16 +236,16 @@ public class Area implements IShape, Cloneable @Override // from interface IShape public boolean intersects (IRectangle r) { - return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + return intersects(r.x(), r.y(), r.width(), r.height()); } @Override // from interface IShape - public Rectangle getBounds () { - return getBounds(new Rectangle()); + public Rectangle bounds () { + return bounds(new Rectangle()); } @Override // from interface IShape - public Rectangle getBounds (Rectangle target) { + public Rectangle bounds (Rectangle target) { float maxX = coords[0], maxY = coords[1]; float minX = coords[0], minY = coords[1]; for (int i = 0; i < coordsSize;) { @@ -258,13 +258,13 @@ public class Area implements IShape, Cloneable } @Override // from interface IShape - public PathIterator getPathIterator (Transform t) { + public PathIterator pathIterator (Transform t) { return new AreaPathIterator(t); } @Override // from interface IShape - public PathIterator getPathIterator (Transform t, float flatness) { - return new FlatteningPathIterator(getPathIterator(t), flatness); + public PathIterator pathIterator (Transform t, float flatness) { + return new FlatteningPathIterator(pathIterator(t), flatness); } @Override // from Object @@ -296,9 +296,9 @@ public class Area implements IShape, Cloneable IntersectPoint[] intersectPoints = crossHelper.findCrossing(); if (intersectPoints.length == 0) { - if (area.contains(getBounds())) { + if (area.contains(bounds())) { copy(area, this); - } else if (!contains(area.getBounds())) { + } else if (!contains(area.bounds())) { coords = adjustSize(coords, coordsSize + area.coordsSize); System.arraycopy(area.coords, 0, coords, coordsSize, area.coordsSize); coordsSize += area.coordsSize; @@ -324,9 +324,9 @@ public class Area implements IShape, Cloneable resultOffsets[resultRulesPos++] = resultCoordPos; do { - resultCoords[resultCoordPos++] = point.getX(); - resultCoords[resultCoordPos++] = point.getY(); - int curIndex = point.getEndIndex(true); + resultCoords[resultCoordPos++] = point.x(); + resultCoords[resultCoordPos++] = point.y(); + int curIndex = point.endIndex(true); if (curIndex < 0) { isCurrentArea = !isCurrentArea; } else if (area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) > 0) { @@ -335,13 +335,13 @@ public class Area implements IShape, Cloneable isCurrentArea = true; } - IntersectPoint nextPoint = getNextIntersectPoint(intersectPoints, point, isCurrentArea); + IntersectPoint nextPoint = nextIntersectPoint(intersectPoints, point, isCurrentArea); float[] coords = (isCurrentArea) ? this.coords : area.coords; int[] offsets = (isCurrentArea) ? this.offsets : area.offsets; int[] rules = (isCurrentArea) ? this.rules : area.rules; - int offset = point.getRuleIndex(isCurrentArea); + int offset = point.ruleIndex(isCurrentArea); boolean isCopyUntilZero = false; - if ((point.getRuleIndex(isCurrentArea) > nextPoint.getRuleIndex(isCurrentArea))) { + if ((point.ruleIndex(isCurrentArea) > nextPoint.ruleIndex(isCurrentArea))) { int rulesSize = (isCurrentArea) ? this.rulesSize : area.rulesSize; resultCoordPos = includeCoordsAndRules(offset + 1, rulesSize, rules, offsets, resultRules, resultOffsets, resultCoords, coords, resultRulesPos, @@ -351,7 +351,7 @@ public class Area implements IShape, Cloneable isCopyUntilZero = true; } - int length = nextPoint.getRuleIndex(isCurrentArea) - offset + 1; + int length = nextPoint.ruleIndex(isCurrentArea) - offset + 1; if (isCopyUntilZero) { offset = 0; } @@ -379,9 +379,9 @@ public class Area implements IShape, Cloneable IntersectPoint[] intersectPoints = crossHelper.findCrossing(); if (intersectPoints.length == 0) { - if (area.contains(getBounds())) { + if (area.contains(bounds())) { copy(area, this); - } else if (!contains(area.getBounds())) { + } else if (!contains(area.bounds())) { coords = adjustSize(coords, coordsSize + area.coordsSize); System.arraycopy(area.coords, 0, coords, coordsSize, area.coordsSize); coordsSize += area.coordsSize; @@ -406,11 +406,11 @@ public class Area implements IShape, Cloneable resultOffsets[resultRulesPos++] = resultCoordPos; do { - resultCoords[resultCoordPos++] = point.getX(); - resultCoords[resultCoordPos++] = point.getY(); + resultCoords[resultCoordPos++] = point.x(); + resultCoords[resultCoordPos++] = point.y(); resultRules[resultRulesPos] = PathIterator.SEG_LINETO; resultOffsets[resultRulesPos++] = resultCoordPos - 2; - int curIndex = point.getEndIndex(true); + int curIndex = point.endIndex(true); if (curIndex < 0) { isCurrentArea = !isCurrentArea; } else if (area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) > 0) { @@ -419,11 +419,11 @@ public class Area implements IShape, Cloneable isCurrentArea = true; } - IntersectPoint nextPoint = getNextIntersectPoint(intersectPoints, point, isCurrentArea); + IntersectPoint nextPoint = nextIntersectPoint(intersectPoints, point, isCurrentArea); float[] coords = (isCurrentArea) ? this.coords : area.coords; - int offset = 2 * point.getEndIndex(isCurrentArea); + int offset = 2 * point.endIndex(isCurrentArea); if ((offset >= 0) && - (nextPoint.getBegIndex(isCurrentArea) < point.getEndIndex(isCurrentArea))) { + (nextPoint.begIndex(isCurrentArea) < point.endIndex(isCurrentArea))) { int coordSize = (isCurrentArea) ? this.coordsSize : area.coordsSize; int length = coordSize - offset; System.arraycopy(coords, offset, resultCoords, resultCoordPos, length); @@ -438,7 +438,7 @@ public class Area implements IShape, Cloneable } if (offset >= 0) { - int length = 2 * nextPoint.getBegIndex(isCurrentArea) - offset + 2; + int length = 2 * nextPoint.begIndex(isCurrentArea) - offset + 2; System.arraycopy(coords, offset, resultCoords, resultCoordPos, length); for (int i = 0; i < length / 2; i++) { @@ -469,9 +469,9 @@ public class Area implements IShape, Cloneable new int[][] { offsets, area.offsets }); IntersectPoint[] intersectPoints = crossHelper.findCrossing(); if (intersectPoints.length == 0) { - if (contains(area.getBounds())) { + if (contains(area.bounds())) { copy(area, this); - } else if (!area.contains(getBounds())) { + } else if (!area.contains(bounds())) { reset(); } return; @@ -490,10 +490,10 @@ public class Area implements IShape, Cloneable resultOffsets[resultRulesPos++] = resultCoordPos; do { - resultCoords[resultCoordPos++] = point.getX(); - resultCoords[resultCoordPos++] = point.getY(); + resultCoords[resultCoordPos++] = point.x(); + resultCoords[resultCoordPos++] = point.y(); - int curIndex = point.getEndIndex(true); + int curIndex = point.endIndex(true); if ((curIndex < 0) || (area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) == 0)) { isCurrentArea = !isCurrentArea; @@ -503,14 +503,14 @@ public class Area implements IShape, Cloneable isCurrentArea = false; } - nextPoint = getNextIntersectPoint(intersectPoints, point, isCurrentArea); + nextPoint = nextIntersectPoint(intersectPoints, point, isCurrentArea); float[] coords = (isCurrentArea) ? this.coords : area.coords; int[] offsets = (isCurrentArea) ? this.offsets : area.offsets; int[] rules = (isCurrentArea) ? this.rules : area.rules; - int offset = point.getRuleIndex(isCurrentArea); + int offset = point.ruleIndex(isCurrentArea); boolean isCopyUntilZero = false; - if (point.getRuleIndex(isCurrentArea) > nextPoint.getRuleIndex(isCurrentArea)) { + if (point.ruleIndex(isCurrentArea) > nextPoint.ruleIndex(isCurrentArea)) { int rulesSize = (isCurrentArea) ? this.rulesSize : area.rulesSize; resultCoordPos = includeCoordsAndRules( offset + 1, rulesSize, rules, offsets, resultRules, resultOffsets, @@ -521,17 +521,17 @@ public class Area implements IShape, Cloneable isCopyUntilZero = true; } - int length = nextPoint.getRuleIndex(isCurrentArea) - offset + 1; + int length = nextPoint.ruleIndex(isCurrentArea) - offset + 1; if (isCopyUntilZero) { offset = 0; isCopyUntilZero = false; } if ((length == offset) && - (nextPoint.getRule(isCurrentArea) != PathIterator.SEG_LINETO) && - (nextPoint.getRule(isCurrentArea) != PathIterator.SEG_CLOSE) && - (point.getRule(isCurrentArea) != PathIterator.SEG_LINETO) && - (point.getRule(isCurrentArea) != PathIterator.SEG_CLOSE)) { + (nextPoint.rule(isCurrentArea) != PathIterator.SEG_LINETO) && + (nextPoint.rule(isCurrentArea) != PathIterator.SEG_CLOSE) && + (point.rule(isCurrentArea) != PathIterator.SEG_LINETO) && + (point.rule(isCurrentArea) != PathIterator.SEG_CLOSE)) { isCopyUntilZero = true; length++; } @@ -548,8 +548,8 @@ public class Area implements IShape, Cloneable if (resultRules[resultRulesPos - 1] == PathIterator.SEG_LINETO) { resultRules[resultRulesPos - 1] = PathIterator.SEG_CLOSE; } else { - resultCoords[resultCoordPos++] = nextPoint.getX(); - resultCoords[resultCoordPos++] = nextPoint.getY(); + resultCoords[resultCoordPos++] = nextPoint.x(); + resultCoords[resultCoordPos++] = nextPoint.y(); resultRules[resultRulesPos++] = PathIterator.SEG_CLOSE; } @@ -567,9 +567,9 @@ public class Area implements IShape, Cloneable new int[] { coordsSize, area.coordsSize }); IntersectPoint[] intersectPoints = crossHelper.findCrossing(); if (intersectPoints.length == 0) { - if (contains(area.getBounds())) { + if (contains(area.bounds())) { copy(area, this); - } else if (!area.contains(getBounds())) { + } else if (!area.contains(bounds())) { reset(); } return; @@ -587,11 +587,11 @@ public class Area implements IShape, Cloneable resultOffsets[resultRulesPos++] = resultCoordPos; do { - resultCoords[resultCoordPos++] = point.getX(); - resultCoords[resultCoordPos++] = point.getY(); + resultCoords[resultCoordPos++] = point.x(); + resultCoords[resultCoordPos++] = point.y(); resultRules[resultRulesPos] = PathIterator.SEG_LINETO; resultOffsets[resultRulesPos++] = resultCoordPos - 2; - int curIndex = point.getEndIndex(true); + int curIndex = point.endIndex(true); if ((curIndex < 0) || (area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) == 0)) { @@ -602,11 +602,11 @@ public class Area implements IShape, Cloneable isCurrentArea = false; } - IntersectPoint nextPoint = getNextIntersectPoint(intersectPoints, point, isCurrentArea); + IntersectPoint nextPoint = nextIntersectPoint(intersectPoints, point, isCurrentArea); float[] coords = (isCurrentArea) ? this.coords : area.coords; - int offset = 2 * point.getEndIndex(isCurrentArea); + int offset = 2 * point.endIndex(isCurrentArea); if ((offset >= 0) && - (nextPoint.getBegIndex(isCurrentArea) < point.getEndIndex(isCurrentArea))) { + (nextPoint.begIndex(isCurrentArea) < point.endIndex(isCurrentArea))) { int coordSize = (isCurrentArea) ? this.coordsSize : area.coordsSize; int length = coordSize - offset; System.arraycopy(coords, offset, resultCoords, resultCoordPos, length); @@ -621,7 +621,7 @@ public class Area implements IShape, Cloneable } if (offset >= 0) { - int length = 2 * nextPoint.getBegIndex(isCurrentArea) - offset + 2; + int length = 2 * nextPoint.begIndex(isCurrentArea) - offset + 2; System.arraycopy(coords, offset, resultCoords, resultCoordPos, length); for (int i = 0; i < length / 2; i++) { @@ -651,7 +651,7 @@ public class Area implements IShape, Cloneable new int[] { rulesSize, area.rulesSize }, new int[][] { offsets, area.offsets }); IntersectPoint[] intersectPoints = crossHelper.findCrossing(); - if (intersectPoints.length == 0 && contains(area.getBounds())) { + if (intersectPoints.length == 0 && contains(area.bounds())) { copy(area, this); return; } @@ -668,9 +668,9 @@ public class Area implements IShape, Cloneable resultOffsets[resultRulesPos++] = resultCoordPos; do { - resultCoords[resultCoordPos++] = point.getX(); - resultCoords[resultCoordPos++] = point.getY(); - int curIndex = offsets[point.getRuleIndex(true)] % coordsSize; + resultCoords[resultCoordPos++] = point.x(); + resultCoords[resultCoordPos++] = point.y(); + int curIndex = offsets[point.ruleIndex(true)] % coordsSize; if (area.containsExact(coords[curIndex], coords[curIndex + 1]) == 0) { isCurrentArea = !isCurrentArea; } else if (area.containsExact(coords[curIndex], coords[curIndex + 1]) > 0) { @@ -680,19 +680,19 @@ public class Area implements IShape, Cloneable } IntersectPoint nextPoint = (isCurrentArea) ? - getNextIntersectPoint(intersectPoints, point, isCurrentArea) : - getPrevIntersectPoint(intersectPoints, point, isCurrentArea); + nextIntersectPoint(intersectPoints, point, isCurrentArea) : + prevIntersectPoint(intersectPoints, point, isCurrentArea); float[] coords = (isCurrentArea) ? this.coords : area.coords; int[] offsets = (isCurrentArea) ? this.offsets : area.offsets; int[] rules = (isCurrentArea) ? this.rules : area.rules; - int offset = (isCurrentArea) ? point.getRuleIndex(isCurrentArea) : - nextPoint.getRuleIndex(isCurrentArea); + int offset = (isCurrentArea) ? point.ruleIndex(isCurrentArea) : + nextPoint.ruleIndex(isCurrentArea); boolean isCopyUntilZero = false; if (((isCurrentArea) && - (point.getRuleIndex(isCurrentArea) > nextPoint.getRuleIndex(isCurrentArea))) || + (point.ruleIndex(isCurrentArea) > nextPoint.ruleIndex(isCurrentArea))) || ((!isCurrentArea) && - (nextPoint.getRuleIndex(isCurrentArea) > nextPoint.getRuleIndex(isCurrentArea)))) { + (nextPoint.ruleIndex(isCurrentArea) > nextPoint.ruleIndex(isCurrentArea)))) { int rulesSize = (isCurrentArea) ? this.rulesSize : area.rulesSize; resultCoordPos = includeCoordsAndRules( offset + 1, rulesSize, rules, offsets, resultRules, resultOffsets, resultCoords, @@ -702,7 +702,7 @@ public class Area implements IShape, Cloneable isCopyUntilZero = true; } - int length = nextPoint.getRuleIndex(isCurrentArea) - offset + 1; + int length = nextPoint.ruleIndex(isCurrentArea) - offset + 1; if (isCopyUntilZero) { offset = 0; @@ -740,7 +740,7 @@ public class Area implements IShape, Cloneable new int[] { coordsSize, area.coordsSize }); IntersectPoint[] intersectPoints = crossHelper.findCrossing(); if (intersectPoints.length == 0) { - if (contains(area.getBounds())) { + if (contains(area.bounds())) { copy(area, this); return; } @@ -763,18 +763,18 @@ public class Area implements IShape, Cloneable resultOffsets[resultRulesPos++] = resultCoordPos; do { - resultCoords[resultCoordPos++] = point.getX(); - resultCoords[resultCoordPos++] = point.getY(); + resultCoords[resultCoordPos++] = point.x(); + resultCoords[resultCoordPos++] = point.y(); resultRules[resultRulesPos] = PathIterator.SEG_LINETO; resultOffsets[resultRulesPos++] = resultCoordPos - 2; - int curIndex = point.getEndIndex(true); + int curIndex = point.endIndex(true); if ((curIndex < 0) || (area.isVertex(coords[2 * curIndex], coords[2 * curIndex + 1]) && crossHelper.containsPoint(new float[] { coords[2 * curIndex], coords[2 * curIndex + 1] }) && - (coords[2 * curIndex] != point.getX() || - coords[2 * curIndex + 1] != point.getY()))) { + (coords[2 * curIndex] != point.x() || + coords[2 * curIndex + 1] != point.y()))) { isCurrentArea = !isCurrentArea; } else if (area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) > 0) { isCurrentArea = false; @@ -793,18 +793,18 @@ public class Area implements IShape, Cloneable } IntersectPoint nextPoint = (isCurrentArea) ? - getNextIntersectPoint(intersectPoints, point, isCurrentArea) : - getPrevIntersectPoint(intersectPoints, point, isCurrentArea); + nextIntersectPoint(intersectPoints, point, isCurrentArea) : + prevIntersectPoint(intersectPoints, point, isCurrentArea); float[] coords = (isCurrentArea) ? this.coords : area.coords; - int offset = (isCurrentArea) ? 2 * point.getEndIndex(isCurrentArea) : - 2 * nextPoint.getEndIndex(isCurrentArea); + int offset = (isCurrentArea) ? 2 * point.endIndex(isCurrentArea) : + 2 * nextPoint.endIndex(isCurrentArea); if ((offset > 0) && (((isCurrentArea) && - (nextPoint.getBegIndex(isCurrentArea) < point.getEndIndex(isCurrentArea))) || + (nextPoint.begIndex(isCurrentArea) < point.endIndex(isCurrentArea))) || ((!isCurrentArea) && - (nextPoint.getEndIndex(isCurrentArea) < nextPoint.getBegIndex(isCurrentArea))))) { + (nextPoint.endIndex(isCurrentArea) < nextPoint.begIndex(isCurrentArea))))) { int coordSize = (isCurrentArea) ? this.coordsSize : area.coordsSize; int length = coordSize - offset; @@ -829,8 +829,8 @@ public class Area implements IShape, Cloneable if (offset >= 0) { int length = (isCurrentArea) ? - 2 * nextPoint.getBegIndex(isCurrentArea) - offset + 2 : - 2 * point.getBegIndex(isCurrentArea) - offset + 2; + 2 * nextPoint.begIndex(isCurrentArea) - offset + 2 : + 2 * point.begIndex(isCurrentArea) - offset + 2; if (isCurrentArea) { System.arraycopy(coords, offset, resultCoords, resultCoordPos, length); @@ -861,10 +861,10 @@ public class Area implements IShape, Cloneable rulesSize = resultRulesPos; } - private IntersectPoint getNextIntersectPoint (IntersectPoint[] iPoints, + private IntersectPoint nextIntersectPoint (IntersectPoint[] iPoints, IntersectPoint isectPoint, boolean isCurrentArea) { - int endIndex = isectPoint.getEndIndex(isCurrentArea); + int endIndex = isectPoint.endIndex(isCurrentArea); if (endIndex < 0) { return iPoints[Math.abs(endIndex) - 1]; } @@ -872,11 +872,11 @@ public class Area implements IShape, Cloneable IntersectPoint firstIsectPoint = null; IntersectPoint nextIsectPoint = null; for (IntersectPoint point : iPoints) { - int begIndex = point.getBegIndex(isCurrentArea); + int begIndex = point.begIndex(isCurrentArea); if (begIndex >= 0) { if (firstIsectPoint == null) { firstIsectPoint = point; - } else if (begIndex < firstIsectPoint.getBegIndex(isCurrentArea)) { + } else if (begIndex < firstIsectPoint.begIndex(isCurrentArea)) { firstIsectPoint = point; } } @@ -884,7 +884,7 @@ public class Area implements IShape, Cloneable if (endIndex <= begIndex) { if (nextIsectPoint == null) { nextIsectPoint = point; - } else if (begIndex < nextIsectPoint.getBegIndex(isCurrentArea)) { + } else if (begIndex < nextIsectPoint.begIndex(isCurrentArea)) { nextIsectPoint = point; } } @@ -893,10 +893,10 @@ public class Area implements IShape, Cloneable return (nextIsectPoint != null) ? nextIsectPoint : firstIsectPoint; } - private IntersectPoint getPrevIntersectPoint (IntersectPoint[] iPoints, + private IntersectPoint prevIntersectPoint (IntersectPoint[] iPoints, IntersectPoint isectPoint, boolean isCurrentArea) { - int begIndex = isectPoint.getBegIndex(isCurrentArea); + int begIndex = isectPoint.begIndex(isCurrentArea); if (begIndex < 0) { return iPoints[Math.abs(begIndex) - 1]; } @@ -904,11 +904,11 @@ public class Area implements IShape, Cloneable IntersectPoint firstIsectPoint = null; IntersectPoint predIsectPoint = null; for (IntersectPoint point : iPoints) { - int endIndex = point.getEndIndex(isCurrentArea); + int endIndex = point.endIndex(isCurrentArea); if (endIndex >= 0) { if (firstIsectPoint == null) { firstIsectPoint = point; - } else if (endIndex < firstIsectPoint.getEndIndex(isCurrentArea)) { + } else if (endIndex < firstIsectPoint.endIndex(isCurrentArea)) { firstIsectPoint = point; } } @@ -916,7 +916,7 @@ public class Area implements IShape, Cloneable if (endIndex <= begIndex) { if (predIsectPoint == null) { predIsectPoint = point; - } else if (endIndex > predIsectPoint.getEndIndex(isCurrentArea)) { + } else if (endIndex > predIsectPoint.endIndex(isCurrentArea)) { predIsectPoint = point; } } @@ -976,7 +976,7 @@ public class Area implements IShape, Cloneable resultRules[resultRulesPos] = PathIterator.SEG_LINETO; resultOffsets[resultRulesPos++] = resultCoordPos + 2; boolean isLeft = CrossingHelper.compare( - coords[index], coords[index + 1], point.getX(), point.getY()) > 0; + coords[index], coords[index + 1], point.x(), point.y()) > 0; if (way || !isLeft) { temp[coordsCount++] = coords[index]; temp[coordsCount++] = coords[index + 1]; @@ -990,13 +990,13 @@ public class Area implements IShape, Cloneable coords[index - 2], coords[index - 1], coords[index], coords[index + 1], coords[index + 2], coords[index + 3] }; isLeft = CrossingHelper.compare( - coords[index - 2], coords[index - 1], point.getX(), point.getY()) > 0; + coords[index - 2], coords[index - 1], point.x(), point.y()) > 0; if ((!additional) && (operation == 0 || operation == 2)) { isLeft = !isLeft; way = false; } - GeometryUtil.subQuad(coefs, point.getParam(isCurrentArea), isLeft); + GeometryUtil.subQuad(coefs, point.param(isCurrentArea), isLeft); if (way || isLeft) { temp[coordsCount++] = coefs[2]; @@ -1014,8 +1014,8 @@ public class Area implements IShape, Cloneable coords[index + 1], coords[index + 2], coords[index + 3], coords[index + 4], coords[index + 5] }; isLeft = CrossingHelper.compare( - coords[index - 2], coords[index - 1], point.getX(), point.getY()) > 0; - GeometryUtil.subCubic(coefs, point.getParam(isCurrentArea), !isLeft); + coords[index - 2], coords[index - 1], point.x(), point.y()) > 0; + GeometryUtil.subCubic(coefs, point.param(isCurrentArea), !isLeft); if (isLeft) { System.arraycopy(coefs, 2, temp, coordsCount, 6); @@ -1048,7 +1048,7 @@ public class Area implements IShape, Cloneable } private int containsExact (float x, float y) { - PathIterator pi = getPathIterator(null); + PathIterator pi = pathIterator(null); int crossCount = Crossing.crossPath(pi, x, y); if (Crossing.isInsideEvenOdd(crossCount)) { return 1; @@ -1062,7 +1062,7 @@ public class Area implements IShape, Cloneable float moveX = -1; float moveY = -1; - for (pi = getPathIterator(null); !pi.isDone(); pi.next()) { + for (pi = pathIterator(null); !pi.isDone(); pi.next()) { rule = pi.currentSegment(segmentCoords); switch (rule) { case PathIterator.SEG_MOVETO: @@ -1123,9 +1123,9 @@ public class Area implements IShape, Cloneable } } - private float getAreaBoundsSquare () { - Rectangle bounds = getBounds(); - return bounds.getHeight() * bounds.getWidth(); + private float areaBoundsSquare () { + Rectangle bounds = bounds(); + return bounds.height() * bounds.width(); } private boolean isVertex (float x, float y) { @@ -1167,7 +1167,7 @@ public class Area implements IShape, Cloneable this.transform = t; } - @Override public int getWindingRule () { + @Override public int windingRule () { return WIND_EVEN_ODD; } diff --git a/src/main/java/pythagoras/f/Crossing.java b/src/main/java/pythagoras/f/Crossing.java index 02dcef8..50853c6 100644 --- a/src/main/java/pythagoras/f/Crossing.java +++ b/src/main/java/pythagoras/f/Crossing.java @@ -472,10 +472,10 @@ class Crossing * Returns how many times a ray from point (x,y) crosses a shape. */ public static int crossShape (IShape s, float x, float y) { - if (!s.getBounds().contains(x, y)) { + if (!s.bounds().contains(x, y)) { return 0; } - return crossPath(s.getPathIterator(null), x, y); + return crossPath(s.pathIterator(null), x, y); } /** @@ -759,10 +759,10 @@ class Crossing * Returns how many times rectangle stripe cross shape or the are intersect */ public static int intersectShape (IShape s, float x, float y, float w, float h) { - if (!s.getBounds().intersects(x, y, w, h)) { + if (!s.bounds().intersects(x, y, w, h)) { return 0; } - return intersectPath(s.getPathIterator(null), x, y, w, h); + return intersectPath(s.pathIterator(null), x, y, w, h); } /** diff --git a/src/main/java/pythagoras/f/CrossingHelper.java b/src/main/java/pythagoras/f/CrossingHelper.java index 46f0686..4e7ed93 100644 --- a/src/main/java/pythagoras/f/CrossingHelper.java +++ b/src/main/java/pythagoras/f/CrossingHelper.java @@ -177,8 +177,8 @@ class CrossingHelper IntersectPoint ip; for (Iterator i = isectPoints.iterator(); i.hasNext();) { ip = i.next(); - if ((initBegin == ip.getBegIndex(true)) && (initEnd == ip.getEndIndex(true))) { - if (compare(ip.getX(), ip.getY(), point[0], point[1]) > 0) { + if ((initBegin == ip.begIndex(true)) && (initEnd == ip.endIndex(true))) { + if (compare(ip.x(), ip.y(), point[0], point[1]) > 0) { initEnd = -(isectPoints.indexOf(ip) + 1); ip.setBegIndex1(-(isectPoints.size() + 1)); } else { @@ -187,8 +187,8 @@ class CrossingHelper } } - if ((addBegin == ip.getBegIndex(false)) && (addEnd == ip.getEndIndex(false))) { - if (compare(ip.getX(), ip.getY(), point[0], point[1]) > 0) { + if ((addBegin == ip.begIndex(false)) && (addEnd == ip.endIndex(false))) { + if (compare(ip.x(), ip.y(), point[0], point[1]) > 0) { addEnd = -(isectPoints.indexOf(ip) + 1); ip.setBegIndex2(-(isectPoints.size() + 1)); } else { @@ -256,7 +256,7 @@ class CrossingHelper IntersectPoint ipoint; for (Iterator i = isectPoints.iterator(); i.hasNext();) { ipoint = i.next(); - if (ipoint.getX() == point[0] && ipoint.getY() == point[1]) { + if (ipoint.x() == point[0] && ipoint.y() == point[1]) { return true; } } diff --git a/src/main/java/pythagoras/f/CubicCurve.java b/src/main/java/pythagoras/f/CubicCurve.java index de3088a..fa3232c 100644 --- a/src/main/java/pythagoras/f/CubicCurve.java +++ b/src/main/java/pythagoras/f/CubicCurve.java @@ -68,8 +68,8 @@ public class CubicCurve extends AbstractCubicCurve implements Serializable * Configures the start, control and end points for this curve. */ public void setCurve (IPoint p1, IPoint cp1, IPoint cp2, IPoint p2) { - setCurve(p1.getX(), p1.getY(), cp1.getX(), cp1.getY(), - cp2.getX(), cp2.getY(), p2.getX(), p2.getY()); + setCurve(p1.x(), p1.y(), cp1.x(), cp1.y(), + cp2.x(), cp2.y(), p2.x(), p2.y()); } /** @@ -86,10 +86,10 @@ public class CubicCurve extends AbstractCubicCurve implements Serializable * specified offset in the {@code points} array. */ public void setCurve (IPoint[] points, int offset) { - setCurve(points[offset + 0].getX(), points[offset + 0].getY(), - points[offset + 1].getX(), points[offset + 1].getY(), - points[offset + 2].getX(), points[offset + 2].getY(), - points[offset + 3].getX(), points[offset + 3].getY()); + setCurve(points[offset + 0].x(), points[offset + 0].y(), + points[offset + 1].x(), points[offset + 1].y(), + points[offset + 2].x(), points[offset + 2].y(), + points[offset + 3].x(), points[offset + 3].y()); } /** @@ -97,47 +97,47 @@ public class CubicCurve extends AbstractCubicCurve implements Serializable * curve. */ public void setCurve (ICubicCurve curve) { - setCurve(curve.getX1(), curve.getY1(), curve.getCtrlX1(), curve.getCtrlY1(), - curve.getCtrlX2(), curve.getCtrlY2(), curve.getX2(), curve.getY2()); + setCurve(curve.x1(), curve.y1(), curve.ctrlX1(), curve.ctrlY1(), + curve.ctrlX2(), curve.ctrlY2(), curve.x2(), curve.y2()); } @Override // from interface ICubicCurve - public float getX1 () { + public float x1 () { return x1; } @Override // from interface ICubicCurve - public float getY1 () { + public float y1 () { return y1; } @Override // from interface ICubicCurve - public float getCtrlX1 () { + public float ctrlX1 () { return ctrlx1; } @Override // from interface ICubicCurve - public float getCtrlY1 () { + public float ctrlY1 () { return ctrly1; } @Override // from interface ICubicCurve - public float getCtrlX2 () { + public float ctrlX2 () { return ctrlx2; } @Override // from interface ICubicCurve - public float getCtrlY2 () { + public float ctrlY2 () { return ctrly2; } @Override // from interface ICubicCurve - public float getX2 () { + public float x2 () { return x2; } @Override // from interface ICubicCurve - public float getY2 () { + public float y2 () { return y2; } } diff --git a/src/main/java/pythagoras/f/CubicCurves.java b/src/main/java/pythagoras/f/CubicCurves.java index 3f8d10c..749ba0a 100644 --- a/src/main/java/pythagoras/f/CubicCurves.java +++ b/src/main/java/pythagoras/f/CubicCurves.java @@ -9,34 +9,34 @@ package pythagoras.f; */ public class CubicCurves { - public static float getFlatnessSq (float x1, float y1, float ctrlx1, float ctrly1, + public static float flatnessSq (float x1, float y1, float ctrlx1, float ctrly1, float ctrlx2, float ctrly2, float x2, float y2) { return Math.max(Lines.pointSegDistSq(ctrlx1, ctrly1, x1, y1, x2, y2), Lines.pointSegDistSq(ctrlx2, ctrly2, x1, y1, x2, y2)); } - public static float getFlatnessSq (float[] coords, int offset) { - return getFlatnessSq(coords[offset + 0], coords[offset + 1], coords[offset + 2], + public static float flatnessSq (float[] coords, int offset) { + return flatnessSq(coords[offset + 0], coords[offset + 1], coords[offset + 2], coords[offset + 3], coords[offset + 4], coords[offset + 5], coords[offset + 6], coords[offset + 7]); } - public static float getFlatness (float x1, float y1, float ctrlx1, float ctrly1, + public static float flatness (float x1, float y1, float ctrlx1, float ctrly1, float ctrlx2, float ctrly2, float x2, float y2) { - return FloatMath.sqrt(getFlatnessSq(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2)); + return FloatMath.sqrt(flatnessSq(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2)); } - public static float getFlatness (float[] coords, int offset) { - return getFlatness(coords[offset + 0], coords[offset + 1], coords[offset + 2], + public static float flatness (float[] coords, int offset) { + return flatness(coords[offset + 0], coords[offset + 1], coords[offset + 2], coords[offset + 3], coords[offset + 4], coords[offset + 5], coords[offset + 6], coords[offset + 7]); } public static void subdivide (ICubicCurve src, CubicCurve left, CubicCurve right) { - float x1 = src.getX1(), y1 = src.getY1(); - float cx1 = src.getCtrlX1(), cy1 = src.getCtrlY1(); - float cx2 = src.getCtrlX2(), cy2 = src.getCtrlY2(); - float x2 = src.getX2(), y2 = src.getY2(); + float x1 = src.x1(), y1 = src.y1(); + float cx1 = src.ctrlX1(), cy1 = src.ctrlY1(); + float cx2 = src.ctrlX2(), cy2 = src.ctrlY2(); + float x2 = src.x2(), y2 = src.y2(); float cx = (cx1 + cx2) / 2f, cy = (cy1 + cy2) / 2f; cx1 = (x1 + cx1) / 2f; cy1 = (y1 + cy1) / 2f; diff --git a/src/main/java/pythagoras/f/CurveCrossingHelper.java b/src/main/java/pythagoras/f/CurveCrossingHelper.java index bf851dd..7b4ea94 100644 --- a/src/main/java/pythagoras/f/CurveCrossingHelper.java +++ b/src/main/java/pythagoras/f/CurveCrossingHelper.java @@ -43,11 +43,11 @@ class CurveCrossingHelper for (int i = 0; i < rulesSizes[0]; i++) { rule1 = rules[0][i]; - endIndex1 = getCurrentEdge(0, i, edge1, mp1, cp1); + endIndex1 = currentEdge(0, i, edge1, mp1, cp1); for (int j = 0; j < rulesSizes[1]; j++) { ipCount = 0; rule2 = rules[1][j]; - endIndex2 = getCurrentEdge(1, j, edge2, mp2, cp2); + endIndex2 = currentEdge(1, j, edge2, mp2, cp2); if (((rule1 == PathIterator.SEG_LINETO) || (rule1 == PathIterator.SEG_CLOSE)) && ((rule2 == PathIterator.SEG_LINETO) || (rule2 == PathIterator.SEG_CLOSE))) { ipCount = GeometryUtil.intersectLinesWithParams( @@ -167,9 +167,9 @@ class CurveCrossingHelper for (Iterator iter = isectPoints.iterator(); iter.hasNext();) { ip = iter.next(); - if ((begIndex1 == ip.getBegIndex(true)) && - (endIndex1 == ip.getEndIndex(true))) { - if (ip.getParam(true) > params[2 * k]) { + if ((begIndex1 == ip.begIndex(true)) && + (endIndex1 == ip.endIndex(true))) { + if (ip.param(true) > params[2 * k]) { endIndex1 = -(isectPoints.indexOf(ip) + 1); ip.setBegIndex1(-(isectPoints.size() + 1)); } else { @@ -178,9 +178,9 @@ class CurveCrossingHelper } } - if ((begIndex2 == ip.getBegIndex(false)) && - (endIndex2 == ip.getEndIndex(false))) { - if (ip.getParam(false) > params[2 * k + 1]) { + if ((begIndex2 == ip.begIndex(false)) && + (endIndex2 == ip.endIndex(false))) { + if (ip.param(false) > params[2 * k + 1]) { endIndex2 = -(isectPoints.indexOf(ip) + 1); ip.setBegIndex2(-(isectPoints.size() + 1)); } else { @@ -209,7 +209,7 @@ class CurveCrossingHelper return isectPoints.toArray(new IntersectPoint[isectPoints.size()]); } - private int getCurrentEdge (int areaIndex, int index, float[] c, float[] mp, float[] cp) { + private int currentEdge (int areaIndex, int index, float[] c, float[] mp, float[] cp) { int endIndex = 0; switch (rules[areaIndex][index]) { @@ -263,8 +263,8 @@ class CurveCrossingHelper IntersectPoint ipoint; for (Iterator i = isectPoints.iterator(); i.hasNext();) { ipoint = i.next(); - if ((Math.abs(ipoint.getX() - x) < Math.pow(10, -6)) && - (Math.abs(ipoint.getY() - y) < Math.pow(10, -6))) { + if ((Math.abs(ipoint.x() - x) < Math.pow(10, -6)) && + (Math.abs(ipoint.y() - y) < Math.pow(10, -6))) { return true; } } diff --git a/src/main/java/pythagoras/f/Dimension.java b/src/main/java/pythagoras/f/Dimension.java index 8df3803..2c6db71 100644 --- a/src/main/java/pythagoras/f/Dimension.java +++ b/src/main/java/pythagoras/f/Dimension.java @@ -35,7 +35,7 @@ public class Dimension extends AbstractDimension implements Serializable * Creates a dimension with width and height equal to the supplied dimension. */ public Dimension (IDimension d) { - this(d.getWidth(), d.getHeight()); + this(d.width(), d.height()); } /** @@ -50,16 +50,16 @@ public class Dimension extends AbstractDimension implements Serializable * Sets the magnitudes of this dimension to be equal to the supplied dimension. */ public void setSize (IDimension d) { - setSize(d.getWidth(), d.getHeight()); + setSize(d.width(), d.height()); } @Override // from interface IDimension - public float getWidth () { + public float width () { return width; } @Override // from interface IDimension - public float getHeight () { + public float height () { return height; } } diff --git a/src/main/java/pythagoras/f/Ellipse.java b/src/main/java/pythagoras/f/Ellipse.java index 2b0f108..77d446a 100644 --- a/src/main/java/pythagoras/f/Ellipse.java +++ b/src/main/java/pythagoras/f/Ellipse.java @@ -37,22 +37,22 @@ public class Ellipse extends AbstractEllipse implements Serializable } @Override // from interface IRectangularShape - public float getX () { + public float x () { return x; } @Override // from interface IRectangularShape - public float getY () { + public float y () { return y; } @Override // from interface IRectangularShape - public float getWidth () { + public float width () { return width; } @Override // from interface IRectangularShape - public float getHeight () { + public float height () { return height; } diff --git a/src/main/java/pythagoras/f/FlatteningPathIterator.java b/src/main/java/pythagoras/f/FlatteningPathIterator.java index a702afd..6893798 100644 --- a/src/main/java/pythagoras/f/FlatteningPathIterator.java +++ b/src/main/java/pythagoras/f/FlatteningPathIterator.java @@ -34,18 +34,18 @@ class FlatteningPathIterator implements PathIterator this.bufIndex = bufSize; } - public float getFlatness () { + public float flatness () { return flatness; } - public int getRecursionLimit () { + public int recursionLimit () { return bufLimit; } @Override // from interface PathIterator - public int getWindingRule () { - return p.getWindingRule(); + public int windingRule () { + return p.windingRule(); } @Override @@ -81,7 +81,7 @@ class FlatteningPathIterator implements PathIterator } /** Calculates flat path points for the current segment of the source shape. Line segment is - * flat by itself. Flatness of quad and cubic curves are evaluated by the getFlatnessSq() + * flat by itself. Flatness of quad and cubic curves are evaluated by the flatnessSq() * method. Curves are subdivided until current flatness is bigger than user defined value and * subdivision limit isn't exhausted. Single source segments are translated to a series of * buffer points. The smaller the flatness the bigger the series. Every currentSegment() call @@ -109,7 +109,7 @@ class FlatteningPathIterator implements PathIterator } while (bufSubdiv < bufLimit) { - if (QuadCurves.getFlatnessSq(buf, bufIndex) < flatness2) { + if (QuadCurves.flatnessSq(buf, bufIndex) < flatness2) { break; } @@ -150,7 +150,7 @@ class FlatteningPathIterator implements PathIterator } while (bufSubdiv < bufLimit) { - if (CubicCurves.getFlatnessSq(buf, bufIndex) < flatness2) { + if (CubicCurves.flatnessSq(buf, bufIndex) < flatness2) { break; } diff --git a/src/main/java/pythagoras/f/FloatMath.java b/src/main/java/pythagoras/f/FloatMath.java index ba75f5d..676dd43 100644 --- a/src/main/java/pythagoras/f/FloatMath.java +++ b/src/main/java/pythagoras/f/FloatMath.java @@ -319,7 +319,7 @@ public class FloatMath * Returns the (shortest) distance between two angles, assuming that both angles are in * [-pi, +pi]. */ - public static float getAngularDistance (float a1, float a2) + public static float angularDistance (float a1, float a2) { float ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2); return Math.min(Math.abs(a1 - a2), Math.abs(ma1 - ma2)); @@ -329,7 +329,7 @@ public class FloatMath * Returns the (shortest) difference between two angles, assuming that both angles are in * [-pi, +pi]. */ - public static float getAngularDifference (float a1, float a2) + public static float angularDifference (float a1, float a2) { float ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2); float diff = a1 - a2, mdiff = ma2 - ma1; diff --git a/src/main/java/pythagoras/f/IArc.java b/src/main/java/pythagoras/f/IArc.java index a097972..3cb12ac 100644 --- a/src/main/java/pythagoras/f/IArc.java +++ b/src/main/java/pythagoras/f/IArc.java @@ -22,31 +22,31 @@ public interface IArc extends IRectangularShape, Cloneable int PIE = 2; /** Returns the type of this arc: {@link #OPEN}, etc. */ - int getArcType (); + int arcType (); /** Returns the starting angle of this arc. */ - float getAngleStart (); + float angleStart (); /** Returns the angular extent of this arc. */ - float getAngleExtent (); + float angleExtent (); /** Returns the intersection of the ray from the center (defined by the starting angle) and the * elliptical boundary of the arc. */ - Point getStartPoint (); + Point startPoint (); /** Writes the intersection of the ray from the center (defined by the starting angle) and the * elliptical boundary of the arc into {@code target}. * @return the supplied point. */ - Point getStartPoint (Point target); + Point startPoint (Point target); /** Returns the intersection of the ray from the center (defined by the starting angle plus the * angular extent of the arc) and the elliptical boundary of the arc. */ - Point getEndPoint (); + Point endPoint (); /** Writes the intersection of the ray from the center (defined by the starting angle plus the * angular extent of the arc) and the elliptical boundary of the arc into {@code target}. * @return the supplied point. */ - Point getEndPoint (Point target); + Point endPoint (Point target); /** Returns whether the specified angle is within the angular extents of this arc. */ boolean containsAngle (float angle); diff --git a/src/main/java/pythagoras/f/ICubicCurve.java b/src/main/java/pythagoras/f/ICubicCurve.java index 84e5a6a..ac8f97b 100644 --- a/src/main/java/pythagoras/f/ICubicCurve.java +++ b/src/main/java/pythagoras/f/ICubicCurve.java @@ -10,48 +10,48 @@ package pythagoras.f; public interface ICubicCurve extends IShape, Cloneable { /** Returns the x-coordinate of the start of this curve. */ - float getX1 (); + float x1 (); /** Returns the y-coordinate of the start of this curve. */ - float getY1 (); + float y1 (); /** Returns the x-coordinate of the first control point. */ - float getCtrlX1 (); + float ctrlX1 (); /** Returns the y-coordinate of the first control point. */ - float getCtrlY1 (); + float ctrlY1 (); /** Returns the x-coordinate of the second control point. */ - float getCtrlX2 (); + float ctrlX2 (); /** Returns the y-coordinate of the second control point. */ - float getCtrlY2 (); + float ctrlY2 (); /** Returns the x-coordinate of the end of this curve. */ - float getX2 (); + float x2 (); /** Returns the y-coordinate of the end of this curve. */ - float getY2 (); + float y2 (); /** Returns a copy of the starting point of this curve. */ - Point getP1 (); + Point p1 (); /** Returns a copy of the first control point of this curve. */ - Point getCtrlP1 (); + Point ctrlP1 (); /** Returns a copy of the second control point of this curve. */ - Point getCtrlP2 (); + Point ctrlP2 (); /** Returns a copy of the ending point of this curve. */ - Point getP2 (); + Point p2 (); /** Returns the square of the flatness (maximum distance of a control point from the line * connecting the end points) of this curve. */ - float getFlatnessSq (); + float flatnessSq (); /** Returns the flatness (maximum distance of a control point from the line connecting the end * points) of this curve. */ - float getFlatness (); + float flatness (); /** Subdivides this curve and stores the results into {@code left} and {@code right}. */ void subdivide (CubicCurve left, CubicCurve right); diff --git a/src/main/java/pythagoras/f/IDimension.java b/src/main/java/pythagoras/f/IDimension.java index 40b7411..747f1f7 100644 --- a/src/main/java/pythagoras/f/IDimension.java +++ b/src/main/java/pythagoras/f/IDimension.java @@ -12,12 +12,12 @@ public interface IDimension extends Cloneable /** * Returns the magnitude in the x-dimension. */ - float getWidth (); + float width (); /** * Returns the magnitude in the y-dimension. */ - float getHeight (); + float height (); /** * Returns a mutable copy of this dimension. diff --git a/src/main/java/pythagoras/f/ILine.java b/src/main/java/pythagoras/f/ILine.java index 6954537..7b1a58f 100644 --- a/src/main/java/pythagoras/f/ILine.java +++ b/src/main/java/pythagoras/f/ILine.java @@ -10,30 +10,30 @@ package pythagoras.f; public interface ILine extends IShape, Cloneable { /** Returns the x-coordinate of the start of this line. */ - float getX1 (); + float x1 (); /** Returns the y-coordinate of the start of this line. */ - float getY1 (); + float y1 (); /** Returns the x-coordinate of the end of this line. */ - float getX2 (); + float x2 (); /** Returns the y-coordinate of the end of this line. */ - float getY2 (); + float y2 (); /** Returns a copy of the starting point of this line. */ - Point getP1 (); + Point p1 (); /** Initializes the supplied point with this line's starting point. * @return the supplied point. */ - Point getP1 (Point target); + Point p1 (Point target); /** Returns a copy of the ending point of this line. */ - Point getP2 (); + Point p2 (); /** Initializes the supplied point with this line's ending point. * @return the supplied point. */ - Point getP2 (Point target); + Point p2 (Point target); /** Returns the square of the distance from the specified point to the line defined by this * line segment. */ diff --git a/src/main/java/pythagoras/f/IPoint.java b/src/main/java/pythagoras/f/IPoint.java index 7d3a369..9f62af6 100644 --- a/src/main/java/pythagoras/f/IPoint.java +++ b/src/main/java/pythagoras/f/IPoint.java @@ -10,10 +10,10 @@ package pythagoras.f; public interface IPoint extends Cloneable { /** Returns this point's x-coordinate. */ - float getX (); + float x (); /** Returns this point's y-coordinate. */ - float getY (); + float y (); /** Returns the squared Euclidian distance between this point and the specified point. */ float distanceSq (float px, float py); diff --git a/src/main/java/pythagoras/f/IQuadCurve.java b/src/main/java/pythagoras/f/IQuadCurve.java index 85964c9..9b64a41 100644 --- a/src/main/java/pythagoras/f/IQuadCurve.java +++ b/src/main/java/pythagoras/f/IQuadCurve.java @@ -10,39 +10,39 @@ package pythagoras.f; public interface IQuadCurve extends IShape, Cloneable { /** Returns the x-coordinate of the start of this curve. */ - float getX1 (); + float x1 (); /** Returns the y-coordinate of the start of this curve. */ - float getY1 (); + float y1 (); /** Returns the x-coordinate of the control point. */ - float getCtrlX (); + float ctrlX (); /** Returns the y-coordinate of the control point. */ - float getCtrlY (); + float ctrlY (); /** Returns the x-coordinate of the end of this curve. */ - float getX2 (); + float x2 (); /** Returns the y-coordinate of the end of this curve. */ - float getY2 (); + float y2 (); /** Returns a copy of the starting point of this curve. */ - Point getP1 (); + Point p1 (); /** Returns a copy of the control point of this curve. */ - Point getCtrlP (); + Point ctrlP (); /** Returns a copy of the ending point of this curve. */ - Point getP2 (); + Point p2 (); /** Returns the square of the flatness (maximum distance of a control point from the line * connecting the end points) of this curve. */ - float getFlatnessSq (); + float flatnessSq (); /** Returns the flatness (maximum distance of a control point from the line connecting the end * points) of this curve. */ - float getFlatness (); + float flatness (); /** Subdivides this curve and stores the results into {@code left} and {@code right}. */ void subdivide (QuadCurve left, QuadCurve right); diff --git a/src/main/java/pythagoras/f/IRectangle.java b/src/main/java/pythagoras/f/IRectangle.java index 10a9234..257394d 100644 --- a/src/main/java/pythagoras/f/IRectangle.java +++ b/src/main/java/pythagoras/f/IRectangle.java @@ -24,18 +24,18 @@ public interface IRectangle extends IRectangularShape, Cloneable int OUT_BOTTOM = 8; /** Returns a copy of this rectangle's upper-left corner. */ - Point getLocation (); + Point location (); /** Initializes the supplied point with this rectangle's upper-left corner. * @return the supplied point. */ - Point getLocation (Point target); + Point location (Point target); /** Returns a copy of this rectangle's size. */ - Dimension getSize (); + Dimension size (); /** Initializes the supplied dimension with this rectangle's size. * @return the supplied dimension. */ - Dimension getSize (Dimension target); + Dimension size (Dimension target); /** Returns the intersection of the specified rectangle and this rectangle (i.e. the largest * rectangle contained in both this and the specified rectangle). */ diff --git a/src/main/java/pythagoras/f/IRectangularShape.java b/src/main/java/pythagoras/f/IRectangularShape.java index 037b5f9..3e9ae9c 100644 --- a/src/main/java/pythagoras/f/IRectangularShape.java +++ b/src/main/java/pythagoras/f/IRectangularShape.java @@ -12,48 +12,48 @@ package pythagoras.f; public interface IRectangularShape extends IShape { /** Returns the x-coordinate of the upper-left corner of the framing rectangle. */ - float getX (); + float x (); /** Returns the y-coordinate of the upper-left corner of the framing rectangle. */ - float getY (); + float y (); /** Returns the width of the framing rectangle. */ - float getWidth (); + float width (); /** Returns the height of the framing rectangle. */ - float getHeight (); + float height (); /** Returns the minimum x,y-coordinate of the framing rectangle. */ - Point getMin (); + Point min (); /** Returns the minimum x-coordinate of the framing rectangle. */ - float getMinX (); + float minX (); /** Returns the minimum y-coordinate of the framing rectangle. */ - float getMinY (); + float minY (); /** Returns the maximum x,y-coordinate of the framing rectangle. */ - Point getMax (); + Point max (); /** Returns the maximum x-coordinate of the framing rectangle. */ - float getMaxX (); + float maxX (); /** Returns the maximum y-coordinate of the framing rectangle. */ - float getMaxY (); + float maxY (); /** Returns the center of the framing rectangle. */ - Point getCenter (); + Point center (); /** Returns the x-coordinate of the center of the framing rectangle. */ - float getCenterX (); + float centerX (); /** Returns the y-coordinate of the center of the framing rectangle. */ - float getCenterY (); + float centerY (); /** Returns a copy of this shape's framing rectangle. */ - Rectangle getFrame (); + Rectangle frame (); /** Initializes the supplied rectangle with this shape's framing rectangle. * @return the supplied rectangle. */ - Rectangle getFrame (Rectangle target); + Rectangle frame (Rectangle target); } diff --git a/src/main/java/pythagoras/f/IRoundRectangle.java b/src/main/java/pythagoras/f/IRoundRectangle.java index 6d2d81d..8699e1f 100644 --- a/src/main/java/pythagoras/f/IRoundRectangle.java +++ b/src/main/java/pythagoras/f/IRoundRectangle.java @@ -10,10 +10,10 @@ package pythagoras.f; public interface IRoundRectangle extends IRectangularShape, Cloneable { /** Returns the width of the corner arc. */ - float getArcWidth (); + float arcWidth (); /** Returns the height of the corner arc. */ - float getArcHeight (); + float arcHeight (); /** Returns a mutable copy of this round rectangle. */ RoundRectangle clone (); diff --git a/src/main/java/pythagoras/f/IShape.java b/src/main/java/pythagoras/f/IShape.java index 9a3f5e9..9abe0f0 100644 --- a/src/main/java/pythagoras/f/IShape.java +++ b/src/main/java/pythagoras/f/IShape.java @@ -31,18 +31,18 @@ public interface IShape boolean intersects (IRectangle r); /** Returns a copy of the bounding rectangle for this shape. */ - Rectangle getBounds (); + Rectangle bounds (); /** Initializes the supplied rectangle with this shape's bounding rectangle. * @return the supplied rectangle. */ - Rectangle getBounds (Rectangle target); + Rectangle bounds (Rectangle target); /** * Returns an iterator over the path described by this shape. * * @param at if supplied, the points in the path are transformed using this. */ - PathIterator getPathIterator (Transform at); + PathIterator pathIterator (Transform at); /** * Returns an iterator over the path described by this shape. @@ -52,5 +52,5 @@ public interface IShape * distance the lines are allowed to deviate from the approximated curve, thus a higher * flatness value generally allows for a path with fewer segments. */ - PathIterator getPathIterator (Transform at, float flatness); + PathIterator pathIterator (Transform at, float flatness); } diff --git a/src/main/java/pythagoras/f/IVector.java b/src/main/java/pythagoras/f/IVector.java index 87a4734..1959cde 100644 --- a/src/main/java/pythagoras/f/IVector.java +++ b/src/main/java/pythagoras/f/IVector.java @@ -10,10 +10,10 @@ package pythagoras.f; public interface IVector { /** Returns the x-component of this vector. */ - float getX (); + float x (); /** Returns the y-component of this vector. */ - float getY (); + float y (); /** Computes and returns the dot product of this and the specified other vector. */ float dot (IVector other); diff --git a/src/main/java/pythagoras/f/IdentityTransform.java b/src/main/java/pythagoras/f/IdentityTransform.java index d7e1f22..3704884 100644 --- a/src/main/java/pythagoras/f/IdentityTransform.java +++ b/src/main/java/pythagoras/f/IdentityTransform.java @@ -13,32 +13,32 @@ public class IdentityTransform extends AbstractTransform public static final int GENERALITY = 0; @Override // from Transform - public float getUniformScale () { + public float uniformScale () { return 1; } @Override // from Transform - public float getScaleX () { + public float scaleX () { return 1; } @Override // from Transform - public float getScaleY () { + public float scaleY () { return 1; } @Override // from Transform - public float getRotation () { + public float rotation () { return 0; } @Override // from Transform - public float getTx () { + public float tx () { return 0; } @Override // from Transform - public float getTy () { + public float ty () { return 0; } diff --git a/src/main/java/pythagoras/f/IntersectPoint.java b/src/main/java/pythagoras/f/IntersectPoint.java index a8f146b..0c37956 100644 --- a/src/main/java/pythagoras/f/IntersectPoint.java +++ b/src/main/java/pythagoras/f/IntersectPoint.java @@ -36,31 +36,31 @@ class IntersectPoint this.y = y; } - public int getBegIndex (boolean isCurrentArea) { + public int begIndex (boolean isCurrentArea) { return isCurrentArea ? begIndex1 : begIndex2; } - public int getEndIndex (boolean isCurrentArea) { + public int endIndex (boolean isCurrentArea) { return isCurrentArea ? endIndex1 : endIndex2; } - public int getRuleIndex (boolean isCurrentArea) { + public int ruleIndex (boolean isCurrentArea) { return isCurrentArea ? ruleIndex1 : ruleIndex2; } - public float getParam (boolean isCurrentArea) { + public float param (boolean isCurrentArea) { return isCurrentArea ? param1 : param2; } - public int getRule (boolean isCurrentArea) { + public int rule (boolean isCurrentArea) { return isCurrentArea ? rule1 : rule2; } - public float getX () { + public float x () { return x; } - public float getY () { + public float y () { return y; } diff --git a/src/main/java/pythagoras/f/Line.java b/src/main/java/pythagoras/f/Line.java index 2bf32c2..c35ddb3 100644 --- a/src/main/java/pythagoras/f/Line.java +++ b/src/main/java/pythagoras/f/Line.java @@ -57,26 +57,26 @@ public class Line extends AbstractLine implements Serializable * Sets the start and end of this line to the specified points. */ public void setLine (IPoint p1, IPoint p2) { - setLine(p1.getX(), p1.getY(), p2.getY(), p2.getY()); + setLine(p1.x(), p1.y(), p2.y(), p2.y()); } @Override // from interface ILine - public float getX1 () { + public float x1 () { return x1; } @Override // from interface ILine - public float getY1 () { + public float y1 () { return y1; } @Override // from interface ILine - public float getX2 () { + public float x2 () { return x2; } @Override // from interface ILine - public float getY2 () { + public float y2 () { return y2; } } diff --git a/src/main/java/pythagoras/f/NonUniformTransform.java b/src/main/java/pythagoras/f/NonUniformTransform.java index 95a5fcf..3ad2b58 100644 --- a/src/main/java/pythagoras/f/NonUniformTransform.java +++ b/src/main/java/pythagoras/f/NonUniformTransform.java @@ -34,32 +34,32 @@ public class NonUniformTransform extends AbstractTransform } @Override // from Transform - public float getUniformScale () { + public float uniformScale () { return (scaleX + scaleY) / 2; // TODO: is this sane } @Override // from Transform - public float getScaleX () { + public float scaleX () { return scaleX; } @Override // from Transform - public float getScaleY () { + public float scaleY () { return scaleY; } @Override // from Transform - public float getRotation () { + public float rotation () { return rotation; } @Override // from Transform - public float getTx () { + public float tx () { return tx; } @Override // from Transform - public float getTy () { + public float ty () { return ty; } @@ -160,14 +160,14 @@ public class NonUniformTransform extends AbstractTransform return other.preConcatenate(this); } - float otx = other.getTx(), oty = other.getTy(); + float otx = other.tx(), oty = other.ty(); float sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation); - float ntx = (otx*cosa - oty*sina) * scaleX + getTx(); - float nty = (otx*sina + oty*cosa) * scaleY + getTy(); + float ntx = (otx*cosa - oty*sina) * scaleX + tx(); + float nty = (otx*sina + oty*cosa) * scaleY + ty(); - float nrotation = FloatMath.normalizeAngle(rotation + other.getRotation()); - float nscaleX = scaleX * other.getScaleX(); - float nscaleY = scaleY * other.getScaleY(); + float nrotation = FloatMath.normalizeAngle(rotation + other.rotation()); + float nscaleX = scaleX * other.scaleX(); + float nscaleY = scaleY * other.scaleY(); return new NonUniformTransform(nscaleX, nscaleY, nrotation, ntx, nty); } @@ -177,13 +177,13 @@ public class NonUniformTransform extends AbstractTransform return other.concatenate(this); } - float tx = getTx(), ty = getTy(); - float sina = FloatMath.sin(other.getRotation()), cosa = FloatMath.cos(other.getRotation()); - float ntx = (tx*cosa - ty*sina) * other.getScaleX() + other.getTx(); - float nty = (tx*sina + ty*cosa) * other.getScaleY() + other.getTy(); - float nrotation = FloatMath.normalizeAngle(other.getRotation() + rotation); - float nscaleX = other.getScaleX() * scaleX; - float nscaleY = other.getScaleY() * scaleY; + float tx = tx(), ty = ty(); + float sina = FloatMath.sin(other.rotation()), cosa = FloatMath.cos(other.rotation()); + float ntx = (tx*cosa - ty*sina) * other.scaleX() + other.tx(); + float nty = (tx*sina + ty*cosa) * other.scaleY() + other.ty(); + float nrotation = FloatMath.normalizeAngle(other.rotation() + rotation); + float nscaleX = other.scaleX() * scaleX; + float nscaleY = other.scaleY() * scaleY; return new NonUniformTransform(nscaleX, nscaleY, nrotation, ntx, nty); } @@ -193,17 +193,17 @@ public class NonUniformTransform extends AbstractTransform return other.lerp(this, -t); // TODO: is this correct? } - float ntx = FloatMath.lerpa(tx, other.getTx(), t); - float nty = FloatMath.lerpa(ty, other.getTy(), t); - float nrotation = FloatMath.lerpa(rotation, other.getRotation(), t); - float nscaleX = FloatMath.lerp(scaleX, other.getScaleX(), t); - float nscaleY = FloatMath.lerp(scaleY, other.getScaleY(), t); + float ntx = FloatMath.lerpa(tx, other.tx(), t); + float nty = FloatMath.lerpa(ty, other.ty(), t); + float nrotation = FloatMath.lerpa(rotation, other.rotation(), t); + float nscaleX = FloatMath.lerp(scaleX, other.scaleX(), t); + float nscaleY = FloatMath.lerp(scaleY, other.scaleY(), t); return new NonUniformTransform(nscaleX, nscaleY, nrotation, ntx, nty); } @Override // from Transform public Point transform (IPoint p, Point into) { - return Points.transform(p.getX(), p.getY(), scaleX, scaleY, rotation, tx, ty, into); + return Points.transform(p.x(), p.y(), scaleX, scaleY, rotation, tx, ty, into); } @Override // from Transform @@ -211,7 +211,7 @@ public class NonUniformTransform extends AbstractTransform float sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation); for (int ii = 0; ii < count; ii++) { IPoint s = src[srcOff++]; - Points.transform(s.getX(), s.getY(), scaleX, scaleY, sina, cosa, tx, ty, dst[dstOff++]); + Points.transform(s.x(), s.y(), scaleX, scaleY, sina, cosa, tx, ty, dst[dstOff++]); } } @@ -228,17 +228,17 @@ public class NonUniformTransform extends AbstractTransform @Override // from Transform public Point inverseTransform (IPoint p, Point into) { - return Points.inverseTransform(p.getX(), p.getY(), scaleX, scaleY, rotation, tx, ty, into); + return Points.inverseTransform(p.x(), p.y(), scaleX, scaleY, rotation, tx, ty, into); } @Override // from Transform public Vector transform (IVector v, Vector into) { - return Vectors.transform(v.getX(), v.getY(), scaleX, scaleY, rotation, into); + return Vectors.transform(v.x(), v.y(), scaleX, scaleY, rotation, into); } @Override // from Transform public Vector inverseTransform (IVector v, Vector into) { - return Vectors.inverseTransform(v.getX(), v.getY(), scaleX, scaleY, rotation, into); + return Vectors.inverseTransform(v.x(), v.y(), scaleX, scaleY, rotation, into); } @Override // from Transform @@ -253,7 +253,7 @@ public class NonUniformTransform extends AbstractTransform @Override public String toString () { - return "nonunif [scale=" + getScale() + ", rot=" + rotation + - ", trans=" + getTranslation() + "]"; + return "nonunif [scale=" + scale() + ", rot=" + rotation + + ", trans=" + translation() + "]"; } } diff --git a/src/main/java/pythagoras/f/Path.java b/src/main/java/pythagoras/f/Path.java index 68f212c..1fd4e56 100644 --- a/src/main/java/pythagoras/f/Path.java +++ b/src/main/java/pythagoras/f/Path.java @@ -35,8 +35,8 @@ public final class Path implements IShape, Cloneable public Path (IShape shape) { this(WIND_NON_ZERO, BUFFER_SIZE); - PathIterator p = shape.getPathIterator(null); - setWindingRule(p.getWindingRule()); + PathIterator p = shape.pathIterator(null); + setWindingRule(p.windingRule()); append(p, false); } @@ -47,7 +47,7 @@ public final class Path implements IShape, Cloneable this.rule = rule; } - public int getWindingRule () { + public int windingRule () { return rule; } @@ -98,7 +98,7 @@ public final class Path implements IShape, Cloneable } public void append (IShape shape, boolean connect) { - PathIterator p = shape.getPathIterator(null); + PathIterator p = shape.pathIterator(null); append(p, connect); } @@ -135,7 +135,7 @@ public final class Path implements IShape, Cloneable } } - public Point getCurrentPoint () { + public Point currentPoint () { if (typeSize == 0) { return null; } @@ -170,12 +170,12 @@ public final class Path implements IShape, Cloneable } @Override // from interface IShape - public Rectangle getBounds () { - return getBounds(new Rectangle()); + public Rectangle bounds () { + return bounds(new Rectangle()); } @Override // from interface IShape - public Rectangle getBounds (Rectangle target) { + public Rectangle bounds (Rectangle target) { float rx1, ry1, rx2, ry2; if (pointSize == 0) { rx1 = ry1 = rx2 = ry2 = 0f; @@ -205,7 +205,7 @@ public final class Path implements IShape, Cloneable @Override // from interface IShape public boolean isEmpty () { // TODO: will this be insanely difficult to do correctly? - return getBounds().isEmpty(); + return bounds().isEmpty(); } @Override // from interface IShape @@ -227,27 +227,27 @@ public final class Path implements IShape, Cloneable @Override // from interface IShape public boolean contains (IPoint p) { - return contains(p.getX(), p.getY()); + return contains(p.x(), p.y()); } @Override // from interface IShape public boolean contains (IRectangle r) { - return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + return contains(r.x(), r.y(), r.width(), r.height()); } @Override // from interface IShape public boolean intersects (IRectangle r) { - return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + return intersects(r.x(), r.y(), r.width(), r.height()); } @Override // from interface IShape - public PathIterator getPathIterator (Transform t) { + public PathIterator pathIterator (Transform t) { return new Iterator(this, t); } @Override // from interface IShape - public PathIterator getPathIterator (Transform t, float flatness) { - return new FlatteningPathIterator(getPathIterator(t), flatness); + public PathIterator pathIterator (Transform t, float flatness) { + return new FlatteningPathIterator(pathIterator(t), flatness); } // @Override // can't declare @Override due to GWT @@ -320,8 +320,8 @@ public final class Path implements IShape, Cloneable this.t = at; } - @Override public int getWindingRule () { - return p.getWindingRule(); + @Override public int windingRule () { + return p.windingRule(); } @Override public boolean isDone () { diff --git a/src/main/java/pythagoras/f/PathIterator.java b/src/main/java/pythagoras/f/PathIterator.java index f4e452a..1042e29 100644 --- a/src/main/java/pythagoras/f/PathIterator.java +++ b/src/main/java/pythagoras/f/PathIterator.java @@ -36,7 +36,7 @@ public interface PathIterator /** * Returns the winding rule used to determine the interior of this path. */ - int getWindingRule (); + int windingRule (); /** * Returns true if this path has no additional segments. diff --git a/src/main/java/pythagoras/f/Point.java b/src/main/java/pythagoras/f/Point.java index 9cc3998..6ec5a9f 100644 --- a/src/main/java/pythagoras/f/Point.java +++ b/src/main/java/pythagoras/f/Point.java @@ -34,13 +34,13 @@ public class Point extends AbstractPoint implements Serializable * Constructs a point with coordinates equal to the supplied point. */ public Point (IPoint p) { - set(p.getX(), p.getY()); + set(p.x(), p.y()); } /** Sets the coordinates of this point to be equal to those of the supplied point. * @return a reference to this this, for chaining. */ public Point set (IPoint p) { - return set(p.getX(), p.getY()); + return set(p.x(), p.y()); } /** Sets the coordinates of this point to the supplied values. @@ -70,12 +70,12 @@ public class Point extends AbstractPoint implements Serializable } @Override // from interface IPoint - public float getX () { + public float x () { return x; } @Override // from interface IPoint - public float getY () { + public float y () { return y; } } diff --git a/src/main/java/pythagoras/f/QuadCurve.java b/src/main/java/pythagoras/f/QuadCurve.java index 1c67c67..60135d3 100644 --- a/src/main/java/pythagoras/f/QuadCurve.java +++ b/src/main/java/pythagoras/f/QuadCurve.java @@ -58,7 +58,7 @@ public class QuadCurve extends AbstractQuadCurve implements Serializable * Configures the start, control, and end points for this curve. */ public void setCurve (IPoint p1, IPoint cp, IPoint p2) { - setCurve(p1.getX(), p1.getY(), cp.getX(), cp.getY(), p2.getX(), p2.getY()); + setCurve(p1.x(), p1.y(), cp.x(), cp.y(), p2.x(), p2.y()); } /** @@ -76,9 +76,9 @@ public class QuadCurve extends AbstractQuadCurve implements Serializable * specified offset in the {@code points} array. */ public void setCurve (IPoint[] points, int offset) { - setCurve(points[offset + 0].getX(), points[offset + 0].getY(), - points[offset + 1].getX(), points[offset + 1].getY(), - points[offset + 2].getX(), points[offset + 2].getY()); + setCurve(points[offset + 0].x(), points[offset + 0].y(), + points[offset + 1].x(), points[offset + 1].y(), + points[offset + 2].x(), points[offset + 2].y()); } /** @@ -86,37 +86,37 @@ public class QuadCurve extends AbstractQuadCurve implements Serializable * curve. */ public void setCurve (IQuadCurve curve) { - setCurve(curve.getX1(), curve.getY1(), curve.getCtrlX(), curve.getCtrlY(), - curve.getX2(), curve.getY2()); + setCurve(curve.x1(), curve.y1(), curve.ctrlX(), curve.ctrlY(), + curve.x2(), curve.y2()); } @Override // from interface IQuadCurve - public float getX1 () { + public float x1 () { return x1; } @Override // from interface IQuadCurve - public float getY1 () { + public float y1 () { return y1; } @Override // from interface IQuadCurve - public float getCtrlX () { + public float ctrlX () { return ctrlx; } @Override // from interface IQuadCurve - public float getCtrlY () { + public float ctrlY () { return ctrly; } @Override // from interface IQuadCurve - public float getX2 () { + public float x2 () { return x2; } @Override // from interface IQuadCurve - public float getY2 () { + public float y2 () { return y2; } } diff --git a/src/main/java/pythagoras/f/QuadCurves.java b/src/main/java/pythagoras/f/QuadCurves.java index af2981d..ed8d84c 100644 --- a/src/main/java/pythagoras/f/QuadCurves.java +++ b/src/main/java/pythagoras/f/QuadCurves.java @@ -9,35 +9,35 @@ package pythagoras.f; */ public class QuadCurves { - public static float getFlatnessSq (float x1, float y1, float ctrlx, float ctrly, + public static float flatnessSq (float x1, float y1, float ctrlx, float ctrly, float x2, float y2) { return Lines.pointSegDistSq(ctrlx, ctrly, x1, y1, x2, y2); } - public static float getFlatnessSq (float[] coords, int offset) { + public static float flatnessSq (float[] coords, int offset) { return Lines.pointSegDistSq(coords[offset + 2], coords[offset + 3], coords[offset + 0], coords[offset + 1], coords[offset + 4], coords[offset + 5]); } - public static float getFlatness (float x1, float y1, float ctrlx, float ctrly, + public static float flatness (float x1, float y1, float ctrlx, float ctrly, float x2, float y2) { return Lines.pointSegDist(ctrlx, ctrly, x1, y1, x2, y2); } - public static float getFlatness (float[] coords, int offset) { + public static float flatness (float[] coords, int offset) { return Lines.pointSegDist(coords[offset + 2], coords[offset + 3], coords[offset + 0], coords[offset + 1], coords[offset + 4], coords[offset + 5]); } public static void subdivide (IQuadCurve src, QuadCurve left, QuadCurve right) { - float x1 = src.getX1(); - float y1 = src.getY1(); - float cx = src.getCtrlX(); - float cy = src.getCtrlY(); - float x2 = src.getX2(); - float y2 = src.getY2(); + float x1 = src.x1(); + float y1 = src.y1(); + float cx = src.ctrlX(); + float cy = src.ctrlY(); + float x2 = src.x2(); + float y2 = src.y2(); float cx1 = (x1 + cx) / 2f; float cy1 = (y1 + cy) / 2f; float cx2 = (x2 + cx) / 2f; diff --git a/src/main/java/pythagoras/f/Rectangle.java b/src/main/java/pythagoras/f/Rectangle.java index bc7fa45..0d82f15 100644 --- a/src/main/java/pythagoras/f/Rectangle.java +++ b/src/main/java/pythagoras/f/Rectangle.java @@ -33,14 +33,14 @@ public class Rectangle extends AbstractRectangle implements Serializable * Constructs a rectangle with the supplied upper-left corner and dimensions (0,0). */ public Rectangle (IPoint p) { - setBounds(p.getX(), p.getY(), 0, 0); + setBounds(p.x(), p.y(), 0, 0); } /** * Constructs a rectangle with upper-left corner at (0,) and the supplied dimensions. */ public Rectangle (IDimension d) { - setBounds(0, 0, d.getWidth(), d.getHeight()); + setBounds(0, 0, d.width(), d.height()); } /** @@ -48,7 +48,7 @@ public class Rectangle extends AbstractRectangle implements Serializable * dimensions. */ public Rectangle (IPoint p, IDimension d) { - setBounds(p.getX(), p.getY(), d.getWidth(), d.getHeight()); + setBounds(p.x(), p.y(), d.width(), d.height()); } /** @@ -62,7 +62,7 @@ public class Rectangle extends AbstractRectangle implements Serializable * Constructs a rectangle with bounds equal to the supplied rectangle. */ public Rectangle (IRectangle r) { - setBounds(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + setBounds(r.x(), r.y(), r.width(), r.height()); } /** @@ -77,7 +77,7 @@ public class Rectangle extends AbstractRectangle implements Serializable * Sets the upper-left corner of this rectangle to the supplied point. */ public void setLocation (IPoint p) { - setLocation(p.getX(), p.getY()); + setLocation(p.x(), p.y()); } /** @@ -92,7 +92,7 @@ public class Rectangle extends AbstractRectangle implements Serializable * Sets the size of this rectangle to the supplied dimensions. */ public void setSize (IDimension d) { - setSize(d.getWidth(), d.getHeight()); + setSize(d.width(), d.height()); } /** @@ -109,7 +109,7 @@ public class Rectangle extends AbstractRectangle implements Serializable * Sets the bounds of this rectangle to those of the supplied rectangle. */ public void setBounds (IRectangle r) { - setBounds(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + setBounds(r.x(), r.y(), r.width(), r.height()); } /** @@ -147,37 +147,37 @@ public class Rectangle extends AbstractRectangle implements Serializable * Expands the bounds of this rectangle to contain the supplied point. */ public void add (IPoint p) { - add(p.getX(), p.getY()); + add(p.x(), p.y()); } /** * Expands the bounds of this rectangle to contain the supplied rectangle. */ public void add (IRectangle r) { - float x1 = Math.min(x, r.getX()); - float x2 = Math.max(x + width, r.getX() + r.getWidth()); - float y1 = Math.min(y, r.getY()); - float y2 = Math.max(y + height, r.getY() + r.getHeight()); + float x1 = Math.min(x, r.x()); + float x2 = Math.max(x + width, r.x() + r.width()); + float y1 = Math.min(y, r.y()); + float y2 = Math.max(y + height, r.y() + r.height()); setBounds(x1, y1, x2 - x1, y2 - y1); } @Override // from interface IRectangularShape - public float getX () { + public float x () { return x; } @Override // from interface IRectangularShape - public float getY () { + public float y () { return y; } @Override // from interface IRectangularShape - public float getWidth () { + public float width () { return width; } @Override // from interface IRectangularShape - public float getHeight () { + public float height () { return height; } diff --git a/src/main/java/pythagoras/f/Rectangles.java b/src/main/java/pythagoras/f/Rectangles.java index be20614..982ed5d 100644 --- a/src/main/java/pythagoras/f/Rectangles.java +++ b/src/main/java/pythagoras/f/Rectangles.java @@ -13,10 +13,10 @@ public class Rectangles * Intersects the supplied two rectangles, writing the result into {@code dst}. */ public static void intersect (IRectangle src1, IRectangle src2, Rectangle dst) { - float x1 = Math.max(src1.getMinX(), src2.getMinX()); - float y1 = Math.max(src1.getMinY(), src2.getMinY()); - float x2 = Math.min(src1.getMaxX(), src2.getMaxX()); - float y2 = Math.min(src1.getMaxY(), src2.getMaxY()); + float x1 = Math.max(src1.minX(), src2.minX()); + float y1 = Math.max(src1.minY(), src2.minY()); + float x2 = Math.min(src1.maxX(), src2.maxX()); + float y2 = Math.min(src1.maxY(), src2.maxY()); dst.setBounds(x1, y1, x2 - x1, y2 - y1); } @@ -24,10 +24,10 @@ public class Rectangles * Unions the supplied two rectangles, writing the result into {@code dst}. */ public static void union (IRectangle src1, IRectangle src2, Rectangle dst) { - float x1 = Math.min(src1.getMinX(), src2.getMinX()); - float y1 = Math.min(src1.getMinY(), src2.getMinY()); - float x2 = Math.max(src1.getMaxX(), src2.getMaxX()); - float y2 = Math.max(src1.getMaxY(), src2.getMaxY()); + float x1 = Math.min(src1.minX(), src2.minX()); + float y1 = Math.min(src1.minY(), src2.minY()); + float x2 = Math.max(src1.maxX(), src2.maxX()); + float y2 = Math.max(src1.maxY(), src2.maxY()); dst.setBounds(x1, y1, x2 - x1, y2 - y1); } } diff --git a/src/main/java/pythagoras/f/RectangularShape.java b/src/main/java/pythagoras/f/RectangularShape.java index c47c4aa..5cf7546 100644 --- a/src/main/java/pythagoras/f/RectangularShape.java +++ b/src/main/java/pythagoras/f/RectangularShape.java @@ -19,7 +19,7 @@ public abstract class RectangularShape implements IRectangularShape * Sets the location and size of the framing rectangle of this shape to the supplied values. */ public void setFrame (IPoint loc, IDimension size) { - setFrame(loc.getX(), loc.getY(), size.getWidth(), size.getHeight()); + setFrame(loc.x(), loc.y(), size.width(), size.height()); } /** @@ -27,7 +27,7 @@ public abstract class RectangularShape implements IRectangularShape * supplied rectangle. */ public void setFrame (IRectangle r) { - setFrame(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + setFrame(r.x(), r.y(), r.width(), r.height()); } /** @@ -58,7 +58,7 @@ public abstract class RectangularShape implements IRectangularShape * diagonal line. */ public void setFrameFromDiagonal (IPoint p1, IPoint p2) { - setFrameFromDiagonal(p1.getX(), p1.getY(), p2.getX(), p2.getY()); + setFrameFromDiagonal(p1.x(), p1.y(), p2.x(), p2.y()); } /** @@ -77,100 +77,100 @@ public abstract class RectangularShape implements IRectangularShape * center and corner points. */ public void setFrameFromCenter (IPoint center, IPoint corner) { - setFrameFromCenter(center.getX(), center.getY(), corner.getX(), corner.getY()); + setFrameFromCenter(center.x(), center.y(), corner.x(), corner.y()); } @Override // from IRectangularShape - public Point getMin () + public Point min () { - return new Point(getMinX(), getMinY()); + return new Point(minX(), minY()); } @Override // from IRectangularShape - public float getMinX () { - return getX(); + public float minX () { + return x(); } @Override // from IRectangularShape - public float getMinY () { - return getY(); + public float minY () { + return y(); } @Override // from IRectangularShape - public Point getMax () + public Point max () { - return new Point(getMaxX(), getMaxY()); + return new Point(maxX(), maxY()); } @Override // from IRectangularShape - public float getMaxX () { - return getX() + getWidth(); + public float maxX () { + return x() + width(); } @Override // from IRectangularShape - public float getMaxY () { - return getY() + getHeight(); + public float maxY () { + return y() + height(); } @Override // from IRectangularShape - public Point getCenter () + public Point center () { - return new Point(getCenterX(), getCenterY()); + return new Point(centerX(), centerY()); } @Override // from IRectangularShape - public float getCenterX () { - return getX() + getWidth() / 2; + public float centerX () { + return x() + width() / 2; } @Override // from IRectangularShape - public float getCenterY () { - return getY() + getHeight() / 2; + public float centerY () { + return y() + height() / 2; } @Override // from IRectangularShape - public Rectangle getFrame () { - return getBounds(); + public Rectangle frame () { + return bounds(); } @Override // from IRectangularShape - public Rectangle getFrame (Rectangle target) { - return getBounds(target); + public Rectangle frame (Rectangle target) { + return bounds(target); } @Override // from interface IShape public boolean isEmpty () { - return getWidth() <= 0 || getHeight() <= 0; + return width() <= 0 || height() <= 0; } @Override // from interface IShape public boolean contains (IPoint point) { - return contains(point.getX(), point.getY()); + return contains(point.x(), point.y()); } @Override // from interface IShape public boolean contains (IRectangle rect) { - return contains(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); + return contains(rect.x(), rect.y(), rect.width(), rect.height()); } @Override // from interface IShape public boolean intersects (IRectangle rect) { - return intersects(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); + return intersects(rect.x(), rect.y(), rect.width(), rect.height()); } @Override // from interface IShape - public Rectangle getBounds () { - return getBounds(new Rectangle()); + public Rectangle bounds () { + return bounds(new Rectangle()); } @Override // from interface IShape - public Rectangle getBounds (Rectangle target) { - target.setBounds(getX(), getY(), getWidth(), getHeight()); + public Rectangle bounds (Rectangle target) { + target.setBounds(x(), y(), width(), height()); return target; } @Override // from interface IShape - public PathIterator getPathIterator (Transform t, float flatness) { - return new FlatteningPathIterator(getPathIterator(t), flatness); + public PathIterator pathIterator (Transform t, float flatness) { + return new FlatteningPathIterator(pathIterator(t), flatness); } } diff --git a/src/main/java/pythagoras/f/RigidTransform.java b/src/main/java/pythagoras/f/RigidTransform.java index 9cba744..25551ff 100644 --- a/src/main/java/pythagoras/f/RigidTransform.java +++ b/src/main/java/pythagoras/f/RigidTransform.java @@ -29,32 +29,32 @@ public class RigidTransform extends AbstractTransform } @Override // from Transform - public float getUniformScale () { + public float uniformScale () { return 1; } @Override // from Transform - public float getScaleX () { + public float scaleX () { return 1; } @Override // from Transform - public float getScaleY () { + public float scaleY () { return 1; } @Override // from Transform - public float getRotation () { + public float rotation () { return rotation; } @Override // from Transform - public float getTx () { + public float tx () { return tx; } @Override // from Transform - public float getTy () { + public float ty () { return ty; } @@ -102,7 +102,7 @@ public class RigidTransform extends AbstractTransform @Override // from Transform public Transform invert () { - Vector t = getTranslation().negateLocal().rotateLocal(-rotation); + Vector t = translation().negateLocal().rotateLocal(-rotation); return new RigidTransform(-rotation, t.x, t.y); } @@ -112,9 +112,9 @@ public class RigidTransform extends AbstractTransform return other.preConcatenate(this); } - Vector nt = other.getTranslation(); - nt.rotateAndAdd(rotation, getTranslation(), nt); - float nrotation = FloatMath.normalizeAngle(rotation + other.getRotation()); + Vector nt = other.translation(); + nt.rotateAndAdd(rotation, translation(), nt); + float nrotation = FloatMath.normalizeAngle(rotation + other.rotation()); return new RigidTransform(nrotation, nt.x, nt.y); } @@ -124,9 +124,9 @@ public class RigidTransform extends AbstractTransform return other.concatenate(this); } - Vector nt = getTranslation(); - nt.rotateAndAdd(other.getRotation(), other.getTranslation(), nt); - float nrotation = FloatMath.normalizeAngle(other.getRotation() + rotation); + Vector nt = translation(); + nt.rotateAndAdd(other.rotation(), other.translation(), nt); + float nrotation = FloatMath.normalizeAngle(other.rotation() + rotation); return new RigidTransform(nrotation, nt.x, nt.y); } @@ -135,13 +135,13 @@ public class RigidTransform extends AbstractTransform if (generality() < other.generality()) { return other.lerp(this, -t); // TODO: is this correct? } - Vector nt = getTranslation().lerpLocal(other.getTranslation(), t); - return new RigidTransform(FloatMath.lerpa(rotation, other.getRotation(), t), nt.x, nt.y); + Vector nt = translation().lerpLocal(other.translation(), t); + return new RigidTransform(FloatMath.lerpa(rotation, other.rotation(), t), nt.x, nt.y); } @Override // from Transform public Point transform (IPoint p, Point into) { - return Points.transform(p.getX(), p.getY(), 1, 1, rotation, tx, ty, into); + return Points.transform(p.x(), p.y(), 1, 1, rotation, tx, ty, into); } @Override // from Transform @@ -149,7 +149,7 @@ public class RigidTransform extends AbstractTransform float sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation); for (int ii = 0; ii < count; ii++) { IPoint s = src[srcOff++]; - Points.transform(s.getX(), s.getY(), 1, 1, sina, cosa, tx, ty, dst[dstOff++]); + Points.transform(s.x(), s.y(), 1, 1, sina, cosa, tx, ty, dst[dstOff++]); } } @@ -166,7 +166,7 @@ public class RigidTransform extends AbstractTransform @Override // from Transform public Point inverseTransform (IPoint p, Point into) { - return Points.inverseTransform(p.getX(), p.getY(), 1, 1, rotation, tx, ty, into); + return Points.inverseTransform(p.x(), p.y(), 1, 1, rotation, tx, ty, into); } @Override // from Transform @@ -191,6 +191,6 @@ public class RigidTransform extends AbstractTransform @Override public String toString () { - return "rigid [rot=" + rotation + ", trans=" + getTranslation() + "]"; + return "rigid [rot=" + rotation + ", trans=" + translation() + "]"; } } diff --git a/src/main/java/pythagoras/f/RoundRectangle.java b/src/main/java/pythagoras/f/RoundRectangle.java index 36ebafb..8debb07 100644 --- a/src/main/java/pythagoras/f/RoundRectangle.java +++ b/src/main/java/pythagoras/f/RoundRectangle.java @@ -61,37 +61,37 @@ public class RoundRectangle extends AbstractRoundRectangle implements Serializab * rectangle. */ public void setRoundRect (IRoundRectangle rr) { - setRoundRect(rr.getX(), rr.getY(), rr.getWidth(), rr.getHeight(), - rr.getArcWidth(), rr.getArcHeight()); + setRoundRect(rr.x(), rr.y(), rr.width(), rr.height(), + rr.arcWidth(), rr.arcHeight()); } @Override // from interface IRoundRectangle - public float getArcWidth () { + public float arcWidth () { return arcwidth; } @Override // from interface IRoundRectangle - public float getArcHeight () { + public float arcHeight () { return archeight; } @Override // from interface IRectangularShape - public float getX () { + public float x () { return x; } @Override // from interface IRectangularShape - public float getY () { + public float y () { return y; } @Override // from interface IRectangularShape - public float getWidth () { + public float width () { return width; } @Override // from interface IRectangularShape - public float getHeight () { + public float height () { return height; } diff --git a/src/main/java/pythagoras/f/Transform.java b/src/main/java/pythagoras/f/Transform.java index ac98645..477e09c 100644 --- a/src/main/java/pythagoras/f/Transform.java +++ b/src/main/java/pythagoras/f/Transform.java @@ -12,32 +12,32 @@ public interface Transform { /** Returns the uniform scale applied by this transform. The uniform scale will be approximated * for non-uniform transforms. */ - float getUniformScale (); + float uniformScale (); /** Returns the scale vector for this transform. */ - Vector getScale (); + Vector scale (); /** Returns the x-component of the scale applied by this transform. Note that this will be * extracted and therefore approximate for affine transforms. */ - float getScaleX (); + float scaleX (); /** Returns the y-component of the scale applied by this transform. Note that this will be * extracted and therefore approximate for affine transforms. */ - float getScaleY (); + float scaleY (); /** Returns the rotation applied by this transform. Note that the rotation is extracted and * therefore approximate for affine transforms. * @throws NoninvertibleTransformException if the transform is not invertible. */ - float getRotation (); + float rotation (); /** Returns the translation vector for this transform. */ - Vector getTranslation (); + Vector translation (); /** Returns the x-coordinate of the translation component. */ - float getTx (); + float tx (); /** Returns the y-coordinate of the translation component. */ - float getTy (); + float ty (); /** Sets the uniform scale of this transform. * @return this instance, for chaining. diff --git a/src/main/java/pythagoras/f/Transforms.java b/src/main/java/pythagoras/f/Transforms.java index 9c7b21d..a287256 100644 --- a/src/main/java/pythagoras/f/Transforms.java +++ b/src/main/java/pythagoras/f/Transforms.java @@ -20,8 +20,8 @@ public class Transforms if (src instanceof Path) { return ((Path)src).createTransformedShape(t); } - PathIterator path = src.getPathIterator(t); - Path dst = new Path(path.getWindingRule()); + PathIterator path = src.pathIterator(t); + Path dst = new Path(path.windingRule()); dst.append(path, false); return dst; } diff --git a/src/main/java/pythagoras/f/UniformTransform.java b/src/main/java/pythagoras/f/UniformTransform.java index 45779cf..2b46a6a 100644 --- a/src/main/java/pythagoras/f/UniformTransform.java +++ b/src/main/java/pythagoras/f/UniformTransform.java @@ -34,32 +34,32 @@ public class UniformTransform extends AbstractTransform } @Override // from Transform - public float getUniformScale () { + public float uniformScale () { return scale; } @Override // from Transform - public float getScaleX () { + public float scaleX () { return scale; } @Override // from Transform - public float getScaleY () { + public float scaleY () { return scale; } @Override // from Transform - public float getRotation () { + public float rotation () { return rotation; } @Override // from Transform - public float getTx () { + public float tx () { return tx; } @Override // from Transform - public float getTy () { + public float ty () { return ty; } @@ -124,7 +124,7 @@ public class UniformTransform extends AbstractTransform @Override // from Transform public Transform invert () { float nscale = 1f / scale, nrotation = -rotation; - Vector t = getTranslation().negateLocal().rotateLocal(nrotation).multLocal(nscale); + Vector t = translation().negateLocal().rotateLocal(nrotation).multLocal(nscale); return new UniformTransform(nscale, nrotation, t.x, t.y); } @@ -134,10 +134,10 @@ public class UniformTransform extends AbstractTransform return other.preConcatenate(this); } - Vector nt = other.getTranslation(); - nt.rotateScaleAndAdd(rotation, scale, getTranslation(), nt); - float nrotation = FloatMath.normalizeAngle(rotation + other.getRotation()); - float nscale = scale * other.getUniformScale(); + Vector nt = other.translation(); + nt.rotateScaleAndAdd(rotation, scale, translation(), nt); + float nrotation = FloatMath.normalizeAngle(rotation + other.rotation()); + float nscale = scale * other.uniformScale(); return new UniformTransform(nscale, nrotation, nt.x, nt.y); } @@ -147,11 +147,11 @@ public class UniformTransform extends AbstractTransform return other.concatenate(this); } - Vector nt = getTranslation(); - nt.rotateScaleAndAdd(other.getRotation(), other.getUniformScale(), - other.getTranslation(), nt); - float nrotation = FloatMath.normalizeAngle(other.getRotation() + rotation); - float nscale = other.getUniformScale() * scale; + Vector nt = translation(); + nt.rotateScaleAndAdd(other.rotation(), other.uniformScale(), + other.translation(), nt); + float nrotation = FloatMath.normalizeAngle(other.rotation() + rotation); + float nscale = other.uniformScale() * scale; return new UniformTransform(nscale, nrotation, nt.x, nt.y); } @@ -161,15 +161,15 @@ public class UniformTransform extends AbstractTransform return other.lerp(this, -t); // TODO: is this correct? } - Vector nt = getTranslation().lerpLocal(other.getTranslation(), t); - float nrotation = FloatMath.lerpa(rotation, other.getRotation(), t); - float nscale = FloatMath.lerp(scale, other.getUniformScale(), t); + Vector nt = translation().lerpLocal(other.translation(), t); + float nrotation = FloatMath.lerpa(rotation, other.rotation(), t); + float nscale = FloatMath.lerp(scale, other.uniformScale(), t); return new UniformTransform(nscale, nrotation, nt.x, nt.y); } @Override // from Transform public Point transform (IPoint p, Point into) { - return Points.transform(p.getX(), p.getY(), scale, scale, rotation, tx, ty, into); + return Points.transform(p.x(), p.y(), scale, scale, rotation, tx, ty, into); } @Override // from Transform @@ -177,7 +177,7 @@ public class UniformTransform extends AbstractTransform float sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation); for (int ii = 0; ii < count; ii++) { IPoint p = src[srcOff++]; - Points.transform(p.getX(), p.getY(), scale, scale, sina, cosa, tx, ty, dst[dstOff++]); + Points.transform(p.x(), p.y(), scale, scale, sina, cosa, tx, ty, dst[dstOff++]); } } @@ -194,17 +194,17 @@ public class UniformTransform extends AbstractTransform @Override // from Transform public Point inverseTransform (IPoint p, Point into) { - return Points.inverseTransform(p.getX(), p.getY(), scale, scale, rotation, tx, ty, into); + return Points.inverseTransform(p.x(), p.y(), scale, scale, rotation, tx, ty, into); } @Override // from Transform public Vector transform (IVector v, Vector into) { - return Vectors.transform(v.getX(), v.getY(), scale, scale, rotation, into); + return Vectors.transform(v.x(), v.y(), scale, scale, rotation, into); } @Override // from Transform public Vector inverseTransform (IVector v, Vector into) { - return Vectors.inverseTransform(v.getX(), v.getY(), scale, scale, rotation, into); + return Vectors.inverseTransform(v.x(), v.y(), scale, scale, rotation, into); } @Override // from Transform @@ -220,6 +220,6 @@ public class UniformTransform extends AbstractTransform @Override public String toString () { return "uniform [scale=" + scale + ", rot=" + rotation + - ", trans=" + getTranslation() + "]"; + ", trans=" + translation() + "]"; } } diff --git a/src/main/java/pythagoras/f/Vector.java b/src/main/java/pythagoras/f/Vector.java index ff6ac9c..bdd814d 100644 --- a/src/main/java/pythagoras/f/Vector.java +++ b/src/main/java/pythagoras/f/Vector.java @@ -92,7 +92,7 @@ public class Vector extends AbstractVector /** Copies the elements of another vector. * @return a reference to this vector, for chaining. */ public Vector set (IVector other) { - return set(other.getX(), other.getY()); + return set(other.x(), other.y()); } /** Copies the elements of an array. @@ -110,12 +110,12 @@ public class Vector extends AbstractVector } @Override // from AbstractVector - public float getX () { + public float x () { return x; } @Override // from AbstractVector - public float getY () { + public float y () { return y; } } diff --git a/src/main/java/pythagoras/i/AbstractDimension.java b/src/main/java/pythagoras/i/AbstractDimension.java index 469352d..b885b6d 100644 --- a/src/main/java/pythagoras/i/AbstractDimension.java +++ b/src/main/java/pythagoras/i/AbstractDimension.java @@ -17,7 +17,7 @@ public abstract class AbstractDimension implements IDimension @Override public int hashCode () { - return getWidth() ^ getHeight(); + return width() ^ height(); } @Override @@ -27,13 +27,13 @@ public abstract class AbstractDimension implements IDimension } if (obj instanceof AbstractDimension) { AbstractDimension d = (AbstractDimension)obj; - return (d.getWidth() == getWidth() && d.getHeight() == getHeight()); + return (d.width() == width() && d.height() == height()); } return false; } @Override public String toString () { - return Dimensions.dimenToString(getWidth(), getHeight()); + return Dimensions.dimenToString(width(), height()); } } diff --git a/src/main/java/pythagoras/i/AbstractPoint.java b/src/main/java/pythagoras/i/AbstractPoint.java index db1d342..9f653f2 100644 --- a/src/main/java/pythagoras/i/AbstractPoint.java +++ b/src/main/java/pythagoras/i/AbstractPoint.java @@ -12,22 +12,22 @@ public abstract class AbstractPoint implements IPoint { @Override // from interface IPoint public int distanceSq (int px, int py) { - return Points.distanceSq(getX(), getY(), px, py); + return Points.distanceSq(x(), y(), px, py); } @Override // from interface IPoint public int distanceSq (IPoint p) { - return Points.distanceSq(getX(), getY(), p.getX(), p.getY()); + return Points.distanceSq(x(), y(), p.x(), p.y()); } @Override // from interface IPoint public int distance (int px, int py) { - return Points.distance(getX(), getY(), px, py); + return Points.distance(x(), y(), px, py); } @Override // from interface IPoint public int distance (IPoint p) { - return Points.distance(getX(), getY(), p.getX(), p.getY()); + return Points.distance(x(), y(), p.x(), p.y()); } @Override // from interface IPoint @@ -42,18 +42,18 @@ public abstract class AbstractPoint implements IPoint } if (obj instanceof AbstractPoint) { AbstractPoint p = (AbstractPoint)obj; - return getX() == p.getX() && getY() == p.getY(); + return x() == p.x() && y() == p.y(); } return false; } @Override public int hashCode () { - return getX() ^ getY(); + return x() ^ y(); } @Override public String toString () { - return Points.pointToString(getX(), getY()); + return Points.pointToString(x(), y()); } } diff --git a/src/main/java/pythagoras/i/AbstractRectangle.java b/src/main/java/pythagoras/i/AbstractRectangle.java index 43d6de1..c7ba847 100644 --- a/src/main/java/pythagoras/i/AbstractRectangle.java +++ b/src/main/java/pythagoras/i/AbstractRectangle.java @@ -11,59 +11,59 @@ package pythagoras.i; public abstract class AbstractRectangle implements IRectangle { @Override // from IRectangle - public int getMinX () { - return getX(); + public int minX () { + return x(); } @Override // from IRectangle - public int getMinY () { - return getY(); + public int minY () { + return y(); } @Override // from IRectangle - public int getMaxX () { - return getX() + getWidth() - 1; + public int maxX () { + return x() + width() - 1; } @Override // from IRectangle - public int getMaxY () { - return getY() + getHeight() - 1; + public int maxY () { + return y() + height() - 1; } @Override // from interface IRectangle - public Point getLocation () { - return getLocation(new Point()); + public Point location () { + return location(new Point()); } @Override // from interface IRectangle - public Point getLocation (Point target) { - target.setLocation(getX(), getY()); + public Point location (Point target) { + target.setLocation(x(), y()); return target; } @Override // from interface IRectangle - public Dimension getSize () { - return getSize(new Dimension()); + public Dimension size () { + return size(new Dimension()); } @Override // from interface IRectangle - public Dimension getSize (Dimension target) { - target.setSize(getWidth(), getHeight()); + public Dimension size (Dimension target) { + target.setSize(width(), height()); return target; } @Override // from interface IRectangle public Rectangle intersection (int rx, int ry, int rw, int rh) { - int x1 = Math.max(getX(), rx); - int y1 = Math.max(getY(), ry); - int x2 = Math.min(getMaxX(), rx + rw - 1); - int y2 = Math.min(getMaxY(), ry + rh - 1); + int x1 = Math.max(x(), rx); + int y1 = Math.max(y(), ry); + int x2 = Math.min(maxX(), rx + rw - 1); + int y2 = Math.min(maxY(), ry + rh - 1); return new Rectangle(x1, y1, x2 - x1, y2 - y1); } @Override // from interface IRectangle public Rectangle intersection (IRectangle r) { - return intersection(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + return intersection(r.x(), r.y(), r.width(), r.height()); } @Override // from interface IRectangle @@ -77,19 +77,19 @@ public abstract class AbstractRectangle implements IRectangle public int outcode (int px, int py) { int code = 0; - if (getWidth() <= 0) { + if (width() <= 0) { code |= OUT_LEFT | OUT_RIGHT; - } else if (px < getX()) { + } else if (px < x()) { code |= OUT_LEFT; - } else if (px > getMaxX()) { + } else if (px > maxX()) { code |= OUT_RIGHT; } - if (getHeight() <= 0) { + if (height() <= 0) { code |= OUT_TOP | OUT_BOTTOM; - } else if (py < getY()) { + } else if (py < y()) { code |= OUT_TOP; - } else if (py > getMaxY()) { + } else if (py > maxY()) { code |= OUT_BOTTOM; } @@ -98,7 +98,7 @@ public abstract class AbstractRectangle implements IRectangle @Override // from interface IRectangle public int outcode (IPoint p) { - return outcode(p.getX(), p.getY()); + return outcode(p.x(), p.y()); } @Override // from interface IRectangle @@ -108,60 +108,60 @@ public abstract class AbstractRectangle implements IRectangle @Override // from interface IShape public boolean isEmpty () { - return getWidth() <= 0 || getHeight() <= 0; + return width() <= 0 || height() <= 0; } @Override // from interface IShape public boolean contains (int px, int py) { if (isEmpty()) return false; - int x = getX(), y = getY(); + int x = x(), y = y(); if (px < x || py < y) return false; px -= x; py -= y; - return px < getWidth() && py < getHeight(); + return px < width() && py < height(); } @Override // from interface IShape public boolean contains (IPoint point) { - return contains(point.getX(), point.getY()); + return contains(point.x(), point.y()); } @Override // from interface IShape public boolean contains (int rx, int ry, int rw, int rh) { if (isEmpty()) return false; - int x1 = getX(), y1 = getY(), x2 = x1 + getWidth(), y2 = y1 + getHeight(); + int x1 = x(), y1 = y(), x2 = x1 + width(), y2 = y1 + height(); return (x1 <= rx) && (rx + rw <= x2) && (y1 <= ry) && (ry + rh <= y2); } @Override // from interface IShape public boolean contains (IRectangle rect) { - return contains(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); + return contains(rect.x(), rect.y(), rect.width(), rect.height()); } @Override // from interface IShape public boolean intersects (int rx, int ry, int rw, int rh) { if (isEmpty()) return false; - int x1 = getX(), y1 = getY(), x2 = x1 + getWidth(), y2 = y1 + getHeight(); + int x1 = x(), y1 = y(), x2 = x1 + width(), y2 = y1 + height(); return (rx + rw > x1) && (rx < x2) && (ry + rh > y1) && (ry < y2); } @Override // from interface IShape public boolean intersects (IRectangle rect) { - return intersects(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); + return intersects(rect.x(), rect.y(), rect.width(), rect.height()); } @Override // from interface IShape - public Rectangle getBounds () { - return getBounds(new Rectangle()); + public Rectangle bounds () { + return bounds(new Rectangle()); } @Override // from interface IShape - public Rectangle getBounds (Rectangle target) { - target.setBounds(getX(), getY(), getWidth(), getHeight()); + public Rectangle bounds (Rectangle target) { + target.setBounds(x(), y(), width(), height()); return target; } @@ -172,20 +172,20 @@ public abstract class AbstractRectangle implements IRectangle } if (obj instanceof AbstractRectangle) { AbstractRectangle r = (AbstractRectangle)obj; - return r.getX() == getX() && r.getY() == getY() && - r.getWidth() == getWidth() && r.getHeight() == getHeight(); + return r.x() == x() && r.y() == y() && + r.width() == width() && r.height() == height(); } return false; } @Override // from Object public int hashCode () { - return getX() ^ getY() ^ getWidth() ^ getHeight(); + return x() ^ y() ^ width() ^ height(); } @Override // from Object public String toString () { - return Dimensions.dimenToString(getWidth(), getHeight()) + - Points.pointToString(getX(), getY()); + return Dimensions.dimenToString(width(), height()) + + Points.pointToString(x(), y()); } } diff --git a/src/main/java/pythagoras/i/Dimension.java b/src/main/java/pythagoras/i/Dimension.java index 1d0ed0f..ad544ab 100644 --- a/src/main/java/pythagoras/i/Dimension.java +++ b/src/main/java/pythagoras/i/Dimension.java @@ -35,7 +35,7 @@ public class Dimension extends AbstractDimension implements Serializable * Creates a dimension with width and height equal to the supplied dimension. */ public Dimension (IDimension d) { - this(d.getWidth(), d.getHeight()); + this(d.width(), d.height()); } /** @@ -50,16 +50,16 @@ public class Dimension extends AbstractDimension implements Serializable * Sets the magnitudes of this dimension to be equal to the supplied dimension. */ public void setSize (IDimension d) { - setSize(d.getWidth(), d.getHeight()); + setSize(d.width(), d.height()); } @Override // from interface IDimension - public int getWidth () { + public int width () { return width; } @Override // from interface IDimension - public int getHeight () { + public int height () { return height; } } diff --git a/src/main/java/pythagoras/i/IDimension.java b/src/main/java/pythagoras/i/IDimension.java index 2fdfc5f..7dfa1c4 100644 --- a/src/main/java/pythagoras/i/IDimension.java +++ b/src/main/java/pythagoras/i/IDimension.java @@ -12,12 +12,12 @@ public interface IDimension extends Cloneable /** * Returns the magnitude in the x-dimension. */ - int getWidth (); + int width (); /** * Returns the magnitude in the y-dimension. */ - int getHeight (); + int height (); /** * Returns a mutable copy of this dimension. diff --git a/src/main/java/pythagoras/i/IPoint.java b/src/main/java/pythagoras/i/IPoint.java index b9e8f7b..a1fe9fb 100644 --- a/src/main/java/pythagoras/i/IPoint.java +++ b/src/main/java/pythagoras/i/IPoint.java @@ -10,10 +10,10 @@ package pythagoras.i; public interface IPoint extends Cloneable { /** Returns this point's x-coordinate. */ - int getX (); + int x (); /** Returns this point's y-coordinate. */ - int getY (); + int y (); /** Returns the squared Euclidian distance between this point and the specified point. */ int distanceSq (int px, int py); diff --git a/src/main/java/pythagoras/i/IRectangle.java b/src/main/java/pythagoras/i/IRectangle.java index 899eaa9..a113734 100644 --- a/src/main/java/pythagoras/i/IRectangle.java +++ b/src/main/java/pythagoras/i/IRectangle.java @@ -24,46 +24,46 @@ public interface IRectangle extends IShape, Cloneable int OUT_BOTTOM = 8; /** Returns the x-coordinate of the upper-left corner of the framing rectangle. */ - int getX (); + int x (); /** Returns the y-coordinate of the upper-left corner of the framing rectangle. */ - int getY (); + int y (); /** Returns the width of the framing rectangle. */ - int getWidth (); + int width (); /** Returns the height of the framing rectangle. */ - int getHeight (); + int height (); /** Returns the minimum x-coordinate of the framing rectangle. */ - int getMinX (); + int minX (); /** Returns the minimum y-coordinate of the framing rectangle. */ - int getMinY (); + int minY (); /** Returns the maximum x-coordinate of the framing rectangle. Note: this method * differs from its floating-point counterparts in that it considers {@code (x + width - 1)} to * be a rectangle's maximum x-coordinate. */ - int getMaxX (); + int maxX (); /** Returns the maximum y-coordinate of the framing rectangle. Note: this method * differs from its floating-point counterparts in that it considers {@code (y + height - 1)} * to be a rectangle's maximum x-coordinate. */ - int getMaxY (); + int maxY (); /** Returns a copy of this rectangle's upper-left corner. */ - Point getLocation (); + Point location (); /** Initializes the supplied point with this rectangle's upper-left corner. * @return the supplied point. */ - Point getLocation (Point target); + Point location (Point target); /** Returns a copy of this rectangle's size. */ - Dimension getSize (); + Dimension size (); /** Initializes the supplied dimension with this rectangle's size. * @return the supplied dimension. */ - Dimension getSize (Dimension target); + Dimension size (Dimension target); /** Returns the intersection of the specified rectangle and this rectangle (i.e. the largest * rectangle contained in both this and the specified rectangle). */ diff --git a/src/main/java/pythagoras/i/IShape.java b/src/main/java/pythagoras/i/IShape.java index a97ba0a..6759ffd 100644 --- a/src/main/java/pythagoras/i/IShape.java +++ b/src/main/java/pythagoras/i/IShape.java @@ -31,9 +31,9 @@ public interface IShape boolean intersects (IRectangle r); /** Returns a copy of the bounding rectangle for this shape. */ - Rectangle getBounds (); + Rectangle bounds (); /** Initializes the supplied rectangle with this shape's bounding rectangle. * @return the supplied rectangle. */ - Rectangle getBounds (Rectangle target); + Rectangle bounds (Rectangle target); } diff --git a/src/main/java/pythagoras/i/Point.java b/src/main/java/pythagoras/i/Point.java index 6871ccd..b79f893 100644 --- a/src/main/java/pythagoras/i/Point.java +++ b/src/main/java/pythagoras/i/Point.java @@ -34,14 +34,14 @@ public class Point extends AbstractPoint implements Serializable * Constructs a point with coordinates equal to the supplied point. */ public Point (IPoint p) { - setLocation(p.getX(), p.getY()); + setLocation(p.x(), p.y()); } /** * Sets the coordinates of this point to be equal to those of the supplied point. */ public void setLocation (IPoint p) { - setLocation(p.getX(), p.getY()); + setLocation(p.x(), p.y()); } /** @@ -68,12 +68,12 @@ public class Point extends AbstractPoint implements Serializable } @Override // from interface IPoint - public int getX () { + public int x () { return x; } @Override // from interface IPoint - public int getY () { + public int y () { return y; } } diff --git a/src/main/java/pythagoras/i/Rectangle.java b/src/main/java/pythagoras/i/Rectangle.java index 19cbbbf..3acd8b8 100644 --- a/src/main/java/pythagoras/i/Rectangle.java +++ b/src/main/java/pythagoras/i/Rectangle.java @@ -33,14 +33,14 @@ public class Rectangle extends AbstractRectangle implements Serializable * Constructs a rectangle with the supplied upper-left corner and dimensions (0,0). */ public Rectangle (IPoint p) { - setBounds(p.getX(), p.getY(), 0, 0); + setBounds(p.x(), p.y(), 0, 0); } /** * Constructs a rectangle with upper-left corner at (0,) and the supplied dimensions. */ public Rectangle (IDimension d) { - setBounds(0, 0, d.getWidth(), d.getHeight()); + setBounds(0, 0, d.width(), d.height()); } /** @@ -48,7 +48,7 @@ public class Rectangle extends AbstractRectangle implements Serializable * dimensions. */ public Rectangle (IPoint p, IDimension d) { - setBounds(p.getX(), p.getY(), d.getWidth(), d.getHeight()); + setBounds(p.x(), p.y(), d.width(), d.height()); } /** @@ -62,7 +62,7 @@ public class Rectangle extends AbstractRectangle implements Serializable * Constructs a rectangle with bounds equal to the supplied rectangle. */ public Rectangle (IRectangle r) { - setBounds(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + setBounds(r.x(), r.y(), r.width(), r.height()); } /** @@ -77,7 +77,7 @@ public class Rectangle extends AbstractRectangle implements Serializable * Sets the upper-left corner of this rectangle to the supplied point. */ public void setLocation (IPoint p) { - setLocation(p.getX(), p.getY()); + setLocation(p.x(), p.y()); } /** @@ -92,7 +92,7 @@ public class Rectangle extends AbstractRectangle implements Serializable * Sets the size of this rectangle to the supplied dimensions. */ public void setSize (IDimension d) { - setSize(d.getWidth(), d.getHeight()); + setSize(d.width(), d.height()); } /** @@ -109,7 +109,7 @@ public class Rectangle extends AbstractRectangle implements Serializable * Sets the bounds of this rectangle to those of the supplied rectangle. */ public void setBounds (IRectangle r) { - setBounds(r.getX(), r.getY(), r.getWidth(), r.getHeight()); + setBounds(r.x(), r.y(), r.width(), r.height()); } /** @@ -147,37 +147,37 @@ public class Rectangle extends AbstractRectangle implements Serializable * Expands the bounds of this rectangle to contain the supplied point. */ public void add (IPoint p) { - add(p.getX(), p.getY()); + add(p.x(), p.y()); } /** * Expands the bounds of this rectangle to contain the supplied rectangle. */ public void add (IRectangle r) { - int x1 = Math.min(x, r.getX()); - int x2 = Math.max(x + width, r.getX() + r.getWidth()); - int y1 = Math.min(y, r.getY()); - int y2 = Math.max(y + height, r.getY() + r.getHeight()); + int x1 = Math.min(x, r.x()); + int x2 = Math.max(x + width, r.x() + r.width()); + int y1 = Math.min(y, r.y()); + int y2 = Math.max(y + height, r.y() + r.height()); setBounds(x1, y1, x2 - x1, y2 - y1); } @Override // from interface IRectangle - public int getX () { + public int x () { return x; } @Override // from interface IRectangle - public int getY () { + public int y () { return y; } @Override // from interface IRectangle - public int getWidth () { + public int width () { return width; } @Override // from interface IRectangle - public int getHeight () { + public int height () { return height; } } diff --git a/src/main/java/pythagoras/i/Rectangles.java b/src/main/java/pythagoras/i/Rectangles.java index 0eee539..6165f2f 100644 --- a/src/main/java/pythagoras/i/Rectangles.java +++ b/src/main/java/pythagoras/i/Rectangles.java @@ -13,10 +13,10 @@ public class Rectangles * Intersects the supplied two rectangles, writing the result into {@code dst}. */ public static void intersect (IRectangle src1, IRectangle src2, Rectangle dst) { - int x1 = Math.max(src1.getMinX(), src2.getMinX()); - int y1 = Math.max(src1.getMinY(), src2.getMinY()); - int x2 = Math.min(src1.getMaxX(), src2.getMaxX()); - int y2 = Math.min(src1.getMaxY(), src2.getMaxY()); + int x1 = Math.max(src1.minX(), src2.minX()); + int y1 = Math.max(src1.minY(), src2.minY()); + int x2 = Math.min(src1.maxX(), src2.maxX()); + int y2 = Math.min(src1.maxY(), src2.maxY()); dst.setBounds(x1, y1, x2 - x1, y2 - y1); } @@ -24,10 +24,10 @@ public class Rectangles * Unions the supplied two rectangles, writing the result into {@code dst}. */ public static void union (IRectangle src1, IRectangle src2, Rectangle dst) { - int x1 = Math.min(src1.getMinX(), src2.getMinX()); - int y1 = Math.min(src1.getMinY(), src2.getMinY()); - int x2 = Math.max(src1.getMaxX(), src2.getMaxX()); - int y2 = Math.max(src1.getMaxY(), src2.getMaxY()); + int x1 = Math.min(src1.minX(), src2.minX()); + int y1 = Math.min(src1.minY(), src2.minY()); + int x2 = Math.max(src1.maxX(), src2.maxX()); + int y2 = Math.max(src1.maxY(), src2.maxY()); dst.setBounds(x1, y1, x2 - x1, y2 - y1); } }