movement.map
Class MapRoute

java.lang.Object
  extended by movement.map.MapRoute

public class MapRoute
extends java.lang.Object

A route that consists of map nodes. There can be different kind of routes and the type is determined by the type parameter (1 or 2).


Field Summary
static int CIRCULAR
          Type of the route ID: circular (1).
static int PINGPONG
          Type of the route ID: ping-pong (2).
 
Constructor Summary
MapRoute(int type, java.util.List<MapNode> stops)
          Creates a new map route
 
Method Summary
 int getNrofStops()
          Returns the number of stops on this route
 java.util.List<MapNode> getStops()
           
 MapNode nextStop()
          Returns the next stop on the route (depenging on the route mode)
static java.util.List<MapRoute> readRoutes(java.lang.String fileName, int type, SimMap map)
          Reads routes from files defined in Settings
 MapRoute replicate()
          Returns a new route with the same settings
 void setNextIndex(int index)
          Sets the next index for this route
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CIRCULAR

public static final int CIRCULAR
Type of the route ID: circular (1). After reaching the last node on path, the next node is the first node

See Also:
Constant Field Values

PINGPONG

public static final int PINGPONG
Type of the route ID: ping-pong (2). After last node on path, the direction on path is reversed

See Also:
Constant Field Values
Constructor Detail

MapRoute

public MapRoute(int type,
                java.util.List<MapNode> stops)
Creates a new map route

Parameters:
stops - The stops of this route in a list
type - Type of the route (e.g. CIRCULAR or PINGPONG)
Method Detail

setNextIndex

public void setNextIndex(int index)
Sets the next index for this route

Parameters:
index - The index to set

getNrofStops

public int getNrofStops()
Returns the number of stops on this route

Returns:
the number of stops on this route

getStops

public java.util.List<MapNode> getStops()

nextStop

public MapNode nextStop()
Returns the next stop on the route (depenging on the route mode)

Returns:
the next stop on the route

replicate

public MapRoute replicate()
Returns a new route with the same settings

Returns:
a replicate of this route

toString

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

readRoutes

public static java.util.List<MapRoute> readRoutes(java.lang.String fileName,
                                                  int type,
                                                  SimMap map)
Reads routes from files defined in Settings

Parameters:
fileName - name of the file where to read routes
type - Type of the route
map - SimMap where corresponding map nodes are found
Returns:
A list of MapRoutes that were read