org.eclipse.draw2d.geometry
Class Point
java.lang.Object
org.eclipse.draw2d.geometry.Point
-
All Implemented Interfaces:
- java.lang.Cloneable, java.io.Serializable,
Translatable
-
Direct Known Subclasses:
-
AbsoluteBendpoint,
PrecisionPoint
- public class Point
- extends java.lang.Object
- implements java.lang.Cloneable, java.io.Serializable,
Translatable
Represents a point (x, y) in 2-dimensional space. This class provides various methods
for manipulating this Point or creating new derived geometrical Objects.
-
See Also:
-
Serialized Form
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 at the same location as the given Point. |
Method Summary
|
boolean
|
equals
(java.lang.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. |
org.eclipse.swt.graphics.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.
|
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 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. |
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. |
Methods inherited from class java.lang.Object
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
|
SINGLETON
public static final
Point SINGLETON
- A singleton for use in short calculations
x
public int x
- x value
y
public int y
- y value
Point
public Point()
- Constructs a Point at location (0,0).
-
Since:
- 2.0
Point
public Point(
Point copy)
- Constructs a Point at the same location as the given Point.
-
Parameters:
-
copy
- Point from which the initial values are taken. -
Since:
- 2.0
Point
public Point(int x,
int y)
- Constructs a Point at the specified x and y locations.
-
Parameters:
-
x
- x value -
y
- y value -
Since:
- 2.0
Point
public Point(double x,
double y)
- Constructs a Point at the specified x and y locations.
-
Parameters:
-
x
- x value -
y
- y value -
Since:
- 2.0
equals
public boolean equals(java.lang.Object o)
- Test for equality.
-
-
-
Parameters:
-
o
- Object being tested for equality
-
Returns:
- true if both x and y values are equal
-
Since:
- 2.0
getCopy
public
Point getCopy()
-
-
-
Returns:
- a copy of this Point
-
Since:
- 2.0
getDifference
public
Dimension getDifference(
Point pt)
- Calculates the difference in between this Point and the one specified.
-
-
-
Parameters:
-
pt
- The Point being subtracted from this Point
-
Returns:
- A new Dimension representing the difference
-
Since:
- 2.0
getDistance
public double getDistance(
Point pt)
- Calculates the distance from this Point to the one specified.
-
-
-
Parameters:
-
pt
- The Point being compared to this
-
Returns:
- The distance
-
Since:
- 2.0
getDistance2
public int getDistance2(
Point pt)
- Calculates the distance squared between this Point and the one specified. If
the distance squared is larger than the maximum integer value, then
Integer.MAX_VALUE
will be returned.
-
-
-
Parameters:
-
pt
- The reference Point
-
Returns:
- distance2
-
Since:
- 2.0
getDistanceOrthogonal
public int getDistanceOrthogonal(
Point pt)
- Calculates the orthogonal distance to the specified point. The orthogonal distance is
the sum of the horizontal and vertical differences.
-
-
-
Parameters:
-
pt
- The reference Point
-
Returns:
- the orthoganal distance
getNegated
public
Point getNegated()
- Creates a Point with negated x and y values.
-
-
-
Returns:
- A new Point
-
Since:
- 2.0
getPosition
public int getPosition(
Point p)
- Calculates the relative position of the specified Point to this Point.
-
-
-
Parameters:
-
p
- The reference Point
-
Returns:
- NORTH, SOUTH, EAST, or WEST, as defined in
PositionConstants
getScaled
public
Point getScaled(double amount)
- Creates a new Point from this Point by scaling by the specified amount.
-
-
-
Parameters:
-
amount
- scale factor
-
Returns:
- A new Point
-
Since:
- 2.0
getSWTPoint
public org.eclipse.swt.graphics.Point getSWTPoint()
- Creates a new SWT
Point
from this Point.
-
-
-
Returns:
- A new SWT Point
-
Since:
- 2.0
getTranslated
public
Point getTranslated(
Dimension delta)
- Creates a new Point which is translated by the values of the input Dimension.
-
-
-
Parameters:
-
delta
- Dimension which provides the translation amounts.
-
Returns:
- A new Point
-
Since:
- 2.0
getTranslated
public
Point getTranslated(int x,
int y)
- Creates a new Point which is translated by the specified x and y values
-
-
-
Parameters:
-
x
- horizontal component -
y
- vertical component
-
Returns:
- A new Point
-
Since:
- 2.0
getTranslated
public
Point getTranslated(
Point pt)
- Creates a new Point which is translated by the values of the provided Point.
-
-
-
Parameters:
-
pt
- Point which provides the translation amounts.
-
Returns:
- A new Point
-
Since:
- 2.0
getTransposed
public
Point getTransposed()
- Creates a new Point with the transposed values of this Point.
Can be useful in orientation change calculations.
-
-
-
Returns:
- A new Point
-
Since:
- 2.0
hashCode
public int hashCode()
-
-
-
See Also:
-
Object.hashCode()
max
public static
Point max(
Point p1,
Point p2)
- Creates a new Point representing the MAX of two provided Points.
-
-
-
Parameters:
-
p1
- first point -
p2
- second point
-
Returns:
- A new Point representing the Max()
min
public static
Point min(
Point p1,
Point p2)
- Creates a new Point representing the MIN of two provided Points.
-
-
-
Parameters:
-
p1
- first point -
p2
- second point
-
Returns:
- A new Point representing the Min()
negate
public
Point negate()
- Negates the x and y values of this Point.
-
-
-
Returns:
-
this
for convenience -
Since:
- 2.0
performScale
public void performScale(double factor)
-
Description copied from interface:
Translatable
- Scales this object by the scale factor.
-
-
Specified by:
-
performScale
in interface
Translatable
-
-
Parameters:
-
factor
- The scale factor -
See Also:
-
Translatable.performScale(double)
performTranslate
public void performTranslate(int dx,
int dy)
-
Description copied from interface:
Translatable
- Translates this object horizontally by
dx
and vertically by
dy
.
-
-
Specified by:
-
performTranslate
in interface
Translatable
-
-
Parameters:
-
dx
- The amount to translate horizontally -
dy
- The amount to translate vertically -
See Also:
-
Translatable.performTranslate(int, int)
scale
public
Point scale(double amount)
- Scales this Point by the specified amount.
-
-
-
Parameters:
-
amount
- scale factor
-
Returns:
-
this
for convenience -
Since:
- 2.0
scale
public
Point scale(double xAmount,
double yAmount)
- Scales this Point by the specified values.
-
-
-
Parameters:
-
xAmount
- horizontal scale factor -
yAmount
- vertical scale factor
-
Returns:
-
this
for convenience -
Since:
- 2.0
setLocation
public
Point setLocation(int x,
int y)
- Sets the location of this Point to the provided x and y locations.
-
-
-
Parameters:
-
x
- the x location -
y
- the y location
-
Returns:
-
this
for convenience -
Since:
- 2.0
setLocation
public
Point setLocation(
Point pt)
- Sets the location of this Point to the specified Point.
-
-
-
Parameters:
-
pt
- the Location
-
Returns:
-
this
for convenience -
Since:
- 2.0
toString
public java.lang.String toString()
-
-
-
Returns:
- String representation.
-
Since:
- 2.0
translate
public
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.
-
-
-
Parameters:
-
p
- Point to which the origin is being shifted.
-
Returns:
-
this
for convenience -
Since:
- 2.0
translate
public
Point translate(
Dimension d)
- Shifts this Point by the values of the Dimension along
each axis, and returns this for convenience.
-
-
-
Parameters:
-
d
- Dimension by which the origin is being shifted.
-
Returns:
-
this
for convenience -
Since:
- 2.0
translate
public
Point translate(int dx,
int dy)
- Shifts this Point by the values supplied along each axes, and
returns this for convenience.
-
-
-
Parameters:
-
dx
- Amount by which point is shifted along X axis. -
dy
- Amount by which point is shifted along Y axis.
-
Returns:
-
this
for convenience -
Since:
- 2.0
transpose
public
Point transpose()
- Transposes this object. X and Y values are exchanged.
-
-
-
Returns:
-
this
for convenience -
Since:
- 2.0
preciseX
public double preciseX()
- Returns
double
x coordinate
-
-
-
Returns:
-
double
x coordinate -
Since:
- 3.4
preciseY
public double preciseY()
- Returns
double
y coordinate
-
-
-
Returns:
-
double
y coordinate -
Since:
- 3.4
Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved.