public class Point extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable, Translatable
Modifier and Type | Field and Description |
---|---|
static Point |
SINGLETON
A singleton for use in short calculations
|
int |
x
x value
|
int |
y
y value
|
Constructor and Description |
---|
Point()
Constructs a Point at location (0,0).
|
Point(double x,
double y)
Deprecated.
Use
PrecisionPoint or Point(int, int)
instead. |
Point(int x,
int y)
Constructs a Point at the specified x and y locations.
|
Point(Point p)
Constructs a Point at the same location as the given SWT Point.
|
Point(Point p)
Constructs a Point at the same location as the given Point.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(int x,
int 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.
|
Point |
getCopy() |
Dimension |
getDifference(Point p)
Calculates the difference in between this Point and the one specified.
|
double |
getDistance(Point p)
Calculates the distance from this Point to the one specified.
|
int |
getDistance2(Point p)
Deprecated.
Use
getDistance(Point) and square the result
instead. |
int |
getDistanceOrthogonal(Point p)
Deprecated.
May not be guaranteed by precision subclasses and should thus
not be used any more.
|
Point |
getNegated()
Creates a Point with negated x and y values.
|
int |
getPosition(Point p)
Calculates the relative position of the specified Point to this Point.
|
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 x and y
factors.
|
Point |
getSWTPoint()
Creates a new SWT
Point from this
Point. |
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(int x,
int 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.
|
Point |
negate()
Negates the x and y values of this Point.
|
void |
performScale(double factor)
Scales this object by the scale factor.
|
void |
performTranslate(int dx,
int dy)
Translates this object horizontally by
dx and vertically by
dy . |
double |
preciseX()
Returns
double x coordinate |
double |
preciseY()
Returns
double y coordinate |
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 |
setLocation(int x,
int 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(int x)
Sets the x value of this Point to the given value.
|
Point |
setY(int 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 x,
double y)
Shifts this Point by the values supplied along each axes, and returns
this for convenience.
|
Point |
translate(int dx,
int 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.
|
Point |
transpose()
Transposes this object.
|
int |
x()
Returns the x value of this Point.
|
int |
y()
Returns the y value of this Point.
|
public static final Point SINGLETON
public int x
public int y
public Point()
public Point(double x, double y)
PrecisionPoint
or Point(int, int)
instead.x
- x valuey
- y valuepublic Point(int x, int y)
x
- x valuey
- y valuepublic Point(Point p)
p
- Point from which the initial values are taken.public Point(Point p)
p
- Point from which the initial values are taken.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 boolean equals(int x, int 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.Object
o
- Object being tested for equalitypublic Point getCopy()
public Dimension getDifference(Point p)
p
- The Point being subtracted from this Pointpublic double getDistance(Point p)
p
- The Point being compared to thispublic int getDistance2(Point p)
getDistance(Point)
and square the result
instead.Integer.MAX_VALUE
will be returned.p
- The reference Pointpublic int getDistanceOrthogonal(Point p)
p
- The reference Pointpublic Point getNegated()
public int getPosition(Point p)
p
- The reference PointPositionConstants
public Point getScaled(double factor)
factor
- scale factorpublic Point getScaled(double xFactor, double yFactor)
xFactor
- x scale factoryFactor
- y scale factorpublic Point getSWTPoint()
Point
from this
Point.public 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(int x, int 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.Object
Object.hashCode()
public Point negate()
this
for conveniencepublic void performScale(double factor)
Translatable
performScale
in interface Translatable
factor
- The scale factorTranslatable.performScale(double)
public void performTranslate(int dx, int dy)
Translatable
dx
and vertically by
dy
.performTranslate
in interface Translatable
dx
- The amount to translate horizontallydy
- The amount to translate verticallyTranslatable.performTranslate(int, int)
public double preciseX()
double
x coordinatedouble
x coordinatepublic double preciseY()
double
y coordinatedouble
y coordinatepublic 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 setLocation(int x, int y)
x
- the x locationy
- the y locationthis
for conveniencepublic Point setLocation(Point p)
p
- the Locationthis
for conveniencepublic Point setX(int x)
x
- The new x valuepublic Point setY(int y)
y
- The new y valuepublic java.lang.String toString()
toString
in class java.lang.Object
public Point translate(Dimension d)
d
- Dimension by which the origin is being shifted.this
for conveniencepublic Point translate(double x, double y)
x
- Amount by which point is shifted along X axis.y
- Amount by which point is shifted along Y axis.this
for conveniencepublic Point translate(int dx, int 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 int x()
public int y()
Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.