jfreerails.world.train
Class PathOnTiles

java.lang.Object
  extended by jfreerails.world.train.PathOnTiles
All Implemented Interfaces:
java.io.Serializable, FreerailsSerializable

public class PathOnTiles
extends java.lang.Object
implements FreerailsSerializable

An immutable class that stores a path made up of OneTileMoveVectors.

Author:
Luke
See Also:
Serialized Form

Field Summary
private static long serialVersionUID
           
private  ImPoint start
           
private  ImList<Step> vectors
           
 
Constructor Summary
PathOnTiles(ImPoint start, java.util.List<Step> vectorsList)
           
PathOnTiles(ImPoint start, Step... vectors)
           
 
Method Summary
 PathOnTiles addSteps(Step... newSteps)
           
 boolean equals(java.lang.Object o)
           
 double getDistance(int steps)
           
 PositionOnTrack getFinalPosition()
           
 ImPoint getPoint(double distance)
          Returns the coordinates of the point you would be standing at if you walked the specified distance along the path from the start point.
 ImPoint getStart()
           
 Step getStep(int i)
           
 int getStepIndex(int distance)
          Returns the index of the step that takes the distance travelled over the specified distance.
 double getTotalDistance()
          Returns the distance you would travel if you walked the all the way along the path.
 int hashCode()
           
 int steps()
           
 FreerailsPathIterator subPath(double offset, double length)
          Returns a FreerailsPathIterator that exposes a sub section of the path this object represents.
 java.util.Iterator<ImPoint> tiles()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

start

private final ImPoint start

vectors

private final ImList<Step> vectors
Constructor Detail

PathOnTiles

public PathOnTiles(ImPoint start,
                   java.util.List<Step> vectorsList)
Throws:
java.lang.NullPointerException - if null == start
java.lang.NullPointerException - if null == vectorsList
java.lang.NullPointerException - if null == vectorsList.get(i) for any i;

PathOnTiles

public PathOnTiles(ImPoint start,
                   Step... vectors)
Throws:
java.lang.NullPointerException - if null == start
java.lang.NullPointerException - if null == vectors
java.lang.NullPointerException - if null == vectors[i] for any i;
Method Detail

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getTotalDistance

public double getTotalDistance()
Returns the distance you would travel if you walked the all the way along the path.


getDistance

public double getDistance(int steps)

getPoint

public ImPoint getPoint(double distance)
Returns the coordinates of the point you would be standing at if you walked the specified distance along the path from the start point.

Throws:
java.lang.IllegalArgumentException - if distance < 0
java.lang.IllegalArgumentException - if distance > getLength()

getStart

public ImPoint getStart()

getStep

public Step getStep(int i)

getFinalPosition

public PositionOnTrack getFinalPosition()

getStepIndex

public int getStepIndex(int distance)
Returns the index of the step that takes the distance travelled over the specified distance.

Throws:
java.lang.IllegalArgumentException - if distance < 0
java.lang.IllegalArgumentException - if distance > getLength()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

steps

public int steps()

addSteps

public PathOnTiles addSteps(Step... newSteps)

subPath

public FreerailsPathIterator subPath(double offset,
                                     double length)
Returns a FreerailsPathIterator that exposes a sub section of the path this object represents.

Throws:
java.lang.IllegalArgumentException - if offset < 0
java.lang.IllegalArgumentException - if length <= 0
java.lang.IllegalArgumentException - if offset + length > getLength()

tiles

public java.util.Iterator<ImPoint> tiles()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object