org.jscience.architecture.traffic.infrastructure
Class Junction

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

public class Junction
extends Node

Basic junction. A Node either is a Junction or an EdgeNode.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.jscience.architecture.traffic.infrastructure.Node
Node.NodeStatistics
 
Field Summary
protected  Road[] allRoads
          A vector containing all roads connected to this node
protected  Road[] alphaRoads
          A vector containing all roads that have this node as their Alpha node
protected  org.jscience.architecture.traffic.infrastructure.Junction.TwoStageLoaderData loadData
          Temporary data structure to tranfer info from the first stage loader to the second stage loader
protected  Sign[][] signconfigs
          Contains all possible combinations of signs which may be turned green at the same time
protected  Sign[] signs
          A Vector containing all Signs on this node
protected static int type
          The type of this node
protected  int width
          The width/height of this node in drivelanes.
 
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
Junction()
          Creates an empty junction (for loading)
Junction(java.awt.Point _coord)
          Creates a new standard Junction
 
Method Summary
 void addRoad(Road r, int pos)
          DOCUMENT ME!
 void addSignconfig(Sign[] conf)
          Adds a sign configuration
 boolean areOtherTailsFree(Sign[] mayUse)
           
protected  int calcDelay(Roaduser ru, int stop, int distance)
          Calculates the delay that has to be logged for this Node.
 void calculateWidth()
          (Re)Calculates the width of this junction
 Drivelane[] getAllLanes()
          Returns an array of all lanes on this node
 Drivelane[] getAllLanesCW(Drivelane lane)
          Returns an array of all lanes connected to this node, in clock-wise order, starting at the given lane
 Road[] getAllRoads()
          Returns all roads connected to this node
 Road[] getAlphaRoads()
          Returns the alpha roads connected to this node
 int getDesiredSignType()
          DOCUMENT ME!
 Drivelane[] getInboundLanes()
          Returns an array of all inbound lanes on this junction
 Drivelane[] getLanesLeadingFrom(Drivelane lane)
          DOCUMENT ME!
 Drivelane[] getLanesLeadingFrom(Drivelane lane, int ruType)
          Returns an array of all outbound lanes supporting roadusers of given type that can be reached from the given inbound lane.
 Drivelane[] getLanesLeadingTo(Drivelane lane, int ruType)
          Returns an array of all inbound lanes supporting roadusers of given type that lead to the given outbound lane.
 java.lang.String getName()
          Returns the name of this junction.
 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()
          Returns an array of all outbound lanes on this junction
protected  int[] getRoadIdArray()
          DOCUMENT ME!
protected  Sign getSign(java.util.Dictionary laneDictionary, int id)
          DOCUMENT ME!
protected  int[][] getSignConfigIdArray()
          DOCUMENT ME!
 Sign[][] getSignConfigs()
          Returns all possible sign configurations
protected  int[] getSignIdArray()
          DOCUMENT ME!
 Sign[] getSigns()
          Returns the signs on this Node
 int getType()
          Returns the type of this junction
 int getWidth()
          Returns the width of this Node in number of lanes
 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 paint(java.awt.Graphics g)
          DOCUMENT ME!
 void paint(java.awt.Graphics g, int x, int y, float zf)
          DOCUMENT ME!
 void paint(java.awt.Graphics g, int x, int y, float zf, double bogus)
          DOCUMENT ME!
 void remAllRoads()
          DOCUMENT ME!
 void remRoad(int pos)
          DOCUMENT ME!
 void remRoad(Road r)
          DOCUMENT ME!
 void remSignconfig(Sign[] conf)
          Removes a sign configuration
 void reset()
          Resets the data of this node.
 void saveChilds(XMLSaver saver)
          DOCUMENT ME!
 XMLElement saveSelf()
          DOCUMENT ME!
 void setAllRoads(Road[] r)
          Sets the array that contains all roads connected to this node
 void setAlphaRoad(int pos)
          DOCUMENT ME!
 void setAlphaRoads(Road[] r)
          Sets the alpha roads connected to this node
 void setSignConfigs(Sign[][] s)
          Sets all possible sign configurations
 void setSigns(Sign[] s)
          Sets the signs on this Node
 void setWidth(int max)
          Sets the width of this Node in number of lanes
 
Methods inherited from class org.jscience.architecture.traffic.infrastructure.Node
addShortestPath, areAllTailsFree, canCreateInstance, createInstance, getBounds, getCenterPoint, getChildren, getComplexBounds, getCoord, getDirection, getDistance, getId, getNumSkip, getSelectionPoint, getSelectionPoints, getShortestPathDestinations, getShortestPaths, getStatistics, getStatistics, hasChildren, initStats, isSelectable, 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
 

Field Detail

type

protected static final int type
The type of this node

See Also:
Constant Field Values

width

protected int width
The width/height of this node in drivelanes. Needed to draw the node


allRoads

protected Road[] allRoads
A vector containing all roads connected to this node


alphaRoads

protected Road[] alphaRoads
A vector containing all roads that have this node as their Alpha node


signs

protected Sign[] signs
A Vector containing all Signs on this node


signconfigs

protected Sign[][] signconfigs
Contains all possible combinations of signs which may be turned green at the same time


