public class Point
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
double |
x
The x value.
|
double |
y
The y value.
|
| Constructor and Description |
|---|
Point()
Constructs a Point at location (0,0).
|
Point(double x,
double y)
Constructs a Point at the specified x and y locations.
|
Point(Point p)
Constructs a Point at the same location as the given Point.
|
| Modifier and Type | Method and Description |
|---|---|
Point |
clone()
Overwritten with public visibility as proposed in
Cloneable. |
boolean |
equals(double x,
double y)
Returns
true if this Points x and y are equal to the given x
and y. |
boolean |
equals(java.lang.Object o)
Test for equality.
|
static Rectangle |
getBounds(Point... points)
|
static Point |
getCentroid(Point... points)
Computes the centroid of the given
Points. |
static Point[] |
getConvexHull(Point... points)
Computes the convex hull of the given set of
Points using the
Graham scan algorithm. |
Point |
getCopy() |
static Point[] |
getCopy(Point... points)
Copies an array of points, by copying each point contained in the array.
|
Point |
getDifference(Point other)
|
double |
getDistance(Point p)
Calculates the distance from this Point to the one specified.
|
Point |
getNegated()
Creates a Point with negated x and y values.
|
static Point[] |
getReverseCopy(Point... points)
Returns a copy of the given array of points, where the points are placed
in reversed order.
|
Point |
getScaled(double factor)
Creates a new Point from this Point by scaling by the specified amount.
|
Point |
getScaled(double xFactor,
double yFactor)
Creates a new Point from this Point by scaling by the specified values.
|
Point |
getScaled(double factorX,
double factorY,
Point center)
Returns a new
Point scaled by the given scale-factors. |
Point |
getTranslated(Dimension d)
Creates a new Point which is translated by the values of the input
Dimension.
|
Point |
getTranslated(double x,
double y)
Creates a new Point which is translated by the specified x and y values
|
Point |
getTranslated(Point p)
Creates a new Point which is translated by the values of the provided
Point.
|
Point |
getTransposed()
Creates a new Point with the transposed values of this Point.
|
int |
hashCode() |
static Point |
max(Point p1,
Point p2)
Creates a new Point representing the MAX of two provided Points.
|
static Point |
min(Point p1,
Point p2)
Creates a new Point representing the MIN of two provided Points.
|
static Point |
nearest(Point referencePoint,
Point... candidates)
Returns (one of) the candidate(s) with minimal distance to the given
reference point.
|
Point |
negate()
Negates the x and y values of this Point.
|
static void |
rotateCCW(Point[] points,
Angle angle,
double cx,
double cy)
|
static void |
rotateCW(Point[] points,
Angle angle,
double cx,
double cy)
|
Point |
scale(double factor)
Scales this Point by the specified amount.
|
Point |
scale(double xFactor,
double yFactor)
Scales this Point by the specified values.
|
Point |
scale(double factorX,
double factorY,
Point center)
Scales this
Point by the given scale-factors. |
static void |
scale(Point[] points,
double fx,
double fy,
double cx,
double cy)
|
Point |
setLocation(double x,
double y)
Sets the location of this Point to the provided x and y locations.
|
Point |
setLocation(Point p)
Sets the location of this Point to the specified Point.
|
Point |
setX(double x)
Sets the x value of this Point to the given value.
|
Point |
setY(double y)
Sets the y value of this Point to the given value;
|
java.lang.String |
toString() |
Point |
translate(Dimension d)
Shifts this Point by the values of the Dimension along each axis, and
returns this for convenience.
|
Point |
translate(double dx,
double dy)
Shifts this Point by the values supplied along each axes, and returns
this for convenience.
|
Point |
translate(Point p)
Shifts the location of this Point by the location of the input Point
along each of the axes, and returns this for convenience.
|
static void |
translate(Point[] points,
double dx,
double dy)
Translates an array of
Points by translating each individual
point by a given x and y offset. |
Point |
transpose()
Transposes this object.
|
double |
x()
Returns the x value of this Point.
|
double |
y()
Returns the y value of this Point.
|
public Point()
public Point(double x,
double y)
x - x valuey - y valuepublic Point(Point p)
p - Point from which the initial values are taken.public static Point[] getConvexHull(Point... points)
Points using the
Graham scan algorithm.public static final Point[] getCopy(Point... points)
public static final Point[] getReverseCopy(Point... points)
public static Point max(Point p1, Point p2)
p1 - first pointp2 - second pointpublic static Point min(Point p1, Point p2)
p1 - first pointp2 - second pointpublic static Point nearest(Point referencePoint, Point... candidates)
referencePoint - The reference point, to which distance has to be minimal.candidates - The points from which to choose the one with minimal distance.public static void scale(Point[] points, double fx, double fy, double cx, double cy)
Points by the given x and y scale
factors around the given center Point (cx, cy).points - The array of Points to scale.fx - The horizontal scale factor.fy - Ther vertical scale factor.cx - The x-coordinate of the scale's pivot point.cy - The y-coordinate of the scale's pivot point.public static void translate(Point[] points, double dx, double dy)
Points by translating each individual
point by a given x and y offset.public Point clone()
Cloneable.clone in class java.lang.Objectpublic boolean equals(double x,
double y)
true if this Points x and y are equal to the given x
and y.x - the x valuey - the y valuetrue if this point's x and y are equal to those
given.public boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - Object being tested for equalitypublic Point getCopy()
public double getDistance(Point p)
p - The Point being compared to thispublic Point getNegated()
public Point getScaled(double factor)
factor - scale factorpublic Point getScaled(double xFactor, double yFactor)
xFactor - horizontal scale factoryFactor - vertical scale factorpublic Point getTranslated(Dimension d)
d - Dimension which provides the translation amounts.public Point getTranslated(double x, double y)
x - horizontal componenty - vertical componentpublic Point getTranslated(Point p)
p - Point which provides the translation amounts.public Point getTransposed()
public int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()public Point negate()
this for conveniencepublic Point scale(double factor)
factor - scale factorthis for conveniencepublic Point scale(double xFactor, double yFactor)
xFactor - horizontal scale factoryFactor - vertical scale factorthis for conveniencepublic Point scale(double factorX, double factorY, Point center)
Point by the given scale-factors. The scaling is
performed relative to the given Point center.factorX - The horizontal scale-factorfactorY - The vertical scale-factorcenter - The relative Point for the scalingthis for conveniencepublic Point setLocation(double x, double y)
x - the x locationy - the y locationthis for conveniencepublic Point setLocation(Point p)
p - the Locationthis for conveniencepublic Point setX(double x)
x - The new x valuepublic Point setY(double y)
y - The new y valuepublic java.lang.String toString()
toString in class java.lang.ObjectObject.toString()public Point translate(Dimension d)
d - Dimension by which the origin is being shifted.this for conveniencepublic Point translate(double dx, double dy)
dx - Amount by which point is shifted along X axis.dy - Amount by which point is shifted along Y axis.this for conveniencepublic Point translate(Point p)
p - Point to which the origin is being shifted.this for conveniencepublic Point transpose()
this for conveniencepublic double x()
public double y()
Copyright (c) 2014 itemis AG, and others. All rights reserved.