Class PathSegment

java.lang.Object
me.nabdev.pathfinding.structures.PathSegment

public class PathSegment extends Object
Represents one segment of a path. A segment is either a corner or a straightaway between two corners.
  • Field Details

    • points

      public ArrayList<Vertex> points
      The points that make up this segment.
    • corner

      public boolean corner
      Whether or not this segment is a corner. If true, it is a corner. If false, it is a straightaway.
  • Constructor Details

    • PathSegment

      public PathSegment()
      Creates a new corner segment.
    • PathSegment

      public PathSegment(Vertex v1, Vertex v2)
      Creates a new straightaway segment.
      Parameters:
      v1 - The first vertex in the segment.
      v2 - The second vertex in the segment.
  • Method Details

    • end

      public Vertex end()
      Get the last vertex in the segment.
      Returns:
      The last vertex in the segment.
    • start

      public Vertex start()
      Get the first vertex in the segment.
      Returns:
      The first vertex in the segment.
    • add

      public void add(Vertex v)
      Add a vertex to the segment.
      Parameters:
      v - The vertex to add.
    • get

      public Vertex get(int i)
      Get a vertex in the segment.
      Parameters:
      i - The index of the vertex to get.
      Returns:
      The vertex at the given index.
    • replace

      public void replace(ArrayList<Vertex> newArr)
      Replace the points in the segment with a new set of points.
      Parameters:
      newArr - The new set of points.