Draw2D v2.0

org.eclipse.draw2d.geometry
Class Point

java.lang.Object
  |
  +--org.eclipse.draw2d.geometry.Point
All Implemented Interfaces:
Cloneable, Serializable, Translatable
Direct Known Subclasses:
AbsoluteBendpoint

public class Point
extends Object
implements Cloneable, Serializable, Translatable

Provides support for a point in two dimensional space.

See Also:
Serialized Form

Field Summary
static Point SINGLETON
           
 int x
           
 int y
           
 
Constructor Summary
Point()
          Constructs a Point at location (0,0).
Point(double x, double y)
          Constructs a Point at the locations along axes suplied as input in double format.
Point(int x, int y)
          Constructs a Point at the locations along axes suplied as input.
Point(Point copy)
          Constructs a Point which is at the same location as the input Point.
 
Method Summary
 boolean equals(Object o)
          Returns whether this Point is equal to the Object input.
 Point getCopy()
          Returns a copy of this Point.
 Dimension getDifference(Point pt)
          Returns the difference in location between this Point and the Point pt as a Dimension.
 double getDistance(Point pt)
          Returns the distance of this Point from the Point pt.
 int getDistance2(Point pt)
          Returns the sum of the squares of the length between this Point and the Point pt.
 int getDistanceOrthogonal(Point pt)
          Returns the orthogonal distance to the specified point.
 Point getNegated()
          Returns a new Point with the negated values of this Point.
 int getPosition(Point p)
           
 Point getScaled(float amount)
          Returns a new Point, which is scaled by the input value.
 Point getSWTPoint()
          Returns a new org.eclipse.swt.graphics.Point, that is equivalent to this Point.
 Point getTranslated(Dimension delta)
          Returns a new Point which is translated by the values of the input Dimension.
 Point getTranslated(int x, int y)
          Returns a new Point which is translated by the values of the inputs.
 Point getTranslated(Point pt)
          Returns a new Point which is translated by the values of the input Point.
 Point getTransposed()
          Returns a new Point with the transposed values of this Point.
static Point max(Point p1, Point p2)
           
static Point min(Point p1, Point p2)
           
 Point negate()
          Mirrors this Point about the origin, and returns this for conveinience.
 void performScale(float factor)
          Scales the location of this Point along both X and Y axes by factor.
 void performTranslate(int dx, int dy)
          Translates this Point by (dx,dy).
 Point scale(float amount)
          Scales the location of this Point along both X and Y axes by the value input.
 Point scale(float xAmount, float yAmount)
          Scales the location of this Point along X and Y axes by the respective values given as input, and returns this for convenience.
 Point setLocation(int x, int y)
          Sets the location of this Point by setting its x and y coordinates to the x and y values passed in.
 Point setLocation(Point pt)
          Sets the location of this Point by setting its x and y coordinates to pt.x and pt.y, respectively.
 String toString()
          Returns the description of this Point as a String.
 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()
          Interchanges the location of this Point along each of the axes and returns this for convenience.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public int x

y

public int y

SINGLETON

public static final Point SINGLETON
Constructor Detail

Point

public Point()
Constructs a Point at location (0,0).
Since:
2.0

Point

public Point(Point copy)
Constructs a Point which is at the same location as the input 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 locations along axes suplied as input.
Parameters:
x - Position of point along X axis.
y - Position of point along Y axis.
Since:
2.0

Point

public Point(double x,
             double y)
Constructs a Point at the locations along axes suplied as input in double format.
Parameters:
x - Position of point along X axis.
y - Position of point along Y axis.
Since:
2.0
Method Detail

equals

public boolean equals(Object o)
Returns whether this Point is equal to the Object input. Points are deemed equal if their x and y values are equivalent.
Overrides:
equals in class Object
Parameters:
o - Object being tested for equality.
Returns:
Result of the equality test.
Since:
2.0

getNegated

public Point getNegated()
Returns a new Point with the negated values of this Point.
Returns:
A new point with the negated values.
Since:
2.0

getPosition

public int getPosition(Point p)

getScaled

