Package org.eclipse.gef.geometry.planar

# Class Point

java.lang.Object
org.eclipse.gef.geometry.planar.Point

All Implemented Interfaces:
  `Serializable`, `Cloneable`

public class Point extends Object implements Cloneable, Serializable
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

Fields
Modifier and Type
Field
Description
`double`
`x`
The x value.
`double`
`y`
The y value.

## Constructor Summary

Constructors
Constructor
Description
`Point()`
Constructs a Point at location (0,0).
`Point(double x, double y)`
Constructs a Point at the specified x and y locations.
`Point(Point p)`
Constructs a Point at the same location as the given Point.

## Method Summary

Modifier and Type
Method
Description
`Point`
`clone()`
Overwritten with public visibility as proposed in `Cloneable`.
`boolean`
`equals(double x, double y)`
Returns `true` if this Points x and y are equal to the given x and y.
`boolean`
`equals(Object o)`
Test for equality.
`static Rectangle`
`getBounds(Point... points)`
Returns the smallest `Rectangle` that encloses all `Point`s in the given sequence.
`static Point`
`getCentroid(Point... points)`
Computes the centroid of the given `Point`s.
`static Point[]`
`getConvexHull(Point... points)`
Computes the convex hull of the given set of `Point`s using the Graham scan algorithm.
`Point`
`getCopy()`
`static final Point[]`
`getCopy(Point... points)`
Copies an array of points, by copying each point contained in the array.
`Point`
`getDifference(Point other)`
Returns the translation required to move this `Point` to the other `Point`
`double`
`getDistance(Point p)`
Calculates the distance from this Point to the one specified.
`Point`
`getNegated()`
Creates a Point with negated x and y values.
`static final Point[]`
`getReverseCopy(Point... points)`
Returns a copy of the given array of points, where the points are placed in reversed order.
`Point`
`getScaled(double factor)`
Creates a new Point from this Point by scaling by the specified amount.
`Point`
`getScaled(double xFactor, double yFactor)`
Creates a new Point from this Point by scaling by the specified values.
`Point`
`getScaled(double factorX, double factorY, Point center)`
Returns a new `Point` scaled by the given scale-factors.
`Point`
`getTransformed(AffineTransform transformation)`
Transforms a copy of this `Point` using the given `AffineTransform`.
`Point`
`getTranslated(double x, double y)`
Creates a new Point which is translated by the specified x and y values
`Point`
`getTranslated(Dimension d)`
Creates a new Point which is translated by the values of the input Dimension.
`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.
`static Point`
`nearest(Point referencePoint, Point... candidates)`
Returns (one of) the candidate(s) with minimal distance to the given reference point.
`Point`
`negate()`
Negates the x and y values of this Point.
`static void`
`rotateCCW(Point[] points, Angle angle, double cx, double cy)`
Rotates (in-place) the given `Point`s counter-clock-wise (CCW) by the specified `Angle` around the given center `Point`.
`static void`
`rotateCW(Point[] points, Angle angle, double cx, double cy)`
Rotates (in-place) the given `Point`s clock-wise (CW) by the specified `Angle` around the given center `Point`.
`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`
`scale(double factorX, double factorY, Point center)`
Scales this `Point` by the given scale-factors.
`static void`
`scale(Point[] points, double fx, double fy, double cx, double cy)`
Scales the given array of `Point`s by the given x and y scale factors around the given center `Point` (cx, cy).
`Point`
`setLocation(double x, double 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(double x)`
Sets the x value of this Point to the given value.
`Point`
`setY(double y)`
Sets the y value of this Point to the given value;
`String`
`toString()`
`Point`
`transform(AffineTransform transformation)`
Transforms this `Point` in-place using the given `AffineTransform`.
`Point`
`translate(double dx, double dy)`
Shifts this Point by the values supplied along each axes, and returns this for convenience.
`Point`
`translate(Dimension d)`
Shifts this Point by the values of the Dimension along each axis, 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.
`static void`
`translate(Point[] points, double dx, double dy)`
Translates an array of `Point`s by translating each individual point by a given x and y offset.
`Point`
`transpose()`
Transposes this object.
`double`
`x()`
Returns the x value of this Point.
`double`
`y()`
Returns the y value of this Point.

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

## Field Details

### x

public double x
The x value.

### y

public double y
The y value.

## Constructor Details

### Point

public Point()
Constructs a Point at location (0,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

### Point

public Point(Point p)
Constructs a Point at the same location as the given Point.

Parameters:
  `p` - Point from which the initial values are taken.

## Method Details

### getBounds

public static Rectangle getBounds(Point... points)
Returns the smallest `Rectangle` that encloses all `Point`s in the given sequence. Note that the right and bottom borders of a `Rectangle` are regarded as being part of the `Rectangle`.

Parameters:
  `points` - a sequence of `Point`s which should all be contained in the to be computed `Rectangle`
Returns:
  a new `Rectangle`, which is the smallest `Rectangle` that contains all given `Point`s

### getCentroid

public static Point getCentroid(Point... points)
Computes the centroid of the given `Point`s. The centroid is the "center of gravity", i.e. assuming the `Polygon` spanned by the `Point`s is made of a material of constant density, it will be in a balanced state, if you put it on a pin that is placed exactly on its centroid.

Parameters:
  `points` - The array of `Point`s for which the centroid is computed.
Returns:
  the center `Point` (or centroid) of the given `Point` s

### getConvexHull

public static Point[] getConvexHull(Point... points)
Computes the convex hull of the given set of `Point`s using the Graham scan algorithm.

Parameters:
  `points` - the set of `Point`s to calculate the convex hull for
Returns:
  the convex hull of the given set of `Point`s

### getCopy

public static final Point[] getCopy(Point... points)
Copies an array of points, by copying each point contained in the array.

Parameters:
  `points` - the array of `Point`s to copy
Returns:
  a new array, which contains copies of the given `Point`s at the respective index positions

### getReverseCopy

public static final Point[] getReverseCopy(Point... points)
Returns a copy of the given array of points, where the points are placed in reversed order.

Parameters:
  `points` - the array of `Point`s to reverse
Returns:
  a new array, which contains a copy of each `Point` of the given array of points at the respective reverse index

### 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()

### nearest

public static Point nearest(Point referencePoint, Point... candidates)
Returns (one of) the candidate(s) with minimal distance to the given reference point.

Parameters:
  `referencePoint` - The reference point, to which distance has to be minimal.
  `candidates` - The points from which to choose the one with minimal distance.
Returns:
  One of the candidates with minimal distance.

### rotateCCW

public static void rotateCCW(Point[] points, Angle angle, double cx, double cy)
Rotates (in-place) the given `Point`s counter-clock-wise (CCW) by the specified `Angle` around the given center `Point`.

Parameters:
  `points` - The array of `Point`s to rotate.
  `angle` - The rotation `Angle`.
  `cx` - The x-coordinate of the rotation's pivot point.
  `cy` - The y-coordinate of the rotation's pivot point.

### rotateCW

public static void rotateCW(Point[] points, Angle angle, double cx, double cy)
Rotates (in-place) the given `Point`s clock-wise (CW) by the specified `Angle` around the given center `Point`.

Parameters:
  `points` - The array of `Point`s to rotate.
  `angle` - The rotation `Angle`.
  `cx` - The x-coordinate of the rotation's pivot point.
  `cy` - The y-coordinate of the rotation's pivot point.

### scale

public static void scale(Point[] points, double fx, double fy, double cx, double cy)
Scales the given array of `Point`s by the given x and y scale factors around the given center `Point` (cx, cy).

Parameters:
  `points` - The array of `Point`s to scale.
  `fx` - The horizontal scale factor.
  `fy` - Ther vertical scale factor.
  `cx` - The x-coordinate of the scale's pivot point.
  `cy` - The y-coordinate of the scale's pivot point.

### translate

public static void translate(Point[] points, double dx, double dy)
Translates an array of `Point`s by translating each individual point by a given x and y offset.

Parameters:
  `points` - an array of points to translate
  `dx` - the x offset to translate each `Point` by
  `dy` - the y offset to translate each `Point` by

### clone

public Point clone()
Overwritten with public visibility as proposed in `Cloneable`.

Overrides:
  `clone` in class `Object`

### equals

public boolean equals(double x, double y)
Returns `true` if this Points x and y are equal to the given x and y.

Parameters:
  `x` - the x value
  `y` - the y value
Returns:
  `true` if this point's x and y are equal to those given.

### equals

public boolean equals(Object o)
Test for equality.

Overrides:
  `equals` in class `Object`
Parameters:
  `o` - Object being tested for equality
Returns:
  true if both x and y values are equal

### getCopy

public Point getCopy()

Returns:
  a copy of this Point

### getDifference

public Point getDifference(Point other)
Returns the translation required to move this `Point` to the other `Point`

Parameters:
  `other` - the `Point` to get the difference from
Returns:
  the translation required to move this `Point` to the other `Point`

### getDistance

public double getDistance(Point p)
Calculates the distance from this Point to the one specified.

Parameters:
  `p` - The Point being compared to this
Returns:
  The distance

### getNegated

public Point getNegated()
Creates a Point with negated x and y values.

Returns:
  A new Point

### getScaled

public Point getScaled(double factor)
Creates a new Point from this Point by scaling by the specified amount.

Parameters:
  `factor` - scale factor
Returns:
  A new Point

### getScaled

public Point getScaled(double xFactor, double yFactor)
Creates a new Point from this Point by scaling by the specified values.

Parameters:
  `xFactor` - horizontal scale factor
  `yFactor` - vertical scale factor
Returns:
  A new Point

### getScaled

public Point getScaled(double factorX, double factorY, Point center)
Returns a new `Point` scaled by the given scale-factors. The scaling is performed relative to the given `Point` center.

Parameters:
  `factorX` - The horizontal scale-factor
  `factorY` - The vertical scale-factor
  `center` - The relative `Point` for the scaling
Returns:
  The new, scaled `Point`

### getTransformed

public Point getTransformed(AffineTransform transformation)
Transforms a copy of this `Point` using the given `AffineTransform`.

Parameters:
  `transformation` - The `AffineTransform` to apply.
Returns:
  A copy of this `Point`, transformed by the given `AffineTransform`.

### getTranslated

public Point getTranslated(Dimension d)
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

### getTranslated

public Point getTranslated(double x, double 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

### getTranslated

public Point getTranslated(Point p)
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

### 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

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`
See Also:
  - `Object.hashCode()`

### negate

public Point negate()
Negates the x and y values of this Point.

Returns:
  `this` for convenience

### scale

public Point scale(double factor)
Scales this Point by the specified amount.

Parameters:
  `factor` - scale factor
Returns:
  `this` for convenience

### scale

public Point scale(double xFactor, double yFactor)
Scales this Point by the specified values.

Parameters:
  `xFactor` - horizontal scale factor
  `yFactor` - vertical scale factor
Returns:
  `this` for convenience

### scale

public Point scale(double factorX, double factorY, Point center)
Scales this `Point` by the given scale-factors. The scaling is performed relative to the given `Point` center.

Parameters:
  `factorX` - The horizontal scale-factor
  `factorY` - The vertical scale-factor
  `center` - The relative `Point` for the scaling
Returns:
  `this` for convenience

### setLocation

public Point setLocation(double x, double 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

### setLocation

public Point setLocation(Point p)
Sets the location of this Point to the specified Point.

Parameters:
  `p` - the Location
Returns:
  `this` for convenience

### setX

public Point setX(double x)
Sets the x value of this Point to the given value.

Parameters:
  `x` - The new x value
Returns:
  this for convenience

### setY

public Point setY(double y)
Sets the y value of this Point to the given value;

Parameters:
  `y` - The new y value
Returns:
  this for convenience

### toString

public String toString()

Overrides:
  `toString` in class `Object`
See Also:
  - `Object.toString()`

### transform

public Point transform(AffineTransform transformation)
Transforms this `Point` in-place using the given `AffineTransform`.

Parameters:
  `transformation` - The `AffineTransform` to apply.
Returns:
  `this` for convenience.

### 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

### translate

public Point translate(double dx, double 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

### 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

### transpose

public Point transpose()
Transposes this object. X and Y values are exchanged.

Returns:
  `this` for convenience

### x

public double x()
Returns the x value of this Point.

Returns:
  The current x value

### y

public double y()
Returns the y value of this Point.

Returns:
  The current y value