org.jscience.architecture.traffic.infrastructure
Class SpecialNode

java.lang.Object
  extended by org.jscience.architecture.traffic.infrastructure.Node
      extended by org.jscience.architecture.traffic.infrastructure.SpecialNode
All Implemented Interfaces:
Selectable, SelectionStarter, InstantiationAssistant, TwoStageLoader, XMLSerializable
Direct Known Subclasses:
EdgeNode, NetTunnel

public abstract class SpecialNode
extends Node
implements XMLSerializable, TwoStageLoader

Class with common code for NetTunnels and EdgeNodes


Nested Class Summary
 
Nested classes/interfaces inherited from class org.jscience.architecture.traffic.infrastructure.Node
Node.NodeStatistics
 
Field Summary
protected  boolean isAlpha
          True if the connected road is an alpha road
protected  org.jscience.architecture.traffic.infrastructure.SpecialNode.TwoStageLoaderData loadData
          Temporary data structure to tranfer info from the first stage loader to the second stage loader
protected  Road road
          The road this SpecialNode is connected to
protected  int roadPos
          The connection-position of the connected road
protected  java.util.LinkedList waitingQueue
          The queue with all road users which have not entered the road.
 
Fields inherited from class org.jscience.architecture.traffic.infrastructure.Node
C_DOWN, C_LEFT, C_RIGHT, C_UP, coord, D_AHEAD, D_BACK, D_LEFT, D_RIGHT, EDGE, inboundLanes, JUNCTION, NET_TUNNEL, nodeId, NON_TL, outboundLanes, parentName, spdata, STAT_NUM_DATA, statistics
 
Constructor Summary
SpecialNode()
          Creates a new SpecialNode object.
SpecialNode(java.awt.Point _coord)
          Creates a new SpecialNode object.
 
Method Summary
 void addRoad(Road r, int pos)
          DOCUMENT ME!
protected  int calcDelay(Roaduser ru, int stop, int distance)
          Calculates the delay that has to be logged for this Node.
 Roaduser dequeueRoaduser()
          Remove a roaduser from the waitingQueue
 void doStep(SimModel model)
           
 void enqueueRoaduser(Roaduser ru)
          Place a roaduser in the waitingQueue
 void enter(Roaduser ru)
          Hook method that is called by the infra when a roaduser reaches this node
 Drivelane[] getAllLanes()
          DOCUMENT ME!
 Road[] getAllRoads()
          Returns all roads connected to this node
 boolean getAlpha()
          Returns true if the road is an alpha road
 Road[] getAlphaRoads()
          Returns the alpha roads connected to this node
 int getDesiredSignType()
          DOCUMENT ME!
 Drivelane[] getInboundLanes()
          DOCUMENT ME!
 Drivelane[] getLanesLeadingFrom(Drivelane lane, int ruType)
          DOCUMENT ME!
 Drivelane[] getLanesLeadingTo(Drivelane lane, int ruType)
          DOCUMENT ME!
 int getNumAllLanes()
          DOCUMENT ME!
 int getNumAlphaRoads()
          DOCUMENT ME!
 int getNumInboundLanes()
          DOCUMENT ME!
 int getNumOutboundLanes()
          DOCUMENT ME!
 int getNumRealSigns()
          DOCUMENT ME!
 int getNumRoads()
          DOCUMENT ME!
 int getNumSigns()
          DOCUMENT ME!
 Drivelane[] getOutboundLanes()
          DOCUMENT ME!
 Road getRoad()
          Returns the road this SpecialNode is connected to
 int getRoadPos()
          Returns the position of the road
 java.util.LinkedList getWaitingQueue()
          Returns the queue with waiting road users for this node
 int getWaitingQueueLength()
          Get the number of waiting road users, i.e. the length of the waitingQueue
 int getWidth()
          DOCUMENT ME!
 java.lang.String getXMLName()
          DOCUMENT ME!
 boolean isAlphaRoad(Road r)
          Checks if the given road is an alpha road of this node.
 boolean isConnected(Road r)
          DOCUMENT ME!
 int isConnectedAt(Road r)
          DOCUMENT ME!
 boolean isConnectionPosFree(int pos)
          DOCUMENT ME!
 void load(XMLElement myElement, XMLLoader loader)
          Load this XMLSerializable
 void loadSecondStage(java.util.Dictionary dictionaries)
          DOCUMENT ME!
 void placeRoaduser(Roaduser ru)
          Place a roaduser in one of the outbound queues
 void remAllRoads()
          DOCUMENT ME!
 void remRoad(int pos)
          DOCUMENT ME!
 void remRoad(Road r)
          DOCUMENT ME!
 void reset()
          Resets the data of this node.
 void saveChilds(XMLSaver saver)
          DOCUMENT ME!
 XMLElement saveSelf()
          DOCUMENT ME!
 void setAlpha(boolean f)
          Sets the isAlpha flag
 void setAlphaRoad(int pos)
          DOCUMENT ME!
 void setRoad(Road r)
          Sets the road this SpecialNode is connected to
 void setRoadPos(int pos)
          Sets the position of the road
 void setSigns(Sign[] s)
          DOCUMENT ME!
 void setWaitingQueue(java.util.LinkedList l)
          Sets a new queue with waiting road users
 void start()
          Hook method for stuff that has to be done when the simulation is started
 void stop()
          Hook method for stuff that has to be done when the simulation is stopped
 
