Take XY wherever we took IPoint.
Be lenient in what you accept, strict in what you produce.
This commit is contained in:
@@ -19,7 +19,7 @@ public abstract class AbstractCircle implements ICircle
|
||||
}
|
||||
|
||||
@Override // from ICircle
|
||||
public boolean contains (IPoint p) {
|
||||
public boolean contains (XY p) {
|
||||
double r = radius();
|
||||
return Points.distanceSq(x(), y(), p.x(), p.y()) < r * r;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public abstract class AbstractCubicCurve implements ICubicCurve
|
||||
}
|
||||
|
||||
@Override // from interface IShape
|
||||
public boolean contains (IPoint p) {
|
||||
public boolean contains (XY p) {
|
||||
return contains(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class AbstractLine implements ILine
|
||||
}
|
||||
|
||||
@Override // from interface ILine
|
||||
public double pointLineDistSq (IPoint p) {
|
||||
public double pointLineDistSq (XY p) {
|
||||
return Lines.pointLineDistSq(p.x(), p.y(), x1(), y1(), x2(), y2());
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class AbstractLine implements ILine
|
||||
}
|
||||
|
||||
@Override // from interface ILine
|
||||
public double pointLineDist (IPoint p) {
|
||||
public double pointLineDist (XY p) {
|
||||
return Lines.pointLineDist(p.x(), p.y(), x1(), y1(), x2(), y2());
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public abstract class AbstractLine implements ILine
|
||||
}
|
||||
|
||||
@Override // from interface ILine
|
||||
public double pointSegDistSq (IPoint p) {
|
||||
public double pointSegDistSq (XY p) {
|
||||
return Lines.pointSegDistSq(p.x(), p.y(), x1(), y1(), x2(), y2());
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public abstract class AbstractLine implements ILine
|
||||
}
|
||||
|
||||
@Override // from interface ILine
|
||||
public double pointSegDist (IPoint p) {
|
||||
public double pointSegDist (XY p) {
|
||||
return Lines.pointSegDist(p.x(), p.y(), x1(), y1(), x2(), y2());
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public abstract class AbstractLine implements ILine
|
||||
}
|
||||
|
||||
@Override // from interface ILine
|
||||
public int relativeCCW (IPoint p) {
|
||||
public int relativeCCW (XY p) {
|
||||
return Lines.relativeCCW(p.x(), p.y(), x1(), y1(), x2(), y2());
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public abstract class AbstractLine implements ILine
|
||||
}
|
||||
|
||||
@Override // from interface IShape
|
||||
public boolean contains (IPoint point) {
|
||||
public boolean contains (XY point) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public abstract class AbstractPoint implements IPoint
|
||||
}
|
||||
|
||||
@Override // from IPoint
|
||||
public double distanceSq (IPoint p) {
|
||||
public double distanceSq (XY p) {
|
||||
return Points.distanceSq(x(), y(), p.x(), p.y());
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@ public abstract class AbstractPoint implements IPoint
|
||||
}
|
||||
|
||||
@Override // from IPoint
|
||||
public double distance (IPoint p) {
|
||||
public double distance (XY p) {
|
||||
return Points.distance(x(), y(), p.x(), p.y());
|
||||
}
|
||||
|
||||
@Override // from interface IPoint
|
||||
public double direction (IPoint other) {
|
||||
public double direction (XY other) {
|
||||
return Math.atan2(other.y() - y(), other.x() - x());
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public abstract class AbstractPoint implements IPoint
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point subtract (IPoint other, Point result) {
|
||||
public Point subtract (XY other, Point result) {
|
||||
return subtract(other.x(), other.y(), result);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class AbstractQuadCurve implements IQuadCurve
|
||||
}
|
||||
|
||||
@Override // from interface IShape
|
||||
public boolean contains (IPoint p) {
|
||||
public boolean contains (XY p) {
|
||||
return contains(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public abstract class AbstractRectangle extends RectangularShape implements IRec
|
||||
}
|
||||
|
||||
@Override // from interface IRectangle
|
||||
public int outcode (IPoint p) {
|
||||
public int outcode (XY p) {
|
||||
return outcode(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ public class Arc extends AbstractArc implements Serializable
|
||||
* Sets the location, size, angular extents, and closure type of this arc to the specified
|
||||
* values.
|
||||
*/
|
||||
public void setArc (IPoint point, IDimension size, double start, double extent, int type) {
|
||||
public void setArc (XY point, IDimension size, double start, double extent, int type) {
|
||||
setArc(point.x(), point.y(), size.width(), size.height(), start, extent, type);
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public class Arc extends AbstractArc implements Serializable
|
||||
* Sets the location, size, angular extents, and closure type of this arc based on the
|
||||
* specified values.
|
||||
*/
|
||||
public void setArcByTangent (IPoint p1, IPoint p2, IPoint p3, double radius) {
|
||||
public void setArcByTangent (XY p1, XY p2, XY p3, double radius) {
|
||||
// use simple geometric calculations of arc center, radius and angles by tangents
|
||||
double a1 = -Math.atan2(p1.y() - p2.y(), p1.x() - p2.x());
|
||||
double a2 = -Math.atan2(p3.y() - p2.y(), p3.x() - p2.x());
|
||||
@@ -195,7 +195,7 @@ public class Arc extends AbstractArc implements Serializable
|
||||
* Sets the starting angle of this arc to the angle defined by the supplied point relative to
|
||||
* the center of this arc.
|
||||
*/
|
||||
public void setAngleStart (IPoint point) {
|
||||
public void setAngleStart (XY point) {
|
||||
double angle = Math.atan2(point.y() - centerY(), point.x() - centerX());
|
||||
setAngleStart(normAngle(-Math.toDegrees(angle)));
|
||||
}
|
||||
@@ -227,7 +227,7 @@ public class Arc extends AbstractArc implements Serializable
|
||||
* point relative to the arc's center. The arc will always be non-empty and extend
|
||||
* counterclockwise from the first point around to the second point.
|
||||
*/
|
||||
public void setAngles (IPoint p1, IPoint p2) {
|
||||
public void setAngles (XY p1, XY p2) {
|
||||
setAngles(p1.x(), p1.y(), p2.x(), p2.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ public class Area implements IShape, Cloneable
|
||||
}
|
||||
|
||||
@Override // from interface IShape
|
||||
public boolean contains (IPoint p) {
|
||||
public boolean contains (XY p) {
|
||||
return contains(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Circle extends AbstractCircle implements Serializable
|
||||
/**
|
||||
* Constructs a circle with the specified properties
|
||||
*/
|
||||
public Circle (IPoint p, double radius) {
|
||||
public Circle (XY p, double radius) {
|
||||
this(p.x(), p.y(), radius);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class CubicCurve extends AbstractCubicCurve implements Serializable
|
||||
/**
|
||||
* Configures the start, control and end points for this curve.
|
||||
*/
|
||||
public void setCurve (IPoint p1, IPoint cp1, IPoint cp2, IPoint p2) {
|
||||
public void setCurve (XY p1, XY cp1, XY cp2, XY p2) {
|
||||
setCurve(p1.x(), p1.y(), cp1.x(), cp1.y(),
|
||||
cp2.x(), cp2.y(), p2.x(), p2.y());
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class CubicCurve extends AbstractCubicCurve implements Serializable
|
||||
* Configures the start, control and end points for this curve, using the values at the
|
||||
* specified offset in the {@code points} array.
|
||||
*/
|
||||
public void setCurve (IPoint[] points, int offset) {
|
||||
public void setCurve (XY[] points, int offset) {
|
||||
setCurve(points[offset + 0].x(), points[offset + 0].y(),
|
||||
points[offset + 1].x(), points[offset + 1].y(),
|
||||
points[offset + 2].x(), points[offset + 2].y(),
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface ICircle
|
||||
boolean intersects (ICircle c);
|
||||
|
||||
/** Returns true if this circle contains the supplied point. */
|
||||
boolean contains (IPoint p);
|
||||
boolean contains (XY p);
|
||||
|
||||
/** Returns true if this circle contains the specified point. */
|
||||
boolean contains (double x, double y);
|
||||
|
||||
@@ -41,32 +41,32 @@ public interface ILine extends IShape, Cloneable
|
||||
|
||||
/** Returns the square of the distance from the supplied point to the line defined by this line
|
||||
* segment. */
|
||||
double pointLineDistSq (IPoint p);
|
||||
double pointLineDistSq (XY p);
|
||||
|
||||
/** Returns the distance from the specified point to the line defined by this line segment. */
|
||||
double pointLineDist (double px, double py);
|
||||
|
||||
/** Returns the distance from the supplied point to the line defined by this line segment. */
|
||||
double pointLineDist (IPoint p);
|
||||
double pointLineDist (XY p);
|
||||
|
||||
/** Returns the square of the distance from the specified point this line segment. */
|
||||
double pointSegDistSq (double px, double py);
|
||||
|
||||
/** Returns the square of the distance from the supplied point this line segment. */
|
||||
double pointSegDistSq (IPoint p);
|
||||
double pointSegDistSq (XY p);
|
||||
|
||||
/** Returns the distance from the specified point this line segment. */
|
||||
double pointSegDist (double px, double py);
|
||||
|
||||
/** Returns the distance from the supplied point this line segment. */
|
||||
double pointSegDist (IPoint p);
|
||||
double pointSegDist (XY p);
|
||||
|
||||
/** Returns an indicator of where the specified point (px,py) lies with respect to this line
|
||||
* segment. */
|
||||
int relativeCCW (double px, double py);
|
||||
|
||||
/** Returns an indicator of where the specified point lies with respect to this line segment. */
|
||||
int relativeCCW (IPoint p);
|
||||
int relativeCCW (XY p);
|
||||
|
||||
/** Returns a mutable copy of this line. */
|
||||
Line clone ();
|
||||
|
||||
@@ -13,17 +13,17 @@ public interface IPoint extends XY, Cloneable
|
||||
double distanceSq (double px, double py);
|
||||
|
||||
/** Returns the squared Euclidian distance between this point and the supplied point. */
|
||||
double distanceSq (IPoint p);
|
||||
double distanceSq (XY p);
|
||||
|
||||
/** Returns the Euclidian distance between this point and the specified point. */
|
||||
double distance (double px, double py);
|
||||
|
||||
/** Returns the Euclidian distance between this point and the supplied point. */
|
||||
double distance (IPoint p);
|
||||
double distance (XY p);
|
||||
|
||||
/** Returns the angle (in radians) of the vector starting at this point and ending at the
|
||||
* supplied other point. */
|
||||
double direction (IPoint other);
|
||||
double direction (XY other);
|
||||
|
||||
/** Multiplies this point by a scale factor.
|
||||
* @return a new point containing the result. */
|
||||
@@ -51,7 +51,7 @@ public interface IPoint extends XY, Cloneable
|
||||
|
||||
/** Subtracts the supplied point from {@code this} and stores the result in {@code result}.
|
||||
* @return a reference to the result, for chaining. */
|
||||
Point subtract (IPoint other, Point result);
|
||||
Point subtract (XY other, Point result);
|
||||
|
||||
/** Rotates this point around the origin by the specified angle.
|
||||
* @return a new point containing the result. */
|
||||
|
||||
@@ -61,7 +61,7 @@ public interface IRectangle extends IRectangularShape, Cloneable
|
||||
|
||||
/** Returns a set of flags indicating where the supplied point lies in relation to the bounds of
|
||||
* this rectangle. See {@link #OUT_LEFT}, etc. */
|
||||
int outcode (IPoint point);
|
||||
int outcode (XY point);
|
||||
|
||||
/** Returns a mutable copy of this rectangle. */
|
||||
Rectangle clone ();
|
||||
|
||||
@@ -16,7 +16,7 @@ public interface IShape
|
||||
boolean contains (double x, double y);
|
||||
|
||||
/** Returns true if this shape contains the supplied point. */
|
||||
boolean contains (IPoint point);
|
||||
boolean contains (XY point);
|
||||
|
||||
/** Returns true if this shape completely contains the specified rectangle. */
|
||||
boolean contains (double x, double y, double width, double height);
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Line extends AbstractLine implements Serializable
|
||||
/**
|
||||
* Creates a line from p1 to p2.
|
||||
*/
|
||||
public Line (IPoint p1, IPoint p2) {
|
||||
public Line (XY p1, XY p2) {
|
||||
setLine(p1, p2);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Line extends AbstractLine implements Serializable
|
||||
/**
|
||||
* Sets the start and end of this line to the specified points.
|
||||
*/
|
||||
public void setLine (IPoint p1, IPoint p2) {
|
||||
public void setLine (XY p1, XY p2) {
|
||||
setLine(p1.x(), p1.y(), p2.x(), p2.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ public final class Path implements IShape, Cloneable
|
||||
}
|
||||
|
||||
@Override // from interface IShape
|
||||
public boolean contains (IPoint p) {
|
||||
public boolean contains (XY p) {
|
||||
return contains(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -33,13 +33,13 @@ public class Point extends AbstractPoint implements Serializable
|
||||
/**
|
||||
* Constructs a point with coordinates equal to the supplied point.
|
||||
*/
|
||||
public Point (IPoint p) {
|
||||
public Point (XY p) {
|
||||
set(p.x(), p.y());
|
||||
}
|
||||
|
||||
/** Sets the coordinates of this point to be equal to those of the supplied point.
|
||||
* @return a reference to this this, for chaining. */
|
||||
public Point set (IPoint p) {
|
||||
public Point set (XY p) {
|
||||
return set(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class QuadCurve extends AbstractQuadCurve implements Serializable
|
||||
/**
|
||||
* Configures the start, control, and end points for this curve.
|
||||
*/
|
||||
public void setCurve (IPoint p1, IPoint cp, IPoint p2) {
|
||||
public void setCurve (XY p1, XY cp, XY p2) {
|
||||
setCurve(p1.x(), p1.y(), cp.x(), cp.y(), p2.x(), p2.y());
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class QuadCurve extends AbstractQuadCurve implements Serializable
|
||||
* Configures the start, control, and end points for this curve, using the values at the
|
||||
* specified offset in the {@code points} array.
|
||||
*/
|
||||
public void setCurve (IPoint[] points, int offset) {
|
||||
public void setCurve (XY[] points, int offset) {
|
||||
setCurve(points[offset + 0].x(), points[offset + 0].y(),
|
||||
points[offset + 1].x(), points[offset + 1].y(),
|
||||
points[offset + 2].x(), points[offset + 2].y());
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Rectangle extends AbstractRectangle implements Serializable
|
||||
/**
|
||||
* Constructs a rectangle with the supplied upper-left corner and dimensions (0,0).
|
||||
*/
|
||||
public Rectangle (IPoint p) {
|
||||
public Rectangle (XY p) {
|
||||
setBounds(p.x(), p.y(), 0, 0);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class Rectangle extends AbstractRectangle implements Serializable
|
||||
* Constructs a rectangle with upper-left corner at the supplied point and with the supplied
|
||||
* dimensions.
|
||||
*/
|
||||
public Rectangle (IPoint p, IDimension d) {
|
||||
public Rectangle (XY p, IDimension d) {
|
||||
setBounds(p.x(), p.y(), d.width(), d.height());
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class Rectangle extends AbstractRectangle implements Serializable
|
||||
/**
|
||||
* Sets the upper-left corner of this rectangle to the supplied point.
|
||||
*/
|
||||
public void setLocation (IPoint p) {
|
||||
public void setLocation (XY p) {
|
||||
setLocation(p.x(), p.y());
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public class Rectangle extends AbstractRectangle implements Serializable
|
||||
/**
|
||||
* Expands the bounds of this rectangle to contain the supplied point.
|
||||
*/
|
||||
public void add (IPoint p) {
|
||||
public void add (XY p) {
|
||||
add(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public abstract class RectangularShape implements IRectangularShape
|
||||
/**
|
||||
* Sets the location and size of the framing rectangle of this shape to the supplied values.
|
||||
*/
|
||||
public void setFrame (IPoint loc, IDimension size) {
|
||||
public void setFrame (XY loc, IDimension size) {
|
||||
setFrame(loc.x(), loc.y(), size.width(), size.height());
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public abstract class RectangularShape implements IRectangularShape
|
||||
* Sets the location and size of the framing rectangle of this shape based on the supplied
|
||||
* diagonal line.
|
||||
*/
|
||||
public void setFrameFromDiagonal (IPoint p1, IPoint p2) {
|
||||
public void setFrameFromDiagonal (XY p1, XY p2) {
|
||||
setFrameFromDiagonal(p1.x(), p1.y(), p2.x(), p2.y());
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public abstract class RectangularShape implements IRectangularShape
|
||||
* Sets the location and size of the framing rectangle of this shape based on the supplied
|
||||
* center and corner points.
|
||||
*/
|
||||
public void setFrameFromCenter (IPoint center, IPoint corner) {
|
||||
public void setFrameFromCenter (XY center, XY corner) {
|
||||
setFrameFromCenter(center.x(), center.y(), corner.x(), corner.y());
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public abstract class RectangularShape implements IRectangularShape
|
||||
}
|
||||
|
||||
@Override // from interface IShape
|
||||
public boolean contains (IPoint point) {
|
||||
public boolean contains (XY point) {
|
||||
return contains(point.x(), point.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Vectors
|
||||
/**
|
||||
* Creates a vector from {@code from} to {@code to}.
|
||||
*/
|
||||
public static Vector from (IPoint from, IPoint to) {
|
||||
public static Vector from (XY from, XY to) {
|
||||
return new Vector(to.x() - from.x(), to.y() - from.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public abstract class AbstractCircle implements ICircle
|
||||
}
|
||||
|
||||
@Override // from ICircle
|
||||
public boolean contains (IPoint p) {
|
||||
public boolean contains (XY p) {
|
||||
float r = radius();
|
||||
return Points.distanceSq(x(), y(), p.x(), p.y()) < r * r;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public abstract class AbstractCubicCurve implements ICubicCurve
|
||||
}
|
||||
|
||||
@Override // from interface IShape
|
||||
public boolean contains (IPoint p) {
|
||||
public boolean contains (XY p) {
|
||||
return contains(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class AbstractLine implements ILine
|
||||
}
|
||||
|
||||
@Override // from interface ILine
|
||||
public float pointLineDistSq (IPoint p) {
|
||||
public float pointLineDistSq (XY p) {
|
||||
return Lines.pointLineDistSq(p.x(), p.y(), x1(), y1(), x2(), y2());
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class AbstractLine implements ILine
|
||||
}
|
||||
|
||||
@Override // from interface ILine
|
||||
public float pointLineDist (IPoint p) {
|
||||
public float pointLineDist (XY p) {
|
||||
return Lines.pointLineDist(p.x(), p.y(), x1(), y1(), x2(), y2());
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public abstract class AbstractLine implements ILine
|
||||
}
|
||||
|
||||
@Override // from interface ILine
|
||||
public float pointSegDistSq (IPoint p) {
|
||||
public float pointSegDistSq (XY p) {
|
||||
return Lines.pointSegDistSq(p.x(), p.y(), x1(), y1(), x2(), y2());
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public abstract class AbstractLine implements ILine
|
||||
}
|
||||
|
||||
@Override // from interface ILine
|
||||
public float pointSegDist (IPoint p) {
|
||||
public float pointSegDist (XY p) {
|
||||
return Lines.pointSegDist(p.x(), p.y(), x1(), y1(), x2(), y2());
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public abstract class AbstractLine implements ILine
|
||||
}
|
||||
|
||||
@Override // from interface ILine
|
||||
public int relativeCCW (IPoint p) {
|
||||
public int relativeCCW (XY p) {
|
||||
return Lines.relativeCCW(p.x(), p.y(), x1(), y1(), x2(), y2());
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public abstract class AbstractLine implements ILine
|
||||
}
|
||||
|
||||
@Override // from interface IShape
|
||||
public boolean contains (IPoint point) {
|
||||
public boolean contains (XY point) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public abstract class AbstractPoint implements IPoint
|
||||
}
|
||||
|
||||
@Override // from IPoint
|
||||
public float distanceSq (IPoint p) {
|
||||
public float distanceSq (XY p) {
|
||||
return Points.distanceSq(x(), y(), p.x(), p.y());
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@ public abstract class AbstractPoint implements IPoint
|
||||
}
|
||||
|
||||
@Override // from IPoint
|
||||
public float distance (IPoint p) {
|
||||
public float distance (XY p) {
|
||||
return Points.distance(x(), y(), p.x(), p.y());
|
||||
}
|
||||
|
||||
@Override // from interface IPoint
|
||||
public float direction (IPoint other) {
|
||||
public float direction (XY other) {
|
||||
return FloatMath.atan2(other.y() - y(), other.x() - x());
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ public abstract class AbstractPoint implements IPoint
|
||||
}
|
||||
|
||||
@Override
|
||||
public Point subtract (IPoint other, Point result) {
|
||||
public Point subtract (XY other, Point result) {
|
||||
return subtract(other.x(), other.y(), result);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public abstract class AbstractQuadCurve implements IQuadCurve
|
||||
}
|
||||
|
||||
@Override // from interface IShape
|
||||
public boolean contains (IPoint p) {
|
||||
public boolean contains (XY p) {
|
||||
return contains(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ public abstract class AbstractRectangle extends RectangularShape implements IRec
|
||||
}
|
||||
|
||||
@Override // from interface IRectangle
|
||||
public int outcode (IPoint p) {
|
||||
public int outcode (XY p) {
|
||||
return outcode(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ public class Arc extends AbstractArc implements Serializable
|
||||
* Sets the location, size, angular extents, and closure type of this arc to the specified
|
||||
* values.
|
||||
*/
|
||||
public void setArc (IPoint point, IDimension size, float start, float extent, int type) {
|
||||
public void setArc (XY point, IDimension size, float start, float extent, int type) {
|
||||
setArc(point.x(), point.y(), size.width(), size.height(), start, extent, type);
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ public class Arc extends AbstractArc implements Serializable
|
||||
* Sets the location, size, angular extents, and closure type of this arc based on the
|
||||
* specified values.
|
||||
*/
|
||||
public void setArcByTangent (IPoint p1, IPoint p2, IPoint p3, float radius) {
|
||||
public void setArcByTangent (XY p1, XY p2, XY p3, float radius) {
|
||||
// use simple geometric calculations of arc center, radius and angles by tangents
|
||||
float a1 = -FloatMath.atan2(p1.y() - p2.y(), p1.x() - p2.x());
|
||||
float a2 = -FloatMath.atan2(p3.y() - p2.y(), p3.x() - p2.x());
|
||||
@@ -195,7 +195,7 @@ public class Arc extends AbstractArc implements Serializable
|
||||
* Sets the starting angle of this arc to the angle defined by the supplied point relative to
|
||||
* the center of this arc.
|
||||
*/
|
||||
public void setAngleStart (IPoint point) {
|
||||
public void setAngleStart (XY point) {
|
||||
float angle = FloatMath.atan2(point.y() - centerY(), point.x() - centerX());
|
||||
setAngleStart(normAngle(-FloatMath.toDegrees(angle)));
|
||||
}
|
||||
@@ -227,7 +227,7 @@ public class Arc extends AbstractArc implements Serializable
|
||||
* point relative to the arc's center. The arc will always be non-empty and extend
|
||||
* counterclockwise from the first point around to the second point.
|
||||
*/
|
||||
public void setAngles (IPoint p1, IPoint p2) {
|
||||
public void setAngles (XY p1, XY p2) {
|
||||
setAngles(p1.x(), p1.y(), p2.x(), p2.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ public class Area implements IShape, Cloneable
|
||||
}
|
||||
|
||||
@Override // from interface IShape
|
||||
public boolean contains (IPoint p) {
|
||||
public boolean contains (XY p) {
|
||||
return contains(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Circle extends AbstractCircle implements Serializable
|
||||
/**
|
||||
* Constructs a circle with the specified properties
|
||||
*/
|
||||
public Circle (IPoint p, float radius) {
|
||||
public Circle (XY p, float radius) {
|
||||
this(p.x(), p.y(), radius);
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class CubicCurve extends AbstractCubicCurve implements Serializable
|
||||
/**
|
||||
* Configures the start, control and end points for this curve.
|
||||
*/
|
||||
public void setCurve (IPoint p1, IPoint cp1, IPoint cp2, IPoint p2) {
|
||||
public void setCurve (XY p1, XY cp1, XY cp2, XY p2) {
|
||||
setCurve(p1.x(), p1.y(), cp1.x(), cp1.y(),
|
||||
cp2.x(), cp2.y(), p2.x(), p2.y());
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class CubicCurve extends AbstractCubicCurve implements Serializable
|
||||
* Configures the start, control and end points for this curve, using the values at the
|
||||
* specified offset in the {@code points} array.
|
||||
*/
|
||||
public void setCurve (IPoint[] points, int offset) {
|
||||
public void setCurve (XY[] points, int offset) {
|
||||
setCurve(points[offset + 0].x(), points[offset + 0].y(),
|
||||
points[offset + 1].x(), points[offset + 1].y(),
|
||||
points[offset + 2].x(), points[offset + 2].y(),
|
||||
|
||||
@@ -22,7 +22,7 @@ public interface ICircle
|
||||
boolean intersects (ICircle c);
|
||||
|
||||
/** Returns true if this circle contains the supplied point. */
|
||||
boolean contains (IPoint p);
|
||||
boolean contains (XY p);
|
||||
|
||||
/** Returns true if this circle contains the specified point. */
|
||||
boolean contains (float x, float y);
|
||||
|
||||
@@ -41,32 +41,32 @@ public interface ILine extends IShape, Cloneable
|
||||
|
||||
/** Returns the square of the distance from the supplied point to the line defined by this line
|
||||
* segment. */
|
||||
float pointLineDistSq (IPoint p);
|
||||
float pointLineDistSq (XY p);
|
||||
|
||||
/** Returns the distance from the specified point to the line defined by this line segment. */
|
||||
float pointLineDist (float px, float py);
|
||||
|
||||
/** Returns the distance from the supplied point to the line defined by this line segment. */
|
||||
float pointLineDist (IPoint p);
|
||||
float pointLineDist (XY p);
|
||||
|
||||
/** Returns the square of the distance from the specified point this line segment. */
|
||||
float pointSegDistSq (float px, float py);
|
||||
|
||||
/** Returns the square of the distance from the supplied point this line segment. */
|
||||
float pointSegDistSq (IPoint p);
|
||||
float pointSegDistSq (XY p);
|
||||
|
||||
/** Returns the distance from the specified point this line segment. */
|
||||
float pointSegDist (float px, float py);
|
||||
|
||||
/** Returns the distance from the supplied point this line segment. */
|
||||
float pointSegDist (IPoint p);
|
||||
float pointSegDist (XY p);
|
||||
|
||||
/** Returns an indicator of where the specified point (px,py) lies with respect to this line
|
||||
* segment. */
|
||||
int relativeCCW (float px, float py);
|
||||
|
||||
/** Returns an indicator of where the specified point lies with respect to this line segment. */
|
||||
int relativeCCW (IPoint p);
|
||||
int relativeCCW (XY p);
|
||||
|
||||
/** Returns a mutable copy of this line. */
|
||||
Line clone ();
|
||||
|
||||
@@ -13,17 +13,17 @@ public interface IPoint extends XY, Cloneable
|
||||
float distanceSq (float px, float py);
|
||||
|
||||
/** Returns the squared Euclidian distance between this point and the supplied point. */
|
||||
float distanceSq (IPoint p);
|
||||
float distanceSq (XY p);
|
||||
|
||||
/** Returns the Euclidian distance between this point and the specified point. */
|
||||
float distance (float px, float py);
|
||||
|
||||
/** Returns the Euclidian distance between this point and the supplied point. */
|
||||
float distance (IPoint p);
|
||||
float distance (XY p);
|
||||
|
||||
/** Returns the angle (in radians) of the vector starting at this point and ending at the
|
||||
* supplied other point. */
|
||||
float direction (IPoint other);
|
||||
float direction (XY other);
|
||||
|
||||
/** Multiplies this point by a scale factor.
|
||||
* @return a new point containing the result. */
|
||||
@@ -51,7 +51,7 @@ public interface IPoint extends XY, Cloneable
|
||||
|
||||
/** Subtracts the supplied point from {@code this} and stores the result in {@code result}.
|
||||
* @return a reference to the result, for chaining. */
|
||||
Point subtract (IPoint other, Point result);
|
||||
Point subtract (XY other, Point result);
|
||||
|
||||
/** Rotates this point around the origin by the specified angle.
|
||||
* @return a new point containing the result. */
|
||||
|
||||
@@ -61,7 +61,7 @@ public interface IRectangle extends IRectangularShape, Cloneable
|
||||
|
||||
/** Returns a set of flags indicating where the supplied point lies in relation to the bounds of
|
||||
* this rectangle. See {@link #OUT_LEFT}, etc. */
|
||||
int outcode (IPoint point);
|
||||
int outcode (XY point);
|
||||
|
||||
/** Returns a mutable copy of this rectangle. */
|
||||
Rectangle clone ();
|
||||
|
||||
@@ -16,7 +16,7 @@ public interface IShape
|
||||
boolean contains (float x, float y);
|
||||
|
||||
/** Returns true if this shape contains the supplied point. */
|
||||
boolean contains (IPoint point);
|
||||
boolean contains (XY point);
|
||||
|
||||
/** Returns true if this shape completely contains the specified rectangle. */
|
||||
boolean contains (float x, float y, float width, float height);
|
||||
|
||||
@@ -39,7 +39,7 @@ public class Line extends AbstractLine implements Serializable
|
||||
/**
|
||||
* Creates a line from p1 to p2.
|
||||
*/
|
||||
public Line (IPoint p1, IPoint p2) {
|
||||
public Line (XY p1, XY p2) {
|
||||
setLine(p1, p2);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Line extends AbstractLine implements Serializable
|
||||
/**
|
||||
* Sets the start and end of this line to the specified points.
|
||||
*/
|
||||
public void setLine (IPoint p1, IPoint p2) {
|
||||
public void setLine (XY p1, XY p2) {
|
||||
setLine(p1.x(), p1.y(), p2.x(), p2.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ public final class Path implements IShape, Cloneable
|
||||
}
|
||||
|
||||
@Override // from interface IShape
|
||||
public boolean contains (IPoint p) {
|
||||
public boolean contains (XY p) {
|
||||
return contains(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -33,13 +33,13 @@ public class Point extends AbstractPoint implements Serializable
|
||||
/**
|
||||
* Constructs a point with coordinates equal to the supplied point.
|
||||
*/
|
||||
public Point (IPoint p) {
|
||||
public Point (XY p) {
|
||||
set(p.x(), p.y());
|
||||
}
|
||||
|
||||
/** Sets the coordinates of this point to be equal to those of the supplied point.
|
||||
* @return a reference to this this, for chaining. */
|
||||
public Point set (IPoint p) {
|
||||
public Point set (XY p) {
|
||||
return set(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class QuadCurve extends AbstractQuadCurve implements Serializable
|
||||
/**
|
||||
* Configures the start, control, and end points for this curve.
|
||||
*/
|
||||
public void setCurve (IPoint p1, IPoint cp, IPoint p2) {
|
||||
public void setCurve (XY p1, XY cp, XY p2) {
|
||||
setCurve(p1.x(), p1.y(), cp.x(), cp.y(), p2.x(), p2.y());
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class QuadCurve extends AbstractQuadCurve implements Serializable
|
||||
* Configures the start, control, and end points for this curve, using the values at the
|
||||
* specified offset in the {@code points} array.
|
||||
*/
|
||||
public void setCurve (IPoint[] points, int offset) {
|
||||
public void setCurve (XY[] points, int offset) {
|
||||
setCurve(points[offset + 0].x(), points[offset + 0].y(),
|
||||
points[offset + 1].x(), points[offset + 1].y(),
|
||||
points[offset + 2].x(), points[offset + 2].y());
|
||||
|
||||
@@ -32,7 +32,7 @@ public class Rectangle extends AbstractRectangle implements Serializable
|
||||
/**
|
||||
* Constructs a rectangle with the supplied upper-left corner and dimensions (0,0).
|
||||
*/
|
||||
public Rectangle (IPoint p) {
|
||||
public Rectangle (XY p) {
|
||||
setBounds(p.x(), p.y(), 0, 0);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class Rectangle extends AbstractRectangle implements Serializable
|
||||
* Constructs a rectangle with upper-left corner at the supplied point and with the supplied
|
||||
* dimensions.
|
||||
*/
|
||||
public Rectangle (IPoint p, IDimension d) {
|
||||
public Rectangle (XY p, IDimension d) {
|
||||
setBounds(p.x(), p.y(), d.width(), d.height());
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class Rectangle extends AbstractRectangle implements Serializable
|
||||
/**
|
||||
* Sets the upper-left corner of this rectangle to the supplied point.
|
||||
*/
|
||||
public void setLocation (IPoint p) {
|
||||
public void setLocation (XY p) {
|
||||
setLocation(p.x(), p.y());
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public class Rectangle extends AbstractRectangle implements Serializable
|
||||
/**
|
||||
* Expands the bounds of this rectangle to contain the supplied point.
|
||||
*/
|
||||
public void add (IPoint p) {
|
||||
public void add (XY p) {
|
||||
add(p.x(), p.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public abstract class RectangularShape implements IRectangularShape
|
||||
/**
|
||||
* Sets the location and size of the framing rectangle of this shape to the supplied values.
|
||||
*/
|
||||
public void setFrame (IPoint loc, IDimension size) {
|
||||
public void setFrame (XY loc, IDimension size) {
|
||||
setFrame(loc.x(), loc.y(), size.width(), size.height());
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public abstract class RectangularShape implements IRectangularShape
|
||||
* Sets the location and size of the framing rectangle of this shape based on the supplied
|
||||
* diagonal line.
|
||||
*/
|
||||
public void setFrameFromDiagonal (IPoint p1, IPoint p2) {
|
||||
public void setFrameFromDiagonal (XY p1, XY p2) {
|
||||
setFrameFromDiagonal(p1.x(), p1.y(), p2.x(), p2.y());
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public abstract class RectangularShape implements IRectangularShape
|
||||
* Sets the location and size of the framing rectangle of this shape based on the supplied
|
||||
* center and corner points.
|
||||
*/
|
||||
public void setFrameFromCenter (IPoint center, IPoint corner) {
|
||||
public void setFrameFromCenter (XY center, XY corner) {
|
||||
setFrameFromCenter(center.x(), center.y(), corner.x(), corner.y());
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public abstract class RectangularShape implements IRectangularShape
|
||||
}
|
||||
|
||||
@Override // from interface IShape
|
||||
public boolean contains (IPoint point) {
|
||||
public boolean contains (XY point) {
|
||||
return contains(point.x(), point.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Vectors
|
||||
/**
|
||||
* Creates a vector from {@code from} to {@code to}.
|
||||
*/
|
||||
public static Vector from (IPoint from, IPoint to) {
|
||||
public static Vector from (XY from, XY to) {
|
||||
return new Vector(to.x() - from.x(), to.y() - from.y());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user