getX -> x (in both the literal and algebraic sense).
In anticipation of the saying of nay, I offer this: these are value classes, and in a civilized language, I wouldn't have setters either. "foo.x = x" would call a setter method over which I had control. However, rather than throwing my hands up and saying "Gee, I have to have verbose setters, so I guess I better have verbose getters," I say, "I'll take what I can get." Methods that verb can be verbs, and we can all agree to understand that methods that are nouns are getters. foo.width() does not width my foo, it's my foo's width. foo.invert() inverts up my foo, it is not some attribute of my foo's nonsensically named invert. I don't want to add my foo's getWidth and getHeight, I want to add my foo's width and height. So why should I have to type get over and over again just because I want to protect myself from future representation change? (Or in this case, to offer immutable views of my value classes.)
This commit is contained in:
@@ -13,37 +13,37 @@ import java.util.NoSuchElementException;
|
|||||||
public abstract class AbstractArc extends RectangularShape implements IArc
|
public abstract class AbstractArc extends RectangularShape implements IArc
|
||||||
{
|
{
|
||||||
@Override // from interface IArc
|
@Override // from interface IArc
|
||||||
public Point getStartPoint () {
|
public Point startPoint () {
|
||||||
return getStartPoint(new Point());
|
return startPoint(new Point());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IArc
|
@Override // from interface IArc
|
||||||
public Point getStartPoint (Point target) {
|
public Point startPoint (Point target) {
|
||||||
float a = FloatMath.toRadians(getAngleStart());
|
float a = FloatMath.toRadians(angleStart());
|
||||||
return target.set(getX() + (1f + FloatMath.cos(a)) * getWidth() / 2f,
|
return target.set(x() + (1f + FloatMath.cos(a)) * width() / 2f,
|
||||||
getY() + (1f - FloatMath.sin(a)) * getHeight() / 2f);
|
y() + (1f - FloatMath.sin(a)) * height() / 2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IArc
|
@Override // from interface IArc
|
||||||
public Point getEndPoint () {
|
public Point endPoint () {
|
||||||
return getEndPoint(new Point());
|
return endPoint(new Point());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IArc
|
@Override // from interface IArc
|
||||||
public Point getEndPoint (Point target) {
|
public Point endPoint (Point target) {
|
||||||
float a = FloatMath.toRadians(getAngleStart() + getAngleExtent());
|
float a = FloatMath.toRadians(angleStart() + angleExtent());
|
||||||
return target.set(getX() + (1f + FloatMath.cos(a)) * getWidth() / 2f,
|
return target.set(x() + (1f + FloatMath.cos(a)) * width() / 2f,
|
||||||
getY() + (1f - FloatMath.sin(a)) * getHeight() / 2f);
|
y() + (1f - FloatMath.sin(a)) * height() / 2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IArc
|
@Override // from interface IArc
|
||||||
public boolean containsAngle (float angle) {
|
public boolean containsAngle (float angle) {
|
||||||
float extent = getAngleExtent();
|
float extent = angleExtent();
|
||||||
if (extent >= 360f) {
|
if (extent >= 360f) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
angle = getNormAngle(angle);
|
angle = normAngle(angle);
|
||||||
float a1 = getNormAngle(getAngleStart());
|
float a1 = normAngle(angleStart());
|
||||||
float a2 = a1 + extent;
|
float a2 = a1 + extent;
|
||||||
if (a2 > 360f) {
|
if (a2 > 360f) {
|
||||||
return angle >= a1 || angle <= a2 - 360f;
|
return angle >= a1 || angle <= a2 - 360f;
|
||||||
@@ -56,41 +56,41 @@ public abstract class AbstractArc extends RectangularShape implements IArc
|
|||||||
|
|
||||||
@Override // from interface IArc
|
@Override // from interface IArc
|
||||||
public Arc clone () {
|
public Arc clone () {
|
||||||
return new Arc(getX(), getY(), getWidth(), getHeight(), getAngleStart(), getAngleExtent(),
|
return new Arc(x(), y(), width(), height(), angleStart(), angleExtent(),
|
||||||
getArcType());
|
arcType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from RectangularShape
|
@Override // from RectangularShape
|
||||||
public boolean isEmpty () {
|
public boolean isEmpty () {
|
||||||
return getArcType() == OPEN || super.isEmpty();
|
return arcType() == OPEN || super.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from RectangularShape
|
@Override // from RectangularShape
|
||||||
public boolean contains (float px, float py) {
|
public boolean contains (float px, float py) {
|
||||||
// normalize point
|
// normalize point
|
||||||
float nx = (px - getX()) / getWidth() - 0.5f;
|
float nx = (px - x()) / width() - 0.5f;
|
||||||
float ny = (py - getY()) / getHeight() - 0.5f;
|
float ny = (py - y()) / height() - 0.5f;
|
||||||
if ((nx * nx + ny * ny) > 0.25) {
|
if ((nx * nx + ny * ny) > 0.25) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float extent = getAngleExtent();
|
float extent = angleExtent();
|
||||||
float absExtent = Math.abs(extent);
|
float absExtent = Math.abs(extent);
|
||||||
if (absExtent >= 360f) {
|
if (absExtent >= 360f) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean containsAngle = containsAngle(FloatMath.toDegrees(-FloatMath.atan2(ny, nx)));
|
boolean containsAngle = containsAngle(FloatMath.toDegrees(-FloatMath.atan2(ny, nx)));
|
||||||
if (getArcType() == PIE) {
|
if (arcType() == PIE) {
|
||||||
return containsAngle;
|
return containsAngle;
|
||||||
}
|
}
|
||||||
if (absExtent <= 180f && !containsAngle) {
|
if (absExtent <= 180f && !containsAngle) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Line l = new Line(getStartPoint(), getEndPoint());
|
Line l = new Line(startPoint(), endPoint());
|
||||||
int ccw1 = l.relativeCCW(px, py);
|
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);
|
return ccw1 == 0 || ccw2 == 0 || ((ccw1 + ccw2) == 0 ^ absExtent > 180f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,20 +101,20 @@ public abstract class AbstractArc extends RectangularShape implements IArc
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float absExtent = Math.abs(getAngleExtent());
|
float absExtent = Math.abs(angleExtent());
|
||||||
if (getArcType() != PIE || absExtent <= 180f || absExtent >= 360f) {
|
if (arcType() != PIE || absExtent <= 180f || absExtent >= 360f) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle r = new Rectangle(rx, ry, rw, rh);
|
Rectangle r = new Rectangle(rx, ry, rw, rh);
|
||||||
float cx = getCenterX(), cy = getCenterY();
|
float cx = centerX(), cy = centerY();
|
||||||
if (r.contains(cx, cy)) {
|
if (r.contains(cx, cy)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point p1 = getStartPoint(), p2 = getEndPoint();
|
Point p1 = startPoint(), p2 = endPoint();
|
||||||
return !r.intersectsLine(cx, cy, p1.getX(), p1.getY()) &&
|
return !r.intersectsLine(cx, cy, p1.x(), p1.y()) &&
|
||||||
!r.intersectsLine(cx, cy, p2.getX(), p2.getY());
|
!r.intersectsLine(cx, cy, p2.x(), p2.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from RectangularShape
|
@Override // from RectangularShape
|
||||||
@@ -129,22 +129,22 @@ public abstract class AbstractArc extends RectangularShape implements IArc
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float cx = getCenterX(), cy = getCenterY();
|
float cx = centerX(), cy = centerY();
|
||||||
Point p1 = getStartPoint(), p2 = getEndPoint();
|
Point p1 = startPoint(), p2 = endPoint();
|
||||||
|
|
||||||
// check: does rectangle contain arc's points
|
// check: does rectangle contain arc's points
|
||||||
Rectangle r = new Rectangle(rx, ry, rw, rh);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getArcType() == PIE) {
|
if (arcType() == PIE) {
|
||||||
if (r.intersectsLine(p1.getX(), p1.getY(), cx, cy) ||
|
if (r.intersectsLine(p1.x(), p1.y(), cx, cy) ||
|
||||||
r.intersectsLine(p2.getX(), p2.getY(), cx, cy)) {
|
r.intersectsLine(p2.x(), p2.y(), cx, cy)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,27 +156,27 @@ public abstract class AbstractArc extends RectangularShape implements IArc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from RectangularShape
|
@Override // from RectangularShape
|
||||||
public Rectangle getBounds (Rectangle target) {
|
public Rectangle bounds (Rectangle target) {
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
target.setBounds(getX(), getY(), getWidth(), getHeight());
|
target.setBounds(x(), y(), width(), height());
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
float rx1 = getX();
|
float rx1 = x();
|
||||||
float ry1 = getY();
|
float ry1 = y();
|
||||||
float rx2 = rx1 + getWidth();
|
float rx2 = rx1 + width();
|
||||||
float ry2 = ry1 + getHeight();
|
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 bx1 = containsAngle(180f) ? rx1 : Math.min(p1.x(), p2.x());
|
||||||
float by1 = containsAngle(90f) ? ry1 : Math.min(p1.getY(), p2.getY());
|
float by1 = containsAngle(90f) ? ry1 : Math.min(p1.y(), p2.y());
|
||||||
float bx2 = containsAngle(0f) ? rx2 : Math.max(p1.getX(), p2.getX());
|
float bx2 = containsAngle(0f) ? rx2 : Math.max(p1.x(), p2.x());
|
||||||
float by2 = containsAngle(270f) ? ry2 : Math.max(p1.getY(), p2.getY());
|
float by2 = containsAngle(270f) ? ry2 : Math.max(p1.y(), p2.y());
|
||||||
|
|
||||||
if (getArcType() == PIE) {
|
if (arcType() == PIE) {
|
||||||
float cx = getCenterX();
|
float cx = centerX();
|
||||||
float cy = getCenterY();
|
float cy = centerY();
|
||||||
bx1 = Math.min(bx1, cx);
|
bx1 = Math.min(bx1, cx);
|
||||||
by1 = Math.min(by1, cy);
|
by1 = Math.min(by1, cy);
|
||||||
bx2 = Math.max(bx2, cx);
|
bx2 = Math.max(bx2, cx);
|
||||||
@@ -187,12 +187,12 @@ public abstract class AbstractArc extends RectangularShape implements IArc
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform at) {
|
public PathIterator pathIterator (Transform at) {
|
||||||
return new Iterator(this, at);
|
return new Iterator(this, at);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a normalized angle (bound between 0 and 360 degrees). */
|
/** 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;
|
return angle - FloatMath.floor(angle / 360f) * 360f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,13 +258,13 @@ public abstract class AbstractArc extends RectangularShape implements IArc
|
|||||||
private float my;
|
private float my;
|
||||||
|
|
||||||
Iterator (IArc a, Transform t) {
|
Iterator (IArc a, Transform t) {
|
||||||
this.width = a.getWidth() / 2f;
|
this.width = a.width() / 2f;
|
||||||
this.height = a.getHeight() / 2f;
|
this.height = a.height() / 2f;
|
||||||
this.x = a.getX() + width;
|
this.x = a.x() + width;
|
||||||
this.y = a.getY() + height;
|
this.y = a.y() + height;
|
||||||
this.angle = -FloatMath.toRadians(a.getAngleStart());
|
this.angle = -FloatMath.toRadians(a.angleStart());
|
||||||
this.extent = -a.getAngleExtent();
|
this.extent = -a.angleExtent();
|
||||||
this.type = a.getArcType();
|
this.type = a.arcType();
|
||||||
this.t = t;
|
this.t = t;
|
||||||
|
|
||||||
if (width < 0 || height < 0) {
|
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;
|
return WIND_NON_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,35 +13,35 @@ import java.util.NoSuchElementException;
|
|||||||
public abstract class AbstractCubicCurve implements ICubicCurve
|
public abstract class AbstractCubicCurve implements ICubicCurve
|
||||||
{
|
{
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public Point getP1 () {
|
public Point p1 () {
|
||||||
return new Point(getX1(), getY1());
|
return new Point(x1(), y1());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public Point getCtrlP1 () {
|
public Point ctrlP1 () {
|
||||||
return new Point(getCtrlX1(), getCtrlY1());
|
return new Point(ctrlX1(), ctrlY1());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public Point getCtrlP2 () {
|
public Point ctrlP2 () {
|
||||||
return new Point(getCtrlX2(), getCtrlY2());
|
return new Point(ctrlX2(), ctrlY2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public Point getP2 () {
|
public Point p2 () {
|
||||||
return new Point(getX2(), getY2());
|
return new Point(x2(), y2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public float getFlatnessSq () {
|
public float flatnessSq () {
|
||||||
return CubicCurves.getFlatnessSq(getX1(), getY1(), getCtrlX1(), getCtrlY1(),
|
return CubicCurves.flatnessSq(x1(), y1(), ctrlX1(), ctrlY1(),
|
||||||
getCtrlX2(), getCtrlY2(), getX2(), getY2());
|
ctrlX2(), ctrlY2(), x2(), y2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public float getFlatness () {
|
public float flatness () {
|
||||||
return CubicCurves.getFlatness(getX1(), getY1(), getCtrlX1(), getCtrlY1(),
|
return CubicCurves.flatness(x1(), y1(), ctrlX1(), ctrlY1(),
|
||||||
getCtrlX2(), getCtrlY2(), getX2(), getY2());
|
ctrlX2(), ctrlY2(), x2(), y2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
@@ -51,8 +51,8 @@ public abstract class AbstractCubicCurve implements ICubicCurve
|
|||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public CubicCurve clone () {
|
public CubicCurve clone () {
|
||||||
return new CubicCurve(getX1(), getY1(), getCtrlX1(), getCtrlY1(),
|
return new CubicCurve(x1(), y1(), ctrlX1(), ctrlY1(),
|
||||||
getCtrlX2(), getCtrlY2(), getX2(), getY2());
|
ctrlX2(), ctrlY2(), x2(), y2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
@@ -73,12 +73,12 @@ public abstract class AbstractCubicCurve implements ICubicCurve
|
|||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (IPoint p) {
|
public boolean contains (IPoint p) {
|
||||||
return contains(p.getX(), p.getY());
|
return contains(p.x(), p.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (IRectangle r) {
|
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
|
@Override // from interface IShape
|
||||||
@@ -89,19 +89,19 @@ public abstract class AbstractCubicCurve implements ICubicCurve
|
|||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean intersects (IRectangle r) {
|
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
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds () {
|
public Rectangle bounds () {
|
||||||
return getBounds(new Rectangle());
|
return bounds(new Rectangle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds (Rectangle target) {
|
public Rectangle bounds (Rectangle target) {
|
||||||
float x1 = getX1(), y1 = getY1(), x2 = getX2(), y2 = getY2();
|
float x1 = x1(), y1 = y1(), x2 = x2(), y2 = y2();
|
||||||
float ctrlx1 = getCtrlX1(), ctrly1 = getCtrlY1();
|
float ctrlx1 = ctrlX1(), ctrly1 = ctrlY1();
|
||||||
float ctrlx2 = getCtrlX2(), ctrly2 = getCtrlY2();
|
float ctrlx2 = ctrlX2(), ctrly2 = ctrlY2();
|
||||||
float rx1 = Math.min(Math.min(x1, x2), Math.min(ctrlx1, ctrlx2));
|
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 ry1 = Math.min(Math.min(y1, y2), Math.min(ctrly1, ctrly2));
|
||||||
float rx2 = Math.max(Math.max(x1, x2), Math.max(ctrlx1, ctrlx2));
|
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
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform t) {
|
public PathIterator pathIterator (Transform t) {
|
||||||
return new Iterator(this, t);
|
return new Iterator(this, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform at, float flatness) {
|
public PathIterator pathIterator (Transform at, float flatness) {
|
||||||
return new FlatteningPathIterator(getPathIterator(at), flatness);
|
return new FlatteningPathIterator(pathIterator(at), flatness);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** An iterator over an {@link ICubicCurve}. */
|
/** An iterator over an {@link ICubicCurve}. */
|
||||||
@@ -132,7 +132,7 @@ public abstract class AbstractCubicCurve implements ICubicCurve
|
|||||||
this.t = t;
|
this.t = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getWindingRule () {
|
@Override public int windingRule () {
|
||||||
return WIND_NON_ZERO;
|
return WIND_NON_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,17 +152,17 @@ public abstract class AbstractCubicCurve implements ICubicCurve
|
|||||||
int count;
|
int count;
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
type = SEG_MOVETO;
|
type = SEG_MOVETO;
|
||||||
coords[0] = c.getX1();
|
coords[0] = c.x1();
|
||||||
coords[1] = c.getY1();
|
coords[1] = c.y1();
|
||||||
count = 1;
|
count = 1;
|
||||||
} else {
|
} else {
|
||||||
type = SEG_CUBICTO;
|
type = SEG_CUBICTO;
|
||||||
coords[0] = c.getCtrlX1();
|
coords[0] = c.ctrlX1();
|
||||||
coords[1] = c.getCtrlY1();
|
coords[1] = c.ctrlY1();
|
||||||
coords[2] = c.getCtrlX2();
|
coords[2] = c.ctrlX2();
|
||||||
coords[3] = c.getCtrlY2();
|
coords[3] = c.ctrlY2();
|
||||||
coords[4] = c.getX2();
|
coords[4] = c.x2();
|
||||||
coords[5] = c.getY2();
|
coords[5] = c.y2();
|
||||||
count = 3;
|
count = 3;
|
||||||
}
|
}
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public abstract class AbstractDimension implements IDimension
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode () {
|
public int hashCode () {
|
||||||
return Platform.hashCode(getWidth()) ^ Platform.hashCode(getHeight());
|
return Platform.hashCode(width()) ^ Platform.hashCode(height());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -29,13 +29,13 @@ public abstract class AbstractDimension implements IDimension
|
|||||||
}
|
}
|
||||||
if (obj instanceof AbstractDimension) {
|
if (obj instanceof AbstractDimension) {
|
||||||
AbstractDimension d = (AbstractDimension)obj;
|
AbstractDimension d = (AbstractDimension)obj;
|
||||||
return (d.getWidth() == getWidth() && d.getHeight() == getHeight());
|
return (d.width() == width() && d.height() == height());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return Dimensions.dimenToString(getWidth(), getHeight());
|
return Dimensions.dimenToString(width(), height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ public abstract class AbstractEllipse extends RectangularShape implements IEllip
|
|||||||
{
|
{
|
||||||
@Override // from IEllipse
|
@Override // from IEllipse
|
||||||
public Ellipse clone () {
|
public Ellipse clone () {
|
||||||
return new Ellipse(getX(), getY(), getWidth(), getHeight());
|
return new Ellipse(x(), y(), width(), height());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (float px, float py) {
|
public boolean contains (float px, float py) {
|
||||||
if (isEmpty()) return false;
|
if (isEmpty()) return false;
|
||||||
float a = (px - getX()) / getWidth() - 0.5f;
|
float a = (px - x()) / width() - 0.5f;
|
||||||
float b = (py - getY()) / getHeight() - 0.5f;
|
float b = (py - y()) / height() - 0.5f;
|
||||||
return a * a + b * b < 0.25f;
|
return a * a + b * b < 0.25f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,8 +35,8 @@ public abstract class AbstractEllipse extends RectangularShape implements IEllip
|
|||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean intersects (float rx, float ry, float rw, float rh) {
|
public boolean intersects (float rx, float ry, float rw, float rh) {
|
||||||
if (isEmpty() || rw <= 0f || rh <= 0f) return false;
|
if (isEmpty() || rw <= 0f || rh <= 0f) return false;
|
||||||
float cx = getX() + getWidth() / 2f;
|
float cx = x() + width() / 2f;
|
||||||
float cy = getY() + getHeight() / 2f;
|
float cy = y() + height() / 2f;
|
||||||
float rx1 = rx, ry1 = ry, rx2 = rx + rw, ry2 = ry + rh;
|
float rx1 = rx, ry1 = ry, rx2 = rx + rw, ry2 = ry + rh;
|
||||||
float nx = cx < rx1 ? rx1 : (cx > rx2 ? rx2 : cx);
|
float nx = cx < rx1 ? rx1 : (cx > rx2 ? rx2 : cx);
|
||||||
float ny = cy < ry1 ? ry1 : (cy > ry2 ? ry2 : cy);
|
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
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform at) {
|
public PathIterator pathIterator (Transform at) {
|
||||||
return new Iterator(this, at);
|
return new Iterator(this, at);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,17 +56,17 @@ public abstract class AbstractEllipse extends RectangularShape implements IEllip
|
|||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
Iterator (IEllipse e, Transform t) {
|
Iterator (IEllipse e, Transform t) {
|
||||||
this.x = e.getX();
|
this.x = e.x();
|
||||||
this.y = e.getY();
|
this.y = e.y();
|
||||||
this.width = e.getWidth();
|
this.width = e.width();
|
||||||
this.height = e.getHeight();
|
this.height = e.height();
|
||||||
this.t = t;
|
this.t = t;
|
||||||
if (width < 0f || height < 0f) {
|
if (width < 0f || height < 0f) {
|
||||||
index = 6;
|
index = 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getWindingRule () {
|
@Override public int windingRule () {
|
||||||
return WIND_NON_ZERO;
|
return WIND_NON_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,78 +13,78 @@ import java.util.NoSuchElementException;
|
|||||||
public abstract class AbstractLine implements ILine
|
public abstract class AbstractLine implements ILine
|
||||||
{
|
{
|
||||||
@Override // from interface ILine
|
@Override // from interface ILine
|
||||||
public Point getP1 () {
|
public Point p1 () {
|
||||||
return getP1(new Point());
|
return p1(new Point());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ILine
|
@Override // from interface ILine
|
||||||
public Point getP1 (Point target) {
|
public Point p1 (Point target) {
|
||||||
return target.set(getX1(), getY1());
|
return target.set(x1(), y1());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ILine
|
@Override // from interface ILine
|
||||||
public Point getP2 () {
|
public Point p2 () {
|
||||||
return getP2(new Point());
|
return p2(new Point());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ILine
|
@Override // from interface ILine
|
||||||
public Point getP2 (Point target) {
|
public Point p2 (Point target) {
|
||||||
return target.set(getX2(), getY2());
|
return target.set(x2(), y2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ILine
|
@Override // from interface ILine
|
||||||
public float pointLineDistSq (float px, float py) {
|
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
|
@Override // from interface ILine
|
||||||
public float pointLineDistSq (IPoint p) {
|
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
|
@Override // from interface ILine
|
||||||
public float pointLineDist (float px, float py) {
|
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
|
@Override // from interface ILine
|
||||||
public float pointLineDist (IPoint p) {
|
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
|
@Override // from interface ILine
|
||||||
public float pointSegDistSq (float px, float py) {
|
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
|
@Override // from interface ILine
|
||||||
public float pointSegDistSq (IPoint p) {
|
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
|
@Override // from interface ILine
|
||||||
public float pointSegDist (float px, float py) {
|
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
|
@Override // from interface ILine
|
||||||
public float pointSegDist (IPoint p) {
|
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
|
@Override // from interface ILine
|
||||||
public int relativeCCW (float px, float py) {
|
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
|
@Override // from interface ILine
|
||||||
public int relativeCCW (IPoint p) {
|
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
|
@Override // from interface ILine
|
||||||
public Line clone () {
|
public Line clone () {
|
||||||
return new Line(getX1(), getY1(), getX2(), getY2());
|
return new Line(x1(), y1(), x2(), y2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
@@ -114,7 +114,7 @@ public abstract class AbstractLine implements ILine
|
|||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean intersects (float rx, float ry, float rw, float rh) {
|
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
|
@Override // from interface IShape
|
||||||
@@ -123,13 +123,13 @@ public abstract class AbstractLine implements ILine
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds () {
|
public Rectangle bounds () {
|
||||||
return getBounds(new Rectangle());
|
return bounds(new Rectangle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds (Rectangle target) {
|
public Rectangle bounds (Rectangle target) {
|
||||||
float x1 = getX1(), x2 = getX2(), y1 = getY1(), y2 = getY2();
|
float x1 = x1(), x2 = x2(), y1 = y1(), y2 = y2();
|
||||||
float rx, ry, rw, rh;
|
float rx, ry, rw, rh;
|
||||||
if (x1 < x2) {
|
if (x1 < x2) {
|
||||||
rx = x1;
|
rx = x1;
|
||||||
@@ -150,12 +150,12 @@ public abstract class AbstractLine implements ILine
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform at) {
|
public PathIterator pathIterator (Transform at) {
|
||||||
return new Iterator(this, at);
|
return new Iterator(this, at);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform at, float flatness) {
|
public PathIterator pathIterator (Transform at, float flatness) {
|
||||||
return new Iterator(this, at);
|
return new Iterator(this, at);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,14 +167,14 @@ public abstract class AbstractLine implements ILine
|
|||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
Iterator (ILine l, Transform at) {
|
Iterator (ILine l, Transform at) {
|
||||||
this.x1 = l.getX1();
|
this.x1 = l.x1();
|
||||||
this.y1 = l.getY1();
|
this.y1 = l.y1();
|
||||||
this.x2 = l.getX2();
|
this.x2 = l.x2();
|
||||||
this.y2 = l.getY2();
|
this.y2 = l.y2();
|
||||||
this.t = at;
|
this.t = at;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getWindingRule () {
|
@Override public int windingRule () {
|
||||||
return WIND_NON_ZERO;
|
return WIND_NON_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,22 +14,22 @@ public abstract class AbstractPoint implements IPoint
|
|||||||
{
|
{
|
||||||
@Override // from IPoint
|
@Override // from IPoint
|
||||||
public float distanceSq (float px, float py) {
|
public float distanceSq (float px, float py) {
|
||||||
return Points.distanceSq(getX(), getY(), px, py);
|
return Points.distanceSq(x(), y(), px, py);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IPoint
|
@Override // from IPoint
|
||||||
public float distanceSq (IPoint p) {
|
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
|
@Override // from IPoint
|
||||||
public float distance (float px, float py) {
|
public float distance (float px, float py) {
|
||||||
return Points.distance(getX(), getY(), px, py);
|
return Points.distance(x(), y(), px, py);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IPoint
|
@Override // from IPoint
|
||||||
public float distance (IPoint p) {
|
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
|
@Override // from IPoint
|
||||||
@@ -39,17 +39,17 @@ public abstract class AbstractPoint implements IPoint
|
|||||||
|
|
||||||
@Override // from IPoint
|
@Override // from IPoint
|
||||||
public Point mult (float s, Point result) {
|
public Point mult (float s, Point result) {
|
||||||
return result.set(getX() * s, getY() * s);
|
return result.set(x() * s, y() * s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IPoint
|
@Override // from IPoint
|
||||||
public Point add (float x, float y) {
|
public Point add (float x, float y) {
|
||||||
return new Point(getX() + x, getY() + y);
|
return new Point(x() + x, y() + y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IPoint
|
@Override // from IPoint
|
||||||
public Point add (float x, float y, Point result) {
|
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
|
@Override // from IPoint
|
||||||
@@ -59,7 +59,7 @@ public abstract class AbstractPoint implements IPoint
|
|||||||
|
|
||||||
@Override // from IPoint
|
@Override // from IPoint
|
||||||
public Point rotate (float angle, Point result) {
|
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);
|
float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle);
|
||||||
return result.set(x*cosa - y*sina, x*sina + y*cosa);
|
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) {
|
if (obj instanceof AbstractPoint) {
|
||||||
AbstractPoint p = (AbstractPoint)obj;
|
AbstractPoint p = (AbstractPoint)obj;
|
||||||
return getX() == p.getX() && getY() == p.getY();
|
return x() == p.x() && y() == p.y();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode () {
|
public int hashCode () {
|
||||||
return Platform.hashCode(getX()) ^ Platform.hashCode(getY());
|
return Platform.hashCode(x()) ^ Platform.hashCode(y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return Points.pointToString(getX(), getY());
|
return Points.pointToString(x(), y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,28 +13,28 @@ import java.util.NoSuchElementException;
|
|||||||
public abstract class AbstractQuadCurve implements IQuadCurve
|
public abstract class AbstractQuadCurve implements IQuadCurve
|
||||||
{
|
{
|
||||||
@Override // from interface IQuadCurve
|
@Override // from interface IQuadCurve
|
||||||
public Point getP1 () {
|
public Point p1 () {
|
||||||
return new Point(getX1(), getY1());
|
return new Point(x1(), y1());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IQuadCurve
|
@Override // from interface IQuadCurve
|
||||||
public Point getCtrlP () {
|
public Point ctrlP () {
|
||||||
return new Point(getCtrlX(), getCtrlY());
|
return new Point(ctrlX(), ctrlY());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IQuadCurve
|
@Override // from interface IQuadCurve
|
||||||
public Point getP2 () {
|
public Point p2 () {
|
||||||
return new Point(getX2(), getY2());
|
return new Point(x2(), y2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IQuadCurve
|
@Override // from interface IQuadCurve
|
||||||
public float getFlatnessSq () {
|
public float flatnessSq () {
|
||||||
return Lines.pointSegDistSq(getCtrlX(), getCtrlY(), getX1(), getY1(), getX2(), getY2());
|
return Lines.pointSegDistSq(ctrlX(), ctrlY(), x1(), y1(), x2(), y2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IQuadCurve
|
@Override // from interface IQuadCurve
|
||||||
public float getFlatness () {
|
public float flatness () {
|
||||||
return Lines.pointSegDist(getCtrlX(), getCtrlY(), getX1(), getY1(), getX2(), getY2());
|
return Lines.pointSegDist(ctrlX(), ctrlY(), x1(), y1(), x2(), y2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IQuadCurve
|
@Override // from interface IQuadCurve
|
||||||
@@ -44,7 +44,7 @@ public abstract class AbstractQuadCurve implements IQuadCurve
|
|||||||
|
|
||||||
@Override // from interface IQuadCurve
|
@Override // from interface IQuadCurve
|
||||||
public QuadCurve clone () {
|
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
|
@Override // from interface IShape
|
||||||
@@ -65,12 +65,12 @@ public abstract class AbstractQuadCurve implements IQuadCurve
|
|||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (IPoint p) {
|
public boolean contains (IPoint p) {
|
||||||
return contains(p.getX(), p.getY());
|
return contains(p.x(), p.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (IRectangle r) {
|
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
|
@Override // from interface IShape
|
||||||
@@ -81,18 +81,18 @@ public abstract class AbstractQuadCurve implements IQuadCurve
|
|||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean intersects (IRectangle r) {
|
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
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds () {
|
public Rectangle bounds () {
|
||||||
return getBounds(new Rectangle());
|
return bounds(new Rectangle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds (Rectangle target) {
|
public Rectangle bounds (Rectangle target) {
|
||||||
float x1 = getX1(), y1 = getY1(), x2 = getX2(), y2 = getY2();
|
float x1 = x1(), y1 = y1(), x2 = x2(), y2 = y2();
|
||||||
float ctrlx = getCtrlX(), ctrly = getCtrlY();
|
float ctrlx = ctrlX(), ctrly = ctrlY();
|
||||||
float rx0 = Math.min(Math.min(x1, x2), ctrlx);
|
float rx0 = Math.min(Math.min(x1, x2), ctrlx);
|
||||||
float ry0 = Math.min(Math.min(y1, y2), ctrly);
|
float ry0 = Math.min(Math.min(y1, y2), ctrly);
|
||||||
float rx1 = Math.max(Math.max(x1, x2), ctrlx);
|
float rx1 = Math.max(Math.max(x1, x2), ctrlx);
|
||||||
@@ -102,13 +102,13 @@ public abstract class AbstractQuadCurve implements IQuadCurve
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform t) {
|
public PathIterator pathIterator (Transform t) {
|
||||||
return new Iterator(this, t);
|
return new Iterator(this, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform t, float flatness) {
|
public PathIterator pathIterator (Transform t, float flatness) {
|
||||||
return new FlatteningPathIterator(getPathIterator(t), flatness);
|
return new FlatteningPathIterator(pathIterator(t), flatness);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** An iterator over an {@link IQuadCurve}. */
|
/** An iterator over an {@link IQuadCurve}. */
|
||||||
@@ -123,7 +123,7 @@ public abstract class AbstractQuadCurve implements IQuadCurve
|
|||||||
this.t = t;
|
this.t = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getWindingRule () {
|
@Override public int windingRule () {
|
||||||
return WIND_NON_ZERO;
|
return WIND_NON_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,15 +143,15 @@ public abstract class AbstractQuadCurve implements IQuadCurve
|
|||||||
int count;
|
int count;
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
type = SEG_MOVETO;
|
type = SEG_MOVETO;
|
||||||
coords[0] = c.getX1();
|
coords[0] = c.x1();
|
||||||
coords[1] = c.getY1();
|
coords[1] = c.y1();
|
||||||
count = 1;
|
count = 1;
|
||||||
} else {
|
} else {
|
||||||
type = SEG_QUADTO;
|
type = SEG_QUADTO;
|
||||||
coords[0] = c.getCtrlX();
|
coords[0] = c.ctrlX();
|
||||||
coords[1] = c.getCtrlY();
|
coords[1] = c.ctrlY();
|
||||||
coords[2] = c.getX2();
|
coords[2] = c.x2();
|
||||||
coords[3] = c.getY2();
|
coords[3] = c.y2();
|
||||||
count = 2;
|
count = 2;
|
||||||
}
|
}
|
||||||
if (t != null) {
|
if (t != null) {
|
||||||
|
|||||||
@@ -15,38 +15,38 @@ import pythagoras.util.Platform;
|
|||||||
public abstract class AbstractRectangle extends RectangularShape implements IRectangle
|
public abstract class AbstractRectangle extends RectangularShape implements IRectangle
|
||||||
{
|
{
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public Point getLocation () {
|
public Point location () {
|
||||||
return getLocation(new Point());
|
return location(new Point());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public Point getLocation (Point target) {
|
public Point location (Point target) {
|
||||||
return target.set(getX(), getY());
|
return target.set(x(), y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public Dimension getSize () {
|
public Dimension size () {
|
||||||
return getSize(new Dimension());
|
return size(new Dimension());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public Dimension getSize (Dimension target) {
|
public Dimension size (Dimension target) {
|
||||||
target.setSize(getWidth(), getHeight());
|
target.setSize(width(), height());
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public Rectangle intersection (float rx, float ry, float rw, float rh) {
|
public Rectangle intersection (float rx, float ry, float rw, float rh) {
|
||||||
float x1 = Math.max(getX(), rx);
|
float x1 = Math.max(x(), rx);
|
||||||
float y1 = Math.max(getY(), ry);
|
float y1 = Math.max(y(), ry);
|
||||||
float x2 = Math.min(getMaxX(), rx + rw);
|
float x2 = Math.min(maxX(), rx + rw);
|
||||||
float y2 = Math.min(getMaxY(), ry + rh);
|
float y2 = Math.min(maxY(), ry + rh);
|
||||||
return new Rectangle(x1, y1, x2 - x1, y2 - y1);
|
return new Rectangle(x1, y1, x2 - x1, y2 - y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public Rectangle intersection (IRectangle r) {
|
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
|
@Override // from interface IRectangle
|
||||||
@@ -58,31 +58,31 @@ public abstract class AbstractRectangle extends RectangularShape implements IRec
|
|||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public boolean intersectsLine (float x1, float y1, float x2, float y2) {
|
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
|
@Override // from interface IRectangle
|
||||||
public boolean intersectsLine (ILine l) {
|
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
|
@Override // from interface IRectangle
|
||||||
public int outcode (float px, float py) {
|
public int outcode (float px, float py) {
|
||||||
int code = 0;
|
int code = 0;
|
||||||
|
|
||||||
if (getWidth() <= 0) {
|
if (width() <= 0) {
|
||||||
code |= OUT_LEFT | OUT_RIGHT;
|
code |= OUT_LEFT | OUT_RIGHT;
|
||||||
} else if (px < getX()) {
|
} else if (px < x()) {
|
||||||
code |= OUT_LEFT;
|
code |= OUT_LEFT;
|
||||||
} else if (px > getMaxX()) {
|
} else if (px > maxX()) {
|
||||||
code |= OUT_RIGHT;
|
code |= OUT_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getHeight() <= 0) {
|
if (height() <= 0) {
|
||||||
code |= OUT_TOP | OUT_BOTTOM;
|
code |= OUT_TOP | OUT_BOTTOM;
|
||||||
} else if (py < getY()) {
|
} else if (py < y()) {
|
||||||
code |= OUT_TOP;
|
code |= OUT_TOP;
|
||||||
} else if (py > getMaxY()) {
|
} else if (py > maxY()) {
|
||||||
code |= OUT_BOTTOM;
|
code |= OUT_BOTTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public abstract class AbstractRectangle extends RectangularShape implements IRec
|
|||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public int outcode (IPoint p) {
|
public int outcode (IPoint p) {
|
||||||
return outcode(p.getX(), p.getY());
|
return outcode(p.x(), p.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
@@ -103,19 +103,19 @@ public abstract class AbstractRectangle extends RectangularShape implements IRec
|
|||||||
public boolean contains (float px, float py) {
|
public boolean contains (float px, float py) {
|
||||||
if (isEmpty()) return false;
|
if (isEmpty()) return false;
|
||||||
|
|
||||||
float x = getX(), y = getY();
|
float x = x(), y = y();
|
||||||
if (px < x || py < y) return false;
|
if (px < x || py < y) return false;
|
||||||
|
|
||||||
px -= x;
|
px -= x;
|
||||||
py -= y;
|
py -= y;
|
||||||
return px < getWidth() && py < getHeight();
|
return px < width() && py < height();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (float rx, float ry, float rw, float rh) {
|
public boolean contains (float rx, float ry, float rw, float rh) {
|
||||||
if (isEmpty()) return false;
|
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);
|
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) {
|
public boolean intersects (float rx, float ry, float rw, float rh) {
|
||||||
if (isEmpty()) return false;
|
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);
|
return (rx + rw > x1) && (rx < x2) && (ry + rh > y1) && (ry < y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform t) {
|
public PathIterator pathIterator (Transform t) {
|
||||||
return new Iterator(this, t);
|
return new Iterator(this, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform t, float flatness) {
|
public PathIterator pathIterator (Transform t, float flatness) {
|
||||||
return new Iterator(this, t);
|
return new Iterator(this, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,22 +144,22 @@ public abstract class AbstractRectangle extends RectangularShape implements IRec
|
|||||||
}
|
}
|
||||||
if (obj instanceof AbstractRectangle) {
|
if (obj instanceof AbstractRectangle) {
|
||||||
AbstractRectangle r = (AbstractRectangle)obj;
|
AbstractRectangle r = (AbstractRectangle)obj;
|
||||||
return r.getX() == getX() && r.getY() == getY() &&
|
return r.x() == x() && r.y() == y() &&
|
||||||
r.getWidth() == getWidth() && r.getHeight() == getHeight();
|
r.width() == width() && r.height() == height();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Object
|
@Override // from Object
|
||||||
public int hashCode () {
|
public int hashCode () {
|
||||||
return Platform.hashCode(getX()) ^ Platform.hashCode(getY()) ^
|
return Platform.hashCode(x()) ^ Platform.hashCode(y()) ^
|
||||||
Platform.hashCode(getWidth()) ^ Platform.hashCode(getHeight());
|
Platform.hashCode(width()) ^ Platform.hashCode(height());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Object
|
@Override // from Object
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return Dimensions.dimenToString(getWidth(), getHeight()) +
|
return Dimensions.dimenToString(width(), height()) +
|
||||||
Points.pointToString(getX(), getY());
|
Points.pointToString(x(), y());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** An iterator over an {@link IRectangle}. */
|
/** An iterator over an {@link IRectangle}. */
|
||||||
@@ -172,17 +172,17 @@ public abstract class AbstractRectangle extends RectangularShape implements IRec
|
|||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
Iterator (IRectangle r, Transform at) {
|
Iterator (IRectangle r, Transform at) {
|
||||||
this.x = r.getX();
|
this.x = r.x();
|
||||||
this.y = r.getY();
|
this.y = r.y();
|
||||||
this.width = r.getWidth();
|
this.width = r.width();
|
||||||
this.height = r.getHeight();
|
this.height = r.height();
|
||||||
this.t = at;
|
this.t = at;
|
||||||
if (width < 0f || height < 0f) {
|
if (width < 0f || height < 0f) {
|
||||||
index = 6;
|
index = 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getWindingRule () {
|
@Override public int windingRule () {
|
||||||
return WIND_NON_ZERO;
|
return WIND_NON_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,21 +14,21 @@ public abstract class AbstractRoundRectangle extends RectangularShape implements
|
|||||||
{
|
{
|
||||||
@Override // from interface IRoundRectangle
|
@Override // from interface IRoundRectangle
|
||||||
public RoundRectangle clone () {
|
public RoundRectangle clone () {
|
||||||
return new RoundRectangle(getX(), getY(), getWidth(), getHeight(),
|
return new RoundRectangle(x(), y(), width(), height(),
|
||||||
getArcWidth(), getArcHeight());
|
arcWidth(), arcHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (float px, float py) {
|
public boolean contains (float px, float py) {
|
||||||
if (isEmpty()) return false;
|
if (isEmpty()) return false;
|
||||||
|
|
||||||
float rx1 = getX(), ry1 = getY();
|
float rx1 = x(), ry1 = y();
|
||||||
float rx2 = rx1 + getWidth(), ry2 = ry1 + getHeight();
|
float rx2 = rx1 + width(), ry2 = ry1 + height();
|
||||||
if (px < rx1 || px >= rx2 || py < ry1 || py >= ry2) {
|
if (px < rx1 || px >= rx2 || py < ry1 || py >= ry2) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float aw = getArcWidth() / 2f, ah = getArcHeight() / 2f;
|
float aw = arcWidth() / 2f, ah = arcHeight() / 2f;
|
||||||
float cx, cy;
|
float cx, cy;
|
||||||
if (px < rx1 + aw) {
|
if (px < rx1 + aw) {
|
||||||
cx = 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) {
|
public boolean intersects (float rx, float ry, float rw, float rh) {
|
||||||
if (isEmpty() || rw <= 0f || rh <= 0f) return false;
|
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;
|
float rx1 = rx, ry1 = ry, rx2 = rx + rw, ry2 = ry + rh;
|
||||||
if (rx2 < x1 || x2 < rx1 || ry2 < y1 || y2 < ry1) {
|
if (rx2 < x1 || x2 < rx1 || ry2 < y1 || y2 < ry1) {
|
||||||
return false;
|
return false;
|
||||||
@@ -75,7 +75,7 @@ public abstract class AbstractRoundRectangle extends RectangularShape implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform at) {
|
public PathIterator pathIterator (Transform at) {
|
||||||
return new Iterator(this, at);
|
return new Iterator(this, at);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,19 +87,19 @@ public abstract class AbstractRoundRectangle extends RectangularShape implements
|
|||||||
private int index;
|
private int index;
|
||||||
|
|
||||||
Iterator (IRoundRectangle rr, Transform at) {
|
Iterator (IRoundRectangle rr, Transform at) {
|
||||||
this.x = rr.getX();
|
this.x = rr.x();
|
||||||
this.y = rr.getY();
|
this.y = rr.y();
|
||||||
this.width = rr.getWidth();
|
this.width = rr.width();
|
||||||
this.height = rr.getHeight();
|
this.height = rr.height();
|
||||||
this.aw = Math.min(width, rr.getArcWidth());
|
this.aw = Math.min(width, rr.arcWidth());
|
||||||
this.ah = Math.min(height, rr.getArcHeight());
|
this.ah = Math.min(height, rr.arcHeight());
|
||||||
this.t = at;
|
this.t = at;
|
||||||
if (width < 0f || height < 0f || aw < 0f || ah < 0f) {
|
if (width < 0f || height < 0f || aw < 0f || ah < 0f) {
|
||||||
index = POINTS.length;
|
index = POINTS.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getWindingRule () {
|
@Override public int windingRule () {
|
||||||
return WIND_NON_ZERO;
|
return WIND_NON_ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,13 +10,13 @@ package pythagoras.f;
|
|||||||
public abstract class AbstractTransform implements Transform
|
public abstract class AbstractTransform implements Transform
|
||||||
{
|
{
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Vector getScale () {
|
public Vector scale () {
|
||||||
return new Vector(getScaleX(), getScaleY());
|
return new Vector(scaleX(), scaleY());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Vector getTranslation () {
|
public Vector translation () {
|
||||||
return new Vector(getTx(), getTy());
|
return new Vector(tx(), ty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public abstract class AbstractVector implements IVector
|
|||||||
{
|
{
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public float dot (IVector other) {
|
public float dot (IVector other) {
|
||||||
return getX()*other.getX() + getY()*other.getY();
|
return x()*other.x() + y()*other.y();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
@@ -24,7 +24,7 @@ public abstract class AbstractVector implements IVector
|
|||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public Vector negate (Vector result) {
|
public Vector negate (Vector result) {
|
||||||
return result.set(-getX(), -getY());
|
return result.set(-x(), -y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
@@ -45,7 +45,7 @@ public abstract class AbstractVector implements IVector
|
|||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public float direction (IVector other) {
|
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
|
@Override // from interface IVector
|
||||||
@@ -55,7 +55,7 @@ public abstract class AbstractVector implements IVector
|
|||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public float lengthSq () {
|
public float lengthSq () {
|
||||||
float x = getX(), y = getY();
|
float x = x(), y = y();
|
||||||
return (x*x + y*y);
|
return (x*x + y*y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public abstract class AbstractVector implements IVector
|
|||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public float distanceSq (IVector other) {
|
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;
|
return dx*dx + dy*dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ public abstract class AbstractVector implements IVector
|
|||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public Vector mult (float v, Vector result) {
|
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
|
@Override // from interface IVector
|
||||||
@@ -87,7 +87,7 @@ public abstract class AbstractVector implements IVector
|
|||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public Vector mult (IVector other, Vector result) {
|
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
|
@Override // from interface IVector
|
||||||
@@ -97,7 +97,7 @@ public abstract class AbstractVector implements IVector
|
|||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public Vector add (IVector other, Vector result) {
|
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
|
@Override // from interface IVector
|
||||||
@@ -107,7 +107,7 @@ public abstract class AbstractVector implements IVector
|
|||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public Vector subtract (IVector other, Vector result) {
|
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
|
@Override // from interface IVector
|
||||||
@@ -117,7 +117,7 @@ public abstract class AbstractVector implements IVector
|
|||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public Vector add (float x, float y, Vector result) {
|
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
|
@Override // from interface IVector
|
||||||
@@ -127,7 +127,7 @@ public abstract class AbstractVector implements IVector
|
|||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public Vector addScaled (IVector other, float v, Vector result) {
|
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
|
@Override // from interface IVector
|
||||||
@@ -137,24 +137,24 @@ public abstract class AbstractVector implements IVector
|
|||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public Vector rotate (float angle, Vector result) {
|
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);
|
float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle);
|
||||||
return result.set(x*cosa - y*sina, x*sina + y*cosa);
|
return result.set(x*cosa - y*sina, x*sina + y*cosa);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public Vector rotateAndAdd (float angle, IVector add, Vector result) {
|
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);
|
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
|
@Override // from interface IVector
|
||||||
public Vector rotateScaleAndAdd (float angle, float scale, IVector add, Vector result) {
|
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);
|
float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle);
|
||||||
return result.set((x*cosa - y*sina)*scale + add.getX(),
|
return result.set((x*cosa - y*sina)*scale + add.x(),
|
||||||
(x*sina + y*cosa)*scale + add.getY());
|
(x*sina + y*cosa)*scale + add.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
@@ -164,8 +164,8 @@ public abstract class AbstractVector implements IVector
|
|||||||
|
|
||||||
@Override // from interface IVector
|
@Override // from interface IVector
|
||||||
public Vector lerp (IVector other, float t, Vector result) {
|
public Vector lerp (IVector other, float t, Vector result) {
|
||||||
float x = getX(), y = getY();
|
float x = x(), y = y();
|
||||||
float dx = other.getX() - x, dy = other.getY() - y;
|
float dx = other.x() - x, dy = other.y() - y;
|
||||||
return result.set(x + t*dx, y + t*dy);
|
return result.set(x + t*dx, y + t*dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,18 +181,18 @@ public abstract class AbstractVector implements IVector
|
|||||||
}
|
}
|
||||||
if (obj instanceof AbstractVector) {
|
if (obj instanceof AbstractVector) {
|
||||||
AbstractVector p = (AbstractVector)obj;
|
AbstractVector p = (AbstractVector)obj;
|
||||||
return getX() == p.getX() && getY() == p.getY();
|
return x() == p.x() && y() == p.y();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode () {
|
public int hashCode () {
|
||||||
return Platform.hashCode(getX()) ^ Platform.hashCode(getY());
|
return Platform.hashCode(x()) ^ Platform.hashCode(y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return Vectors.vectorToString(getX(), getY());
|
return Vectors.vectorToString(x(), y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,24 +51,24 @@ public class AffineTransform extends AbstractTransform
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getUniformScale () {
|
public float uniformScale () {
|
||||||
// the square root of the signed area of the parallelogram spanned by the axis vectors
|
// the square root of the signed area of the parallelogram spanned by the axis vectors
|
||||||
float cp = m00*m11 - m01*m10;
|
float cp = m00*m11 - m01*m10;
|
||||||
return (cp < 0f) ? -FloatMath.sqrt(-cp) : FloatMath.sqrt(cp);
|
return (cp < 0f) ? -FloatMath.sqrt(-cp) : FloatMath.sqrt(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getScaleX () {
|
public float scaleX () {
|
||||||
return FloatMath.sqrt(m00*m00 + m01*m01);
|
return FloatMath.sqrt(m00*m00 + m01*m01);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getScaleY () {
|
public float scaleY () {
|
||||||
return FloatMath.sqrt(m10*m10 + m11*m11);
|
return FloatMath.sqrt(m10*m10 + m11*m11);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getRotation () {
|
public float rotation () {
|
||||||
// use the iterative polar decomposition algorithm described by Ken Shoemake:
|
// use the iterative polar decomposition algorithm described by Ken Shoemake:
|
||||||
// http://www.cs.wisc.edu/graphics/Courses/838-s2002/Papers/polar-decomp.pdf
|
// 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
|
@Override // from Transform
|
||||||
public float getTx () {
|
public float tx () {
|
||||||
return this.tx;
|
return this.tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getTy () {
|
public float ty () {
|
||||||
return this.ty;
|
return this.ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ public class AffineTransform extends AbstractTransform
|
|||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Transform setScaleX (float scaleX) {
|
public Transform setScaleX (float scaleX) {
|
||||||
// normalize the scale to 1, then re-apply
|
// normalize the scale to 1, then re-apply
|
||||||
float osx = getScaleX();
|
float osx = scaleX();
|
||||||
m00 /= osx; m01 /= osx;
|
m00 /= osx; m01 /= osx;
|
||||||
m00 *= scaleX; m01 *= scaleX;
|
m00 *= scaleX; m01 *= scaleX;
|
||||||
return this;
|
return this;
|
||||||
@@ -131,7 +131,7 @@ public class AffineTransform extends AbstractTransform
|
|||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Transform setScaleY (float scaleY) {
|
public Transform setScaleY (float scaleY) {
|
||||||
// normalize the scale to 1, then re-apply
|
// normalize the scale to 1, then re-apply
|
||||||
float osy = getScaleY();
|
float osy = scaleY();
|
||||||
m10 /= osy; m11 /= osy;
|
m10 /= osy; m11 /= osy;
|
||||||
m10 *= scaleY; m11 *= scaleY;
|
m10 *= scaleY; m11 *= scaleY;
|
||||||
return this;
|
return this;
|
||||||
@@ -140,7 +140,7 @@ public class AffineTransform extends AbstractTransform
|
|||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Transform setRotation (float angle) {
|
public Transform setRotation (float angle) {
|
||||||
// extract the scale, then reapply rotation and scale together
|
// 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);
|
float sina = FloatMath.sin(angle), cosa = FloatMath.cos(angle);
|
||||||
m00 = cosa * sx; m01 = sina * sx;
|
m00 = cosa * sx; m01 = sina * sx;
|
||||||
m10 = -sina * sy; m11 = cosa * sy;
|
m10 = -sina * sy; m11 = cosa * sy;
|
||||||
@@ -276,7 +276,7 @@ public class AffineTransform extends AbstractTransform
|
|||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Point transform (IPoint p, Point into) {
|
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);
|
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
|
@Override // from Transform
|
||||||
public Point inverseTransform (IPoint p, Point into) {
|
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;
|
float det = m00 * m11 - m01 * m10;
|
||||||
if (Math.abs(det) == 0f) {
|
if (Math.abs(det) == 0f) {
|
||||||
// determinant is zero; matrix is not invertible
|
// determinant is zero; matrix is not invertible
|
||||||
@@ -311,13 +311,13 @@ public class AffineTransform extends AbstractTransform
|
|||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Vector transform (IVector v, Vector into) {
|
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);
|
return into.set(m00*x + m10*y, m01*x + m11*y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Vector inverseTransform (IVector v, Vector into) {
|
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;
|
float det = m00 * m11 - m01 * m10;
|
||||||
if (Math.abs(det) == 0f) {
|
if (Math.abs(det) == 0f) {
|
||||||
// determinant is zero; matrix is not invertible
|
// determinant is zero; matrix is not invertible
|
||||||
@@ -341,13 +341,13 @@ public class AffineTransform extends AbstractTransform
|
|||||||
@Override
|
@Override
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return "affine [" + FloatMath.toString(m00) + " " + FloatMath.toString(m01) + " " +
|
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
|
// 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()
|
// create a new AffineTransform from another AffineTransform using this instead of clone()
|
||||||
protected AffineTransform (Transform other) {
|
protected AffineTransform (Transform other) {
|
||||||
this(other.getScaleX(), other.getScaleY(), other.getRotation(),
|
this(other.scaleX(), other.scaleY(), other.rotation(),
|
||||||
other.getTx(), other.getTy());
|
other.tx(), other.ty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,42 +56,42 @@ public class Arc extends AbstractArc implements Serializable
|
|||||||
* angular extent.
|
* angular extent.
|
||||||
*/
|
*/
|
||||||
public Arc (IRectangle bounds, float start, float extent, int type) {
|
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);
|
start, extent, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IArc
|
@Override // from interface IArc
|
||||||
public int getArcType () {
|
public int arcType () {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IArc
|
@Override // from interface IArc
|
||||||
public float getX () {
|
public float x () {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IArc
|
@Override // from interface IArc
|
||||||
public float getY () {
|
public float y () {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IArc
|
@Override // from interface IArc
|
||||||
public float getWidth () {
|
public float width () {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IArc
|
@Override // from interface IArc
|
||||||
public float getHeight () {
|
public float height () {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IArc
|
@Override // from interface IArc
|
||||||
public float getAngleStart () {
|
public float angleStart () {
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IArc
|
@Override // from interface IArc
|
||||||
public float getAngleExtent () {
|
public float angleExtent () {
|
||||||
return extent;
|
return extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +139,7 @@ public class Arc extends AbstractArc implements Serializable
|
|||||||
* values.
|
* values.
|
||||||
*/
|
*/
|
||||||
public void setArc (IPoint point, IDimension size, float start, float extent, int type) {
|
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.
|
* values.
|
||||||
*/
|
*/
|
||||||
public void setArc (IRectangle rect, float start, float extent, int type) {
|
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.
|
* the supplied arc.
|
||||||
*/
|
*/
|
||||||
public void setArc (IArc arc) {
|
public void setArc (IArc arc) {
|
||||||
setArc(arc.getX(), arc.getY(), arc.getWidth(), arc.getHeight(), arc.getAngleStart(),
|
setArc(arc.x(), arc.y(), arc.width(), arc.height(), arc.angleStart(),
|
||||||
arc.getAngleExtent(), arc.getArcType());
|
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) {
|
public void setArcByTangent (IPoint p1, IPoint p2, IPoint p3, float radius) {
|
||||||
// use simple geometric calculations of arc center, radius and angles by tangents
|
// 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 a1 = -FloatMath.atan2(p1.y() - p2.y(), p1.x() - p2.x());
|
||||||
float a2 = -FloatMath.atan2(p3.getY() - p2.getY(), p3.getX() - p2.getX());
|
float a2 = -FloatMath.atan2(p3.y() - p2.y(), p3.x() - p2.x());
|
||||||
float am = (a1 + a2) / 2f;
|
float am = (a1 + a2) / 2f;
|
||||||
float ah = a1 - am;
|
float ah = a1 - am;
|
||||||
float d = radius / Math.abs(FloatMath.sin(ah));
|
float d = radius / Math.abs(FloatMath.sin(ah));
|
||||||
float x = p2.getX() + d * FloatMath.cos(am);
|
float x = p2.x() + d * FloatMath.cos(am);
|
||||||
float y = p2.getY() - d * FloatMath.sin(am);
|
float y = p2.y() - d * FloatMath.sin(am);
|
||||||
ah = ah >= 0f ? FloatMath.PI * 1.5f - ah : FloatMath.PI * 0.5f - ah;
|
ah = ah >= 0f ? FloatMath.PI * 1.5f - ah : FloatMath.PI * 0.5f - ah;
|
||||||
a1 = getNormAngle(FloatMath.toDegrees(am - ah));
|
a1 = normAngle(FloatMath.toDegrees(am - ah));
|
||||||
a2 = getNormAngle(FloatMath.toDegrees(am + ah));
|
a2 = normAngle(FloatMath.toDegrees(am + ah));
|
||||||
float delta = a2 - a1;
|
float delta = a2 - a1;
|
||||||
if (delta <= 0f) {
|
if (delta <= 0f) {
|
||||||
delta += 360f;
|
delta += 360f;
|
||||||
@@ -196,8 +196,8 @@ public class Arc extends AbstractArc implements Serializable
|
|||||||
* the center of this arc.
|
* the center of this arc.
|
||||||
*/
|
*/
|
||||||
public void setAngleStart (IPoint point) {
|
public void setAngleStart (IPoint point) {
|
||||||
float angle = FloatMath.atan2(point.getY() - getCenterY(), point.getX() - getCenterX());
|
float angle = FloatMath.atan2(point.y() - centerY(), point.x() - centerX());
|
||||||
setAngleStart(getNormAngle(-FloatMath.toDegrees(angle)));
|
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.
|
* counterclockwise from the first point around to the second point.
|
||||||
*/
|
*/
|
||||||
public void setAngles (float x1, float y1, float x2, float y2) {
|
public void setAngles (float x1, float y1, float x2, float y2) {
|
||||||
float cx = getCenterX();
|
float cx = centerX();
|
||||||
float cy = getCenterY();
|
float cy = centerY();
|
||||||
float a1 = getNormAngle(-FloatMath.toDegrees(FloatMath.atan2(y1 - cy, x1 - cx)));
|
float a1 = normAngle(-FloatMath.toDegrees(FloatMath.atan2(y1 - cy, x1 - cx)));
|
||||||
float a2 = getNormAngle(-FloatMath.toDegrees(FloatMath.atan2(y2 - cy, x2 - cx)));
|
float a2 = normAngle(-FloatMath.toDegrees(FloatMath.atan2(y2 - cy, x2 - cx)));
|
||||||
a2 -= a1;
|
a2 -= a1;
|
||||||
if (a2 <= 0f) {
|
if (a2 <= 0f) {
|
||||||
a2 += 360f;
|
a2 += 360f;
|
||||||
@@ -228,12 +228,12 @@ public class Arc extends AbstractArc implements Serializable
|
|||||||
* counterclockwise from the first point around to the second point.
|
* counterclockwise from the first point around to the second point.
|
||||||
*/
|
*/
|
||||||
public void setAngles (IPoint p1, IPoint p2) {
|
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
|
@Override // from RectangularShape
|
||||||
public void setFrame (float x, float y, float width, float height) {
|
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;
|
private int type;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class Area implements IShape, Cloneable
|
|||||||
int rulesIndex = 0;
|
int rulesIndex = 0;
|
||||||
int coordsIndex = 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);
|
coords = adjustSize(coords, coordsIndex + 6);
|
||||||
rules = adjustSize(rules, rulesIndex + 1);
|
rules = adjustSize(rules, rulesIndex + 1);
|
||||||
offsets = adjustSize(offsets, rulesIndex + 1);
|
offsets = adjustSize(offsets, rulesIndex + 1);
|
||||||
@@ -140,7 +140,7 @@ public class Area implements IShape, Cloneable
|
|||||||
addCurvePolygon(area);
|
addCurvePolygon(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getAreaBoundsSquare() < GeometryUtil.EPSILON) {
|
if (areaBoundsSquare() < GeometryUtil.EPSILON) {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ public class Area implements IShape, Cloneable
|
|||||||
intersectCurvePolygon(area);
|
intersectCurvePolygon(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getAreaBoundsSquare() < GeometryUtil.EPSILON) {
|
if (areaBoundsSquare() < GeometryUtil.EPSILON) {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,7 +181,7 @@ public class Area implements IShape, Cloneable
|
|||||||
subtractCurvePolygon(area);
|
subtractCurvePolygon(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getAreaBoundsSquare() < GeometryUtil.EPSILON) {
|
if (areaBoundsSquare() < GeometryUtil.EPSILON) {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,25 +209,25 @@ public class Area implements IShape, Cloneable
|
|||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (float x, float y, float width, float height) {
|
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);
|
return crossCount != Crossing.CROSSING && Crossing.isInsideEvenOdd(crossCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (IPoint p) {
|
public boolean contains (IPoint p) {
|
||||||
return contains(p.getX(), p.getY());
|
return contains(p.x(), p.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (IRectangle r) {
|
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
|
@Override // from interface IShape
|
||||||
public boolean intersects (float x, float y, float width, float height) {
|
public boolean intersects (float x, float y, float width, float height) {
|
||||||
if ((width <= 0f) || (height <= 0f)) {
|
if ((width <= 0f) || (height <= 0f)) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!getBounds().intersects(x, y, width, height)) {
|
} else if (!bounds().intersects(x, y, width, height)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int crossCount = Crossing.intersectShape(this, x, y, width, height);
|
int crossCount = Crossing.intersectShape(this, x, y, width, height);
|
||||||
@@ -236,16 +236,16 @@ public class Area implements IShape, Cloneable
|
|||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean intersects (IRectangle r) {
|
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
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds () {
|
public Rectangle bounds () {
|
||||||
return getBounds(new Rectangle());
|
return bounds(new Rectangle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds (Rectangle target) {
|
public Rectangle bounds (Rectangle target) {
|
||||||
float maxX = coords[0], maxY = coords[1];
|
float maxX = coords[0], maxY = coords[1];
|
||||||
float minX = coords[0], minY = coords[1];
|
float minX = coords[0], minY = coords[1];
|
||||||
for (int i = 0; i < coordsSize;) {
|
for (int i = 0; i < coordsSize;) {
|
||||||
@@ -258,13 +258,13 @@ public class Area implements IShape, Cloneable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform t) {
|
public PathIterator pathIterator (Transform t) {
|
||||||
return new AreaPathIterator(t);
|
return new AreaPathIterator(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform t, float flatness) {
|
public PathIterator pathIterator (Transform t, float flatness) {
|
||||||
return new FlatteningPathIterator(getPathIterator(t), flatness);
|
return new FlatteningPathIterator(pathIterator(t), flatness);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Object
|
@Override // from Object
|
||||||
@@ -296,9 +296,9 @@ public class Area implements IShape, Cloneable
|
|||||||
IntersectPoint[] intersectPoints = crossHelper.findCrossing();
|
IntersectPoint[] intersectPoints = crossHelper.findCrossing();
|
||||||
|
|
||||||
if (intersectPoints.length == 0) {
|
if (intersectPoints.length == 0) {
|
||||||
if (area.contains(getBounds())) {
|
if (area.contains(bounds())) {
|
||||||
copy(area, this);
|
copy(area, this);
|
||||||
} else if (!contains(area.getBounds())) {
|
} else if (!contains(area.bounds())) {
|
||||||
coords = adjustSize(coords, coordsSize + area.coordsSize);
|
coords = adjustSize(coords, coordsSize + area.coordsSize);
|
||||||
System.arraycopy(area.coords, 0, coords, coordsSize, area.coordsSize);
|
System.arraycopy(area.coords, 0, coords, coordsSize, area.coordsSize);
|
||||||
coordsSize += area.coordsSize;
|
coordsSize += area.coordsSize;
|
||||||
@@ -324,9 +324,9 @@ public class Area implements IShape, Cloneable
|
|||||||
resultOffsets[resultRulesPos++] = resultCoordPos;
|
resultOffsets[resultRulesPos++] = resultCoordPos;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
resultCoords[resultCoordPos++] = point.getX();
|
resultCoords[resultCoordPos++] = point.x();
|
||||||
resultCoords[resultCoordPos++] = point.getY();
|
resultCoords[resultCoordPos++] = point.y();
|
||||||
int curIndex = point.getEndIndex(true);
|
int curIndex = point.endIndex(true);
|
||||||
if (curIndex < 0) {
|
if (curIndex < 0) {
|
||||||
isCurrentArea = !isCurrentArea;
|
isCurrentArea = !isCurrentArea;
|
||||||
} else if (area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) > 0) {
|
} else if (area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) > 0) {
|
||||||
@@ -335,13 +335,13 @@ public class Area implements IShape, Cloneable
|
|||||||
isCurrentArea = true;
|
isCurrentArea = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntersectPoint nextPoint = getNextIntersectPoint(intersectPoints, point, isCurrentArea);
|
IntersectPoint nextPoint = nextIntersectPoint(intersectPoints, point, isCurrentArea);
|
||||||
float[] coords = (isCurrentArea) ? this.coords : area.coords;
|
float[] coords = (isCurrentArea) ? this.coords : area.coords;
|
||||||
int[] offsets = (isCurrentArea) ? this.offsets : area.offsets;
|
int[] offsets = (isCurrentArea) ? this.offsets : area.offsets;
|
||||||
int[] rules = (isCurrentArea) ? this.rules : area.rules;
|
int[] rules = (isCurrentArea) ? this.rules : area.rules;
|
||||||
int offset = point.getRuleIndex(isCurrentArea);
|
int offset = point.ruleIndex(isCurrentArea);
|
||||||
boolean isCopyUntilZero = false;
|
boolean isCopyUntilZero = false;
|
||||||
if ((point.getRuleIndex(isCurrentArea) > nextPoint.getRuleIndex(isCurrentArea))) {
|
if ((point.ruleIndex(isCurrentArea) > nextPoint.ruleIndex(isCurrentArea))) {
|
||||||
int rulesSize = (isCurrentArea) ? this.rulesSize : area.rulesSize;
|
int rulesSize = (isCurrentArea) ? this.rulesSize : area.rulesSize;
|
||||||
resultCoordPos = includeCoordsAndRules(offset + 1, rulesSize, rules, offsets,
|
resultCoordPos = includeCoordsAndRules(offset + 1, rulesSize, rules, offsets,
|
||||||
resultRules, resultOffsets, resultCoords, coords, resultRulesPos,
|
resultRules, resultOffsets, resultCoords, coords, resultRulesPos,
|
||||||
@@ -351,7 +351,7 @@ public class Area implements IShape, Cloneable
|
|||||||
isCopyUntilZero = true;
|
isCopyUntilZero = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int length = nextPoint.getRuleIndex(isCurrentArea) - offset + 1;
|
int length = nextPoint.ruleIndex(isCurrentArea) - offset + 1;
|
||||||
if (isCopyUntilZero) {
|
if (isCopyUntilZero) {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
@@ -379,9 +379,9 @@ public class Area implements IShape, Cloneable
|
|||||||
IntersectPoint[] intersectPoints = crossHelper.findCrossing();
|
IntersectPoint[] intersectPoints = crossHelper.findCrossing();
|
||||||
|
|
||||||
if (intersectPoints.length == 0) {
|
if (intersectPoints.length == 0) {
|
||||||
if (area.contains(getBounds())) {
|
if (area.contains(bounds())) {
|
||||||
copy(area, this);
|
copy(area, this);
|
||||||
} else if (!contains(area.getBounds())) {
|
} else if (!contains(area.bounds())) {
|
||||||
coords = adjustSize(coords, coordsSize + area.coordsSize);
|
coords = adjustSize(coords, coordsSize + area.coordsSize);
|
||||||
System.arraycopy(area.coords, 0, coords, coordsSize, area.coordsSize);
|
System.arraycopy(area.coords, 0, coords, coordsSize, area.coordsSize);
|
||||||
coordsSize += area.coordsSize;
|
coordsSize += area.coordsSize;
|
||||||
@@ -406,11 +406,11 @@ public class Area implements IShape, Cloneable
|
|||||||
resultOffsets[resultRulesPos++] = resultCoordPos;
|
resultOffsets[resultRulesPos++] = resultCoordPos;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
resultCoords[resultCoordPos++] = point.getX();
|
resultCoords[resultCoordPos++] = point.x();
|
||||||
resultCoords[resultCoordPos++] = point.getY();
|
resultCoords[resultCoordPos++] = point.y();
|
||||||
resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
|
resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
|
||||||
resultOffsets[resultRulesPos++] = resultCoordPos - 2;
|
resultOffsets[resultRulesPos++] = resultCoordPos - 2;
|
||||||
int curIndex = point.getEndIndex(true);
|
int curIndex = point.endIndex(true);
|
||||||
if (curIndex < 0) {
|
if (curIndex < 0) {
|
||||||
isCurrentArea = !isCurrentArea;
|
isCurrentArea = !isCurrentArea;
|
||||||
} else if (area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) > 0) {
|
} else if (area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) > 0) {
|
||||||
@@ -419,11 +419,11 @@ public class Area implements IShape, Cloneable
|
|||||||
isCurrentArea = true;
|
isCurrentArea = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntersectPoint nextPoint = getNextIntersectPoint(intersectPoints, point, isCurrentArea);
|
IntersectPoint nextPoint = nextIntersectPoint(intersectPoints, point, isCurrentArea);
|
||||||
float[] coords = (isCurrentArea) ? this.coords : area.coords;
|
float[] coords = (isCurrentArea) ? this.coords : area.coords;
|
||||||
int offset = 2 * point.getEndIndex(isCurrentArea);
|
int offset = 2 * point.endIndex(isCurrentArea);
|
||||||
if ((offset >= 0) &&
|
if ((offset >= 0) &&
|
||||||
(nextPoint.getBegIndex(isCurrentArea) < point.getEndIndex(isCurrentArea))) {
|
(nextPoint.begIndex(isCurrentArea) < point.endIndex(isCurrentArea))) {
|
||||||
int coordSize = (isCurrentArea) ? this.coordsSize : area.coordsSize;
|
int coordSize = (isCurrentArea) ? this.coordsSize : area.coordsSize;
|
||||||
int length = coordSize - offset;
|
int length = coordSize - offset;
|
||||||
System.arraycopy(coords, offset, resultCoords, resultCoordPos, length);
|
System.arraycopy(coords, offset, resultCoords, resultCoordPos, length);
|
||||||
@@ -438,7 +438,7 @@ public class Area implements IShape, Cloneable
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (offset >= 0) {
|
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);
|
System.arraycopy(coords, offset, resultCoords, resultCoordPos, length);
|
||||||
|
|
||||||
for (int i = 0; i < length / 2; i++) {
|
for (int i = 0; i < length / 2; i++) {
|
||||||
@@ -469,9 +469,9 @@ public class Area implements IShape, Cloneable
|
|||||||
new int[][] { offsets, area.offsets });
|
new int[][] { offsets, area.offsets });
|
||||||
IntersectPoint[] intersectPoints = crossHelper.findCrossing();
|
IntersectPoint[] intersectPoints = crossHelper.findCrossing();
|
||||||
if (intersectPoints.length == 0) {
|
if (intersectPoints.length == 0) {
|
||||||
if (contains(area.getBounds())) {
|
if (contains(area.bounds())) {
|
||||||
copy(area, this);
|
copy(area, this);
|
||||||
} else if (!area.contains(getBounds())) {
|
} else if (!area.contains(bounds())) {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -490,10 +490,10 @@ public class Area implements IShape, Cloneable
|
|||||||
resultOffsets[resultRulesPos++] = resultCoordPos;
|
resultOffsets[resultRulesPos++] = resultCoordPos;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
resultCoords[resultCoordPos++] = point.getX();
|
resultCoords[resultCoordPos++] = point.x();
|
||||||
resultCoords[resultCoordPos++] = point.getY();
|
resultCoords[resultCoordPos++] = point.y();
|
||||||
|
|
||||||
int curIndex = point.getEndIndex(true);
|
int curIndex = point.endIndex(true);
|
||||||
if ((curIndex < 0) ||
|
if ((curIndex < 0) ||
|
||||||
(area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) == 0)) {
|
(area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) == 0)) {
|
||||||
isCurrentArea = !isCurrentArea;
|
isCurrentArea = !isCurrentArea;
|
||||||
@@ -503,14 +503,14 @@ public class Area implements IShape, Cloneable
|
|||||||
isCurrentArea = false;
|
isCurrentArea = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nextPoint = getNextIntersectPoint(intersectPoints, point, isCurrentArea);
|
nextPoint = nextIntersectPoint(intersectPoints, point, isCurrentArea);
|
||||||
float[] coords = (isCurrentArea) ? this.coords : area.coords;
|
float[] coords = (isCurrentArea) ? this.coords : area.coords;
|
||||||
int[] offsets = (isCurrentArea) ? this.offsets : area.offsets;
|
int[] offsets = (isCurrentArea) ? this.offsets : area.offsets;
|
||||||
int[] rules = (isCurrentArea) ? this.rules : area.rules;
|
int[] rules = (isCurrentArea) ? this.rules : area.rules;
|
||||||
int offset = point.getRuleIndex(isCurrentArea);
|
int offset = point.ruleIndex(isCurrentArea);
|
||||||
boolean isCopyUntilZero = false;
|
boolean isCopyUntilZero = false;
|
||||||
|
|
||||||
if (point.getRuleIndex(isCurrentArea) > nextPoint.getRuleIndex(isCurrentArea)) {
|
if (point.ruleIndex(isCurrentArea) > nextPoint.ruleIndex(isCurrentArea)) {
|
||||||
int rulesSize = (isCurrentArea) ? this.rulesSize : area.rulesSize;
|
int rulesSize = (isCurrentArea) ? this.rulesSize : area.rulesSize;
|
||||||
resultCoordPos = includeCoordsAndRules(
|
resultCoordPos = includeCoordsAndRules(
|
||||||
offset + 1, rulesSize, rules, offsets, resultRules, resultOffsets,
|
offset + 1, rulesSize, rules, offsets, resultRules, resultOffsets,
|
||||||
@@ -521,17 +521,17 @@ public class Area implements IShape, Cloneable
|
|||||||
isCopyUntilZero = true;
|
isCopyUntilZero = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int length = nextPoint.getRuleIndex(isCurrentArea) - offset + 1;
|
int length = nextPoint.ruleIndex(isCurrentArea) - offset + 1;
|
||||||
|
|
||||||
if (isCopyUntilZero) {
|
if (isCopyUntilZero) {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
isCopyUntilZero = false;
|
isCopyUntilZero = false;
|
||||||
}
|
}
|
||||||
if ((length == offset) &&
|
if ((length == offset) &&
|
||||||
(nextPoint.getRule(isCurrentArea) != PathIterator.SEG_LINETO) &&
|
(nextPoint.rule(isCurrentArea) != PathIterator.SEG_LINETO) &&
|
||||||
(nextPoint.getRule(isCurrentArea) != PathIterator.SEG_CLOSE) &&
|
(nextPoint.rule(isCurrentArea) != PathIterator.SEG_CLOSE) &&
|
||||||
(point.getRule(isCurrentArea) != PathIterator.SEG_LINETO) &&
|
(point.rule(isCurrentArea) != PathIterator.SEG_LINETO) &&
|
||||||
(point.getRule(isCurrentArea) != PathIterator.SEG_CLOSE)) {
|
(point.rule(isCurrentArea) != PathIterator.SEG_CLOSE)) {
|
||||||
isCopyUntilZero = true;
|
isCopyUntilZero = true;
|
||||||
length++;
|
length++;
|
||||||
}
|
}
|
||||||
@@ -548,8 +548,8 @@ public class Area implements IShape, Cloneable
|
|||||||
if (resultRules[resultRulesPos - 1] == PathIterator.SEG_LINETO) {
|
if (resultRules[resultRulesPos - 1] == PathIterator.SEG_LINETO) {
|
||||||
resultRules[resultRulesPos - 1] = PathIterator.SEG_CLOSE;
|
resultRules[resultRulesPos - 1] = PathIterator.SEG_CLOSE;
|
||||||
} else {
|
} else {
|
||||||
resultCoords[resultCoordPos++] = nextPoint.getX();
|
resultCoords[resultCoordPos++] = nextPoint.x();
|
||||||
resultCoords[resultCoordPos++] = nextPoint.getY();
|
resultCoords[resultCoordPos++] = nextPoint.y();
|
||||||
resultRules[resultRulesPos++] = PathIterator.SEG_CLOSE;
|
resultRules[resultRulesPos++] = PathIterator.SEG_CLOSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,9 +567,9 @@ public class Area implements IShape, Cloneable
|
|||||||
new int[] { coordsSize, area.coordsSize });
|
new int[] { coordsSize, area.coordsSize });
|
||||||
IntersectPoint[] intersectPoints = crossHelper.findCrossing();
|
IntersectPoint[] intersectPoints = crossHelper.findCrossing();
|
||||||
if (intersectPoints.length == 0) {
|
if (intersectPoints.length == 0) {
|
||||||
if (contains(area.getBounds())) {
|
if (contains(area.bounds())) {
|
||||||
copy(area, this);
|
copy(area, this);
|
||||||
} else if (!area.contains(getBounds())) {
|
} else if (!area.contains(bounds())) {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -587,11 +587,11 @@ public class Area implements IShape, Cloneable
|
|||||||
resultOffsets[resultRulesPos++] = resultCoordPos;
|
resultOffsets[resultRulesPos++] = resultCoordPos;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
resultCoords[resultCoordPos++] = point.getX();
|
resultCoords[resultCoordPos++] = point.x();
|
||||||
resultCoords[resultCoordPos++] = point.getY();
|
resultCoords[resultCoordPos++] = point.y();
|
||||||
resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
|
resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
|
||||||
resultOffsets[resultRulesPos++] = resultCoordPos - 2;
|
resultOffsets[resultRulesPos++] = resultCoordPos - 2;
|
||||||
int curIndex = point.getEndIndex(true);
|
int curIndex = point.endIndex(true);
|
||||||
|
|
||||||
if ((curIndex < 0) ||
|
if ((curIndex < 0) ||
|
||||||
(area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) == 0)) {
|
(area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) == 0)) {
|
||||||
@@ -602,11 +602,11 @@ public class Area implements IShape, Cloneable
|
|||||||
isCurrentArea = false;
|
isCurrentArea = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntersectPoint nextPoint = getNextIntersectPoint(intersectPoints, point, isCurrentArea);
|
IntersectPoint nextPoint = nextIntersectPoint(intersectPoints, point, isCurrentArea);
|
||||||
float[] coords = (isCurrentArea) ? this.coords : area.coords;
|
float[] coords = (isCurrentArea) ? this.coords : area.coords;
|
||||||
int offset = 2 * point.getEndIndex(isCurrentArea);
|
int offset = 2 * point.endIndex(isCurrentArea);
|
||||||
if ((offset >= 0) &&
|
if ((offset >= 0) &&
|
||||||
(nextPoint.getBegIndex(isCurrentArea) < point.getEndIndex(isCurrentArea))) {
|
(nextPoint.begIndex(isCurrentArea) < point.endIndex(isCurrentArea))) {
|
||||||
int coordSize = (isCurrentArea) ? this.coordsSize : area.coordsSize;
|
int coordSize = (isCurrentArea) ? this.coordsSize : area.coordsSize;
|
||||||
int length = coordSize - offset;
|
int length = coordSize - offset;
|
||||||
System.arraycopy(coords, offset, resultCoords, resultCoordPos, length);
|
System.arraycopy(coords, offset, resultCoords, resultCoordPos, length);
|
||||||
@@ -621,7 +621,7 @@ public class Area implements IShape, Cloneable
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (offset >= 0) {
|
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);
|
System.arraycopy(coords, offset, resultCoords, resultCoordPos, length);
|
||||||
|
|
||||||
for (int i = 0; i < length / 2; i++) {
|
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[] { rulesSize, area.rulesSize },
|
||||||
new int[][] { offsets, area.offsets });
|
new int[][] { offsets, area.offsets });
|
||||||
IntersectPoint[] intersectPoints = crossHelper.findCrossing();
|
IntersectPoint[] intersectPoints = crossHelper.findCrossing();
|
||||||
if (intersectPoints.length == 0 && contains(area.getBounds())) {
|
if (intersectPoints.length == 0 && contains(area.bounds())) {
|
||||||
copy(area, this);
|
copy(area, this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -668,9 +668,9 @@ public class Area implements IShape, Cloneable
|
|||||||
resultOffsets[resultRulesPos++] = resultCoordPos;
|
resultOffsets[resultRulesPos++] = resultCoordPos;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
resultCoords[resultCoordPos++] = point.getX();
|
resultCoords[resultCoordPos++] = point.x();
|
||||||
resultCoords[resultCoordPos++] = point.getY();
|
resultCoords[resultCoordPos++] = point.y();
|
||||||
int curIndex = offsets[point.getRuleIndex(true)] % coordsSize;
|
int curIndex = offsets[point.ruleIndex(true)] % coordsSize;
|
||||||
if (area.containsExact(coords[curIndex], coords[curIndex + 1]) == 0) {
|
if (area.containsExact(coords[curIndex], coords[curIndex + 1]) == 0) {
|
||||||
isCurrentArea = !isCurrentArea;
|
isCurrentArea = !isCurrentArea;
|
||||||
} else if (area.containsExact(coords[curIndex], coords[curIndex + 1]) > 0) {
|
} else if (area.containsExact(coords[curIndex], coords[curIndex + 1]) > 0) {
|
||||||
@@ -680,19 +680,19 @@ public class Area implements IShape, Cloneable
|
|||||||
}
|
}
|
||||||
|
|
||||||
IntersectPoint nextPoint = (isCurrentArea) ?
|
IntersectPoint nextPoint = (isCurrentArea) ?
|
||||||
getNextIntersectPoint(intersectPoints, point, isCurrentArea) :
|
nextIntersectPoint(intersectPoints, point, isCurrentArea) :
|
||||||
getPrevIntersectPoint(intersectPoints, point, isCurrentArea);
|
prevIntersectPoint(intersectPoints, point, isCurrentArea);
|
||||||
float[] coords = (isCurrentArea) ? this.coords : area.coords;
|
float[] coords = (isCurrentArea) ? this.coords : area.coords;
|
||||||
int[] offsets = (isCurrentArea) ? this.offsets : area.offsets;
|
int[] offsets = (isCurrentArea) ? this.offsets : area.offsets;
|
||||||
int[] rules = (isCurrentArea) ? this.rules : area.rules;
|
int[] rules = (isCurrentArea) ? this.rules : area.rules;
|
||||||
int offset = (isCurrentArea) ? point.getRuleIndex(isCurrentArea) :
|
int offset = (isCurrentArea) ? point.ruleIndex(isCurrentArea) :
|
||||||
nextPoint.getRuleIndex(isCurrentArea);
|
nextPoint.ruleIndex(isCurrentArea);
|
||||||
boolean isCopyUntilZero = false;
|
boolean isCopyUntilZero = false;
|
||||||
|
|
||||||
if (((isCurrentArea) &&
|
if (((isCurrentArea) &&
|
||||||
(point.getRuleIndex(isCurrentArea) > nextPoint.getRuleIndex(isCurrentArea))) ||
|
(point.ruleIndex(isCurrentArea) > nextPoint.ruleIndex(isCurrentArea))) ||
|
||||||
((!isCurrentArea) &&
|
((!isCurrentArea) &&
|
||||||
(nextPoint.getRuleIndex(isCurrentArea) > nextPoint.getRuleIndex(isCurrentArea)))) {
|
(nextPoint.ruleIndex(isCurrentArea) > nextPoint.ruleIndex(isCurrentArea)))) {
|
||||||
int rulesSize = (isCurrentArea) ? this.rulesSize : area.rulesSize;
|
int rulesSize = (isCurrentArea) ? this.rulesSize : area.rulesSize;
|
||||||
resultCoordPos = includeCoordsAndRules(
|
resultCoordPos = includeCoordsAndRules(
|
||||||
offset + 1, rulesSize, rules, offsets, resultRules, resultOffsets, resultCoords,
|
offset + 1, rulesSize, rules, offsets, resultRules, resultOffsets, resultCoords,
|
||||||
@@ -702,7 +702,7 @@ public class Area implements IShape, Cloneable
|
|||||||
isCopyUntilZero = true;
|
isCopyUntilZero = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int length = nextPoint.getRuleIndex(isCurrentArea) - offset + 1;
|
int length = nextPoint.ruleIndex(isCurrentArea) - offset + 1;
|
||||||
|
|
||||||
if (isCopyUntilZero) {
|
if (isCopyUntilZero) {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
@@ -740,7 +740,7 @@ public class Area implements IShape, Cloneable
|
|||||||
new int[] { coordsSize, area.coordsSize });
|
new int[] { coordsSize, area.coordsSize });
|
||||||
IntersectPoint[] intersectPoints = crossHelper.findCrossing();
|
IntersectPoint[] intersectPoints = crossHelper.findCrossing();
|
||||||
if (intersectPoints.length == 0) {
|
if (intersectPoints.length == 0) {
|
||||||
if (contains(area.getBounds())) {
|
if (contains(area.bounds())) {
|
||||||
copy(area, this);
|
copy(area, this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -763,18 +763,18 @@ public class Area implements IShape, Cloneable
|
|||||||
resultOffsets[resultRulesPos++] = resultCoordPos;
|
resultOffsets[resultRulesPos++] = resultCoordPos;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
resultCoords[resultCoordPos++] = point.getX();
|
resultCoords[resultCoordPos++] = point.x();
|
||||||
resultCoords[resultCoordPos++] = point.getY();
|
resultCoords[resultCoordPos++] = point.y();
|
||||||
resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
|
resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
|
||||||
resultOffsets[resultRulesPos++] = resultCoordPos - 2;
|
resultOffsets[resultRulesPos++] = resultCoordPos - 2;
|
||||||
int curIndex = point.getEndIndex(true);
|
int curIndex = point.endIndex(true);
|
||||||
|
|
||||||
if ((curIndex < 0) ||
|
if ((curIndex < 0) ||
|
||||||
(area.isVertex(coords[2 * curIndex], coords[2 * curIndex + 1]) &&
|
(area.isVertex(coords[2 * curIndex], coords[2 * curIndex + 1]) &&
|
||||||
crossHelper.containsPoint(new float[] { coords[2 * curIndex],
|
crossHelper.containsPoint(new float[] { coords[2 * curIndex],
|
||||||
coords[2 * curIndex + 1] }) &&
|
coords[2 * curIndex + 1] }) &&
|
||||||
(coords[2 * curIndex] != point.getX() ||
|
(coords[2 * curIndex] != point.x() ||
|
||||||
coords[2 * curIndex + 1] != point.getY()))) {
|
coords[2 * curIndex + 1] != point.y()))) {
|
||||||
isCurrentArea = !isCurrentArea;
|
isCurrentArea = !isCurrentArea;
|
||||||
} else if (area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) > 0) {
|
} else if (area.containsExact(coords[2 * curIndex], coords[2 * curIndex + 1]) > 0) {
|
||||||
isCurrentArea = false;
|
isCurrentArea = false;
|
||||||
@@ -793,18 +793,18 @@ public class Area implements IShape, Cloneable
|
|||||||
}
|
}
|
||||||
|
|
||||||
IntersectPoint nextPoint = (isCurrentArea) ?
|
IntersectPoint nextPoint = (isCurrentArea) ?
|
||||||
getNextIntersectPoint(intersectPoints, point, isCurrentArea) :
|
nextIntersectPoint(intersectPoints, point, isCurrentArea) :
|
||||||
getPrevIntersectPoint(intersectPoints, point, isCurrentArea);
|
prevIntersectPoint(intersectPoints, point, isCurrentArea);
|
||||||
float[] coords = (isCurrentArea) ? this.coords : area.coords;
|
float[] coords = (isCurrentArea) ? this.coords : area.coords;
|
||||||
|
|
||||||
int offset = (isCurrentArea) ? 2 * point.getEndIndex(isCurrentArea) :
|
int offset = (isCurrentArea) ? 2 * point.endIndex(isCurrentArea) :
|
||||||
2 * nextPoint.getEndIndex(isCurrentArea);
|
2 * nextPoint.endIndex(isCurrentArea);
|
||||||
|
|
||||||
if ((offset > 0) &&
|
if ((offset > 0) &&
|
||||||
(((isCurrentArea) &&
|
(((isCurrentArea) &&
|
||||||
(nextPoint.getBegIndex(isCurrentArea) < point.getEndIndex(isCurrentArea))) ||
|
(nextPoint.begIndex(isCurrentArea) < point.endIndex(isCurrentArea))) ||
|
||||||
((!isCurrentArea) &&
|
((!isCurrentArea) &&
|
||||||
(nextPoint.getEndIndex(isCurrentArea) < nextPoint.getBegIndex(isCurrentArea))))) {
|
(nextPoint.endIndex(isCurrentArea) < nextPoint.begIndex(isCurrentArea))))) {
|
||||||
|
|
||||||
int coordSize = (isCurrentArea) ? this.coordsSize : area.coordsSize;
|
int coordSize = (isCurrentArea) ? this.coordsSize : area.coordsSize;
|
||||||
int length = coordSize - offset;
|
int length = coordSize - offset;
|
||||||
@@ -829,8 +829,8 @@ public class Area implements IShape, Cloneable
|
|||||||
|
|
||||||
if (offset >= 0) {
|
if (offset >= 0) {
|
||||||
int length = (isCurrentArea) ?
|
int length = (isCurrentArea) ?
|
||||||
2 * nextPoint.getBegIndex(isCurrentArea) - offset + 2 :
|
2 * nextPoint.begIndex(isCurrentArea) - offset + 2 :
|
||||||
2 * point.getBegIndex(isCurrentArea) - offset + 2;
|
2 * point.begIndex(isCurrentArea) - offset + 2;
|
||||||
|
|
||||||
if (isCurrentArea) {
|
if (isCurrentArea) {
|
||||||
System.arraycopy(coords, offset, resultCoords, resultCoordPos, length);
|
System.arraycopy(coords, offset, resultCoords, resultCoordPos, length);
|
||||||
@@ -861,10 +861,10 @@ public class Area implements IShape, Cloneable
|
|||||||
rulesSize = resultRulesPos;
|
rulesSize = resultRulesPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntersectPoint getNextIntersectPoint (IntersectPoint[] iPoints,
|
private IntersectPoint nextIntersectPoint (IntersectPoint[] iPoints,
|
||||||
IntersectPoint isectPoint,
|
IntersectPoint isectPoint,
|
||||||
boolean isCurrentArea) {
|
boolean isCurrentArea) {
|
||||||
int endIndex = isectPoint.getEndIndex(isCurrentArea);
|
int endIndex = isectPoint.endIndex(isCurrentArea);
|
||||||
if (endIndex < 0) {
|
if (endIndex < 0) {
|
||||||
return iPoints[Math.abs(endIndex) - 1];
|
return iPoints[Math.abs(endIndex) - 1];
|
||||||
}
|
}
|
||||||
@@ -872,11 +872,11 @@ public class Area implements IShape, Cloneable
|
|||||||
IntersectPoint firstIsectPoint = null;
|
IntersectPoint firstIsectPoint = null;
|
||||||
IntersectPoint nextIsectPoint = null;
|
IntersectPoint nextIsectPoint = null;
|
||||||
for (IntersectPoint point : iPoints) {
|
for (IntersectPoint point : iPoints) {
|
||||||
int begIndex = point.getBegIndex(isCurrentArea);
|
int begIndex = point.begIndex(isCurrentArea);
|
||||||
if (begIndex >= 0) {
|
if (begIndex >= 0) {
|
||||||
if (firstIsectPoint == null) {
|
if (firstIsectPoint == null) {
|
||||||
firstIsectPoint = point;
|
firstIsectPoint = point;
|
||||||
} else if (begIndex < firstIsectPoint.getBegIndex(isCurrentArea)) {
|
} else if (begIndex < firstIsectPoint.begIndex(isCurrentArea)) {
|
||||||
firstIsectPoint = point;
|
firstIsectPoint = point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -884,7 +884,7 @@ public class Area implements IShape, Cloneable
|
|||||||
if (endIndex <= begIndex) {
|
if (endIndex <= begIndex) {
|
||||||
if (nextIsectPoint == null) {
|
if (nextIsectPoint == null) {
|
||||||
nextIsectPoint = point;
|
nextIsectPoint = point;
|
||||||
} else if (begIndex < nextIsectPoint.getBegIndex(isCurrentArea)) {
|
} else if (begIndex < nextIsectPoint.begIndex(isCurrentArea)) {
|
||||||
nextIsectPoint = point;
|
nextIsectPoint = point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -893,10 +893,10 @@ public class Area implements IShape, Cloneable
|
|||||||
return (nextIsectPoint != null) ? nextIsectPoint : firstIsectPoint;
|
return (nextIsectPoint != null) ? nextIsectPoint : firstIsectPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntersectPoint getPrevIntersectPoint (IntersectPoint[] iPoints,
|
private IntersectPoint prevIntersectPoint (IntersectPoint[] iPoints,
|
||||||
IntersectPoint isectPoint,
|
IntersectPoint isectPoint,
|
||||||
boolean isCurrentArea) {
|
boolean isCurrentArea) {
|
||||||
int begIndex = isectPoint.getBegIndex(isCurrentArea);
|
int begIndex = isectPoint.begIndex(isCurrentArea);
|
||||||
if (begIndex < 0) {
|
if (begIndex < 0) {
|
||||||
return iPoints[Math.abs(begIndex) - 1];
|
return iPoints[Math.abs(begIndex) - 1];
|
||||||
}
|
}
|
||||||
@@ -904,11 +904,11 @@ public class Area implements IShape, Cloneable
|
|||||||
IntersectPoint firstIsectPoint = null;
|
IntersectPoint firstIsectPoint = null;
|
||||||
IntersectPoint predIsectPoint = null;
|
IntersectPoint predIsectPoint = null;
|
||||||
for (IntersectPoint point : iPoints) {
|
for (IntersectPoint point : iPoints) {
|
||||||
int endIndex = point.getEndIndex(isCurrentArea);
|
int endIndex = point.endIndex(isCurrentArea);
|
||||||
if (endIndex >= 0) {
|
if (endIndex >= 0) {
|
||||||
if (firstIsectPoint == null) {
|
if (firstIsectPoint == null) {
|
||||||
firstIsectPoint = point;
|
firstIsectPoint = point;
|
||||||
} else if (endIndex < firstIsectPoint.getEndIndex(isCurrentArea)) {
|
} else if (endIndex < firstIsectPoint.endIndex(isCurrentArea)) {
|
||||||
firstIsectPoint = point;
|
firstIsectPoint = point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -916,7 +916,7 @@ public class Area implements IShape, Cloneable
|
|||||||
if (endIndex <= begIndex) {
|
if (endIndex <= begIndex) {
|
||||||
if (predIsectPoint == null) {
|
if (predIsectPoint == null) {
|
||||||
predIsectPoint = point;
|
predIsectPoint = point;
|
||||||
} else if (endIndex > predIsectPoint.getEndIndex(isCurrentArea)) {
|
} else if (endIndex > predIsectPoint.endIndex(isCurrentArea)) {
|
||||||
predIsectPoint = point;
|
predIsectPoint = point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -976,7 +976,7 @@ public class Area implements IShape, Cloneable
|
|||||||
resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
|
resultRules[resultRulesPos] = PathIterator.SEG_LINETO;
|
||||||
resultOffsets[resultRulesPos++] = resultCoordPos + 2;
|
resultOffsets[resultRulesPos++] = resultCoordPos + 2;
|
||||||
boolean isLeft = CrossingHelper.compare(
|
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) {
|
if (way || !isLeft) {
|
||||||
temp[coordsCount++] = coords[index];
|
temp[coordsCount++] = coords[index];
|
||||||
temp[coordsCount++] = coords[index + 1];
|
temp[coordsCount++] = coords[index + 1];
|
||||||
@@ -990,13 +990,13 @@ public class Area implements IShape, Cloneable
|
|||||||
coords[index - 2], coords[index - 1],
|
coords[index - 2], coords[index - 1],
|
||||||
coords[index], coords[index + 1], coords[index + 2], coords[index + 3] };
|
coords[index], coords[index + 1], coords[index + 2], coords[index + 3] };
|
||||||
isLeft = CrossingHelper.compare(
|
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)) {
|
if ((!additional) && (operation == 0 || operation == 2)) {
|
||||||
isLeft = !isLeft;
|
isLeft = !isLeft;
|
||||||
way = false;
|
way = false;
|
||||||
}
|
}
|
||||||
GeometryUtil.subQuad(coefs, point.getParam(isCurrentArea), isLeft);
|
GeometryUtil.subQuad(coefs, point.param(isCurrentArea), isLeft);
|
||||||
|
|
||||||
if (way || isLeft) {
|
if (way || isLeft) {
|
||||||
temp[coordsCount++] = coefs[2];
|
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 + 1], coords[index + 2], coords[index + 3],
|
||||||
coords[index + 4], coords[index + 5] };
|
coords[index + 4], coords[index + 5] };
|
||||||
isLeft = CrossingHelper.compare(
|
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;
|
||||||
GeometryUtil.subCubic(coefs, point.getParam(isCurrentArea), !isLeft);
|
GeometryUtil.subCubic(coefs, point.param(isCurrentArea), !isLeft);
|
||||||
|
|
||||||
if (isLeft) {
|
if (isLeft) {
|
||||||
System.arraycopy(coefs, 2, temp, coordsCount, 6);
|
System.arraycopy(coefs, 2, temp, coordsCount, 6);
|
||||||
@@ -1048,7 +1048,7 @@ public class Area implements IShape, Cloneable
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int containsExact (float x, float y) {
|
private int containsExact (float x, float y) {
|
||||||
PathIterator pi = getPathIterator(null);
|
PathIterator pi = pathIterator(null);
|
||||||
int crossCount = Crossing.crossPath(pi, x, y);
|
int crossCount = Crossing.crossPath(pi, x, y);
|
||||||
if (Crossing.isInsideEvenOdd(crossCount)) {
|
if (Crossing.isInsideEvenOdd(crossCount)) {
|
||||||
return 1;
|
return 1;
|
||||||
@@ -1062,7 +1062,7 @@ public class Area implements IShape, Cloneable
|
|||||||
float moveX = -1;
|
float moveX = -1;
|
||||||
float moveY = -1;
|
float moveY = -1;
|
||||||
|
|
||||||
for (pi = getPathIterator(null); !pi.isDone(); pi.next()) {
|
for (pi = pathIterator(null); !pi.isDone(); pi.next()) {
|
||||||
rule = pi.currentSegment(segmentCoords);
|
rule = pi.currentSegment(segmentCoords);
|
||||||
switch (rule) {
|
switch (rule) {
|
||||||
case PathIterator.SEG_MOVETO:
|
case PathIterator.SEG_MOVETO:
|
||||||
@@ -1123,9 +1123,9 @@ public class Area implements IShape, Cloneable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getAreaBoundsSquare () {
|
private float areaBoundsSquare () {
|
||||||
Rectangle bounds = getBounds();
|
Rectangle bounds = bounds();
|
||||||
return bounds.getHeight() * bounds.getWidth();
|
return bounds.height() * bounds.width();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isVertex (float x, float y) {
|
private boolean isVertex (float x, float y) {
|
||||||
@@ -1167,7 +1167,7 @@ public class Area implements IShape, Cloneable
|
|||||||
this.transform = t;
|
this.transform = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getWindingRule () {
|
@Override public int windingRule () {
|
||||||
return WIND_EVEN_ODD;
|
return WIND_EVEN_ODD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -472,10 +472,10 @@ class Crossing
|
|||||||
* Returns how many times a ray from point (x,y) crosses a shape.
|
* Returns how many times a ray from point (x,y) crosses a shape.
|
||||||
*/
|
*/
|
||||||
public static int crossShape (IShape s, float x, float y) {
|
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 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
|
* 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) {
|
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 0;
|
||||||
}
|
}
|
||||||
return intersectPath(s.getPathIterator(null), x, y, w, h);
|
return intersectPath(s.pathIterator(null), x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -177,8 +177,8 @@ class CrossingHelper
|
|||||||
IntersectPoint ip;
|
IntersectPoint ip;
|
||||||
for (Iterator<IntersectPoint> i = isectPoints.iterator(); i.hasNext();) {
|
for (Iterator<IntersectPoint> i = isectPoints.iterator(); i.hasNext();) {
|
||||||
ip = i.next();
|
ip = i.next();
|
||||||
if ((initBegin == ip.getBegIndex(true)) && (initEnd == ip.getEndIndex(true))) {
|
if ((initBegin == ip.begIndex(true)) && (initEnd == ip.endIndex(true))) {
|
||||||
if (compare(ip.getX(), ip.getY(), point[0], point[1]) > 0) {
|
if (compare(ip.x(), ip.y(), point[0], point[1]) > 0) {
|
||||||
initEnd = -(isectPoints.indexOf(ip) + 1);
|
initEnd = -(isectPoints.indexOf(ip) + 1);
|
||||||
ip.setBegIndex1(-(isectPoints.size() + 1));
|
ip.setBegIndex1(-(isectPoints.size() + 1));
|
||||||
} else {
|
} else {
|
||||||
@@ -187,8 +187,8 @@ class CrossingHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((addBegin == ip.getBegIndex(false)) && (addEnd == ip.getEndIndex(false))) {
|
if ((addBegin == ip.begIndex(false)) && (addEnd == ip.endIndex(false))) {
|
||||||
if (compare(ip.getX(), ip.getY(), point[0], point[1]) > 0) {
|
if (compare(ip.x(), ip.y(), point[0], point[1]) > 0) {
|
||||||
addEnd = -(isectPoints.indexOf(ip) + 1);
|
addEnd = -(isectPoints.indexOf(ip) + 1);
|
||||||
ip.setBegIndex2(-(isectPoints.size() + 1));
|
ip.setBegIndex2(-(isectPoints.size() + 1));
|
||||||
} else {
|
} else {
|
||||||
@@ -256,7 +256,7 @@ class CrossingHelper
|
|||||||
IntersectPoint ipoint;
|
IntersectPoint ipoint;
|
||||||
for (Iterator<IntersectPoint> i = isectPoints.iterator(); i.hasNext();) {
|
for (Iterator<IntersectPoint> i = isectPoints.iterator(); i.hasNext();) {
|
||||||
ipoint = i.next();
|
ipoint = i.next();
|
||||||
if (ipoint.getX() == point[0] && ipoint.getY() == point[1]) {
|
if (ipoint.x() == point[0] && ipoint.y() == point[1]) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ public class CubicCurve extends AbstractCubicCurve implements Serializable
|
|||||||
* Configures the start, control and end points for this curve.
|
* Configures the start, control and end points for this curve.
|
||||||
*/
|
*/
|
||||||
public void setCurve (IPoint p1, IPoint cp1, IPoint cp2, IPoint p2) {
|
public void setCurve (IPoint p1, IPoint cp1, IPoint cp2, IPoint p2) {
|
||||||
setCurve(p1.getX(), p1.getY(), cp1.getX(), cp1.getY(),
|
setCurve(p1.x(), p1.y(), cp1.x(), cp1.y(),
|
||||||
cp2.getX(), cp2.getY(), p2.getX(), p2.getY());
|
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.
|
* specified offset in the {@code points} array.
|
||||||
*/
|
*/
|
||||||
public void setCurve (IPoint[] points, int offset) {
|
public void setCurve (IPoint[] points, int offset) {
|
||||||
setCurve(points[offset + 0].getX(), points[offset + 0].getY(),
|
setCurve(points[offset + 0].x(), points[offset + 0].y(),
|
||||||
points[offset + 1].getX(), points[offset + 1].getY(),
|
points[offset + 1].x(), points[offset + 1].y(),
|
||||||
points[offset + 2].getX(), points[offset + 2].getY(),
|
points[offset + 2].x(), points[offset + 2].y(),
|
||||||
points[offset + 3].getX(), points[offset + 3].getY());
|
points[offset + 3].x(), points[offset + 3].y());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -97,47 +97,47 @@ public class CubicCurve extends AbstractCubicCurve implements Serializable
|
|||||||
* curve.
|
* curve.
|
||||||
*/
|
*/
|
||||||
public void setCurve (ICubicCurve curve) {
|
public void setCurve (ICubicCurve curve) {
|
||||||
setCurve(curve.getX1(), curve.getY1(), curve.getCtrlX1(), curve.getCtrlY1(),
|
setCurve(curve.x1(), curve.y1(), curve.ctrlX1(), curve.ctrlY1(),
|
||||||
curve.getCtrlX2(), curve.getCtrlY2(), curve.getX2(), curve.getY2());
|
curve.ctrlX2(), curve.ctrlY2(), curve.x2(), curve.y2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public float getX1 () {
|
public float x1 () {
|
||||||
return x1;
|
return x1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public float getY1 () {
|
public float y1 () {
|
||||||
return y1;
|
return y1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public float getCtrlX1 () {
|
public float ctrlX1 () {
|
||||||
return ctrlx1;
|
return ctrlx1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public float getCtrlY1 () {
|
public float ctrlY1 () {
|
||||||
return ctrly1;
|
return ctrly1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public float getCtrlX2 () {
|
public float ctrlX2 () {
|
||||||
return ctrlx2;
|
return ctrlx2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public float getCtrlY2 () {
|
public float ctrlY2 () {
|
||||||
return ctrly2;
|
return ctrly2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public float getX2 () {
|
public float x2 () {
|
||||||
return x2;
|
return x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ICubicCurve
|
@Override // from interface ICubicCurve
|
||||||
public float getY2 () {
|
public float y2 () {
|
||||||
return y2;
|
return y2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,34 +9,34 @@ package pythagoras.f;
|
|||||||
*/
|
*/
|
||||||
public class CubicCurves
|
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) {
|
float ctrlx2, float ctrly2, float x2, float y2) {
|
||||||
return Math.max(Lines.pointSegDistSq(ctrlx1, ctrly1, x1, y1, x2, y2),
|
return Math.max(Lines.pointSegDistSq(ctrlx1, ctrly1, x1, y1, x2, y2),
|
||||||
Lines.pointSegDistSq(ctrlx2, ctrly2, x1, y1, x2, y2));
|
Lines.pointSegDistSq(ctrlx2, ctrly2, x1, y1, x2, y2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float getFlatnessSq (float[] coords, int offset) {
|
public static float flatnessSq (float[] coords, int offset) {
|
||||||
return getFlatnessSq(coords[offset + 0], coords[offset + 1], coords[offset + 2],
|
return flatnessSq(coords[offset + 0], coords[offset + 1], coords[offset + 2],
|
||||||
coords[offset + 3], coords[offset + 4], coords[offset + 5],
|
coords[offset + 3], coords[offset + 4], coords[offset + 5],
|
||||||
coords[offset + 6], coords[offset + 7]);
|
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) {
|
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) {
|
public static float flatness (float[] coords, int offset) {
|
||||||
return getFlatness(coords[offset + 0], coords[offset + 1], coords[offset + 2],
|
return flatness(coords[offset + 0], coords[offset + 1], coords[offset + 2],
|
||||||
coords[offset + 3], coords[offset + 4], coords[offset + 5],
|
coords[offset + 3], coords[offset + 4], coords[offset + 5],
|
||||||
coords[offset + 6], coords[offset + 7]);
|
coords[offset + 6], coords[offset + 7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void subdivide (ICubicCurve src, CubicCurve left, CubicCurve right) {
|
public static void subdivide (ICubicCurve src, CubicCurve left, CubicCurve right) {
|
||||||
float x1 = src.getX1(), y1 = src.getY1();
|
float x1 = src.x1(), y1 = src.y1();
|
||||||
float cx1 = src.getCtrlX1(), cy1 = src.getCtrlY1();
|
float cx1 = src.ctrlX1(), cy1 = src.ctrlY1();
|
||||||
float cx2 = src.getCtrlX2(), cy2 = src.getCtrlY2();
|
float cx2 = src.ctrlX2(), cy2 = src.ctrlY2();
|
||||||
float x2 = src.getX2(), y2 = src.getY2();
|
float x2 = src.x2(), y2 = src.y2();
|
||||||
float cx = (cx1 + cx2) / 2f, cy = (cy1 + cy2) / 2f;
|
float cx = (cx1 + cx2) / 2f, cy = (cy1 + cy2) / 2f;
|
||||||
cx1 = (x1 + cx1) / 2f;
|
cx1 = (x1 + cx1) / 2f;
|
||||||
cy1 = (y1 + cy1) / 2f;
|
cy1 = (y1 + cy1) / 2f;
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ class CurveCrossingHelper
|
|||||||
|
|
||||||
for (int i = 0; i < rulesSizes[0]; i++) {
|
for (int i = 0; i < rulesSizes[0]; i++) {
|
||||||
rule1 = rules[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++) {
|
for (int j = 0; j < rulesSizes[1]; j++) {
|
||||||
ipCount = 0;
|
ipCount = 0;
|
||||||
rule2 = rules[1][j];
|
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)) &&
|
if (((rule1 == PathIterator.SEG_LINETO) || (rule1 == PathIterator.SEG_CLOSE)) &&
|
||||||
((rule2 == PathIterator.SEG_LINETO) || (rule2 == PathIterator.SEG_CLOSE))) {
|
((rule2 == PathIterator.SEG_LINETO) || (rule2 == PathIterator.SEG_CLOSE))) {
|
||||||
ipCount = GeometryUtil.intersectLinesWithParams(
|
ipCount = GeometryUtil.intersectLinesWithParams(
|
||||||
@@ -167,9 +167,9 @@ class CurveCrossingHelper
|
|||||||
for (Iterator<IntersectPoint> iter = isectPoints.iterator();
|
for (Iterator<IntersectPoint> iter = isectPoints.iterator();
|
||||||
iter.hasNext();) {
|
iter.hasNext();) {
|
||||||
ip = iter.next();
|
ip = iter.next();
|
||||||
if ((begIndex1 == ip.getBegIndex(true)) &&
|
if ((begIndex1 == ip.begIndex(true)) &&
|
||||||
(endIndex1 == ip.getEndIndex(true))) {
|
(endIndex1 == ip.endIndex(true))) {
|
||||||
if (ip.getParam(true) > params[2 * k]) {
|
if (ip.param(true) > params[2 * k]) {
|
||||||
endIndex1 = -(isectPoints.indexOf(ip) + 1);
|
endIndex1 = -(isectPoints.indexOf(ip) + 1);
|
||||||
ip.setBegIndex1(-(isectPoints.size() + 1));
|
ip.setBegIndex1(-(isectPoints.size() + 1));
|
||||||
} else {
|
} else {
|
||||||
@@ -178,9 +178,9 @@ class CurveCrossingHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((begIndex2 == ip.getBegIndex(false)) &&
|
if ((begIndex2 == ip.begIndex(false)) &&
|
||||||
(endIndex2 == ip.getEndIndex(false))) {
|
(endIndex2 == ip.endIndex(false))) {
|
||||||
if (ip.getParam(false) > params[2 * k + 1]) {
|
if (ip.param(false) > params[2 * k + 1]) {
|
||||||
endIndex2 = -(isectPoints.indexOf(ip) + 1);
|
endIndex2 = -(isectPoints.indexOf(ip) + 1);
|
||||||
ip.setBegIndex2(-(isectPoints.size() + 1));
|
ip.setBegIndex2(-(isectPoints.size() + 1));
|
||||||
} else {
|
} else {
|
||||||
@@ -209,7 +209,7 @@ class CurveCrossingHelper
|
|||||||
return isectPoints.toArray(new IntersectPoint[isectPoints.size()]);
|
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;
|
int endIndex = 0;
|
||||||
|
|
||||||
switch (rules[areaIndex][index]) {
|
switch (rules[areaIndex][index]) {
|
||||||
@@ -263,8 +263,8 @@ class CurveCrossingHelper
|
|||||||
IntersectPoint ipoint;
|
IntersectPoint ipoint;
|
||||||
for (Iterator<IntersectPoint> i = isectPoints.iterator(); i.hasNext();) {
|
for (Iterator<IntersectPoint> i = isectPoints.iterator(); i.hasNext();) {
|
||||||
ipoint = i.next();
|
ipoint = i.next();
|
||||||
if ((Math.abs(ipoint.getX() - x) < Math.pow(10, -6)) &&
|
if ((Math.abs(ipoint.x() - x) < Math.pow(10, -6)) &&
|
||||||
(Math.abs(ipoint.getY() - y) < Math.pow(10, -6))) {
|
(Math.abs(ipoint.y() - y) < Math.pow(10, -6))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class Dimension extends AbstractDimension implements Serializable
|
|||||||
* Creates a dimension with width and height equal to the supplied dimension.
|
* Creates a dimension with width and height equal to the supplied dimension.
|
||||||
*/
|
*/
|
||||||
public Dimension (IDimension d) {
|
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.
|
* Sets the magnitudes of this dimension to be equal to the supplied dimension.
|
||||||
*/
|
*/
|
||||||
public void setSize (IDimension d) {
|
public void setSize (IDimension d) {
|
||||||
setSize(d.getWidth(), d.getHeight());
|
setSize(d.width(), d.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IDimension
|
@Override // from interface IDimension
|
||||||
public float getWidth () {
|
public float width () {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IDimension
|
@Override // from interface IDimension
|
||||||
public float getHeight () {
|
public float height () {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,22 +37,22 @@ public class Ellipse extends AbstractEllipse implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangularShape
|
@Override // from interface IRectangularShape
|
||||||
public float getX () {
|
public float x () {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangularShape
|
@Override // from interface IRectangularShape
|
||||||
public float getY () {
|
public float y () {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangularShape
|
@Override // from interface IRectangularShape
|
||||||
public float getWidth () {
|
public float width () {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangularShape
|
@Override // from interface IRectangularShape
|
||||||
public float getHeight () {
|
public float height () {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,18 +34,18 @@ class FlatteningPathIterator implements PathIterator
|
|||||||
this.bufIndex = bufSize;
|
this.bufIndex = bufSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getFlatness () {
|
public float flatness () {
|
||||||
return flatness;
|
return flatness;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRecursionLimit () {
|
public int recursionLimit () {
|
||||||
return bufLimit;
|
return bufLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
// from interface PathIterator
|
// from interface PathIterator
|
||||||
public int getWindingRule () {
|
public int windingRule () {
|
||||||
return p.getWindingRule();
|
return p.windingRule();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -81,7 +81,7 @@ class FlatteningPathIterator implements PathIterator
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Calculates flat path points for the current segment of the source shape. Line segment is
|
/** 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
|
* 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
|
* 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
|
* buffer points. The smaller the flatness the bigger the series. Every currentSegment() call
|
||||||
@@ -109,7 +109,7 @@ class FlatteningPathIterator implements PathIterator
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (bufSubdiv < bufLimit) {
|
while (bufSubdiv < bufLimit) {
|
||||||
if (QuadCurves.getFlatnessSq(buf, bufIndex) < flatness2) {
|
if (QuadCurves.flatnessSq(buf, bufIndex) < flatness2) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ class FlatteningPathIterator implements PathIterator
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (bufSubdiv < bufLimit) {
|
while (bufSubdiv < bufLimit) {
|
||||||
if (CubicCurves.getFlatnessSq(buf, bufIndex) < flatness2) {
|
if (CubicCurves.flatnessSq(buf, bufIndex) < flatness2) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ public class FloatMath
|
|||||||
* Returns the (shortest) distance between two angles, assuming that both angles are in
|
* Returns the (shortest) distance between two angles, assuming that both angles are in
|
||||||
* [-pi, +pi].
|
* [-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);
|
float ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2);
|
||||||
return Math.min(Math.abs(a1 - a2), Math.abs(ma1 - ma2));
|
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
|
* Returns the (shortest) difference between two angles, assuming that both angles are in
|
||||||
* [-pi, +pi].
|
* [-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 ma1 = mirrorAngle(a1), ma2 = mirrorAngle(a2);
|
||||||
float diff = a1 - a2, mdiff = ma2 - ma1;
|
float diff = a1 - a2, mdiff = ma2 - ma1;
|
||||||
|
|||||||
@@ -22,31 +22,31 @@ public interface IArc extends IRectangularShape, Cloneable
|
|||||||
int PIE = 2;
|
int PIE = 2;
|
||||||
|
|
||||||
/** Returns the type of this arc: {@link #OPEN}, etc. */
|
/** Returns the type of this arc: {@link #OPEN}, etc. */
|
||||||
int getArcType ();
|
int arcType ();
|
||||||
|
|
||||||
/** Returns the starting angle of this arc. */
|
/** Returns the starting angle of this arc. */
|
||||||
float getAngleStart ();
|
float angleStart ();
|
||||||
|
|
||||||
/** Returns the angular extent of this arc. */
|
/** 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
|
/** Returns the intersection of the ray from the center (defined by the starting angle) and the
|
||||||
* elliptical boundary of the arc. */
|
* 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
|
/** Writes the intersection of the ray from the center (defined by the starting angle) and the
|
||||||
* elliptical boundary of the arc into {@code target}.
|
* elliptical boundary of the arc into {@code target}.
|
||||||
* @return the supplied point. */
|
* @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
|
/** 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. */
|
* 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
|
/** 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}.
|
* angular extent of the arc) and the elliptical boundary of the arc into {@code target}.
|
||||||
* @return the supplied point. */
|
* @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. */
|
/** Returns whether the specified angle is within the angular extents of this arc. */
|
||||||
boolean containsAngle (float angle);
|
boolean containsAngle (float angle);
|
||||||
|
|||||||
@@ -10,48 +10,48 @@ package pythagoras.f;
|
|||||||
public interface ICubicCurve extends IShape, Cloneable
|
public interface ICubicCurve extends IShape, Cloneable
|
||||||
{
|
{
|
||||||
/** Returns the x-coordinate of the start of this curve. */
|
/** Returns the x-coordinate of the start of this curve. */
|
||||||
float getX1 ();
|
float x1 ();
|
||||||
|
|
||||||
/** Returns the y-coordinate of the start of this curve. */
|
/** Returns the y-coordinate of the start of this curve. */
|
||||||
float getY1 ();
|
float y1 ();
|
||||||
|
|
||||||
/** Returns the x-coordinate of the first control point. */
|
/** Returns the x-coordinate of the first control point. */
|
||||||
float getCtrlX1 ();
|
float ctrlX1 ();
|
||||||
|
|
||||||
/** Returns the y-coordinate of the first control point. */
|
/** Returns the y-coordinate of the first control point. */
|
||||||
float getCtrlY1 ();
|
float ctrlY1 ();
|
||||||
|
|
||||||
/** Returns the x-coordinate of the second control point. */
|
/** Returns the x-coordinate of the second control point. */
|
||||||
float getCtrlX2 ();
|
float ctrlX2 ();
|
||||||
|
|
||||||
/** Returns the y-coordinate of the second control point. */
|
/** Returns the y-coordinate of the second control point. */
|
||||||
float getCtrlY2 ();
|
float ctrlY2 ();
|
||||||
|
|
||||||
/** Returns the x-coordinate of the end of this curve. */
|
/** Returns the x-coordinate of the end of this curve. */
|
||||||
float getX2 ();
|
float x2 ();
|
||||||
|
|
||||||
/** Returns the y-coordinate of the end of this curve. */
|
/** Returns the y-coordinate of the end of this curve. */
|
||||||
float getY2 ();
|
float y2 ();
|
||||||
|
|
||||||
/** Returns a copy of the starting point of this curve. */
|
/** 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. */
|
/** 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. */
|
/** 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. */
|
/** 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
|
/** Returns the square of the flatness (maximum distance of a control point from the line
|
||||||
* connecting the end points) of this curve. */
|
* 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
|
/** Returns the flatness (maximum distance of a control point from the line connecting the end
|
||||||
* points) of this curve. */
|
* points) of this curve. */
|
||||||
float getFlatness ();
|
float flatness ();
|
||||||
|
|
||||||
/** Subdivides this curve and stores the results into {@code left} and {@code right}. */
|
/** Subdivides this curve and stores the results into {@code left} and {@code right}. */
|
||||||
void subdivide (CubicCurve left, CubicCurve right);
|
void subdivide (CubicCurve left, CubicCurve right);
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ public interface IDimension extends Cloneable
|
|||||||
/**
|
/**
|
||||||
* Returns the magnitude in the x-dimension.
|
* Returns the magnitude in the x-dimension.
|
||||||
*/
|
*/
|
||||||
float getWidth ();
|
float width ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the magnitude in the y-dimension.
|
* Returns the magnitude in the y-dimension.
|
||||||
*/
|
*/
|
||||||
float getHeight ();
|
float height ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a mutable copy of this dimension.
|
* Returns a mutable copy of this dimension.
|
||||||
|
|||||||
@@ -10,30 +10,30 @@ package pythagoras.f;
|
|||||||
public interface ILine extends IShape, Cloneable
|
public interface ILine extends IShape, Cloneable
|
||||||
{
|
{
|
||||||
/** Returns the x-coordinate of the start of this line. */
|
/** Returns the x-coordinate of the start of this line. */
|
||||||
float getX1 ();
|
float x1 ();
|
||||||
|
|
||||||
/** Returns the y-coordinate of the start of this line. */
|
/** Returns the y-coordinate of the start of this line. */
|
||||||
float getY1 ();
|
float y1 ();
|
||||||
|
|
||||||
/** Returns the x-coordinate of the end of this line. */
|
/** Returns the x-coordinate of the end of this line. */
|
||||||
float getX2 ();
|
float x2 ();
|
||||||
|
|
||||||
/** Returns the y-coordinate of the end of this line. */
|
/** Returns the y-coordinate of the end of this line. */
|
||||||
float getY2 ();
|
float y2 ();
|
||||||
|
|
||||||
/** Returns a copy of the starting point of this line. */
|
/** Returns a copy of the starting point of this line. */
|
||||||
Point getP1 ();
|
Point p1 ();
|
||||||
|
|
||||||
/** Initializes the supplied point with this line's starting point.
|
/** Initializes the supplied point with this line's starting point.
|
||||||
* @return the supplied point. */
|
* @return the supplied point. */
|
||||||
Point getP1 (Point target);
|
Point p1 (Point target);
|
||||||
|
|
||||||
/** Returns a copy of the ending point of this line. */
|
/** Returns a copy of the ending point of this line. */
|
||||||
Point getP2 ();
|
Point p2 ();
|
||||||
|
|
||||||
/** Initializes the supplied point with this line's ending point.
|
/** Initializes the supplied point with this line's ending point.
|
||||||
* @return the supplied 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
|
/** Returns the square of the distance from the specified point to the line defined by this
|
||||||
* line segment. */
|
* line segment. */
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ package pythagoras.f;
|
|||||||
public interface IPoint extends Cloneable
|
public interface IPoint extends Cloneable
|
||||||
{
|
{
|
||||||
/** Returns this point's x-coordinate. */
|
/** Returns this point's x-coordinate. */
|
||||||
float getX ();
|
float x ();
|
||||||
|
|
||||||
/** Returns this point's y-coordinate. */
|
/** Returns this point's y-coordinate. */
|
||||||
float getY ();
|
float y ();
|
||||||
|
|
||||||
/** Returns the squared Euclidian distance between this point and the specified point. */
|
/** Returns the squared Euclidian distance between this point and the specified point. */
|
||||||
float distanceSq (float px, float py);
|
float distanceSq (float px, float py);
|
||||||
|
|||||||
@@ -10,39 +10,39 @@ package pythagoras.f;
|
|||||||
public interface IQuadCurve extends IShape, Cloneable
|
public interface IQuadCurve extends IShape, Cloneable
|
||||||
{
|
{
|
||||||
/** Returns the x-coordinate of the start of this curve. */
|
/** Returns the x-coordinate of the start of this curve. */
|
||||||
float getX1 ();
|
float x1 ();
|
||||||
|
|
||||||
/** Returns the y-coordinate of the start of this curve. */
|
/** Returns the y-coordinate of the start of this curve. */
|
||||||
float getY1 ();
|
float y1 ();
|
||||||
|
|
||||||
/** Returns the x-coordinate of the control point. */
|
/** Returns the x-coordinate of the control point. */
|
||||||
float getCtrlX ();
|
float ctrlX ();
|
||||||
|
|
||||||
/** Returns the y-coordinate of the control point. */
|
/** Returns the y-coordinate of the control point. */
|
||||||
float getCtrlY ();
|
float ctrlY ();
|
||||||
|
|
||||||
/** Returns the x-coordinate of the end of this curve. */
|
/** Returns the x-coordinate of the end of this curve. */
|
||||||
float getX2 ();
|
float x2 ();
|
||||||
|
|
||||||
/** Returns the y-coordinate of the end of this curve. */
|
/** Returns the y-coordinate of the end of this curve. */
|
||||||
float getY2 ();
|
float y2 ();
|
||||||
|
|
||||||
/** Returns a copy of the starting point of this curve. */
|
/** Returns a copy of the starting point of this curve. */
|
||||||
Point getP1 ();
|
Point p1 ();
|
||||||
|
|
||||||
/** Returns a copy of the control point of this curve. */
|
/** Returns a copy of the control point of this curve. */
|
||||||
Point getCtrlP ();
|
Point ctrlP ();
|
||||||
|
|
||||||
/** Returns a copy of the ending point of this curve. */
|
/** 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
|
/** Returns the square of the flatness (maximum distance of a control point from the line
|
||||||
* connecting the end points) of this curve. */
|
* 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
|
/** Returns the flatness (maximum distance of a control point from the line connecting the end
|
||||||
* points) of this curve. */
|
* points) of this curve. */
|
||||||
float getFlatness ();
|
float flatness ();
|
||||||
|
|
||||||
/** Subdivides this curve and stores the results into {@code left} and {@code right}. */
|
/** Subdivides this curve and stores the results into {@code left} and {@code right}. */
|
||||||
void subdivide (QuadCurve left, QuadCurve right);
|
void subdivide (QuadCurve left, QuadCurve right);
|
||||||
|
|||||||
@@ -24,18 +24,18 @@ public interface IRectangle extends IRectangularShape, Cloneable
|
|||||||
int OUT_BOTTOM = 8;
|
int OUT_BOTTOM = 8;
|
||||||
|
|
||||||
/** Returns a copy of this rectangle's upper-left corner. */
|
/** 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.
|
/** Initializes the supplied point with this rectangle's upper-left corner.
|
||||||
* @return the supplied point. */
|
* @return the supplied point. */
|
||||||
Point getLocation (Point target);
|
Point location (Point target);
|
||||||
|
|
||||||
/** Returns a copy of this rectangle's size. */
|
/** Returns a copy of this rectangle's size. */
|
||||||
Dimension getSize ();
|
Dimension size ();
|
||||||
|
|
||||||
/** Initializes the supplied dimension with this rectangle's size.
|
/** Initializes the supplied dimension with this rectangle's size.
|
||||||
* @return the supplied dimension. */
|
* @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
|
/** Returns the intersection of the specified rectangle and this rectangle (i.e. the largest
|
||||||
* rectangle contained in both this and the specified rectangle). */
|
* rectangle contained in both this and the specified rectangle). */
|
||||||
|
|||||||
@@ -12,48 +12,48 @@ package pythagoras.f;
|
|||||||
public interface IRectangularShape extends IShape
|
public interface IRectangularShape extends IShape
|
||||||
{
|
{
|
||||||
/** Returns the x-coordinate of the upper-left corner of the framing rectangle. */
|
/** 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. */
|
/** Returns the y-coordinate of the upper-left corner of the framing rectangle. */
|
||||||
float getY ();
|
float y ();
|
||||||
|
|
||||||
/** Returns the width of the framing rectangle. */
|
/** Returns the width of the framing rectangle. */
|
||||||
float getWidth ();
|
float width ();
|
||||||
|
|
||||||
/** Returns the height of the framing rectangle. */
|
/** Returns the height of the framing rectangle. */
|
||||||
float getHeight ();
|
float height ();
|
||||||
|
|
||||||
/** Returns the minimum x,y-coordinate of the framing rectangle. */
|
/** Returns the minimum x,y-coordinate of the framing rectangle. */
|
||||||
Point getMin ();
|
Point min ();
|
||||||
|
|
||||||
/** Returns the minimum x-coordinate of the framing rectangle. */
|
/** Returns the minimum x-coordinate of the framing rectangle. */
|
||||||
float getMinX ();
|
float minX ();
|
||||||
|
|
||||||
/** Returns the minimum y-coordinate of the framing rectangle. */
|
/** Returns the minimum y-coordinate of the framing rectangle. */
|
||||||
float getMinY ();
|
float minY ();
|
||||||
|
|
||||||
/** Returns the maximum x,y-coordinate of the framing rectangle. */
|
/** Returns the maximum x,y-coordinate of the framing rectangle. */
|
||||||
Point getMax ();
|
Point max ();
|
||||||
|
|
||||||
/** Returns the maximum x-coordinate of the framing rectangle. */
|
/** Returns the maximum x-coordinate of the framing rectangle. */
|
||||||
float getMaxX ();
|
float maxX ();
|
||||||
|
|
||||||
/** Returns the maximum y-coordinate of the framing rectangle. */
|
/** Returns the maximum y-coordinate of the framing rectangle. */
|
||||||
float getMaxY ();
|
float maxY ();
|
||||||
|
|
||||||
/** Returns the center of the framing rectangle. */
|
/** Returns the center of the framing rectangle. */
|
||||||
Point getCenter ();
|
Point center ();
|
||||||
|
|
||||||
/** Returns the x-coordinate of the center of the framing rectangle. */
|
/** 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. */
|
/** Returns the y-coordinate of the center of the framing rectangle. */
|
||||||
float getCenterY ();
|
float centerY ();
|
||||||
|
|
||||||
/** Returns a copy of this shape's framing rectangle. */
|
/** Returns a copy of this shape's framing rectangle. */
|
||||||
Rectangle getFrame ();
|
Rectangle frame ();
|
||||||
|
|
||||||
/** Initializes the supplied rectangle with this shape's framing rectangle.
|
/** Initializes the supplied rectangle with this shape's framing rectangle.
|
||||||
* @return the supplied rectangle. */
|
* @return the supplied rectangle. */
|
||||||
Rectangle getFrame (Rectangle target);
|
Rectangle frame (Rectangle target);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ package pythagoras.f;
|
|||||||
public interface IRoundRectangle extends IRectangularShape, Cloneable
|
public interface IRoundRectangle extends IRectangularShape, Cloneable
|
||||||
{
|
{
|
||||||
/** Returns the width of the corner arc. */
|
/** Returns the width of the corner arc. */
|
||||||
float getArcWidth ();
|
float arcWidth ();
|
||||||
|
|
||||||
/** Returns the height of the corner arc. */
|
/** Returns the height of the corner arc. */
|
||||||
float getArcHeight ();
|
float arcHeight ();
|
||||||
|
|
||||||
/** Returns a mutable copy of this round rectangle. */
|
/** Returns a mutable copy of this round rectangle. */
|
||||||
RoundRectangle clone ();
|
RoundRectangle clone ();
|
||||||
|
|||||||
@@ -31,18 +31,18 @@ public interface IShape
|
|||||||
boolean intersects (IRectangle r);
|
boolean intersects (IRectangle r);
|
||||||
|
|
||||||
/** Returns a copy of the bounding rectangle for this shape. */
|
/** Returns a copy of the bounding rectangle for this shape. */
|
||||||
Rectangle getBounds ();
|
Rectangle bounds ();
|
||||||
|
|
||||||
/** Initializes the supplied rectangle with this shape's bounding rectangle.
|
/** Initializes the supplied rectangle with this shape's bounding rectangle.
|
||||||
* @return the supplied rectangle. */
|
* @return the supplied rectangle. */
|
||||||
Rectangle getBounds (Rectangle target);
|
Rectangle bounds (Rectangle target);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an iterator over the path described by this shape.
|
* Returns an iterator over the path described by this shape.
|
||||||
*
|
*
|
||||||
* @param at if supplied, the points in the path are transformed using this.
|
* @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.
|
* 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
|
* distance the lines are allowed to deviate from the approximated curve, thus a higher
|
||||||
* flatness value generally allows for a path with fewer segments.
|
* flatness value generally allows for a path with fewer segments.
|
||||||
*/
|
*/
|
||||||
PathIterator getPathIterator (Transform at, float flatness);
|
PathIterator pathIterator (Transform at, float flatness);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ package pythagoras.f;
|
|||||||
public interface IVector
|
public interface IVector
|
||||||
{
|
{
|
||||||
/** Returns the x-component of this vector. */
|
/** Returns the x-component of this vector. */
|
||||||
float getX ();
|
float x ();
|
||||||
|
|
||||||
/** Returns the y-component of this vector. */
|
/** Returns the y-component of this vector. */
|
||||||
float getY ();
|
float y ();
|
||||||
|
|
||||||
/** Computes and returns the dot product of this and the specified other vector. */
|
/** Computes and returns the dot product of this and the specified other vector. */
|
||||||
float dot (IVector other);
|
float dot (IVector other);
|
||||||
|
|||||||
@@ -13,32 +13,32 @@ public class IdentityTransform extends AbstractTransform
|
|||||||
public static final int GENERALITY = 0;
|
public static final int GENERALITY = 0;
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getUniformScale () {
|
public float uniformScale () {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getScaleX () {
|
public float scaleX () {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getScaleY () {
|
public float scaleY () {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getRotation () {
|
public float rotation () {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getTx () {
|
public float tx () {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getTy () {
|
public float ty () {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,31 +36,31 @@ class IntersectPoint
|
|||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBegIndex (boolean isCurrentArea) {
|
public int begIndex (boolean isCurrentArea) {
|
||||||
return isCurrentArea ? begIndex1 : begIndex2;
|
return isCurrentArea ? begIndex1 : begIndex2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getEndIndex (boolean isCurrentArea) {
|
public int endIndex (boolean isCurrentArea) {
|
||||||
return isCurrentArea ? endIndex1 : endIndex2;
|
return isCurrentArea ? endIndex1 : endIndex2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRuleIndex (boolean isCurrentArea) {
|
public int ruleIndex (boolean isCurrentArea) {
|
||||||
return isCurrentArea ? ruleIndex1 : ruleIndex2;
|
return isCurrentArea ? ruleIndex1 : ruleIndex2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getParam (boolean isCurrentArea) {
|
public float param (boolean isCurrentArea) {
|
||||||
return isCurrentArea ? param1 : param2;
|
return isCurrentArea ? param1 : param2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRule (boolean isCurrentArea) {
|
public int rule (boolean isCurrentArea) {
|
||||||
return isCurrentArea ? rule1 : rule2;
|
return isCurrentArea ? rule1 : rule2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getX () {
|
public float x () {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getY () {
|
public float y () {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,26 +57,26 @@ public class Line extends AbstractLine implements Serializable
|
|||||||
* Sets the start and end of this line to the specified points.
|
* Sets the start and end of this line to the specified points.
|
||||||
*/
|
*/
|
||||||
public void setLine (IPoint p1, IPoint p2) {
|
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
|
@Override // from interface ILine
|
||||||
public float getX1 () {
|
public float x1 () {
|
||||||
return x1;
|
return x1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ILine
|
@Override // from interface ILine
|
||||||
public float getY1 () {
|
public float y1 () {
|
||||||
return y1;
|
return y1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ILine
|
@Override // from interface ILine
|
||||||
public float getX2 () {
|
public float x2 () {
|
||||||
return x2;
|
return x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface ILine
|
@Override // from interface ILine
|
||||||
public float getY2 () {
|
public float y2 () {
|
||||||
return y2;
|
return y2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,32 +34,32 @@ public class NonUniformTransform extends AbstractTransform
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getUniformScale () {
|
public float uniformScale () {
|
||||||
return (scaleX + scaleY) / 2; // TODO: is this sane
|
return (scaleX + scaleY) / 2; // TODO: is this sane
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getScaleX () {
|
public float scaleX () {
|
||||||
return scaleX;
|
return scaleX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getScaleY () {
|
public float scaleY () {
|
||||||
return scaleY;
|
return scaleY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getRotation () {
|
public float rotation () {
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getTx () {
|
public float tx () {
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getTy () {
|
public float ty () {
|
||||||
return ty;
|
return ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,14 +160,14 @@ public class NonUniformTransform extends AbstractTransform
|
|||||||
return other.preConcatenate(this);
|
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 sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation);
|
||||||
float ntx = (otx*cosa - oty*sina) * scaleX + getTx();
|
float ntx = (otx*cosa - oty*sina) * scaleX + tx();
|
||||||
float nty = (otx*sina + oty*cosa) * scaleY + getTy();
|
float nty = (otx*sina + oty*cosa) * scaleY + ty();
|
||||||
|
|
||||||
float nrotation = FloatMath.normalizeAngle(rotation + other.getRotation());
|
float nrotation = FloatMath.normalizeAngle(rotation + other.rotation());
|
||||||
float nscaleX = scaleX * other.getScaleX();
|
float nscaleX = scaleX * other.scaleX();
|
||||||
float nscaleY = scaleY * other.getScaleY();
|
float nscaleY = scaleY * other.scaleY();
|
||||||
return new NonUniformTransform(nscaleX, nscaleY, nrotation, ntx, nty);
|
return new NonUniformTransform(nscaleX, nscaleY, nrotation, ntx, nty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,13 +177,13 @@ public class NonUniformTransform extends AbstractTransform
|
|||||||
return other.concatenate(this);
|
return other.concatenate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
float tx = getTx(), ty = getTy();
|
float tx = tx(), ty = ty();
|
||||||
float sina = FloatMath.sin(other.getRotation()), cosa = FloatMath.cos(other.getRotation());
|
float sina = FloatMath.sin(other.rotation()), cosa = FloatMath.cos(other.rotation());
|
||||||
float ntx = (tx*cosa - ty*sina) * other.getScaleX() + other.getTx();
|
float ntx = (tx*cosa - ty*sina) * other.scaleX() + other.tx();
|
||||||
float nty = (tx*sina + ty*cosa) * other.getScaleY() + other.getTy();
|
float nty = (tx*sina + ty*cosa) * other.scaleY() + other.ty();
|
||||||
float nrotation = FloatMath.normalizeAngle(other.getRotation() + rotation);
|
float nrotation = FloatMath.normalizeAngle(other.rotation() + rotation);
|
||||||
float nscaleX = other.getScaleX() * scaleX;
|
float nscaleX = other.scaleX() * scaleX;
|
||||||
float nscaleY = other.getScaleY() * scaleY;
|
float nscaleY = other.scaleY() * scaleY;
|
||||||
return new NonUniformTransform(nscaleX, nscaleY, nrotation, ntx, nty);
|
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?
|
return other.lerp(this, -t); // TODO: is this correct?
|
||||||
}
|
}
|
||||||
|
|
||||||
float ntx = FloatMath.lerpa(tx, other.getTx(), t);
|
float ntx = FloatMath.lerpa(tx, other.tx(), t);
|
||||||
float nty = FloatMath.lerpa(ty, other.getTy(), t);
|
float nty = FloatMath.lerpa(ty, other.ty(), t);
|
||||||
float nrotation = FloatMath.lerpa(rotation, other.getRotation(), t);
|
float nrotation = FloatMath.lerpa(rotation, other.rotation(), t);
|
||||||
float nscaleX = FloatMath.lerp(scaleX, other.getScaleX(), t);
|
float nscaleX = FloatMath.lerp(scaleX, other.scaleX(), t);
|
||||||
float nscaleY = FloatMath.lerp(scaleY, other.getScaleY(), t);
|
float nscaleY = FloatMath.lerp(scaleY, other.scaleY(), t);
|
||||||
return new NonUniformTransform(nscaleX, nscaleY, nrotation, ntx, nty);
|
return new NonUniformTransform(nscaleX, nscaleY, nrotation, ntx, nty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Point transform (IPoint p, Point into) {
|
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
|
@Override // from Transform
|
||||||
@@ -211,7 +211,7 @@ public class NonUniformTransform extends AbstractTransform
|
|||||||
float sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation);
|
float sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation);
|
||||||
for (int ii = 0; ii < count; ii++) {
|
for (int ii = 0; ii < count; ii++) {
|
||||||
IPoint s = src[srcOff++];
|
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
|
@Override // from Transform
|
||||||
public Point inverseTransform (IPoint p, Point into) {
|
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
|
@Override // from Transform
|
||||||
public Vector transform (IVector v, Vector into) {
|
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
|
@Override // from Transform
|
||||||
public Vector inverseTransform (IVector v, Vector into) {
|
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
|
@Override // from Transform
|
||||||
@@ -253,7 +253,7 @@ public class NonUniformTransform extends AbstractTransform
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return "nonunif [scale=" + getScale() + ", rot=" + rotation +
|
return "nonunif [scale=" + scale() + ", rot=" + rotation +
|
||||||
", trans=" + getTranslation() + "]";
|
", trans=" + translation() + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ public final class Path implements IShape, Cloneable
|
|||||||
|
|
||||||
public Path (IShape shape) {
|
public Path (IShape shape) {
|
||||||
this(WIND_NON_ZERO, BUFFER_SIZE);
|
this(WIND_NON_ZERO, BUFFER_SIZE);
|
||||||
PathIterator p = shape.getPathIterator(null);
|
PathIterator p = shape.pathIterator(null);
|
||||||
setWindingRule(p.getWindingRule());
|
setWindingRule(p.windingRule());
|
||||||
append(p, false);
|
append(p, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ public final class Path implements IShape, Cloneable
|
|||||||
this.rule = rule;
|
this.rule = rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWindingRule () {
|
public int windingRule () {
|
||||||
return rule;
|
return rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ public final class Path implements IShape, Cloneable
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void append (IShape shape, boolean connect) {
|
public void append (IShape shape, boolean connect) {
|
||||||
PathIterator p = shape.getPathIterator(null);
|
PathIterator p = shape.pathIterator(null);
|
||||||
append(p, connect);
|
append(p, connect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ public final class Path implements IShape, Cloneable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point getCurrentPoint () {
|
public Point currentPoint () {
|
||||||
if (typeSize == 0) {
|
if (typeSize == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -170,12 +170,12 @@ public final class Path implements IShape, Cloneable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds () {
|
public Rectangle bounds () {
|
||||||
return getBounds(new Rectangle());
|
return bounds(new Rectangle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds (Rectangle target) {
|
public Rectangle bounds (Rectangle target) {
|
||||||
float rx1, ry1, rx2, ry2;
|
float rx1, ry1, rx2, ry2;
|
||||||
if (pointSize == 0) {
|
if (pointSize == 0) {
|
||||||
rx1 = ry1 = rx2 = ry2 = 0f;
|
rx1 = ry1 = rx2 = ry2 = 0f;
|
||||||
@@ -205,7 +205,7 @@ public final class Path implements IShape, Cloneable
|
|||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean isEmpty () {
|
public boolean isEmpty () {
|
||||||
// TODO: will this be insanely difficult to do correctly?
|
// TODO: will this be insanely difficult to do correctly?
|
||||||
return getBounds().isEmpty();
|
return bounds().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
@@ -227,27 +227,27 @@ public final class Path implements IShape, Cloneable
|
|||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (IPoint p) {
|
public boolean contains (IPoint p) {
|
||||||
return contains(p.getX(), p.getY());
|
return contains(p.x(), p.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (IRectangle r) {
|
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
|
@Override // from interface IShape
|
||||||
public boolean intersects (IRectangle r) {
|
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
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform t) {
|
public PathIterator pathIterator (Transform t) {
|
||||||
return new Iterator(this, t);
|
return new Iterator(this, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform t, float flatness) {
|
public PathIterator pathIterator (Transform t, float flatness) {
|
||||||
return new FlatteningPathIterator(getPathIterator(t), flatness);
|
return new FlatteningPathIterator(pathIterator(t), flatness);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override // can't declare @Override due to GWT
|
// @Override // can't declare @Override due to GWT
|
||||||
@@ -320,8 +320,8 @@ public final class Path implements IShape, Cloneable
|
|||||||
this.t = at;
|
this.t = at;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int getWindingRule () {
|
@Override public int windingRule () {
|
||||||
return p.getWindingRule();
|
return p.windingRule();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean isDone () {
|
@Override public boolean isDone () {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public interface PathIterator
|
|||||||
/**
|
/**
|
||||||
* Returns the winding rule used to determine the interior of this path.
|
* 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.
|
* Returns true if this path has no additional segments.
|
||||||
|
|||||||
@@ -34,13 +34,13 @@ public class Point extends AbstractPoint implements Serializable
|
|||||||
* Constructs a point with coordinates equal to the supplied point.
|
* Constructs a point with coordinates equal to the supplied point.
|
||||||
*/
|
*/
|
||||||
public Point (IPoint p) {
|
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.
|
/** Sets the coordinates of this point to be equal to those of the supplied point.
|
||||||
* @return a reference to this this, for chaining. */
|
* @return a reference to this this, for chaining. */
|
||||||
public Point set (IPoint p) {
|
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.
|
/** 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
|
@Override // from interface IPoint
|
||||||
public float getX () {
|
public float x () {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IPoint
|
@Override // from interface IPoint
|
||||||
public float getY () {
|
public float y () {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class QuadCurve extends AbstractQuadCurve implements Serializable
|
|||||||
* Configures the start, control, and end points for this curve.
|
* Configures the start, control, and end points for this curve.
|
||||||
*/
|
*/
|
||||||
public void setCurve (IPoint p1, IPoint cp, IPoint p2) {
|
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.
|
* specified offset in the {@code points} array.
|
||||||
*/
|
*/
|
||||||
public void setCurve (IPoint[] points, int offset) {
|
public void setCurve (IPoint[] points, int offset) {
|
||||||
setCurve(points[offset + 0].getX(), points[offset + 0].getY(),
|
setCurve(points[offset + 0].x(), points[offset + 0].y(),
|
||||||
points[offset + 1].getX(), points[offset + 1].getY(),
|
points[offset + 1].x(), points[offset + 1].y(),
|
||||||
points[offset + 2].getX(), points[offset + 2].getY());
|
points[offset + 2].x(), points[offset + 2].y());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,37 +86,37 @@ public class QuadCurve extends AbstractQuadCurve implements Serializable
|
|||||||
* curve.
|
* curve.
|
||||||
*/
|
*/
|
||||||
public void setCurve (IQuadCurve curve) {
|
public void setCurve (IQuadCurve curve) {
|
||||||
setCurve(curve.getX1(), curve.getY1(), curve.getCtrlX(), curve.getCtrlY(),
|
setCurve(curve.x1(), curve.y1(), curve.ctrlX(), curve.ctrlY(),
|
||||||
curve.getX2(), curve.getY2());
|
curve.x2(), curve.y2());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IQuadCurve
|
@Override // from interface IQuadCurve
|
||||||
public float getX1 () {
|
public float x1 () {
|
||||||
return x1;
|
return x1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IQuadCurve
|
@Override // from interface IQuadCurve
|
||||||
public float getY1 () {
|
public float y1 () {
|
||||||
return y1;
|
return y1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IQuadCurve
|
@Override // from interface IQuadCurve
|
||||||
public float getCtrlX () {
|
public float ctrlX () {
|
||||||
return ctrlx;
|
return ctrlx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IQuadCurve
|
@Override // from interface IQuadCurve
|
||||||
public float getCtrlY () {
|
public float ctrlY () {
|
||||||
return ctrly;
|
return ctrly;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IQuadCurve
|
@Override // from interface IQuadCurve
|
||||||
public float getX2 () {
|
public float x2 () {
|
||||||
return x2;
|
return x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IQuadCurve
|
@Override // from interface IQuadCurve
|
||||||
public float getY2 () {
|
public float y2 () {
|
||||||
return y2;
|
return y2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,35 +9,35 @@ package pythagoras.f;
|
|||||||
*/
|
*/
|
||||||
public class QuadCurves
|
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) {
|
float x2, float y2) {
|
||||||
return Lines.pointSegDistSq(ctrlx, ctrly, x1, y1, x2, 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],
|
return Lines.pointSegDistSq(coords[offset + 2], coords[offset + 3],
|
||||||
coords[offset + 0], coords[offset + 1],
|
coords[offset + 0], coords[offset + 1],
|
||||||
coords[offset + 4], coords[offset + 5]);
|
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) {
|
float x2, float y2) {
|
||||||
return Lines.pointSegDist(ctrlx, ctrly, x1, y1, x2, 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],
|
return Lines.pointSegDist(coords[offset + 2], coords[offset + 3],
|
||||||
coords[offset + 0], coords[offset + 1],
|
coords[offset + 0], coords[offset + 1],
|
||||||
coords[offset + 4], coords[offset + 5]);
|
coords[offset + 4], coords[offset + 5]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void subdivide (IQuadCurve src, QuadCurve left, QuadCurve right) {
|
public static void subdivide (IQuadCurve src, QuadCurve left, QuadCurve right) {
|
||||||
float x1 = src.getX1();
|
float x1 = src.x1();
|
||||||
float y1 = src.getY1();
|
float y1 = src.y1();
|
||||||
float cx = src.getCtrlX();
|
float cx = src.ctrlX();
|
||||||
float cy = src.getCtrlY();
|
float cy = src.ctrlY();
|
||||||
float x2 = src.getX2();
|
float x2 = src.x2();
|
||||||
float y2 = src.getY2();
|
float y2 = src.y2();
|
||||||
float cx1 = (x1 + cx) / 2f;
|
float cx1 = (x1 + cx) / 2f;
|
||||||
float cy1 = (y1 + cy) / 2f;
|
float cy1 = (y1 + cy) / 2f;
|
||||||
float cx2 = (x2 + cx) / 2f;
|
float cx2 = (x2 + cx) / 2f;
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ public class Rectangle extends AbstractRectangle implements Serializable
|
|||||||
* Constructs a rectangle with the supplied upper-left corner and dimensions (0,0).
|
* Constructs a rectangle with the supplied upper-left corner and dimensions (0,0).
|
||||||
*/
|
*/
|
||||||
public Rectangle (IPoint p) {
|
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.
|
* Constructs a rectangle with upper-left corner at (0,) and the supplied dimensions.
|
||||||
*/
|
*/
|
||||||
public Rectangle (IDimension d) {
|
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.
|
* dimensions.
|
||||||
*/
|
*/
|
||||||
public Rectangle (IPoint p, IDimension d) {
|
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.
|
* Constructs a rectangle with bounds equal to the supplied rectangle.
|
||||||
*/
|
*/
|
||||||
public Rectangle (IRectangle r) {
|
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.
|
* Sets the upper-left corner of this rectangle to the supplied point.
|
||||||
*/
|
*/
|
||||||
public void setLocation (IPoint p) {
|
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.
|
* Sets the size of this rectangle to the supplied dimensions.
|
||||||
*/
|
*/
|
||||||
public void setSize (IDimension d) {
|
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.
|
* Sets the bounds of this rectangle to those of the supplied rectangle.
|
||||||
*/
|
*/
|
||||||
public void setBounds (IRectangle r) {
|
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.
|
* Expands the bounds of this rectangle to contain the supplied point.
|
||||||
*/
|
*/
|
||||||
public void add (IPoint p) {
|
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.
|
* Expands the bounds of this rectangle to contain the supplied rectangle.
|
||||||
*/
|
*/
|
||||||
public void add (IRectangle r) {
|
public void add (IRectangle r) {
|
||||||
float x1 = Math.min(x, r.getX());
|
float x1 = Math.min(x, r.x());
|
||||||
float x2 = Math.max(x + width, r.getX() + r.getWidth());
|
float x2 = Math.max(x + width, r.x() + r.width());
|
||||||
float y1 = Math.min(y, r.getY());
|
float y1 = Math.min(y, r.y());
|
||||||
float y2 = Math.max(y + height, r.getY() + r.getHeight());
|
float y2 = Math.max(y + height, r.y() + r.height());
|
||||||
setBounds(x1, y1, x2 - x1, y2 - y1);
|
setBounds(x1, y1, x2 - x1, y2 - y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangularShape
|
@Override // from interface IRectangularShape
|
||||||
public float getX () {
|
public float x () {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangularShape
|
@Override // from interface IRectangularShape
|
||||||
public float getY () {
|
public float y () {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangularShape
|
@Override // from interface IRectangularShape
|
||||||
public float getWidth () {
|
public float width () {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangularShape
|
@Override // from interface IRectangularShape
|
||||||
public float getHeight () {
|
public float height () {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ public class Rectangles
|
|||||||
* Intersects the supplied two rectangles, writing the result into {@code dst}.
|
* Intersects the supplied two rectangles, writing the result into {@code dst}.
|
||||||
*/
|
*/
|
||||||
public static void intersect (IRectangle src1, IRectangle src2, Rectangle dst) {
|
public static void intersect (IRectangle src1, IRectangle src2, Rectangle dst) {
|
||||||
float x1 = Math.max(src1.getMinX(), src2.getMinX());
|
float x1 = Math.max(src1.minX(), src2.minX());
|
||||||
float y1 = Math.max(src1.getMinY(), src2.getMinY());
|
float y1 = Math.max(src1.minY(), src2.minY());
|
||||||
float x2 = Math.min(src1.getMaxX(), src2.getMaxX());
|
float x2 = Math.min(src1.maxX(), src2.maxX());
|
||||||
float y2 = Math.min(src1.getMaxY(), src2.getMaxY());
|
float y2 = Math.min(src1.maxY(), src2.maxY());
|
||||||
dst.setBounds(x1, y1, x2 - x1, y2 - y1);
|
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}.
|
* Unions the supplied two rectangles, writing the result into {@code dst}.
|
||||||
*/
|
*/
|
||||||
public static void union (IRectangle src1, IRectangle src2, Rectangle dst) {
|
public static void union (IRectangle src1, IRectangle src2, Rectangle dst) {
|
||||||
float x1 = Math.min(src1.getMinX(), src2.getMinX());
|
float x1 = Math.min(src1.minX(), src2.minX());
|
||||||
float y1 = Math.min(src1.getMinY(), src2.getMinY());
|
float y1 = Math.min(src1.minY(), src2.minY());
|
||||||
float x2 = Math.max(src1.getMaxX(), src2.getMaxX());
|
float x2 = Math.max(src1.maxX(), src2.maxX());
|
||||||
float y2 = Math.max(src1.getMaxY(), src2.getMaxY());
|
float y2 = Math.max(src1.maxY(), src2.maxY());
|
||||||
dst.setBounds(x1, y1, x2 - x1, y2 - y1);
|
dst.setBounds(x1, y1, x2 - x1, y2 - y1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
* Sets the location and size of the framing rectangle of this shape to the supplied values.
|
||||||
*/
|
*/
|
||||||
public void setFrame (IPoint loc, IDimension size) {
|
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.
|
* supplied rectangle.
|
||||||
*/
|
*/
|
||||||
public void setFrame (IRectangle r) {
|
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.
|
* diagonal line.
|
||||||
*/
|
*/
|
||||||
public void setFrameFromDiagonal (IPoint p1, IPoint p2) {
|
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.
|
* center and corner points.
|
||||||
*/
|
*/
|
||||||
public void setFrameFromCenter (IPoint center, IPoint corner) {
|
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
|
@Override // from IRectangularShape
|
||||||
public Point getMin ()
|
public Point min ()
|
||||||
{
|
{
|
||||||
return new Point(getMinX(), getMinY());
|
return new Point(minX(), minY());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IRectangularShape
|
@Override // from IRectangularShape
|
||||||
public float getMinX () {
|
public float minX () {
|
||||||
return getX();
|
return x();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IRectangularShape
|
@Override // from IRectangularShape
|
||||||
public float getMinY () {
|
public float minY () {
|
||||||
return getY();
|
return y();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IRectangularShape
|
@Override // from IRectangularShape
|
||||||
public Point getMax ()
|
public Point max ()
|
||||||
{
|
{
|
||||||
return new Point(getMaxX(), getMaxY());
|
return new Point(maxX(), maxY());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IRectangularShape
|
@Override // from IRectangularShape
|
||||||
public float getMaxX () {
|
public float maxX () {
|
||||||
return getX() + getWidth();
|
return x() + width();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IRectangularShape
|
@Override // from IRectangularShape
|
||||||
public float getMaxY () {
|
public float maxY () {
|
||||||
return getY() + getHeight();
|
return y() + height();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IRectangularShape
|
@Override // from IRectangularShape
|
||||||
public Point getCenter ()
|
public Point center ()
|
||||||
{
|
{
|
||||||
return new Point(getCenterX(), getCenterY());
|
return new Point(centerX(), centerY());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IRectangularShape
|
@Override // from IRectangularShape
|
||||||
public float getCenterX () {
|
public float centerX () {
|
||||||
return getX() + getWidth() / 2;
|
return x() + width() / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IRectangularShape
|
@Override // from IRectangularShape
|
||||||
public float getCenterY () {
|
public float centerY () {
|
||||||
return getY() + getHeight() / 2;
|
return y() + height() / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IRectangularShape
|
@Override // from IRectangularShape
|
||||||
public Rectangle getFrame () {
|
public Rectangle frame () {
|
||||||
return getBounds();
|
return bounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IRectangularShape
|
@Override // from IRectangularShape
|
||||||
public Rectangle getFrame (Rectangle target) {
|
public Rectangle frame (Rectangle target) {
|
||||||
return getBounds(target);
|
return bounds(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean isEmpty () {
|
public boolean isEmpty () {
|
||||||
return getWidth() <= 0 || getHeight() <= 0;
|
return width() <= 0 || height() <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (IPoint point) {
|
public boolean contains (IPoint point) {
|
||||||
return contains(point.getX(), point.getY());
|
return contains(point.x(), point.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (IRectangle rect) {
|
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
|
@Override // from interface IShape
|
||||||
public boolean intersects (IRectangle rect) {
|
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
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds () {
|
public Rectangle bounds () {
|
||||||
return getBounds(new Rectangle());
|
return bounds(new Rectangle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds (Rectangle target) {
|
public Rectangle bounds (Rectangle target) {
|
||||||
target.setBounds(getX(), getY(), getWidth(), getHeight());
|
target.setBounds(x(), y(), width(), height());
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public PathIterator getPathIterator (Transform t, float flatness) {
|
public PathIterator pathIterator (Transform t, float flatness) {
|
||||||
return new FlatteningPathIterator(getPathIterator(t), flatness);
|
return new FlatteningPathIterator(pathIterator(t), flatness);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,32 +29,32 @@ public class RigidTransform extends AbstractTransform
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getUniformScale () {
|
public float uniformScale () {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getScaleX () {
|
public float scaleX () {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getScaleY () {
|
public float scaleY () {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getRotation () {
|
public float rotation () {
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getTx () {
|
public float tx () {
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getTy () {
|
public float ty () {
|
||||||
return ty;
|
return ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,7 +102,7 @@ public class RigidTransform extends AbstractTransform
|
|||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Transform invert () {
|
public Transform invert () {
|
||||||
Vector t = getTranslation().negateLocal().rotateLocal(-rotation);
|
Vector t = translation().negateLocal().rotateLocal(-rotation);
|
||||||
return new RigidTransform(-rotation, t.x, t.y);
|
return new RigidTransform(-rotation, t.x, t.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,9 +112,9 @@ public class RigidTransform extends AbstractTransform
|
|||||||
return other.preConcatenate(this);
|
return other.preConcatenate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector nt = other.getTranslation();
|
Vector nt = other.translation();
|
||||||
nt.rotateAndAdd(rotation, getTranslation(), nt);
|
nt.rotateAndAdd(rotation, translation(), nt);
|
||||||
float nrotation = FloatMath.normalizeAngle(rotation + other.getRotation());
|
float nrotation = FloatMath.normalizeAngle(rotation + other.rotation());
|
||||||
return new RigidTransform(nrotation, nt.x, nt.y);
|
return new RigidTransform(nrotation, nt.x, nt.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,9 +124,9 @@ public class RigidTransform extends AbstractTransform
|
|||||||
return other.concatenate(this);
|
return other.concatenate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector nt = getTranslation();
|
Vector nt = translation();
|
||||||
nt.rotateAndAdd(other.getRotation(), other.getTranslation(), nt);
|
nt.rotateAndAdd(other.rotation(), other.translation(), nt);
|
||||||
float nrotation = FloatMath.normalizeAngle(other.getRotation() + rotation);
|
float nrotation = FloatMath.normalizeAngle(other.rotation() + rotation);
|
||||||
return new RigidTransform(nrotation, nt.x, nt.y);
|
return new RigidTransform(nrotation, nt.x, nt.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,13 +135,13 @@ public class RigidTransform extends AbstractTransform
|
|||||||
if (generality() < other.generality()) {
|
if (generality() < other.generality()) {
|
||||||
return other.lerp(this, -t); // TODO: is this correct?
|
return other.lerp(this, -t); // TODO: is this correct?
|
||||||
}
|
}
|
||||||
Vector nt = getTranslation().lerpLocal(other.getTranslation(), t);
|
Vector nt = translation().lerpLocal(other.translation(), t);
|
||||||
return new RigidTransform(FloatMath.lerpa(rotation, other.getRotation(), t), nt.x, nt.y);
|
return new RigidTransform(FloatMath.lerpa(rotation, other.rotation(), t), nt.x, nt.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Point transform (IPoint p, Point into) {
|
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
|
@Override // from Transform
|
||||||
@@ -149,7 +149,7 @@ public class RigidTransform extends AbstractTransform
|
|||||||
float sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation);
|
float sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation);
|
||||||
for (int ii = 0; ii < count; ii++) {
|
for (int ii = 0; ii < count; ii++) {
|
||||||
IPoint s = src[srcOff++];
|
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
|
@Override // from Transform
|
||||||
public Point inverseTransform (IPoint p, Point into) {
|
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
|
@Override // from Transform
|
||||||
@@ -191,6 +191,6 @@ public class RigidTransform extends AbstractTransform
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return "rigid [rot=" + rotation + ", trans=" + getTranslation() + "]";
|
return "rigid [rot=" + rotation + ", trans=" + translation() + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,37 +61,37 @@ public class RoundRectangle extends AbstractRoundRectangle implements Serializab
|
|||||||
* rectangle.
|
* rectangle.
|
||||||
*/
|
*/
|
||||||
public void setRoundRect (IRoundRectangle rr) {
|
public void setRoundRect (IRoundRectangle rr) {
|
||||||
setRoundRect(rr.getX(), rr.getY(), rr.getWidth(), rr.getHeight(),
|
setRoundRect(rr.x(), rr.y(), rr.width(), rr.height(),
|
||||||
rr.getArcWidth(), rr.getArcHeight());
|
rr.arcWidth(), rr.arcHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRoundRectangle
|
@Override // from interface IRoundRectangle
|
||||||
public float getArcWidth () {
|
public float arcWidth () {
|
||||||
return arcwidth;
|
return arcwidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRoundRectangle
|
@Override // from interface IRoundRectangle
|
||||||
public float getArcHeight () {
|
public float arcHeight () {
|
||||||
return archeight;
|
return archeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangularShape
|
@Override // from interface IRectangularShape
|
||||||
public float getX () {
|
public float x () {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangularShape
|
@Override // from interface IRectangularShape
|
||||||
public float getY () {
|
public float y () {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangularShape
|
@Override // from interface IRectangularShape
|
||||||
public float getWidth () {
|
public float width () {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangularShape
|
@Override // from interface IRectangularShape
|
||||||
public float getHeight () {
|
public float height () {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,32 +12,32 @@ public interface Transform
|
|||||||
{
|
{
|
||||||
/** Returns the uniform scale applied by this transform. The uniform scale will be approximated
|
/** Returns the uniform scale applied by this transform. The uniform scale will be approximated
|
||||||
* for non-uniform transforms. */
|
* for non-uniform transforms. */
|
||||||
float getUniformScale ();
|
float uniformScale ();
|
||||||
|
|
||||||
/** Returns the scale vector for this transform. */
|
/** 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
|
/** Returns the x-component of the scale applied by this transform. Note that this will be
|
||||||
* extracted and therefore approximate for affine transforms. */
|
* 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
|
/** Returns the y-component of the scale applied by this transform. Note that this will be
|
||||||
* extracted and therefore approximate for affine transforms. */
|
* 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
|
/** Returns the rotation applied by this transform. Note that the rotation is extracted and
|
||||||
* therefore approximate for affine transforms.
|
* therefore approximate for affine transforms.
|
||||||
* @throws NoninvertibleTransformException if the transform is not invertible. */
|
* @throws NoninvertibleTransformException if the transform is not invertible. */
|
||||||
float getRotation ();
|
float rotation ();
|
||||||
|
|
||||||
/** Returns the translation vector for this transform. */
|
/** Returns the translation vector for this transform. */
|
||||||
Vector getTranslation ();
|
Vector translation ();
|
||||||
|
|
||||||
/** Returns the x-coordinate of the translation component. */
|
/** Returns the x-coordinate of the translation component. */
|
||||||
float getTx ();
|
float tx ();
|
||||||
|
|
||||||
/** Returns the y-coordinate of the translation component. */
|
/** Returns the y-coordinate of the translation component. */
|
||||||
float getTy ();
|
float ty ();
|
||||||
|
|
||||||
/** Sets the uniform scale of this transform.
|
/** Sets the uniform scale of this transform.
|
||||||
* @return this instance, for chaining.
|
* @return this instance, for chaining.
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ public class Transforms
|
|||||||
if (src instanceof Path) {
|
if (src instanceof Path) {
|
||||||
return ((Path)src).createTransformedShape(t);
|
return ((Path)src).createTransformedShape(t);
|
||||||
}
|
}
|
||||||
PathIterator path = src.getPathIterator(t);
|
PathIterator path = src.pathIterator(t);
|
||||||
Path dst = new Path(path.getWindingRule());
|
Path dst = new Path(path.windingRule());
|
||||||
dst.append(path, false);
|
dst.append(path, false);
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,32 +34,32 @@ public class UniformTransform extends AbstractTransform
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getUniformScale () {
|
public float uniformScale () {
|
||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getScaleX () {
|
public float scaleX () {
|
||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getScaleY () {
|
public float scaleY () {
|
||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getRotation () {
|
public float rotation () {
|
||||||
return rotation;
|
return rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getTx () {
|
public float tx () {
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public float getTy () {
|
public float ty () {
|
||||||
return ty;
|
return ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ public class UniformTransform extends AbstractTransform
|
|||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Transform invert () {
|
public Transform invert () {
|
||||||
float nscale = 1f / scale, nrotation = -rotation;
|
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);
|
return new UniformTransform(nscale, nrotation, t.x, t.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,10 +134,10 @@ public class UniformTransform extends AbstractTransform
|
|||||||
return other.preConcatenate(this);
|
return other.preConcatenate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector nt = other.getTranslation();
|
Vector nt = other.translation();
|
||||||
nt.rotateScaleAndAdd(rotation, scale, getTranslation(), nt);
|
nt.rotateScaleAndAdd(rotation, scale, translation(), nt);
|
||||||
float nrotation = FloatMath.normalizeAngle(rotation + other.getRotation());
|
float nrotation = FloatMath.normalizeAngle(rotation + other.rotation());
|
||||||
float nscale = scale * other.getUniformScale();
|
float nscale = scale * other.uniformScale();
|
||||||
return new UniformTransform(nscale, nrotation, nt.x, nt.y);
|
return new UniformTransform(nscale, nrotation, nt.x, nt.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,11 +147,11 @@ public class UniformTransform extends AbstractTransform
|
|||||||
return other.concatenate(this);
|
return other.concatenate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector nt = getTranslation();
|
Vector nt = translation();
|
||||||
nt.rotateScaleAndAdd(other.getRotation(), other.getUniformScale(),
|
nt.rotateScaleAndAdd(other.rotation(), other.uniformScale(),
|
||||||
other.getTranslation(), nt);
|
other.translation(), nt);
|
||||||
float nrotation = FloatMath.normalizeAngle(other.getRotation() + rotation);
|
float nrotation = FloatMath.normalizeAngle(other.rotation() + rotation);
|
||||||
float nscale = other.getUniformScale() * scale;
|
float nscale = other.uniformScale() * scale;
|
||||||
return new UniformTransform(nscale, nrotation, nt.x, nt.y);
|
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?
|
return other.lerp(this, -t); // TODO: is this correct?
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector nt = getTranslation().lerpLocal(other.getTranslation(), t);
|
Vector nt = translation().lerpLocal(other.translation(), t);
|
||||||
float nrotation = FloatMath.lerpa(rotation, other.getRotation(), t);
|
float nrotation = FloatMath.lerpa(rotation, other.rotation(), t);
|
||||||
float nscale = FloatMath.lerp(scale, other.getUniformScale(), t);
|
float nscale = FloatMath.lerp(scale, other.uniformScale(), t);
|
||||||
return new UniformTransform(nscale, nrotation, nt.x, nt.y);
|
return new UniformTransform(nscale, nrotation, nt.x, nt.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Transform
|
@Override // from Transform
|
||||||
public Point transform (IPoint p, Point into) {
|
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
|
@Override // from Transform
|
||||||
@@ -177,7 +177,7 @@ public class UniformTransform extends AbstractTransform
|
|||||||
float sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation);
|
float sina = FloatMath.sin(rotation), cosa = FloatMath.cos(rotation);
|
||||||
for (int ii = 0; ii < count; ii++) {
|
for (int ii = 0; ii < count; ii++) {
|
||||||
IPoint p = src[srcOff++];
|
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
|
@Override // from Transform
|
||||||
public Point inverseTransform (IPoint p, Point into) {
|
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
|
@Override // from Transform
|
||||||
public Vector transform (IVector v, Vector into) {
|
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
|
@Override // from Transform
|
||||||
public Vector inverseTransform (IVector v, Vector into) {
|
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
|
@Override // from Transform
|
||||||
@@ -220,6 +220,6 @@ public class UniformTransform extends AbstractTransform
|
|||||||
@Override
|
@Override
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return "uniform [scale=" + scale + ", rot=" + rotation +
|
return "uniform [scale=" + scale + ", rot=" + rotation +
|
||||||
", trans=" + getTranslation() + "]";
|
", trans=" + translation() + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class Vector extends AbstractVector
|
|||||||
/** Copies the elements of another vector.
|
/** Copies the elements of another vector.
|
||||||
* @return a reference to this vector, for chaining. */
|
* @return a reference to this vector, for chaining. */
|
||||||
public Vector set (IVector other) {
|
public Vector set (IVector other) {
|
||||||
return set(other.getX(), other.getY());
|
return set(other.x(), other.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copies the elements of an array.
|
/** Copies the elements of an array.
|
||||||
@@ -110,12 +110,12 @@ public class Vector extends AbstractVector
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override // from AbstractVector
|
@Override // from AbstractVector
|
||||||
public float getX () {
|
public float x () {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from AbstractVector
|
@Override // from AbstractVector
|
||||||
public float getY () {
|
public float y () {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public abstract class AbstractDimension implements IDimension
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode () {
|
public int hashCode () {
|
||||||
return getWidth() ^ getHeight();
|
return width() ^ height();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -27,13 +27,13 @@ public abstract class AbstractDimension implements IDimension
|
|||||||
}
|
}
|
||||||
if (obj instanceof AbstractDimension) {
|
if (obj instanceof AbstractDimension) {
|
||||||
AbstractDimension d = (AbstractDimension)obj;
|
AbstractDimension d = (AbstractDimension)obj;
|
||||||
return (d.getWidth() == getWidth() && d.getHeight() == getHeight());
|
return (d.width() == width() && d.height() == height());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return Dimensions.dimenToString(getWidth(), getHeight());
|
return Dimensions.dimenToString(width(), height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,22 +12,22 @@ public abstract class AbstractPoint implements IPoint
|
|||||||
{
|
{
|
||||||
@Override // from interface IPoint
|
@Override // from interface IPoint
|
||||||
public int distanceSq (int px, int py) {
|
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
|
@Override // from interface IPoint
|
||||||
public int distanceSq (IPoint p) {
|
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
|
@Override // from interface IPoint
|
||||||
public int distance (int px, int py) {
|
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
|
@Override // from interface IPoint
|
||||||
public int distance (IPoint p) {
|
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
|
@Override // from interface IPoint
|
||||||
@@ -42,18 +42,18 @@ public abstract class AbstractPoint implements IPoint
|
|||||||
}
|
}
|
||||||
if (obj instanceof AbstractPoint) {
|
if (obj instanceof AbstractPoint) {
|
||||||
AbstractPoint p = (AbstractPoint)obj;
|
AbstractPoint p = (AbstractPoint)obj;
|
||||||
return getX() == p.getX() && getY() == p.getY();
|
return x() == p.x() && y() == p.y();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode () {
|
public int hashCode () {
|
||||||
return getX() ^ getY();
|
return x() ^ y();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return Points.pointToString(getX(), getY());
|
return Points.pointToString(x(), y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,59 +11,59 @@ package pythagoras.i;
|
|||||||
public abstract class AbstractRectangle implements IRectangle
|
public abstract class AbstractRectangle implements IRectangle
|
||||||
{
|
{
|
||||||
@Override // from IRectangle
|
@Override // from IRectangle
|
||||||
public int getMinX () {
|
public int minX () {
|
||||||
return getX();
|
return x();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IRectangle
|
@Override // from IRectangle
|
||||||
public int getMinY () {
|
public int minY () {
|
||||||
return getY();
|
return y();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IRectangle
|
@Override // from IRectangle
|
||||||
public int getMaxX () {
|
public int maxX () {
|
||||||
return getX() + getWidth() - 1;
|
return x() + width() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from IRectangle
|
@Override // from IRectangle
|
||||||
public int getMaxY () {
|
public int maxY () {
|
||||||
return getY() + getHeight() - 1;
|
return y() + height() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public Point getLocation () {
|
public Point location () {
|
||||||
return getLocation(new Point());
|
return location(new Point());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public Point getLocation (Point target) {
|
public Point location (Point target) {
|
||||||
target.setLocation(getX(), getY());
|
target.setLocation(x(), y());
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public Dimension getSize () {
|
public Dimension size () {
|
||||||
return getSize(new Dimension());
|
return size(new Dimension());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public Dimension getSize (Dimension target) {
|
public Dimension size (Dimension target) {
|
||||||
target.setSize(getWidth(), getHeight());
|
target.setSize(width(), height());
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public Rectangle intersection (int rx, int ry, int rw, int rh) {
|
public Rectangle intersection (int rx, int ry, int rw, int rh) {
|
||||||
int x1 = Math.max(getX(), rx);
|
int x1 = Math.max(x(), rx);
|
||||||
int y1 = Math.max(getY(), ry);
|
int y1 = Math.max(y(), ry);
|
||||||
int x2 = Math.min(getMaxX(), rx + rw - 1);
|
int x2 = Math.min(maxX(), rx + rw - 1);
|
||||||
int y2 = Math.min(getMaxY(), ry + rh - 1);
|
int y2 = Math.min(maxY(), ry + rh - 1);
|
||||||
return new Rectangle(x1, y1, x2 - x1, y2 - y1);
|
return new Rectangle(x1, y1, x2 - x1, y2 - y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public Rectangle intersection (IRectangle r) {
|
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
|
@Override // from interface IRectangle
|
||||||
@@ -77,19 +77,19 @@ public abstract class AbstractRectangle implements IRectangle
|
|||||||
public int outcode (int px, int py) {
|
public int outcode (int px, int py) {
|
||||||
int code = 0;
|
int code = 0;
|
||||||
|
|
||||||
if (getWidth() <= 0) {
|
if (width() <= 0) {
|
||||||
code |= OUT_LEFT | OUT_RIGHT;
|
code |= OUT_LEFT | OUT_RIGHT;
|
||||||
} else if (px < getX()) {
|
} else if (px < x()) {
|
||||||
code |= OUT_LEFT;
|
code |= OUT_LEFT;
|
||||||
} else if (px > getMaxX()) {
|
} else if (px > maxX()) {
|
||||||
code |= OUT_RIGHT;
|
code |= OUT_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getHeight() <= 0) {
|
if (height() <= 0) {
|
||||||
code |= OUT_TOP | OUT_BOTTOM;
|
code |= OUT_TOP | OUT_BOTTOM;
|
||||||
} else if (py < getY()) {
|
} else if (py < y()) {
|
||||||
code |= OUT_TOP;
|
code |= OUT_TOP;
|
||||||
} else if (py > getMaxY()) {
|
} else if (py > maxY()) {
|
||||||
code |= OUT_BOTTOM;
|
code |= OUT_BOTTOM;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ public abstract class AbstractRectangle implements IRectangle
|
|||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public int outcode (IPoint p) {
|
public int outcode (IPoint p) {
|
||||||
return outcode(p.getX(), p.getY());
|
return outcode(p.x(), p.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
@@ -108,60 +108,60 @@ public abstract class AbstractRectangle implements IRectangle
|
|||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean isEmpty () {
|
public boolean isEmpty () {
|
||||||
return getWidth() <= 0 || getHeight() <= 0;
|
return width() <= 0 || height() <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (int px, int py) {
|
public boolean contains (int px, int py) {
|
||||||
if (isEmpty()) return false;
|
if (isEmpty()) return false;
|
||||||
|
|
||||||
int x = getX(), y = getY();
|
int x = x(), y = y();
|
||||||
if (px < x || py < y) return false;
|
if (px < x || py < y) return false;
|
||||||
|
|
||||||
px -= x;
|
px -= x;
|
||||||
py -= y;
|
py -= y;
|
||||||
return px < getWidth() && py < getHeight();
|
return px < width() && py < height();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (IPoint point) {
|
public boolean contains (IPoint point) {
|
||||||
return contains(point.getX(), point.getY());
|
return contains(point.x(), point.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (int rx, int ry, int rw, int rh) {
|
public boolean contains (int rx, int ry, int rw, int rh) {
|
||||||
if (isEmpty()) return false;
|
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);
|
return (x1 <= rx) && (rx + rw <= x2) && (y1 <= ry) && (ry + rh <= y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean contains (IRectangle rect) {
|
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
|
@Override // from interface IShape
|
||||||
public boolean intersects (int rx, int ry, int rw, int rh) {
|
public boolean intersects (int rx, int ry, int rw, int rh) {
|
||||||
if (isEmpty()) return false;
|
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);
|
return (rx + rw > x1) && (rx < x2) && (ry + rh > y1) && (ry < y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public boolean intersects (IRectangle rect) {
|
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
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds () {
|
public Rectangle bounds () {
|
||||||
return getBounds(new Rectangle());
|
return bounds(new Rectangle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IShape
|
@Override // from interface IShape
|
||||||
public Rectangle getBounds (Rectangle target) {
|
public Rectangle bounds (Rectangle target) {
|
||||||
target.setBounds(getX(), getY(), getWidth(), getHeight());
|
target.setBounds(x(), y(), width(), height());
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,20 +172,20 @@ public abstract class AbstractRectangle implements IRectangle
|
|||||||
}
|
}
|
||||||
if (obj instanceof AbstractRectangle) {
|
if (obj instanceof AbstractRectangle) {
|
||||||
AbstractRectangle r = (AbstractRectangle)obj;
|
AbstractRectangle r = (AbstractRectangle)obj;
|
||||||
return r.getX() == getX() && r.getY() == getY() &&
|
return r.x() == x() && r.y() == y() &&
|
||||||
r.getWidth() == getWidth() && r.getHeight() == getHeight();
|
r.width() == width() && r.height() == height();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Object
|
@Override // from Object
|
||||||
public int hashCode () {
|
public int hashCode () {
|
||||||
return getX() ^ getY() ^ getWidth() ^ getHeight();
|
return x() ^ y() ^ width() ^ height();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from Object
|
@Override // from Object
|
||||||
public String toString () {
|
public String toString () {
|
||||||
return Dimensions.dimenToString(getWidth(), getHeight()) +
|
return Dimensions.dimenToString(width(), height()) +
|
||||||
Points.pointToString(getX(), getY());
|
Points.pointToString(x(), y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class Dimension extends AbstractDimension implements Serializable
|
|||||||
* Creates a dimension with width and height equal to the supplied dimension.
|
* Creates a dimension with width and height equal to the supplied dimension.
|
||||||
*/
|
*/
|
||||||
public Dimension (IDimension d) {
|
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.
|
* Sets the magnitudes of this dimension to be equal to the supplied dimension.
|
||||||
*/
|
*/
|
||||||
public void setSize (IDimension d) {
|
public void setSize (IDimension d) {
|
||||||
setSize(d.getWidth(), d.getHeight());
|
setSize(d.width(), d.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IDimension
|
@Override // from interface IDimension
|
||||||
public int getWidth () {
|
public int width () {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IDimension
|
@Override // from interface IDimension
|
||||||
public int getHeight () {
|
public int height () {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ public interface IDimension extends Cloneable
|
|||||||
/**
|
/**
|
||||||
* Returns the magnitude in the x-dimension.
|
* Returns the magnitude in the x-dimension.
|
||||||
*/
|
*/
|
||||||
int getWidth ();
|
int width ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the magnitude in the y-dimension.
|
* Returns the magnitude in the y-dimension.
|
||||||
*/
|
*/
|
||||||
int getHeight ();
|
int height ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a mutable copy of this dimension.
|
* Returns a mutable copy of this dimension.
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ package pythagoras.i;
|
|||||||
public interface IPoint extends Cloneable
|
public interface IPoint extends Cloneable
|
||||||
{
|
{
|
||||||
/** Returns this point's x-coordinate. */
|
/** Returns this point's x-coordinate. */
|
||||||
int getX ();
|
int x ();
|
||||||
|
|
||||||
/** Returns this point's y-coordinate. */
|
/** Returns this point's y-coordinate. */
|
||||||
int getY ();
|
int y ();
|
||||||
|
|
||||||
/** Returns the squared Euclidian distance between this point and the specified point. */
|
/** Returns the squared Euclidian distance between this point and the specified point. */
|
||||||
int distanceSq (int px, int py);
|
int distanceSq (int px, int py);
|
||||||
|
|||||||
@@ -24,46 +24,46 @@ public interface IRectangle extends IShape, Cloneable
|
|||||||
int OUT_BOTTOM = 8;
|
int OUT_BOTTOM = 8;
|
||||||
|
|
||||||
/** Returns the x-coordinate of the upper-left corner of the framing rectangle. */
|
/** 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. */
|
/** Returns the y-coordinate of the upper-left corner of the framing rectangle. */
|
||||||
int getY ();
|
int y ();
|
||||||
|
|
||||||
/** Returns the width of the framing rectangle. */
|
/** Returns the width of the framing rectangle. */
|
||||||
int getWidth ();
|
int width ();
|
||||||
|
|
||||||
/** Returns the height of the framing rectangle. */
|
/** Returns the height of the framing rectangle. */
|
||||||
int getHeight ();
|
int height ();
|
||||||
|
|
||||||
/** Returns the minimum x-coordinate of the framing rectangle. */
|
/** Returns the minimum x-coordinate of the framing rectangle. */
|
||||||
int getMinX ();
|
int minX ();
|
||||||
|
|
||||||
/** Returns the minimum y-coordinate of the framing rectangle. */
|
/** Returns the minimum y-coordinate of the framing rectangle. */
|
||||||
int getMinY ();
|
int minY ();
|
||||||
|
|
||||||
/** Returns the maximum x-coordinate of the framing rectangle. <em>Note:</em> this method
|
/** Returns the maximum x-coordinate of the framing rectangle. <em>Note:</em> this method
|
||||||
* differs from its floating-point counterparts in that it considers {@code (x + width - 1)} to
|
* differs from its floating-point counterparts in that it considers {@code (x + width - 1)} to
|
||||||
* be a rectangle's maximum x-coordinate. */
|
* be a rectangle's maximum x-coordinate. */
|
||||||
int getMaxX ();
|
int maxX ();
|
||||||
|
|
||||||
/** Returns the maximum y-coordinate of the framing rectangle. <em>Note:</em> this method
|
/** Returns the maximum y-coordinate of the framing rectangle. <em>Note:</em> this method
|
||||||
* differs from its floating-point counterparts in that it considers {@code (y + height - 1)}
|
* differs from its floating-point counterparts in that it considers {@code (y + height - 1)}
|
||||||
* to be a rectangle's maximum x-coordinate. */
|
* to be a rectangle's maximum x-coordinate. */
|
||||||
int getMaxY ();
|
int maxY ();
|
||||||
|
|
||||||
/** Returns a copy of this rectangle's upper-left corner. */
|
/** 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.
|
/** Initializes the supplied point with this rectangle's upper-left corner.
|
||||||
* @return the supplied point. */
|
* @return the supplied point. */
|
||||||
Point getLocation (Point target);
|
Point location (Point target);
|
||||||
|
|
||||||
/** Returns a copy of this rectangle's size. */
|
/** Returns a copy of this rectangle's size. */
|
||||||
Dimension getSize ();
|
Dimension size ();
|
||||||
|
|
||||||
/** Initializes the supplied dimension with this rectangle's size.
|
/** Initializes the supplied dimension with this rectangle's size.
|
||||||
* @return the supplied dimension. */
|
* @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
|
/** Returns the intersection of the specified rectangle and this rectangle (i.e. the largest
|
||||||
* rectangle contained in both this and the specified rectangle). */
|
* rectangle contained in both this and the specified rectangle). */
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ public interface IShape
|
|||||||
boolean intersects (IRectangle r);
|
boolean intersects (IRectangle r);
|
||||||
|
|
||||||
/** Returns a copy of the bounding rectangle for this shape. */
|
/** Returns a copy of the bounding rectangle for this shape. */
|
||||||
Rectangle getBounds ();
|
Rectangle bounds ();
|
||||||
|
|
||||||
/** Initializes the supplied rectangle with this shape's bounding rectangle.
|
/** Initializes the supplied rectangle with this shape's bounding rectangle.
|
||||||
* @return the supplied rectangle. */
|
* @return the supplied rectangle. */
|
||||||
Rectangle getBounds (Rectangle target);
|
Rectangle bounds (Rectangle target);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ public class Point extends AbstractPoint implements Serializable
|
|||||||
* Constructs a point with coordinates equal to the supplied point.
|
* Constructs a point with coordinates equal to the supplied point.
|
||||||
*/
|
*/
|
||||||
public Point (IPoint p) {
|
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.
|
* Sets the coordinates of this point to be equal to those of the supplied point.
|
||||||
*/
|
*/
|
||||||
public void setLocation (IPoint p) {
|
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
|
@Override // from interface IPoint
|
||||||
public int getX () {
|
public int x () {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IPoint
|
@Override // from interface IPoint
|
||||||
public int getY () {
|
public int y () {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,14 +33,14 @@ public class Rectangle extends AbstractRectangle implements Serializable
|
|||||||
* Constructs a rectangle with the supplied upper-left corner and dimensions (0,0).
|
* Constructs a rectangle with the supplied upper-left corner and dimensions (0,0).
|
||||||
*/
|
*/
|
||||||
public Rectangle (IPoint p) {
|
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.
|
* Constructs a rectangle with upper-left corner at (0,) and the supplied dimensions.
|
||||||
*/
|
*/
|
||||||
public Rectangle (IDimension d) {
|
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.
|
* dimensions.
|
||||||
*/
|
*/
|
||||||
public Rectangle (IPoint p, IDimension d) {
|
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.
|
* Constructs a rectangle with bounds equal to the supplied rectangle.
|
||||||
*/
|
*/
|
||||||
public Rectangle (IRectangle r) {
|
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.
|
* Sets the upper-left corner of this rectangle to the supplied point.
|
||||||
*/
|
*/
|
||||||
public void setLocation (IPoint p) {
|
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.
|
* Sets the size of this rectangle to the supplied dimensions.
|
||||||
*/
|
*/
|
||||||
public void setSize (IDimension d) {
|
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.
|
* Sets the bounds of this rectangle to those of the supplied rectangle.
|
||||||
*/
|
*/
|
||||||
public void setBounds (IRectangle r) {
|
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.
|
* Expands the bounds of this rectangle to contain the supplied point.
|
||||||
*/
|
*/
|
||||||
public void add (IPoint p) {
|
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.
|
* Expands the bounds of this rectangle to contain the supplied rectangle.
|
||||||
*/
|
*/
|
||||||
public void add (IRectangle r) {
|
public void add (IRectangle r) {
|
||||||
int x1 = Math.min(x, r.getX());
|
int x1 = Math.min(x, r.x());
|
||||||
int x2 = Math.max(x + width, r.getX() + r.getWidth());
|
int x2 = Math.max(x + width, r.x() + r.width());
|
||||||
int y1 = Math.min(y, r.getY());
|
int y1 = Math.min(y, r.y());
|
||||||
int y2 = Math.max(y + height, r.getY() + r.getHeight());
|
int y2 = Math.max(y + height, r.y() + r.height());
|
||||||
setBounds(x1, y1, x2 - x1, y2 - y1);
|
setBounds(x1, y1, x2 - x1, y2 - y1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public int getX () {
|
public int x () {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public int getY () {
|
public int y () {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public int getWidth () {
|
public int width () {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // from interface IRectangle
|
@Override // from interface IRectangle
|
||||||
public int getHeight () {
|
public int height () {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ public class Rectangles
|
|||||||
* Intersects the supplied two rectangles, writing the result into {@code dst}.
|
* Intersects the supplied two rectangles, writing the result into {@code dst}.
|
||||||
*/
|
*/
|
||||||
public static void intersect (IRectangle src1, IRectangle src2, Rectangle dst) {
|
public static void intersect (IRectangle src1, IRectangle src2, Rectangle dst) {
|
||||||
int x1 = Math.max(src1.getMinX(), src2.getMinX());
|
int x1 = Math.max(src1.minX(), src2.minX());
|
||||||
int y1 = Math.max(src1.getMinY(), src2.getMinY());
|
int y1 = Math.max(src1.minY(), src2.minY());
|
||||||
int x2 = Math.min(src1.getMaxX(), src2.getMaxX());
|
int x2 = Math.min(src1.maxX(), src2.maxX());
|
||||||
int y2 = Math.min(src1.getMaxY(), src2.getMaxY());
|
int y2 = Math.min(src1.maxY(), src2.maxY());
|
||||||
dst.setBounds(x1, y1, x2 - x1, y2 - y1);
|
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}.
|
* Unions the supplied two rectangles, writing the result into {@code dst}.
|
||||||
*/
|
*/
|
||||||
public static void union (IRectangle src1, IRectangle src2, Rectangle dst) {
|
public static void union (IRectangle src1, IRectangle src2, Rectangle dst) {
|
||||||
int x1 = Math.min(src1.getMinX(), src2.getMinX());
|
int x1 = Math.min(src1.minX(), src2.minX());
|
||||||
int y1 = Math.min(src1.getMinY(), src2.getMinY());
|
int y1 = Math.min(src1.minY(), src2.minY());
|
||||||
int x2 = Math.max(src1.getMaxX(), src2.getMaxX());
|
int x2 = Math.max(src1.maxX(), src2.maxX());
|
||||||
int y2 = Math.max(src1.getMaxY(), src2.getMaxY());
|
int y2 = Math.max(src1.maxY(), src2.maxY());
|
||||||
dst.setBounds(x1, y1, x2 - x1, y2 - y1);
|
dst.setBounds(x1, y1, x2 - x1, y2 - y1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user