Package com.macrofocus.treemap.voronoi
Class Path
- java.lang.Object
-
- com.macrofocus.treemap.voronoi.Path
-
public class Path extends java.lang.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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Two paths are equal if they have the same origin and the same directions.java.util.List<Direction>
getDirections()
double
getLength()
int
getOriginX()
int
getOriginY()
int
getTerminalX()
int
getTerminalY()
int
hashCode()
boolean
isClosed()
java.lang.String
toString()
Path
translate(int deltaX, int deltaY)
Creates a new path by translating this path in the plane.
-
-
-
Constructor Detail
-
Path
public Path(int startX, int startY, java.util.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 planestartY
- the y coordinate of the path's origin in the planedirections
- a list of the directions in the path
-
-
Method Detail
-
getDirections
public java.util.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 coordinatedeltaY
- the change in the path's y coordinate- Returns:
- a new path whose origin has been translated
-
equals
public boolean equals(java.lang.Object obj)
Two paths are equal if they have the same origin and the same directions.- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-