Methods inherited from class org.jscience.architecture.traffic.infrastructure.Node
addShortestPath, areAllTailsFree, canCreateInstance, createInstance, getBounds, getCenterPoint, getChildren, getComplexBounds, getCoord, getDirection, getDistance, getId, getName, getNumSkip, getSelectionPoint, getSelectionPoints, getShortestPathDestinations, getShortestPaths, getStatistics, getStatistics, getType, hasChildren, initStats, isSelectable, paint, paint, processStats, remPaths, resetStats, setCoord, setId, setParentName, setShortestPath, updateLanes, zapShortestPaths
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jscience.architecture.traffic.xml.XMLSerializable
setParentName
 

Field Detail

road

protected Road road
The road this SpecialNode is connected to


isAlpha

protected boolean isAlpha
True if the connected road is an alpha road


roadPos

protected int roadPos
The connection-position of the connected road


waitingQueue

protected java.util.LinkedList waitingQueue
The queue with all road users which have not entered the road. For example because it's already full


loadData

protected org.jscience.architecture.traffic.infrastructure.SpecialNode.TwoStageLoaderData loadData
Temporary data structure to tranfer info from the first stage loader to the second stage loader

Constructor Detail

SpecialNode

public SpecialNode()
Creates a new SpecialNode object.


SpecialNode

public SpecialNode(java.awt.Point _coord)
Creates a new SpecialNode object.

Parameters:
_coord - DOCUMENT ME!
Method Detail

load

public void load(XMLElement myElement,
                 XMLLoader loader)
          throws XMLTreeException,
                 java.io.IOException,
                 XMLInvalidInputException
Description copied from interface: XMLSerializable
Load this XMLSerializable

Specified by:
load in interface XMLSerializable
Overrides:
load in class Node
Parameters:
myElement - The XMLElement which represents this object in the XML tree. It can contain attributes which hold information about the object.
loader - The XMLLoader which this XMLSerializable can use to load child objects.
Throws:
XMLTreeException - The parser can throw this exception if it is called by the XMLSerializable. The XMLSerializable should NOT throw this exception by itself and preferrably not catch it too.
java.io.IOException - Thrown in case of an read error in the XML file.
XMLInvalidInputException - The XMLSerializable can throw this exception if it cannot load itself or one of its child objects for whatever reason.

saveSelf

public XMLElement saveSelf()
                    throws XMLCannotSaveException
DOCUMENT ME!

Specified by:
saveSelf in interface XMLSerializable
Overrides:
saveSelf in class Node
Returns:
DOCUMENT ME!
Throws:
XMLCannotSaveException - DOCUMENT ME!

saveChilds

public void saveChilds(XMLSaver saver)
                throws XMLTreeException,
                       java.io.IOException,
                       XMLCannotSaveException
DOCUMENT ME!

