E
- The type of GeomPoint contained in this list of points.public final class PointString<E extends GeomPoint> extends AbstractPointGeomList<PointString<E>,E>
PointString
is a collection of GeomPoint
objects that make up a
"string of points". Any number of points may be added to a string, but all points in a
string must have the same dimensions.
WARNING: This list allows geometry to be stored in different units. If consistent units are required, then the user must specifically convert the list items.
Modified by: Joseph A. Huwaldt
RESOURCES
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
E value)
Inserts the specified
GeomPoint at the specified position in this list. |
boolean |
addAll(int index,
java.util.Collection<? extends E> c)
Inserts all of the
GeomPoint objects in the specified collection into this
list at the specified position. |
PointString<E> |
copy()
Returns a copy of this
PointString instance
allocated by the calling
thread (possibly on the stack). |
PointString<E> |
copyToReal()
Return a copy of this object with any transformations or subranges
removed (applied).
|
PointString |
enrich()
Returns a new
PointString that is identical to this string but
with a new point linearly interpolated half-way between each of the
existing points. |
Point |
getAverage()
Calculate the average or centroid of all the points in this PointString.
|
int |
getNumberOfPoints()
Return the total number of points in this geometry element.
|
PointString<E> |
getRange(int first,
int last)
Returns the range of elements in this list from the specified start and
ending indexes.
|
PointString |
getTransformed(GTransform transform)
Returns transformed version of this element.
|
Parameter<Length> |
length()
Returns the length of this PointString in terms of the sum of the distances between
each consecutive point in the string.
|
static void |
main(java.lang.String[] args)
Tests the methods in this class.
|
static PointString |
newInstance()
Returns a new, preallocated or recycled
PointString instance
(on the stack when executing in a StackContext ), that can
store a list of GeomPoint objects. |
static PointString |
newInstance(java.lang.String name)
Returns a new, preallocated or recycled
PointString instance
(on the stack when executing in a StackContext ) with the
specified name, that can store a list of GeomPoint objects. |
static void |
recycle(PointString instance)
Recycles a case instance immediately (on the stack when executing in a
StackContext).
|
PointString<E> |
reverse()
Returns an new
PointString with the elements in this list in
reverse order. |
E |
set(int index,
E element)
Replaces the
GeomPoint at the specified position in this list with the
specified element. |
PointString<E> |
sort(int dim,
boolean removeDup,
Parameter<Length> tol)
Return a new
PointString with the points in this list sorted into ascending
order with respect to the specified coordinate dimension. |
PointString<E> |
thin()
Returns a new
PointString that is identical to this string but
with every other point removed. |
PointString |
to(Unit<Length> unit)
Returns the equivalent to this list but with all the elements stated in the
specified unit.
|
PointString |
toDimension(int newDim)
Return the equivalent of this list converted to the specified number
of physical dimensions.
|
static <E extends GeomPoint> |
valueOf(E... elements)
Return a PointString made up of the
GeomPoint objects in the
specified array. |
static <E extends GeomPoint> |
valueOf(java.lang.String name,
java.util.Collection<E> elements)
Return a PointString made up of the
GeomPoint objects in the
specified collection. |
static <E extends GeomPoint> |
valueOf(java.lang.String name,
E... elements)
Return a PointString made up of the
GeomPoint objects in the specified
array. |
getPhyDimension
add, add, add, addAll, addAll, addAll, clear, contains, containsAll, containsGeometry, equals, get, get, getAll, getBoundsMax, getBoundsMin, getFirst, getIndexFromName, getLast, getLimitPoint, getParDimension, getUnit, hashCode, indexOf, isEmpty, isValid, iterator, lastIndexOf, listIterator, listIterator, remove, remove, remove, removeAll, reset, retainAll, size, subList, toArray, toArray, toText, unmodifiableList
addChangeListener, clone, compareTo, getAllUserData, getID, getName, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName, toString
addChangeListener, getAllUserData, getBoundsMax, getBoundsMin, getID, getLimitPoint, getName, getParDimension, getUnit, getUserData, isValid, putAllUserData, putUserData, removeChangeListener, removeUserData, setName, size, toText
public static PointString newInstance()
PointString
instance
(on the stack when executing in a StackContext
), that can
store a list of GeomPoint
objects.public static PointString newInstance(java.lang.String name)
PointString
instance
(on the stack when executing in a StackContext
) with the
specified name, that can store a list of GeomPoint
objects.name
- The name to be assigned to this list (may be null
).public static <E extends GeomPoint> PointString<E> valueOf(java.lang.String name, java.util.Collection<E> elements)
GeomPoint
objects in the
specified collection.E
- The type of GeomPoint contained in this list of points.name
- The name to be assigned to this list (may be null
).elements
- A collection of points. May not be null.public static <E extends GeomPoint> PointString<E> valueOf(java.lang.String name, E... elements)
GeomPoint
objects in the specified
array.E
- The type of GeomPoint contained in this list of points.name
- The name to be assigned to this list (may be null
).elements
- An array of points. May not be null.public static <E extends GeomPoint> PointString<E> valueOf(E... elements)
GeomPoint
objects in the
specified array.E
- The type of GeomPoint contained in this list of points.elements
- An array of points. May not be null.public int getNumberOfPoints()
getNumberOfPoints
in interface PointGeometry<PointString<E extends GeomPoint>>
getNumberOfPoints
in class AbstractPointGeomList<PointString<E extends GeomPoint>,E extends GeomPoint>
public PointString<E> getRange(int first, int last)
getRange
in interface GeometryList<PointString<E extends GeomPoint>,E extends GeomPoint>
getRange
in class AbstractGeomList<PointString<E extends GeomPoint>,E extends GeomPoint>
first
- index of the first element to return (0 returns the 1st
element, -1 returns the last, etc).last
- index of the last element to return (0 returns the 1st
element, -1 returns the last, etc).java.lang.IndexOutOfBoundsException
- if the given index is out of range:
index >= size()
public PointString<E> reverse()
PointString
with the elements in this list in
reverse order.reverse
in interface GeometryList<PointString<E extends GeomPoint>,E extends GeomPoint>
reverse
in class AbstractGeomList<PointString<E extends GeomPoint>,E extends GeomPoint>
public PointString<E> thin()
PointString
that is identical to this string but
with every other point removed. The 1st point (index = 0) and last point
(index = size()-1) are always retained. If there are less than 3 points
in the string, then a new string is returned that contains the same
points as this string.public PointString enrich()
PointString
that is identical to this string but
with a new point linearly interpolated half-way between each of the
existing points. If there are less than 2 points in the string, then a
new string is returned that contains the same point as this string.public Parameter<Length> length()
public Point getAverage()
public PointString<E> sort(int dim, boolean removeDup, Parameter<Length> tol)
PointString
with the points in this list sorted into ascending
order with respect to the specified coordinate dimension. This can also be used to
remove duplicate points after the list has been sorted. To sort in descending
order, use this method followed immediately by reverse() (e.g.:
str.sort(Point.X,false,null).reverse();
).dim
- The physical coordinate dimension to be sorted (e.g.: 0=X, 1=Y, etc).removeDup
- Duplicate points are removed from the output if this is true.tol
- The tolerance for identifying duplicate points. If null is passed,
then essentially exact equality is required (if removeDup is
false, you may pass null).public PointString toDimension(int newDim)
newDim
- The dimension of the element to return.public PointString to(Unit<Length> unit)
unit
- the length unit of the list to be returned. May not be null.ConversionException
- if the the input unit is not a length unit.public PointString<E> copy()
PointString
instance
allocated
by the calling
thread (possibly on the stack).public PointString<E> copyToReal()
public PointString getTransformed(GTransform transform)
GeomTransform
and contains transformed versions of the
contents of this list as children.transform
- The transformation to apply to this geometry. May not be null.DimensionException
- if this element is not 3D.public E set(int index, E element)
GeomPoint
at the specified position in this list with the
specified element. Null elements are ignored. The input element must have the same
physical dimensions as the other items in this list, or an exception is thrown.set
in interface java.util.List<E extends GeomPoint>
set
in class AbstractPointGeomList<PointString<E extends GeomPoint>,E extends GeomPoint>
index
- The index of the element to replace (0 returns the 1st element, -1
returns the last, -2 returns the 2nd from last, etc).element
- The element to be stored at the specified position. May not be null.java.lang.IndexOutOfBoundsException
- - if index > size()
DimensionException
- if the input element's dimensions are different from
this list's dimensions.public void add(int index, E value)
GeomPoint
at the specified position in this list.
Shifts the element currently at that position (if any) and any subsequent elements
to the right (adds one to their indices). Null values are ignored. The input
value must have the same physical dimensions as the other items in this list, or
an exception is thrown.
Note: If this method is used concurrent access must be synchronized (the list is not thread-safe).
add
in interface java.util.List<E extends GeomPoint>
add
in class AbstractPointGeomList<PointString<E extends GeomPoint>,E extends GeomPoint>
index
- the index at which the specified element is to be inserted. (0 returns
the 1st element, -1 returns the last, -2 returns the 2nd from last,
etc).value
- the element to be inserted. May not be null.java.lang.IndexOutOfBoundsException
- if index > size()
DimensionException
- if the input value dimensions are different from
this list's dimensions.public boolean addAll(int index, java.util.Collection<? extends E> c)
GeomPoint
objects in the specified collection into this
list at the specified position. Shifts the element currently at that position (if
any) and any subsequent elements to the right (increases their indices). The new
elements will appear in this list in the order that they are returned by the
specified collection's iterator. The behavior of this operation is unspecified if
the specified collection is modified while the operation is in progress. Note that
this will occur if the specified collection is this list, and it's nonempty. The
input elements must have the same physical dimensions as the other items in this
list, or an exception is thrown.addAll
in interface java.util.List<E extends GeomPoint>
addAll
in class AbstractGeomList<PointString<E extends GeomPoint>,E extends GeomPoint>
index
- index at which to insert first element from the specified collection.c
- Elements to be inserted into this collection. May not be null.true
if this collection changed as a result of the callDimensionException
- if the input element's dimensions are different from
this list's dimensions.public static void recycle(PointString instance)
instance
- The instance to be recycled immediately.public static void main(java.lang.String[] args)
args
- Command-line arguments (not used).