|
Eclipse Draw2d 3.3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.draw2d.geometry.Point
public class 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)
Deprecated. Use PrecisionPoint or Point(int, int)
instead. |
|
Point(int x,
int y)
Constructs a Point at the specified x and y locations. |
|
Point(org.eclipse.swt.graphics.Point p)
Constructs a Point at the same location as the given SWT Point. |
Method Summary | |
---|---|
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. |
org.eclipse.swt.graphics.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(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(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. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Point SINGLETON
public int x
public int y
Constructor Detail |
---|
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(org.eclipse.swt.graphics.Point p)
p
- Point from which the initial values are taken.Method Detail |
---|
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 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 value
true
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 equality
public Point getCopy()
public Dimension getDifference(Point p)
p
- The Point being subtracted from this Point
public double getDistance(Point p)
p
- The Point being compared to this
public int getDistance2(Point p)
getDistance(Point)
and square the result
instead.
Integer.MAX_VALUE
will be returned.
p
- The reference Point
public int getDistanceOrthogonal(Point p)
p
- The reference Point
public Point getNegated()
public int getPosition(Point p)
p
- The reference Point
PositionConstants
public Point getScaled(double factor)
factor
- scale factor
public org.eclipse.swt.graphics.Point getSWTPoint()
Point
from this
Point.
public Point getTranslated(Dimension d)
d
- Dimension which provides the translation amounts.
public Point getTranslated(int x, int y)
x
- horizontal componenty
- vertical component
public 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 coordinate
double
x coordinatepublic double preciseY()
double
y coordinate
double
y coordinatepublic Point scale(double factor)
factor
- scale factor
this
for conveniencepublic Point scale(double xFactor, double yFactor)
xFactor
- horizontal scale factoryFactor
- 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 p)
p
- the Location
this
for conveniencepublic Point setX(int x)
x
- The new x value
public Point setY(int y)
y
- The new y value
public 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(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()
|
Eclipse Draw2d 3.3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |