Package org.eclipse.draw2d.geometry

# Class PrecisionPointList

java.lang.Object
org.eclipse.draw2d.geometry.PointList
org.eclipse.draw2d.geometry.PrecisionPointList

All Implemented Interfaces:
  `Serializable`, `Translatable`

public final class PrecisionPointList extends PointList
A PointList implementation using floating point values. The use of floating point prevents rounding errors from accumulating. For the sake of compatibility with the integer-precision `PointList`, the integer coordinates and their decimal part are stored in two separate arrays. EXPERIMENTAL This class has been added as part of a work in progress and there is no guarantee that this API will remain unchanged. This is likely to not function properly outside some very specific use-cases.

Since:
  3.21
See Also:
  - Serialized Form
@noreference
  This class is not intended to be referenced by clients.

## Constructor Summary

Constructors
Constructor
Description
`PrecisionPointList()`
Constructs an empty PrecisionPointList
`PrecisionPointList(int size)`
Constructs a PrecisionPointList with the given size.
`PrecisionPointList(int[] points)`
Constructs a PrecisionPointList with the given points.
`PrecisionPointList(PointList points)`
Constructs a PrecisionPointList with the given points.

## Method Summary

Modifier and Type
Method
Description
`void`
`addAll(PointList points)`
Appends all of the given points to this PointList.
`void`
`addPoint(Point point)`
Adds Point p to this PointList.
`PointList`
`getCopy()`
Creates a copy
`Point`
`getPoint(int index)`
Returns the Point in the list at the specified index.
`Point`
`getPoint(Point point, int index)`
Copies the x and y values at given index into a specified Point.
`void`
`insertPoint(Point p, int index)`
Inserts a given point at a specified index.
`void`
`performScale(double factor)`
Scales this object by the scale factor.
`Point`
`removePoint(int index)`
Removes the point at the specified index from the PointList, and returns it.
`void`
`reverse()`
Reverses the order of the points in the list.
`void`
`setPoint(Point point, int index)`
Overwrites a point at a given index in the list with the specified Point.
`void`
`setSize(int newSize)`
Sets the size of this PointList.
`double[]`
`toDoubleArray()`
Returns the decimal fractions of this PointList as an double array.
`void`
`transpose()`
Transposes all x and y values.

### Methods inherited from class org.eclipse.draw2d.geometry.PointList

`addPoint, getBounds, getFirstPoint, getLastPoint, getMidpoint, intersects, performTranslate, polygonContainsPoint, polylineContainsPoint, removeAllPoints, size, toIntArray, translate, translate`

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

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

### Methods inherited from interface org.eclipse.draw2d.geometry.Translatable

`performTranslate, performTranslate, performTranslate`

## Constructor Details

### PrecisionPointList

public PrecisionPointList()
Constructs an empty PrecisionPointList

### PrecisionPointList

public PrecisionPointList(int size)
Constructs a PrecisionPointList with the given size.

Parameters:
  `size` - Number of points to hold.

### PrecisionPointList

public PrecisionPointList(int[] points)
Constructs a PrecisionPointList with the given points.

Parameters:
  `points` - int array where two consecutive ints form the coordinates of a point

### PrecisionPointList

public PrecisionPointList(PointList points)
Constructs a PrecisionPointList with the given points.

Parameters:
  `points` - PointList from which the initial values are taken

## Method Details

### addAll

public void addAll(PointList points)
Description copied from class: `PointList`
Appends all of the given points to this PointList.

Overrides:
  `addAll` in class `PointList`
Parameters:
  `points` - the source pointlist
See Also:
  - `PointList.addAll(PointList)`

### addPoint

public void addPoint(Point point)
Description copied from class: `PointList`
Adds Point p to this PointList.

Overrides:
  `addPoint` in class `PointList`
Parameters:
  `point` - the point to be added
See Also:
  - `PointList.addPoint(Point)`

### getCopy

public PointList getCopy()
Description copied from class: `PointList`
Creates a copy

Overrides:
  `getCopy` in class `PointList`
Returns:
  PointList A copy of this PointList
See Also:
  - `PointList.getCopy()`

### getPoint

public Point getPoint(int index)
Description copied from class: `PointList`
Returns the Point in the list at the specified index.

Overrides:
  `getPoint` in class `PointList`
Parameters:
  `index` - Index of the desired Point
Returns:
  The requested Point
See Also:
  - `PointList.getPoint(int)`

### getPoint

public Point getPoint(Point point, int index)
Description copied from class: `PointList`
Copies the x and y values at given index into a specified Point. This method exists to avoid the creation of a new `Point`.

Overrides:
  `getPoint` in class `PointList`
Parameters:
  `point` - The Point which will be set with the <x, y> values
  `index` - The index being requested
Returns:
  The parameter `p` is returned for convenience
See Also:
  - `PointList.getPoint(Point, int)`

### insertPoint

public void insertPoint(Point p, int index)
Description copied from class: `PointList`
Inserts a given point at a specified index.

Overrides:
  `insertPoint` in class `PointList`
Parameters:
  `p` - Point to be inserted.
  `index` - Position where the point is to be inserted.
See Also:
  - `PointList.insertPoint(Point, int)`

### performScale

public void performScale(double factor)
Description copied from interface: `Translatable`
Scales this object by the scale factor.

Specified by:
  `performScale` in interface `Translatable`
Overrides:
  `performScale` in class `PointList`
Parameters:
  `factor` - The scale factor
See Also:
  - `PointList.performScale(double)`

### removePoint

public Point removePoint(int index)
Description copied from class: `PointList`
Removes the point at the specified index from the PointList, and returns it.

Overrides:
  `removePoint` in class `PointList`
Parameters:
  `index` - Index of the point to be removed.
Returns:
  The point which has been removed
See Also:
  - `PointList.removePoint(int)`

### reverse

public void reverse()
Description copied from class: `PointList`
Reverses the order of the points in the list.

Overrides:
  `reverse` in class `PointList`
See Also:
  - `PointList.reverse()`

### setPoint

public void setPoint(Point point, int index)
Description copied from class: `PointList`
Overwrites a point at a given index in the list with the specified Point.

Overrides:
  `setPoint` in class `PointList`
Parameters:
  `point` - Point which is to be stored at the index.
  `index` - Index where the given point is to be stored.
See Also:
  - `PointList.setPoint(Point, int)`

### setSize

public void setSize(int newSize)
Description copied from class: `PointList`
Sets the size of this PointList.

Overrides:
  `setSize` in class `PointList`
Parameters:
  `newSize` - the new size
See Also:
  - `PointList.setSize(int)`

### toDoubleArray

public double[] toDoubleArray()
Returns the decimal fractions of this PointList as an double array. The returned array is by reference. Any changes made to the array will also be changing the original PointList.

Returns:
  the double array of decimal fractions by reference
@noreference
  This method is not intended to be referenced by clients.

### transpose

public void transpose()
Description copied from class: `PointList`
Transposes all x and y values. Useful for orientation changes.

Overrides:
  `transpose` in class `PointList`
See Also:
  - `PointList.transpose()`