org.eclipse.gef.geometry.internal.utils

## Class PointListUtils

- java.lang.Object
- - org.eclipse.gef.geometry.internal.utils.PointListUtils

    public class PointListUtils
    extends Object

Common utilities for point manipulations as needed e.g. within `Polygon` and `Polyline`.

### Method Summary

All Methods Static Methods Concrete Methods
`static double[]` `toCoordinatesArray(Point[] points)` Converts a given array of `Point` into an array of doubles containing the x and y coordinates of the given points, where the x and y coordinates of the n-th `Point` can be found at positions 2*n and 2*n+1.
`static int[]` `toIntegerArray(double[] doubles)` Converts an array of double values into an array of integer values by casting them.
`static Point[]` `toPointsArray(double[] coordinates)` Converts a given array of x/y coordinate values into an array of `Point`s.
`static Point[]` `toPointsArray(Line[] segmentsArray, boolean open)` Transforms a sequence of `Line`s into a list of `Point`s.
`static Line[]` `toSegmentsArray(Point[] points, boolean close)` Transforms a sequence of `Point` coordinates into a sequence of `Line` segments, by creating a `Line` segment for each two adjacent points in the array.

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

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### toCoordinatesArray

    public static double[] toCoordinatesArray(Point[] points)

Converts a given array of `Point` into an array of doubles containing the x and y coordinates of the given points, where the x and y coordinates of the n-th `Point` can be found at positions 2*n and 2*n+1.

Parameters:
  `points` - an array of `Point`s to convert
Returns:
  a new array of doubles, containing the x and y coordinates of the given `Point`s

#### toIntegerArray

    public static int[] toIntegerArray(double[] doubles)

Converts an array of double values into an array of integer values by casting them.

Parameters:
  `doubles` - an array of doubles to convert
Returns:
  a new array of integer values, which is created by casting the double values

#### toPointsArray

    public static Point[] toPointsArray(double[] coordinates)

Converts a given array of x/y coordinate values into an array of `Point`s.

Parameters:
  `coordinates` - The array of coordinates.
Returns:
  a new array of `Point`s, representing the given x and y coordinates

#### toPointsArray

    public static Point[] toPointsArray(Line[] segmentsArray,
                                        boolean open)

Transforms a sequence of `Line`s into a list of `Point`s. Consecutive `Line`s are expected to share one of their end `Point`s. The start `Point`s of the `Line`s are returned. Additionally, the end `Point` of the last `Line` is returned, too if the given boolean flag `open` is set to `false`.

Parameters:
  `segmentsArray` - The array of `Line`s.
  `open` - indicates whether to omit the end `Point` of the last `Line`
Returns:
  the start `Point`s of the `Line`s and the end `Point` of the last `Line` according to `open`

#### toSegmentsArray

    public static Line[] toSegmentsArray(Point[] points,
                                         boolean close)

Transforms a sequence of `Point` coordinates into a sequence of `Line` segments, by creating a `Line` segment for each two adjacent points in the array. In case it is specified to close the segment list, a `Line` segment is furthermore created between the last and the first point in the list.

Parameters:
  `points` - the array of `Point`s to convert
  `close` - a flag indicating whether a line segment will be created from the last point in the list back to the first one
Returns:
  an array of `Line` segments, which is created by creating a `Line` for each two adjacent `Point`s in the given array, which includes a `Line` segment between the last point in the given array in the first one, if and only if the parameter close is given as `true`