public Point getScaled(float amount)
Returns a new Point, which is scaled by the input value.
Parameters:
amount - Value indicating the amount of scaling to be done.
Returns:
A new point with the scaled values of this.
Since:
2.0

getSWTPoint

public Point getSWTPoint()
Returns a new org.eclipse.swt.graphics.Point, that is equivalent to this Point.
Returns:
A new org.eclipse.swt.graphics.Point
Since:
2.0

getTranslated

public Point getTranslated(Dimension delta)
Returns 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 containing the translated values.
Since:
2.0

getTranslated

public Point getTranslated(Point pt)
Returns a new Point which is translated by the values of the input Point.
Parameters:
pt - Point which provides the translation amounts.
Returns:
A new point containing the translated values.
Since:
2.0

getTranslated

public Point getTranslated(int x,
                           int y)
Returns a new Point which is translated by the values of the inputs.
Parameters:
x - Amount by which the Point should be translated along X axis.
y - Amount by which the Point should be translated along Y axis.
Returns:
A new point containing the translated values.
Since:
2.0

getTransposed

public Point getTransposed()
Returns a new Point with the transposed values of this Point. Can be useful in orientation change calculations.
Returns:
A new point with the transposed values of this.
Since:
2.0

max

public static Point max(Point p1,
                        Point p2)

min

public static Point min(Point p1,
                        Point p2)

getCopy

public Point getCopy()
Returns a copy of this Point.
Since:
2.0

getDifference

public Dimension getDifference(Point pt)
Returns the difference in location between this Point and the Point pt as a Dimension.
Parameters:
pt - Point to which the difference is required.
Returns:
Dimension of the difference between the two points.
Since:
2.0

getDistance

public double getDistance(Point pt)
Returns the distance of this Point from the Point pt.
Parameters:
pt - Point from which the distance is required.
Returns:
Distance as a double
Since:
2.0

getDistanceOrthogonal

public int getDistanceOrthogonal(Point pt)
Returns the orthogonal distance to the specified point. The orthogonal distance is the sum of the horizontal and vertical differences.

getDistance2

public int getDistance2(Point pt)
Returns the sum of the squares of the length between this Point and the Point pt.
Parameters:
pt - Point against which the difference calculations are made.
Returns:
The value of the square of the distance.
Since:
2.0

negate

public Point negate()
Mirrors this Point about the origin, and returns this for conveinience.
Returns:
This point with the inverted values.
Since:
2.0

performScale

public void performScale(float factor)
Scales the location of this Point along both X and Y axes by factor.
Specified by:
performScale in interface Translatable
Since:
2.0

performTranslate

public void performTranslate(int dx,
                             int dy)
Translates this Point by (dx,dy).
Specified by:
performTranslate in interface Translatable
Since:
2.0

scale

public Point scale(float amount)
Scales the location of this Point along both X and Y axes by the value input.
Returns:
This point with the scaled values.
Since:
2.0

scale

public Point scale(float xAmount,
                   float yAmount)
Scales the location of this Point along X and Y axes by the respective values given as input, and returns this for convenience.
Parameters:
xAmount - Amounts scaling along X axis.
yAMount - Amounts scaling along Y axis.
Returns:
This point with the scaled values.
Since:
2.0

setLocation

public Point setLocation(Point pt)
Sets the location of this Point by setting its x and y coordinates to pt.x and pt.y, respectively.
Since:
2.0

setLocation

public Point setLocation(int x,
                         int y)
Sets the location of this Point by setting its x and y coordinates to the x and y values passed in.
Since:
2.0

toString

public String toString()
Returns the description of this Point as a String.
Overrides:
toString in class Object
Returns:
String containing the details of this Point.
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 point with its new shifted value.
Since:
2.0
See Also:
translate(int,int), translate(Dimension)

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 point with its new shifted value.
Since:
2.0
See Also:
translate(Point), translate(int,int)

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 point with its new shifted value.
Since:
2.0
See Also:
translate(Point), translate(Dimension)

transpose

public Point transpose()
Interchanges the location of this Point along each of the axes and returns this for convenience.
Returns:
This point with the new values.
Since:
2.0

Draw2D v2.0