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
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:
- @noreference
- This class is not intended to be referenced by clients.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an empty PrecisionPointListPrecisionPointList(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 TypeMethodDescriptionvoidAppends all of the given points to this PointList.voidAdds Point p to this PointList.getCopy()Creates a copygetPoint(int index) Returns the Point in the list at the specified index.Copies the x and y values at given index into a specified Point.voidinsertPoint(Point p, int index) Inserts a given point at a specified index.voidperformScale(double factor) Scales this object by the scale factor.removePoint(int index) Removes the point at the specified index from the PointList, and returns it.voidreverse()Reverses the order of the points in the list.voidOverwrites a point at a given index in the list with the specified Point.voidsetSize(int newSize) Sets the size of this PointList.double[]Returns the decimal fractions of this PointList as an double array.voidTransposes 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, translateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
Constructs a PrecisionPointList with the given points.- Parameters:
points- PointList from which the initial values are taken
-
-
Method Details
-
addAll
Description copied from class:PointListAppends all of the given points to this PointList. -
addPoint
Description copied from class:PointListAdds Point p to this PointList. -
getCopy
Description copied from class:PointListCreates a copy -
getPoint
Description copied from class:PointListReturns the Point in the list at the specified index. -
getPoint
Description copied from class:PointListCopies the x and y values at given index into a specified Point. This method exists to avoid the creation of a newPoint. -
insertPoint
Description copied from class:PointListInserts a given point at a specified index.- Overrides:
insertPointin classPointList- Parameters:
p- Point to be inserted.index- Position where the point is to be inserted.- See Also:
-
performScale
public void performScale(double factor) Description copied from interface:TranslatableScales this object by the scale factor.- Specified by:
performScalein interfaceTranslatable- Overrides:
performScalein classPointList- Parameters:
factor- The scale factor- See Also:
-
removePoint
Description copied from class:PointListRemoves the point at the specified index from the PointList, and returns it.- Overrides:
removePointin classPointList- Parameters:
index- Index of the point to be removed.- Returns:
- The point which has been removed
- See Also:
-
reverse
public void reverse()Description copied from class:PointListReverses the order of the points in the list. -
setPoint
Description copied from class:PointListOverwrites a point at a given index in the list with the specified Point. -
setSize
public void setSize(int newSize) Description copied from class:PointListSets the size of this PointList. -
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:PointListTransposes all x and y values. Useful for orientation changes.
-