Specified by:
saveChilds in interface XMLSerializable
Overrides:
saveChilds in class Node
Parameters:
saver - DOCUMENT ME!
Throws:
XMLTreeException - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
XMLCannotSaveException - DOCUMENT ME!

getXMLName

public java.lang.String getXMLName()
DOCUMENT ME!

Specified by:
getXMLName in interface XMLSerializable
Returns:
DOCUMENT ME!

loadSecondStage

public void loadSecondStage(java.util.Dictionary dictionaries)
                     throws XMLInvalidInputException,
                            XMLTreeException
DOCUMENT ME!

Specified by:
loadSecondStage in interface TwoStageLoader
Overrides:
loadSecondStage in class Node
Parameters:
dictionaries - DOCUMENT ME!
Throws:
XMLInvalidInputException - DOCUMENT ME!
XMLTreeException - DOCUMENT ME!

getRoad

public Road getRoad()
Returns the road this SpecialNode is connected to

Returns:
DOCUMENT ME!

setRoad

public void setRoad(Road r)
             throws InfraException
Sets the road this SpecialNode is connected to

Parameters:
r - DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

getRoadPos

public int getRoadPos()
Returns the position of the road

Returns:
DOCUMENT ME!

setRoadPos

public void setRoadPos(int pos)
                throws InfraException
Sets the position of the road

Parameters:
pos - DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

getAlpha

public boolean getAlpha()
Returns true if the road is an alpha road

Returns:
DOCUMENT ME!

setAlpha

public void setAlpha(boolean f)
Sets the isAlpha flag

Parameters:
f - DOCUMENT ME!

getAllRoads

public Road[] getAllRoads()
Returns all roads connected to this node

Specified by:
getAllRoads in class Node
Returns:
DOCUMENT ME!

getAlphaRoads

public Road[] getAlphaRoads()
Returns the alpha roads connected to this node

Specified by:
getAlphaRoads in class Node
Returns:
DOCUMENT ME!

getWidth

public int getWidth()
DOCUMENT ME!

Specified by:
getWidth in class Node
Returns:
DOCUMENT ME!

placeRoaduser

public void placeRoaduser(Roaduser ru)
                   throws InfraException
Place a roaduser in one of the outbound queues

Parameters:
ru - DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

getWaitingQueue

public java.util.LinkedList getWaitingQueue()
Returns the queue with waiting road users for this node

Returns:
DOCUMENT ME!

setWaitingQueue

public void setWaitingQueue(java.util.LinkedList l)
Sets a new queue with waiting road users

Parameters:
l - DOCUMENT ME!

getWaitingQueueLength

public int getWaitingQueueLength()
Get the number of waiting road users, i.e. the length of the waitingQueue

Returns:
DOCUMENT ME!

enqueueRoaduser

public void enqueueRoaduser(Roaduser ru)
Place a roaduser in the waitingQueue

Parameters:
ru - DOCUMENT ME!

dequeueRoaduser

public Roaduser dequeueRoaduser()
Remove a roaduser from the waitingQueue

Returns:
DOCUMENT ME!

calcDelay

protected int calcDelay(Roaduser ru,
                        int stop,
                        int distance)
Description copied from class: Node
Calculates the delay that has to be logged for this Node.

Specified by:
calcDelay in class Node
Parameters:
ru - DOCUMENT ME!
stop - DOCUMENT ME!
distance - DOCUMENT ME!
Returns:
DOCUMENT ME!

reset

public void reset()
Description copied from class: Node
Resets the data of this node. This also resets all AlphaRoads.

Overrides:
reset in class Node
See Also:
Road.reset()

addRoad

public void addRoad(Road r,
                    int pos)
             throws InfraException
DOCUMENT ME!

Specified by:
addRoad in class Node
Parameters:
r - DOCUMENT ME!
pos - DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

setAlphaRoad

public void setAlphaRoad(int pos)
                  throws InfraException
DOCUMENT ME!

Specified by:
setAlphaRoad in class Node
Parameters:
pos - DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

remRoad

public void remRoad(int pos)
             throws InfraException
DOCUMENT ME!

Specified by:
remRoad in class Node
Parameters:
pos - DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