loadData

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

Constructor Detail

Junction

public Junction()
Creates an empty junction (for loading)


Junction

public Junction(java.awt.Point _coord)
Creates a new standard Junction

Parameters:
_coord - The coordinates of this node on the map in pixels.
Method Detail

getType

public int getType()
Returns the type of this junction

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

getName

public java.lang.String getName()
Returns the name of this junction.

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

getAllRoads

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

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

setAllRoads

public void setAllRoads(Road[] r)
                 throws InfraException
Sets the array that contains all roads connected to this node

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

getAlphaRoads

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

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

setAlphaRoads

public void setAlphaRoads(Road[] r)
                   throws InfraException
Sets the alpha roads connected to this node

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

getSignConfigs

public Sign[][] getSignConfigs()
Returns all possible sign configurations

Returns:
DOCUMENT ME!

setSignConfigs

public void setSignConfigs(Sign[][] s)
Sets all possible sign configurations

Parameters:
s - DOCUMENT ME!

getSigns

public Sign[] getSigns()
Returns the signs on this Node

Returns:
DOCUMENT ME!

setSigns

public void setSigns(Sign[] s)
              throws InfraException
Sets the signs on this Node

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

getWidth

public int getWidth()
Returns the width of this Node in number of lanes

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

setWidth

public void setWidth(int max)
Sets the width of this Node in number of lanes

Parameters:
max - 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!

addSignconfig

public void addSignconfig(Sign[] conf)
                   throws InfraException
Adds a sign configuration

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

remSignconfig

public void remSignconfig(Sign[] conf)
                   throws InfraException
Removes a sign configuration

Parameters:
conf - 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!

getDesiredSignType

public int getDesiredSignType()
                       throws InfraException
DOCUMENT ME!

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

getLanesLeadingTo

public Drivelane[] getLanesLeadingTo(Drivelane lane,
                                     int ruType)
                              throws InfraException
Description copied from class: Node
Returns an array of all inbound lanes supporting roadusers of given type that lead to the given outbound lane.

Specified by:
getLanesLeadingTo in class Node
Parameters:
lane - Outbound lane the lanes lead to
ruType - The type of roaduser the inbound lanes should support
Returns:
An array of inbound lanes
Throws:
InfraException - if the given lane is not an outbound lane on this node

getLanesLeadingFrom

public Drivelane[] getLanesLeadingFrom(Drivelane lane,
                                       int ruType)
                                throws InfraException
Description copied from class: Node
Returns an array of all outbound lanes supporting roadusers of given type that can be reached from the given inbound lane.

Specified by:
getLanesLeadingFrom in class Node
Parameters:
lane - Inbound lane
ruType - The type of roaduser the outbound lanes should support
Returns:
An array of outbound lanes
Throws:
InfraException - if the given lane is not an inbound lane on this node

getLanesLeadingFrom

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

Parameters:
lane - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

getOutboundLanes

public Drivelane[] getOutboundLanes()
                             throws InfraException
Returns an array of all outbound lanes on this junction

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

getInboundLanes

public Drivelane[] getInboundLanes()
                            throws InfraException
Returns an array of all inbound lanes on this junction

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

getAllLanes

public Drivelane[] getAllLanes()
                        throws InfraException
Description copied from class: Node
Returns an array of all lanes on this node

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

getAllLanesCW

public Drivelane[] getAllLanesCW(Drivelane lane)
                          throws InfraException
Returns an array of all lanes connected to this node, in clock-wise order, starting at the given lane

Parameters:
lane - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!

areOtherTailsFree

public boolean areOtherTailsFree(Sign[] mayUse)

paint

public void paint(java.awt.Graphics g)
           throws TrafficException
DOCUMENT ME!

Specified by:
paint in class Node
Parameters:
g - DOCUMENT ME!
Throws:
TrafficException - DOCUMENT ME!

paint

public void paint(java.awt.Graphics g,
                  int x,
                  int y,
                  float zf)
           throws TrafficException
DOCUMENT ME!

Specified by:
paint in class Node
Parameters:
g - DOCUMENT ME!
x - DOCUMENT ME!
y - DOCUMENT ME!
zf - DOCUMENT ME!
Throws:
TrafficException - DOCUMENT ME!

paint

public void paint(java.awt.Graphics g,
                  int x,
                  int y,
                  float zf,
                  double bogus)
           throws TrafficException
DOCUMENT ME!

Parameters:
g - DOCUMENT ME!
x - DOCUMENT ME!
y - DOCUMENT ME!
zf - DOCUMENT ME!
bogus - DOCUMENT ME!
Throws:
TrafficException - DOCUMENT ME!

calculateWidth

public void calculateWidth()
(Re)Calculates the width of this junction


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!

getSignIdArray

protected int[] getSignIdArray()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getRoadIdArray

protected int[] getRoadIdArray()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getSignConfigIdArray

protected int[][] getSignConfigIdArray()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getXMLName

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

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!

getSign

protected Sign getSign(java.util.Dictionary laneDictionary,
                       int id)
DOCUMENT ME!

Parameters:
laneDictionary - DOCUMENT ME!
id - DOCUMENT ME!
Returns:
DOCUMENT ME!