Class Fragments
java.lang.Object
java.util.AbstractCollection<double[]>
java.util.AbstractList<double[]>
java.util.ArrayList<double[]>
org.apache.sis.internal.processing.isoline.Fragments
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<double[]>
,Collection<double[]>
,List<double[]>
,RandomAccess
,SequencedCollection<double[]>
List of
PolylineBuffer
coordinates that have not yet been closed.
Each double[]
in this list is a copy of a PolylineBuffer
used by Tracer.Level
.
Those copies are performed for saving data before they are overwritten by next iterated cell.
List indices and ordering of points
For a givenFragments
list, all double[]
arrays at even indices shall have their points read
in reverse order and all double[]
arrays at odd indices shall have their points read in forward order.
The list size must be even and the list may contain null elements when there is no data in the corresponding
iteration order. This convention makes easy to reverse the order of all points, simply by reversing the order
of double[]
arrays: because even indices become odd and odd indices become even, points order are
implicitly reverted without the need to rewrite all double[]
array contents.- Since:
- 1.1
- Version:
- 1.3
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Point
The first points and last point in this list of polylines.private Point
The first points and last point in this list of polylines.Fields inherited from class java.util.AbstractList
modCount
-
Constructor Summary
ConstructorsConstructorDescriptionFragments
(PolylineBuffer polylineOnLeft, PolylineBuffer polylineOnTop) Creates a list of polylines initialized to the given items. -
Method Summary
Modifier and TypeMethodDescriptionprivate Point
Prepends or appends the given polylines to this list of polylines.(package private) final boolean
addOrMerge
(Map<Point, Fragments> partialPaths) Associates this polyline to its two extremities in the given map.(package private) final boolean
isExtremity
(Point key) Returnstrue
if the given point is equal to the start point or end point.private void
reverse()
Reverse the order of all points.private void
take
(PolylineBuffer polyline) Takes a copy of coordinate values of given polyline, then clears that polyline.(package private) final PolylineBuffer[]
Returns the content of this list as an array ofPolylineBuffer
instances.Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, addFirst, addLast, clear, clone, contains, ensureCapacity, equals, forEach, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeIf, removeLast, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods inherited from interface java.util.List
containsAll, reversed
-
Field Details
-
firstPoint
The first points and last point in this list of polylines. By convention the coordinate having fraction digits has all its bits inverted by the~
operator. May benull
if a coordinate is NaN. Do not modifyPoint
field values, because those instances are keys inTracer.Level.partialPaths
. -
lastPoint
The first points and last point in this list of polylines. By convention the coordinate having fraction digits has all its bits inverted by the~
operator. May benull
if a coordinate is NaN. Do not modifyPoint
field values, because those instances are keys inTracer.Level.partialPaths
.
-
-
Constructor Details
-
Fragments
Fragments(PolylineBuffer polylineOnLeft, PolylineBuffer polylineOnTop) Creates a list of polylines initialized to the given items. The given polylines and their opposite directions are cleared by this method.- Parameters:
polylineOnLeft
- first polyline with points in forward order. Shall not be null.polylineOnTop
- next polyline with points in reverse order, ornull
if none.
-
-
Method Details
-
take
Takes a copy of coordinate values of given polyline, then clears that polyline. -
isExtremity
Returnstrue
if the given point is equal to the start point or end point. This is used in assertions for checking key validity inTracer.Level.partialPaths
. -
addOrMerge
Associates this polyline to its two extremities in the given map. If other polylines already exist for one or both extremities, then this polyline will be merged with previously existing polylines. This method returnstrue
if caller should store the coordinates inTracer.Level.path
immediately. It may be either because the polyline has been closed as a polygon, or because the two extremities contains NaN values in which case the polylines are not anymore inpartialPaths
.- Parameters:
partialPaths
- where to add or merge polylines.- Returns:
true
if this polyline became a closed polygon as a result of merge operation.
-
addAll
Prepends or appends the given polylines to this list of polylines. Points order will be changed as needed in order to match extremities. Theother
instance should be forgotten after this method call.- Parameters:
other
- the other polyline to append or prepend to this polyline.prepend
-true
for prepend operation,false
for append.- Returns:
- extremity of
other
which has not been assigned tothis
.
-
reverse
private void reverse()Reverse the order of all points. The last polyline will become the first polyline and vice-versa. For each polyline, points will be iterated in opposite order. The trick on point order is done by moving polylines at even indices to odd indices, and conversely (see class javadoc for convention about even/odd indices). -
toPolylines
Returns the content of this list as an array ofPolylineBuffer
instances.PolylineBuffer
instances at even index should be written with their points in reverse order.- Returns:
- elements of this array as polylines. May contain null elements.
- See Also:
-