remRoad

public void remRoad(Road r)
             throws InfraException
DOCUMENT ME!

Specified by:
remRoad in class Node
Parameters:
r - DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

remAllRoads

public void remAllRoads()
                 throws InfraException
DOCUMENT ME!

Specified by:
remAllRoads in class Node
Throws:
InfraException - DOCUMENT ME!

setSigns

public void setSigns(Sign[] s)
              throws InfraException
DOCUMENT ME!

Specified by:
setSigns in class Node
Parameters:
s - DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

getDesiredSignType

public int getDesiredSignType()
                       throws InfraException
DOCUMENT ME!

Specified by:
getDesiredSignType in class Node
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

isAlphaRoad

public boolean isAlphaRoad(Road r)
                    throws InfraException
Description copied from class: Node
Checks if the given road is an alpha road of this node.

Specified by:
isAlphaRoad in class Node
Parameters:
r - The road to check
Returns:
true if the given road is an alpha road
Throws:
InfraException - if r is null

isConnected

public boolean isConnected(Road r)
                    throws InfraException
DOCUMENT ME!

Specified by:
isConnected in class Node
Parameters:
r - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

isConnectedAt

public int isConnectedAt(Road r)
                  throws InfraException
DOCUMENT ME!

Specified by:
isConnectedAt in class Node
Parameters:
r - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

isConnectionPosFree

public boolean isConnectionPosFree(int pos)
                            throws InfraException
DOCUMENT ME!

Specified by:
isConnectionPosFree in class Node
Parameters:
pos - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

getNumRoads

public int getNumRoads()
DOCUMENT ME!

Specified by:
getNumRoads in class Node
Returns:
DOCUMENT ME!

getNumAlphaRoads

public int getNumAlphaRoads()
DOCUMENT ME!

Specified by:
getNumAlphaRoads in class Node
Returns:
DOCUMENT ME!

getNumInboundLanes

public int getNumInboundLanes()
                       throws InfraException
DOCUMENT ME!

Specified by:
getNumInboundLanes in class Node
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

getNumOutboundLanes

public int getNumOutboundLanes()
                        throws InfraException
DOCUMENT ME!

Specified by:
getNumOutboundLanes in class Node
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

getNumAllLanes

public int getNumAllLanes()
DOCUMENT ME!

Specified by:
getNumAllLanes in class Node
Returns:
DOCUMENT ME!

getNumSigns

public int getNumSigns()
DOCUMENT ME!

Specified by:
getNumSigns in class Node
Returns:
DOCUMENT ME!

getNumRealSigns

public int getNumRealSigns()
DOCUMENT ME!

Specified by:
getNumRealSigns in class Node
Returns:
DOCUMENT ME!

getLanesLeadingTo

public Drivelane[] getLanesLeadingTo(Drivelane lane,
                                     int ruType)
                              throws InfraException
DOCUMENT ME!

Specified by:
getLanesLeadingTo in class Node
Parameters:
lane - DOCUMENT ME!
ruType - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

getLanesLeadingFrom

public Drivelane[] getLanesLeadingFrom(Drivelane lane,
                                       int ruType)
                                throws InfraException
DOCUMENT ME!

Specified by:
getLanesLeadingFrom in class Node
Parameters:
lane - DOCUMENT ME!
ruType - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

getOutboundLanes

public Drivelane[] getOutboundLanes()
                             throws InfraException
DOCUMENT ME!

Specified by:
getOutboundLanes in class Node
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

getInboundLanes

public Drivelane[] getInboundLanes()
                            throws InfraException
DOCUMENT ME!

Specified by:
getInboundLanes in class Node
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

getAllLanes

public Drivelane[] getAllLanes()
                        throws InfraException
DOCUMENT ME!

Specified by:
getAllLanes in class Node
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

doStep

public void doStep(SimModel model)

start

public void start()
Hook method for stuff that has to be done when the simulation is started


stop

public void stop()
Hook method for stuff that has to be done when the simulation is stopped


enter

public void enter(Roaduser ru)
Hook method that is called by the infra when a roaduser reaches this node

Parameters:
ru - DOCUMENT ME!