Package org.eclipse.draw2d.geometry
Class Point
java.lang.Object
org.eclipse.draw2d.geometry.Point
- All Implemented Interfaces:
Serializable,Cloneable,Translatable
- Direct Known Subclasses:
AbsoluteBendpoint,PrecisionPoint
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:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPoint()Constructs a Point at location (0,0).Point(double x, double y) Deprecated, for removal: This API element is subject to removal in a future version.Point(int x, int y) Constructs a Point at the specified x and y locations.Constructs a Point at the same location as the given Point.Constructs a Point at the same location as the given SWT Point. -
Method Summary
Modifier and TypeMethodDescriptionbooleanequals(int x, int y) Returnstrueif this Points x and y are equal to the given x and y.booleanTest for equality.getCopy()Calculates the difference in between this Point and the one specified.doublegetDistance(Point p) Calculates the distance from this Point to the one specified.intDeprecated, for removal: This API element is subject to removal in a future version.intCalculates the orthogonal distance to the specified point.intCalculates the distance squared between this Point and the one specified.Creates a Point with negated x and y values.intgetPosition(Point p) Calculates the relative position of the specified Point to this Point.getScaled(double factor) Creates a new Point from this Point by scaling by the specified amount.getScaled(double xFactor, double yFactor) Creates a new Point from this Point by scaling by the specified x and y factors.Creates a new SWTPointfrom this Point.getTranslated(double x, double y) Creates a new Point which is translated by the specified x and y valuesgetTranslated(int x, int y) Creates a new Point which is translated by the specified x and y valuesCreates a new Point which is translated by the values of the input Dimension.Creates a new Point which is translated by the values of the provided Point.Creates a new Point with the transposed values of this Point.inthashCode()static PointCreates a new Point representing the MAX of two provided Points.static PointCreates a new Point representing the MIN of two provided Points.negate()Negates the x and y values of this Point.voidperformScale(double factor) Scales this object by the scale factor.voidperformTranslate(int dx, int dy) Translates this object horizontally bydxand vertically bydy.doublepreciseX()Returnsdoublex coordinatedoublepreciseY()Returnsdoubley coordinatescale(double factor) Scales this Point by the specified amount.scale(double xFactor, double yFactor) Scales this Point by the specified values.setLocation(int x, int y) Sets the location of this Point to the provided x and y locations.setLocation(Point p) Sets the location of this Point to the specified Point.setX(int x) Sets the x value of this Point to the given value.setY(int y) Sets the y value of this Point to the given value;toString()translate(double x, double y) Shifts this Point by the values supplied along each axes, and returns this for convenience.translate(int dx, int dy) Shifts this Point by the values supplied along each axes, and returns this for convenience.Shifts this Point by the values of the Dimension along each axis, and returns this for convenience.Shifts the location of this Point by the location of the input Point along each of the axes, and returns this for convenience.Transposes this object.intx()Returns the x value of this Point.inty()Returns the y value of this Point.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.draw2d.geometry.Translatable
performTranslate, performTranslate, performTranslate
-
Field Details
-
SINGLETON
A singleton for use in short calculations -
x
public int xx value -
y
public int yy value
-
-
Constructor Details
-
Point
public Point()Constructs a Point at location (0,0).- Since:
- 2.0
-
Point
Deprecated, for removal: This API element is subject to removal in a future version.UsePrecisionPointorPoint(int, int)instead.Constructs a Point at the specified x and y locations.- Parameters:
x- x valuey- y value- Since:
- 2.0
- @noreference
- This constructor is not intended to be referenced by clients.
-
Point
public Point(int x, int y) Constructs a Point at the specified x and y locations.- Parameters:
x- x valuey- y value- Since:
- 2.0
-
Point
Constructs a Point at the same location as the given SWT Point.- Parameters:
p- Point from which the initial values are taken.- Since:
- 2.0
-
Point
Constructs a Point at the same location as the given Point.- Parameters:
p- Point from which the initial values are taken.- Since:
- 2.0
-
Point
- Parameters:
copy- Dimension from which the initial values are taken.- Since:
- 3.13
-
-
Method Details
-
max
Creates a new Point representing the MAX of two provided Points.- Parameters:
p1- first pointp2- second point- Returns:
- A new Point representing the Max()
-
min
Creates a new Point representing the MIN of two provided Points.- Parameters:
p1- first pointp2- second point- Returns:
- A new Point representing the Min()
-
equals
public boolean equals(int x, int y) Returnstrueif this Points x and y are equal to the given x and y.- Parameters:
x- the x valuey- the y value- Returns:
trueif this point's x and y are equal to those given.- Since:
- 3.7
-
equals
Test for equality. -
getCopy
- Returns:
- a copy of this Point
- Since:
- 2.0
-
getDifference
Calculates the difference in between this Point and the one specified.- Parameters:
p- The Point being subtracted from this Point- Returns:
- A new Dimension representing the difference
- Since:
- 2.0
-
getDistance
Calculates the distance from this Point to the one specified.- Parameters:
p- The Point being compared to this- Returns:
- The distance
- Since:
- 2.0
-
getDistance2
Deprecated, for removal: This API element is subject to removal in a future version.Calculates the distance squared between this Point and the one specified. If the distance squared is larger than the maximum integer value, thenInteger.MAX_VALUEwill be returned.- Parameters:
p- The reference Point- Returns:
- distance2
- Since:
- 2.0
- @noreference
- This method is not intended to be referenced by clients.
-
getDistanceSquared
Calculates the distance squared between this Point and the one specified. If the distance squared is larger than the maximum integer value, thenInteger.MAX_VALUEwill be returned.- Parameters:
p- The reference Point- Returns:
- distance2
- Since:
- 3.18
-
getDistanceOrthogonal
Calculates the orthogonal distance to the specified point. The orthogonal distance is the sum of the horizontal and vertical differences.- Parameters:
p- The reference Point- Returns:
- the orthogonal distance
-
getNegated
Creates a Point with negated x and y values.- Returns:
- A new Point
- Since:
- 2.0
-
getPosition
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
Creates a new Point from this Point by scaling by the specified amount.- Parameters:
factor- scale factor- Returns:
- A new Point
- Since:
- 2.0
-
getScaled
Creates a new Point from this Point by scaling by the specified x and y factors.- Parameters:
xFactor- x scale factoryFactor- y scale factor- Returns:
- A new Point
- Since:
- 3.8
-
getSWTPoint
Creates a new SWTPointfrom this Point.- Returns:
- A new SWT Point
- Since:
- 2.0
-
getTranslated
Creates a new Point which is translated by the values of the input Dimension.- Parameters:
d- Dimension which provides the translation amounts.- Returns:
- A new Point
- Since:
- 2.0
-
getTranslated
Creates a new Point which is translated by the specified x and y values- Parameters:
x- horizontal componenty- vertical component- Returns:
- A new Point
- Since:
- 3.8
-
getTranslated
Creates a new Point which is translated by the specified x and y values- Parameters:
x- horizontal componenty- vertical component- Returns:
- A new Point
- Since:
- 2.0
-
getTranslated
Creates a new Point which is translated by the values of the provided Point.- Parameters:
p- Point which provides the translation amounts.- Returns:
- A new Point
- Since:
- 2.0
-
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() -
negate
Negates the x and y values of this Point.- Returns:
thisfor convenience- Since:
- 2.0
-
performScale
public void performScale(double factor) Description copied from interface:TranslatableScales this object by the scale factor.- Specified by:
performScalein interfaceTranslatable- Parameters:
factor- The scale factor- See Also:
-
performTranslate
public void performTranslate(int dx, int dy) Description copied from interface:TranslatableTranslates this object horizontally bydxand vertically bydy.- Specified by:
performTranslatein interfaceTranslatable- Parameters:
dx- The amount to translate horizontallydy- The amount to translate vertically- See Also:
-
preciseX
public double preciseX()Returnsdoublex coordinate- Returns:
doublex coordinate- Since:
- 3.4
-
preciseY
public double preciseY()Returnsdoubley coordinate- Returns:
doubley coordinate- Since:
- 3.4
-
scale
Scales this Point by the specified amount.- Parameters:
factor- scale factor- Returns:
thisfor convenience- Since:
- 2.0
-
scale
Scales this Point by the specified values.- Parameters:
xFactor- horizontal scale factoryFactor- vertical scale factor- Returns:
thisfor convenience- Since:
- 2.0
-
setLocation
Sets the location of this Point to the provided x and y locations.- Parameters:
x- the x locationy- the y location- Returns:
thisfor convenience- Since:
- 2.0
-
setLocation
Sets the location of this Point to the specified Point.- Parameters:
p- the Location- Returns:
thisfor convenience- Since:
- 2.0
-
setX
Sets the x value of this Point to the given value.- Parameters:
x- The new x value- Returns:
- this for convenience
- Since:
- 3.7
-
setY
Sets the y value of this Point to the given value;- Parameters:
y- The new y value- Returns:
- this for convenience
- Since:
- 3.7
-
toString
-
translate
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:
thisfor convenience- Since:
- 2.0
-
translate
Shifts this Point by the values supplied along each axes, and returns this for convenience.- Parameters:
x- Amount by which point is shifted along X axis.y- Amount by which point is shifted along Y axis.- Returns:
thisfor convenience- Since:
- 3.8
-
translate
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:
thisfor convenience- Since:
- 2.0
-
translate
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:
thisfor convenience- Since:
- 2.0
-
transpose
Transposes this object. X and Y values are exchanged.- Returns:
thisfor convenience- Since:
- 2.0
-
x
public int x()Returns the x value of this Point.- Returns:
- The current x value
- Since:
- 3.7
-
y
public int y()Returns the y value of this Point.- Returns:
- The current y value
- Since:
- 3.7
-
PrecisionPointorPoint(int, int)instead.