Class LinePath.Builder

java.lang.Object
org.apache.commons.geometry.euclidean.twod.path.LinePath.Builder
Enclosing class:
LinePath

public static final class LinePath.Builder extends Object
Class used to build line paths.
  • Method Details

    • setPrecision

      public LinePath.Builder setPrecision(org.apache.commons.numbers.core.Precision.DoubleEquivalence builderPrecision)
      Set the precision context. This context is used only when creating line segments from appended or prepended vertices. It is not used when adding existing LineConvexSubset instances since those contain their own precision contexts.
      Parameters:
      builderPrecision - precision context to use when creating line segments from vertices
      Returns:
      this instance
    • getStart

      Get the line subset at the start of the path or null if it does not exist.
      Returns:
      the line subset at the start of the path
    • getEnd

      Get the line subset at the end of the path or null if it does not exist.
      Returns:
      the line subset at the end of the path
    • append

      Append a line subset to the end of the path.
      Parameters:
      subset - line subset to append to the path
      Returns:
      the current builder instance
      Throws:
      IllegalStateException - if the path contains a previous element and the end vertex of the previous element is not equivalent to the start vertex of the argument
    • append

      public LinePath.Builder append(Vector2D vertex)
      Add a vertex to the end of this path. If the path already has an end vertex, then a line segment is added between the previous end vertex and this vertex, using the configured precision context.
      Parameters:
      vertex - the vertex to add
      Returns:
      this instance
      See Also:
    • appendVertices

      public LinePath.Builder appendVertices(Collection<? extends Vector2D> vertices)
      Convenience method for appending a collection of vertices to the path in a single method call.
      Parameters:
      vertices - the vertices to append
      Returns:
      this instance
      See Also:
    • appendVertices

      Convenience method for appending multiple vertices to the path at once.
      Parameters:
      vertices - the vertices to append
      Returns:
      this instance
      See Also:
    • prepend

      Prepend a line subset to the beginning of the path.
      Parameters:
      subset - line subset to prepend to the path
      Returns:
      the current builder instance
      Throws:
      IllegalStateException - if the path contains a start element and the end vertex of the argument is not equivalent to the start vertex of the start element.
    • prepend

      Add a vertex to the front of this path. If the path already has a start vertex, then a line segment is added between this vertex and the previous start vertex, using the configured precision context.
      Parameters:
      vertex - the vertex to add
      Returns:
      this instance
      See Also:
    • prependVertices

      Convenience method for prepending a collection of vertices to the path in a single method call. The vertices are logically prepended as a single group, meaning that the first vertex in the given collection appears as the first vertex in the path after this method call. Internally, this means that the vertices are actually passed to the prepend(Vector2D) method in reverse order.
      Parameters:
      vertices - the vertices to prepend
      Returns:
      this instance
      See Also:
    • prependVertices

      Convenience method for prepending multiple vertices to the path in a single method call. The vertices are logically prepended as a single group, meaning that the first vertex in the given collection appears as the first vertex in the path after this method call. Internally, this means that the vertices are actually passed to the prepend(Vector2D) method in reverse order.
      Parameters:
      vertices - the vertices to prepend
      Returns:
      this instance
      See Also:
    • close

      public LinePath close()
      Close the current path and build a new LinePath instance. This method is equivalent to builder.build(true).
      Returns:
      new closed path instance
      Throws:
      IllegalStateException - if the builder was given only a single unique vertex
    • build

      public LinePath build()
      Build a LinePath instance from the configured path. This method is equivalent to builder.build(false).
      Returns:
      new path instance
      Throws:
      IllegalStateException - if the builder was given only a single unique vertex
    • build

      public LinePath build(boolean close)
      Build a LinePath instance from the configured path.
      Parameters:
      close - if true, the path will be closed by adding an end point equivalent to the start point
      Returns:
      new path instance
      Throws:
      IllegalStateException - if the builder was given only a single unique vertex