public class PicPoint
extends java.awt.geom.Point2D.Double
implements java.lang.Cloneable
Modifier and Type | Class and Description |
---|---|
static class |
PicPoint.XComparator
a comparator b/w PicPoint for X-axis ordering
|
static class |
PicPoint.YComparator
a comparator b/w PicPoint for Y-axis ordering
|
Modifier and Type | Field and Description |
---|---|
static PicPoint.XComparator |
X_COMPARATOR |
static PicPoint.YComparator |
Y_COMPARATOR |
Constructor and Description |
---|
PicPoint()
Construct a (0,0) point.
|
PicPoint(double[] f)
Construct a point from the first two elements of the given array.
|
PicPoint(double x,
double y)
Construct (x,y)
|
PicPoint(float[] f)
Construct a point from the first two elements of the given array.
|
PicPoint(java.lang.Number x,
java.lang.Number y)
Construct a point from the given pair of Number (using their double value).
|
PicPoint(java.awt.geom.Point2D p)
Clone the given point.
|
PicPoint(java.awt.geom.Point2D p1,
java.awt.geom.Point2D p2,
double ratio)
Construct a new PicPoint "p" located on the line joining p1 with p2, so that
(p1,p) = ratio * (p1,p2)
|
PicPoint(java.lang.String str)
Construct a point by parsing a String similar to that given by the
toString() method, ie (x,y) . |
Modifier and Type | Method and Description |
---|---|
void |
apply(java.awt.geom.AffineTransform at)
Apply the given AffineTransform to the coordinates of this point
|
java.lang.Object |
clone()
Creates and returns a deep copy of this PicPoint.
|
static void |
main(java.lang.String[] args)
validation tests
|
PicPoint |
middle(PicPoint other)
Translate this point to the middle of the segment made of [this,other].
|
PicPoint |
project(PicPoint p1,
PicPoint p2)
Project this point onto the line joining p1 and p2.
|
PicPoint |
project(PicPoint p1,
PicPoint p2,
PicPoint dir)
Project this point onto the line joining p1 and p2.
|
PicPoint |
rotate(PicPoint ptOrg,
double angle)
Apply a rotation of center ptOrg and the given angle in radians to this PicPoint
Current implementation arranges for a very fast code if angle is Math.PI, Math.PI/2 or
-Math.PI/2.
|
PicPoint |
scale(double ptOrgX,
double ptOrgY,
double s)
Apply a scaling transform to this point.
|
PicPoint |
scale(double ptOrgX,
double ptOrgY,
double sx,
double sy)
Apply a scaling transform to this point.
|
PicPoint |
scale(PicPoint ptOrg,
double s)
Apply a scaling transform to this point.
|
PicPoint |
scale(PicPoint ptOrg,
double sx,
double sy)
Apply a scaling transform to this point.
|
void |
setCoordinates(double x,
double y)
Set the coordinates of this point from the given pair
|
PicPoint |
setCoordinates(PicPoint pt)
Set the coordinates of this point from the given point.
|
PicPoint |
shear(PicPoint ptOrg,
double shx,
double shy)
Apply a shearing transform of given parameters wrt to the given origin, to this PicPoint
|
PicPoint |
symmetry(PicPoint center)
Apply a central-symmetry wrt the given point
|
static PicPoint |
symmetry(PicPoint center,
PicPoint src)
Return a new PicPoint obtained by applying a central-symmetry with the given center to
the given src point.
|
double[] |
toDoubleArray(double[] f)
Return a two-element array filled with x and y ; if f is null, a new array is allocated ; otherwise,
the given array is directly modified and returned for convenience.
|
float[] |
toFloatArray(float[] f)
Return a two-element array filled with x and y ; if f is null, a new array is allocated ; otherwise,
the given array is directly modified and returned for convenience.
|
PicPoint |
toMm(double unitLength)
Convert a PicPoint with coordinates expressed in the given unitlenth (expressed in mm),
to a new PicPoint in mm coordinates.
|
PicPoint |
toMm(double xUnit,
double yUnit)
Convert a PicPoint with coordinate expressed in the given unitlenths along X- and Y-axis (the latter being expressed in mm)
to a new PicPoint in mm coordinate.
|
java.lang.String |
toString()
Return a "(x,y)" string representing this point.
|
PicPoint |
translate(double dx,
double dy)
translates this point by (dx,dy)
|
PicPoint |
translate(PicPoint p)
translates this point by (p.x, p.y), ie the given point is considered as a translation vector.
|
PicPoint |
translate(PicPoint p,
double a)
translates this point by a*(p.x, p.y), ie the given point is considered as a translation vector scaled
by the given double.
This method proves a useful when one wants to minimize object creation, since it avoids cloning a given PicPoint, scaling it by "a", then passing it to the translate(PicPoint) method. |
PicPoint |
translate(PicPoint p1,
PicPoint p2)
translates this point by (p2.x-p1.x, p2.y-p2.y), ie the given point is considered as a translation vector
build from the two given points.
|
PicPoint |
translate(PicPoint p1,
PicPoint p2,
double a)
translates this point by a*(p2.x-p1.x, p2.y-p2.y), ie the given point is considered as a translation vector
build from the two given points, then scaled by the given double.
|
public static final PicPoint.XComparator X_COMPARATOR
public static final PicPoint.YComparator Y_COMPARATOR
public PicPoint()
public PicPoint(java.awt.geom.Point2D p)
public PicPoint(java.awt.geom.Point2D p1, java.awt.geom.Point2D p2, double ratio)
ratio
- any double, positive or not.public PicPoint(double x, double y)
public PicPoint(java.lang.Number x, java.lang.Number y)
public PicPoint(float[] f)
public PicPoint(double[] f)
public PicPoint(java.lang.String str) throws java.lang.NumberFormatException
toString()
method, ie (x,y)
.java.lang.NumberFormatException
public java.lang.Object clone()
clone
in class java.awt.geom.Point2D
public PicPoint setCoordinates(PicPoint pt)
public void setCoordinates(double x, double y)
public float[] toFloatArray(float[] f)
public double[] toDoubleArray(double[] f)
public java.lang.String toString()
toString
in class java.awt.geom.Point2D.Double
public PicPoint toMm(double unitLength)
unitLength
- In mmpublic PicPoint toMm(double xUnit, double yUnit)
xUnit
- unilength along the X-axis expressed in mmyUnit
- unilength along the Y-axis expressed in mmpublic PicPoint translate(double dx, double dy)
public PicPoint translate(PicPoint p)
public PicPoint translate(PicPoint p1, PicPoint p2)
public PicPoint translate(PicPoint p, double a)
public PicPoint translate(PicPoint p1, PicPoint p2, double a)
public PicPoint symmetry(PicPoint center)
public static PicPoint symmetry(PicPoint center, PicPoint src)
public PicPoint scale(PicPoint ptOrg, double sx, double sy)
sx
- Scaling factors along the X-axissy
- Scaling factors along the Y-axisptOrg
- transformation centrepublic PicPoint scale(PicPoint ptOrg, double s)
s
- Scaling factors along the X- and Y- axisptOrg
- transformation centrepublic PicPoint scale(double ptOrgX, double ptOrgY, double s)
s
- Scaling factors along the X- and Y- axisptOrgX
- X-coord of transformation centreptOrgY
- Y-coord of transformation centrepublic PicPoint scale(double ptOrgX, double ptOrgY, double sx, double sy)
sx
- Scaling factors along the X-axissy
- Scaling factors along the Y-axisptOrgX
- X-coord of transformation centreptOrgY
- Y-coord of transformation centrepublic PicPoint rotate(PicPoint ptOrg, double angle)
public PicPoint shear(PicPoint ptOrg, double shx, double shy)
public PicPoint middle(PicPoint other)
public PicPoint project(PicPoint p1, PicPoint p2)
public PicPoint project(PicPoint p1, PicPoint p2, PicPoint dir)
dir
- a vector indicating the projection axispublic static void main(java.lang.String[] args)
public void apply(java.awt.geom.AffineTransform at)
Submit a bug : syd@jpicedt.org