|
Eclipse Draw2d 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.draw2d.geometry.Point
Represents a point (x, y) in 2-dimensional space. This class provides various methods for manipulating this Point or creating new derived geometrical Objects.
Field Summary | |
static Point |
SINGLETON
A singleton for use in short calculations |
int |
x
x value |
int |
y
y value |
Constructor Summary | |
Point()
Constructs a Point at location (0,0). |
|
Point(double x,
double y)
Constructs a Point at the specified x and y locations. |
|
Point(int x,
int y)
Constructs a Point at the specified x and y locations. |
|
Point(Point copy)
Constructs a Point which is at the same location as the specified Point. |
Method Summary | |
boolean |
equals(Object o)
Test for equality. |
Point |
getCopy()
|
Dimension |
getDifference(Point pt)
Calculates the difference in between this Point and the one specified. |
double |
getDistance(Point pt)
Calculates the distance from this Point to the one specified. |
int |
getDistance2(Point pt)
Calculates the distance squared between this Point and the one specified. |
int |
getDistanceOrthogonal(Point pt)
Calculates the orthogonal distance to the specified point. |
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 amount)
Creates a new Point from this Point by scaling by the specified amount. |
Point |
getSWTPoint()
Creates a new SWT Point from this Point. |
Point |
getTranslated(Dimension delta)
Creates a new Point which is translated by the values of the input Dimension. |
Point |
getTranslated(int x,
int y)
Creates a new Point which is translated by the specified x and y values |
Point |
getTranslated(Point pt)
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. |
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 . |
Point |
scale(double amount)
Scales this Point by the specified amount. |
Point |
scale(double xAmount,
double yAmount)
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 pt)
Sets the location of this Point to the specified Point. |
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(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. |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final Point SINGLETON
public int x
public int y
Constructor Detail |
public Point()
public Point(Point copy)
copy
- Point from which the initial values are taken.public Point(int x, int y)
x
- x valuey
- y valuepublic Point(double x, double y)
x
- x valuey
- y valueMethod Detail |
public boolean equals(Object o)
equals
in class Object
o
- Object being tested for equality
public Point getCopy()
public Dimension getDifference(Point pt)
pt
- The Point being subtracted from this Point
public double getDistance(Point pt)
pt
- The Point being compared to this
public int getDistance2(Point pt)
pt
- The reference Point
public int getDistanceOrthogonal(Point pt)
pt
- The reference Point
public Point getNegated()
public int getPosition(Point p)
p
- The reference Point
PositionConstants
public Point getScaled(double amount)
amount
- scale factor
public Point getSWTPoint()
Point
from this Point.
public Point getTranslated(Dimension delta)
delta
- Dimension which provides the translation amounts.
public Point getTranslated(int x, int y)
x
- horizontal componenty
- vertical component
public Point getTranslated(Point pt)
pt
- Point which provides the translation amounts.
public Point getTransposed()
public static Point max(Point p1, Point p2)
p1
- first pointp2
- second point
public static Point min(Point p1, Point p2)
p1
- first pointp2
- second point
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 Point scale(double amount)
amount
- scale factor
this
for conveniencepublic Point scale(double xAmount, double yAmount)
xAmount
- horizontal scale factoryAmount
- vertical scale factor
this
for conveniencepublic Point setLocation(int x, int y)
x
- the x locationy
- the y location
this
for conveniencepublic Point setLocation(Point pt)
pt
- the Location
this
for conveniencepublic String toString()
toString
in class Object
public Point translate(Point p)
p
- Point to which the origin is being shifted.
this
for conveniencepublic Point translate(Dimension d)
d
- Dimension by which the origin is being shifted.
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 transpose()
this
for convenience
|
Eclipse Draw2d 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |