Class Path

java.lang.Object
com.treemap.swing.voronoi.Path

public class Path extends Object
Combines a sequence of directions into a path that is rooted at some point in the plane. No restrictions are placed on paths; they may be zero length, open/closed, self-intersecting. Path objects are immutable.
  • Constructor Details

    • Path

      public Path(int startX, int startY, List<Direction> directions)
      Convenience constructor that converts the supplied direction list into an array which is then passed to another constructor.
      Parameters:
      startX - the x coordinate of the path's origin in the plane
      startY - the y coordinate of the path's origin in the plane
      directions - a list of the directions in the path
  • Method Details

    • getDirections

      public List<Direction> getDirections()
      Returns:
      an immutable list of the directions that compose this path, never null
    • getOriginX

      public int getOriginX()
      Returns:
      the x coordinate in the plane at which the path begins
    • getOriginY

      public int getOriginY()
      Returns:
      the y coordinate in the plane at which the path begins
    • getTerminalX

      public int getTerminalX()
      Returns:
      the x coordinate in the plane at which the path ends
    • getTerminalY

      public int getTerminalY()
      Returns:
      the y coordinate in the plane at which the path ends
    • getLength

      public double getLength()
      Returns:
      the length of the path using the standard euclidean metric
    • isClosed

      public boolean isClosed()
      Returns:
      true if and only if the path's point of origin is the same as that of its point of termination
    • translate

      public Path translate(int deltaX, int deltaY)
      Creates a new path by translating this path in the plane.
      Parameters:
      deltaX - the change in the path's x coordinate
      deltaY - the change in the path's y coordinate
      Returns:
      a new path whose origin has been translated
    • equals

      public boolean equals(Object obj)
      Two paths are equal if they have the same origin and the same directions.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object