public class Route extends Object implements Cloneable, Comparable<Route>
Constructor and Description |
---|
Route()
Creates a new instance of Route
|
Modifier and Type | Method and Description |
---|---|
void |
addWaypoint(double[] newPoint)
Adds a point to the end of the route
|
void |
addWaypoint(double[] newPoint,
int index)
Adds a point to the of the route at a specified index.
|
Object |
clone()
Returns a deep copy of the route
|
int |
compareTo(Route route2)
Imlements Comparable--Compares routes based on their total distance
|
void |
divideLeg(int leg,
double[] newWaypoint)
Divides a route leg into two by adding a specified waypoint in the middle
|
double |
getDistance()
Returns the total straight-line distance covered by the route
|
protected Iterator |
getIterator()
Returns an iterator for the waypoint list
|
double |
getLegDistance(int leg)
Returns the distance of the specified leg of the route or 0.0 if
the specified leg is beyond the end of the route or less than zero
|
double |
getPartialDistance(int waypoint)
Returns the distance from the start of the route to the specified waypoint.
|
double[] |
getWaypoint(int index)
Returns a reference to the area specified by an index
|
int |
numWaypoints()
Returns the number of areas in the set
|
String |
toString()
Formats the route for text output
|
public void addWaypoint(double[] newPoint)
newPoint
- double[2] with the X, Y position of the point to be addedpublic void addWaypoint(double[] newPoint, int index)
newPoint
- double[2] with the X, Y position of the point to be addedindex
- number of the waypointpublic void divideLeg(int leg, double[] newWaypoint)
leg
- the number of the leg that is to be dividednewWaypoint
- double[2] with the X, Y position of the waypoint to be addedpublic double[] getWaypoint(int index)
index
- protected Iterator getIterator()
public int numWaypoints()
public double getLegDistance(int leg)
leg
- public double getPartialDistance(int waypoint)
waypoint
- public double getDistance()
public int compareTo(Route route2)
compareTo
in interface Comparable<Route>
route2
-