public class LinePath extends Object implements BoundarySource2D, Sized
line convex subsets
.
The elements in the path are connected end to end, with the end vertex of the previous
element equivalent to the start vertex of the next element. Elements are not required to
be finite. However, since path elements are connected, only the first element and/or last
element may be infinite.
Instances of this class are guaranteed to be immutable.
Modifier and Type | Class and Description |
---|---|
static class |
LinePath.Builder
Class used to build line paths.
|
Modifier and Type | Method and Description |
---|---|
Stream<LineConvexSubset> |
boundaryStream() |
static LinePath.Builder |
builder(Precision.DoubleEquivalence precision)
Return a
LinePath.Builder instance configured with the given precision
context. |
static LinePath |
empty()
Return a path containing no elements.
|
static LinePath |
from(Collection<? extends LineConvexSubset> subsets)
Build a new path from the given line subsets.
|
static LinePath |
from(LineConvexSubset... subsets)
Build a new path from the given line subsets.
|
static LinePath |
fromVertexLoop(Collection<Vector2D> vertices,
Precision.DoubleEquivalence precision)
Build a new path from the given vertices.
|
static LinePath |
fromVertices(Collection<Vector2D> vertices,
boolean close,
Precision.DoubleEquivalence precision)
Build a new path from the given vertices.
|
static LinePath |
fromVertices(Collection<Vector2D> vertices,
Precision.DoubleEquivalence precision)
Build a new path from the given vertices.
|
List<LineConvexSubset> |
getElements()
Get the sequence of line subsets comprising the path.
|
LineConvexSubset |
getEnd()
Get the line subset at the end of the path or null if the path is empty.
|
double |
getSize() |
LineConvexSubset |
getStart()
Get the line subset at the start of the path or null if the path is empty.
|
List<Vector2D> |
getVertexSequence()
Get the sequence of vertices defined by the path.
|
boolean |
isClosed()
Return true if the path is closed, meaning that the end point for the last
element is equivalent to the start point of the first.
|
boolean |
isEmpty()
Return true if the path does not contain any elements.
|
boolean |
isFinite()
Return true if the path has a finite size.
|
boolean |
isInfinite()
Return true if the path has an element with infinite size.
|
LinePath |
reverse()
Return a new instance with all line subset directions, and their order,
reversed.
|
LinePath |
simplify()
Simplify this path, if possible, by combining adjacent elements that lie on the
same line (as determined by
Line.equals(Object) ). |
String |
toString()
Return a string representation of the path.
|
LinePath |
transform(Transform<Vector2D> transform)
Transform this instance with the argument, returning the result in a new instance.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getBounds, linecast, linecastFirst, of, of, toList, toTree
linecast, linecastFirst
public Stream<LineConvexSubset> boundaryStream()
boundaryStream
in interface BoundarySource<LineConvexSubset>
public List<LineConvexSubset> getElements()
public LineConvexSubset getStart()
getEnd()
.getEnd()
public LineConvexSubset getEnd()
getStart()
.getStart()
public List<Vector2D> getVertexSequence()
public boolean isInfinite()
isInfinite
in interface Sized
public boolean isFinite()
public double getSize()
The size of the path is defined as the sum of the sizes (lengths) of all path elements.
public boolean isEmpty()
public boolean isClosed()
public LinePath transform(Transform<Vector2D> transform)
transform
- the transform to applypublic LinePath reverse()
public LinePath simplify()
Line.equals(Object)
).public String toString()
In order to keep the string representation short but useful, the exact format of the return value depends on the properties of the path. See below for examples.
LinePath[empty= true]
LinePath[single= Segment[startPoint= (0.0, 0.0), endPoint= (1.0, 0.0)]]
LinePath[startDirection= (1.0, 0.0), vertices= [(1.0, 0.0), (1.0, 1.0)]]
LinePath[vertices= [(0.0, 1.0), (0.0, 0.0)], endDirection= (1.0, 0.0)]
LinePath[startDirection= (0.0, 1.0), vertices= [(0.0, 0.0)], endDirection= (1.0, 0.0)]
LinePath[vertices= [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0)]]
public static LinePath from(LineConvexSubset... subsets)
subsets
- the line subsets to comprise the pathIllegalStateException
- if the line subsets do not form a connected pathpublic static LinePath from(Collection<? extends LineConvexSubset> subsets)
subsets
- the line subsets to comprise the pathIllegalStateException
- if the subsets do not form a connected pathpublic static LinePath fromVertexLoop(Collection<Vector2D> vertices, Precision.DoubleEquivalence precision)
fromVertices(vertices, true, precision)
vertices
- the vertices to construct the closed path fromprecision
- precision context used to construct the line segment
instances for the pathIllegalStateException
- if vertices
contains only a single unique vertexfromVertices(Collection, boolean, Precision.DoubleEquivalence)
public static LinePath fromVertices(Collection<Vector2D> vertices, Precision.DoubleEquivalence precision)
fromVertices(vertices, false, precision)
.vertices
- the vertices to construct the path fromprecision
- precision context used to construct the line segment
instances for the pathIllegalStateException
- if vertices
contains only a single unique vertexfromVertices(Collection, boolean, Precision.DoubleEquivalence)
public static LinePath fromVertices(Collection<Vector2D> vertices, boolean close, Precision.DoubleEquivalence precision)
vertices
- the vertices to construct the path fromclose
- if true, a line segment is created from the last vertex
given to the first one, if the two vertices are not already considered
equal using the given precision context.precision
- precision context used to construct the line segment
instances for the pathIllegalStateException
- if vertices
contains only a single unique vertexpublic static LinePath empty()
public static LinePath.Builder builder(Precision.DoubleEquivalence precision)
LinePath.Builder
instance configured with the given precision
context. The precision context is used when building line segments from
vertices and may be omitted if raw vertices are not used.precision
- precision context to use when building line segments from
raw vertices; may be null if raw vertices are not used.LinePath.Builder
instanceCopyright © 2016–2021 The Apache Software Foundation. All rights reserved.