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 SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionPoint()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 SummaryModifier 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.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.draw2d.geometry.TranslatableperformTranslate, performTranslate, performTranslate
- 
Field Details- 
SINGLETONA singleton for use in short calculations
- 
xpublic int xx value
- 
ypublic int yy value
 
- 
- 
Constructor Details- 
Pointpublic Point()Constructs a Point at location (0,0).- Since:
- 2.0
 
- 
PointDeprecated, 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 value
- y- y value
- Since:
- 2.0
- @noreference
- This constructor is not intended to be referenced by clients.
 
- 
Pointpublic 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
 
- 
PointConstructs a Point at the same location as the given SWT Point.- Parameters:
- p- Point from which the initial values are taken.
- Since:
- 2.0
 
- 
PointConstructs 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- 
maxCreates a new Point representing the MAX of two provided Points.- Parameters:
- p1- first point
- p2- second point
- Returns:
- A new Point representing the Max()
 
- 
minCreates a new Point representing the MIN of two provided Points.- Parameters:
- p1- first point
- p2- second point
- Returns:
- A new Point representing the Min()
 
- 
equalspublic boolean equals(int x, int y) Returnstrueif this Points x and y are equal to the given x and y.- Parameters:
- x- the x value
- y- the y value
- Returns:
- trueif this point's x and y are equal to those given.
- Since:
- 3.7
 
- 
equalsTest for equality.
- 
getCopy- Returns:
- a copy of this Point
- Since:
- 2.0
 
- 
getDifferenceCalculates 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
 
- 
getDistanceCalculates the distance from this Point to the one specified.- Parameters:
- p- The Point being compared to this
- Returns:
- The distance
- Since:
- 2.0
 
- 
getDistance2Deprecated, 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.
 
- 
getDistanceSquaredCalculates 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
 
- 
getDistanceOrthogonalCalculates 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
 
- 
getNegatedCreates a Point with negated x and y values.- Returns:
- A new Point
- Since:
- 2.0
 
- 
getPositionCalculates 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
 
- 
getScaledCreates a new Point from this Point by scaling by the specified amount.- Parameters:
- factor- scale factor
- Returns:
- A new Point
- Since:
- 2.0
 
- 
getScaledCreates a new Point from this Point by scaling by the specified x and y factors.- Parameters:
- xFactor- x scale factor
- yFactor- y scale factor
- Returns:
- A new Point
- Since:
- 3.8
 
- 
getSWTPointCreates a new SWTPointfrom this Point.- Returns:
- A new SWT Point
- Since:
- 2.0
 
- 
getTranslatedCreates 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
 
- 
getTranslatedCreates 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:
- 3.8
 
- 
getTranslatedCreates 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
 
- 
getTranslatedCreates 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
 
- 
getTransposedCreates a new Point with the transposed values of this Point. Can be useful in orientation change calculations.- Returns:
- A new Point
- Since:
- 2.0
 
- 
hashCodepublic int hashCode()
- 
negateNegates the x and y values of this Point.- Returns:
- thisfor convenience
- Since:
- 2.0
 
- 
performScalepublic void performScale(double factor) Description copied from interface:TranslatableScales this object by the scale factor.- Specified by:
- performScalein interface- Translatable
- Parameters:
- factor- The scale factor
- See Also:
 
- 
performTranslatepublic void performTranslate(int dx, int dy) Description copied from interface:TranslatableTranslates this object horizontally bydxand vertically bydy.- Specified by:
- performTranslatein interface- Translatable
- Parameters:
- dx- The amount to translate horizontally
- dy- The amount to translate vertically
- See Also:
 
- 
preciseXpublic double preciseX()Returnsdoublex coordinate- Returns:
- doublex coordinate
- Since:
- 3.4
 
- 
preciseYpublic double preciseY()Returnsdoubley coordinate- Returns:
- doubley coordinate
- Since:
- 3.4
 
- 
scaleScales this Point by the specified amount.- Parameters:
- factor- scale factor
- Returns:
- thisfor convenience
- Since:
- 2.0
 
- 
scaleScales this Point by the specified values.- Parameters:
- xFactor- horizontal scale factor
- yFactor- vertical scale factor
- Returns:
- thisfor convenience
- Since:
- 2.0
 
- 
setLocationSets the location of this Point to the provided x and y locations.- Parameters:
- x- the x location
- y- the y location
- Returns:
- thisfor convenience
- Since:
- 2.0
 
- 
setLocationSets the location of this Point to the specified Point.- Parameters:
- p- the Location
- Returns:
- thisfor convenience
- Since:
- 2.0
 
- 
setXSets the x value of this Point to the given value.- Parameters:
- x- The new x value
- Returns:
- this for convenience
- Since:
- 3.7
 
- 
setYSets the y value of this Point to the given value;- Parameters:
- y- The new y value
- Returns:
- this for convenience
- Since:
- 3.7
 
- 
toString
- 
translateShifts 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
 
- 
translateShifts 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
 
- 
translateShifts 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
 
- 
translateShifts 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
 
- 
transposeTransposes this object. X and Y values are exchanged.- Returns:
- thisfor convenience
- Since:
- 2.0
 
- 
xpublic int x()Returns the x value of this Point.- Returns:
- The current x value
- Since:
- 3.7
 
- 
ypublic int y()Returns the y value of this Point.- Returns:
- The current y value
- Since:
- 3.7
 
 
- 
PrecisionPointorPoint(int, int)instead.