org.jscience.architecture.traffic.infrastructure
Class Infrastructure

java.lang.Object
  extended by org.jscience.architecture.traffic.infrastructure.Infrastructure
All Implemented Interfaces:
SelectionStarter, XMLSerializable
Direct Known Subclasses:
LessSimpleInfra, SimpleInfra

public class Infrastructure
extends java.lang.Object
implements XMLSerializable, SelectionStarter

The encapsulating class


Field Summary
protected  java.util.Vector allLanes
          All the inbound lanes on all the Nodes in our Infrastructure
protected  Node[] allNodes
          All nodes in this infrastructure, including edge nodes
protected  java.lang.String author
          Meta-data provided by the user
static int blockLength
          DOCUMENT ME!
static int blockWidth
          DOCUMENT ME!
protected  java.lang.String comments
          Meta-data provided by the user
protected  int curCycle
          The current cycle we're in, manely for Nodes to have access to this data
protected  Junction[] junctions
          All nodes that are not EdgeNodes
static java.util.Hashtable laneDictionary
          DOCUMENT ME!
protected  java.lang.String parentName
          DOCUMENT ME!
protected  NumberDispenser signNumbers
          Number dispenser for sign id's
protected  java.awt.Dimension size
          The size of this infrastructure, in pixels
protected  SpecialNode[] specialNodes
          All exit/entry nodes in this infrastructure
protected  java.lang.String title
          Meta-data provided by the user
protected  int version
          The infrastructure version of this implementation.
 
Constructor Summary
Infrastructure()
          Constructor for loading
Infrastructure(java.awt.Dimension dim)
          Creates a new infrastructure object.
Infrastructure(Node[] nodes, SpecialNode[] special, java.awt.Dimension new_size)
          Creates a new infrastructure object.
 
Method Summary
protected  void addAlphaRoads(java.util.Dictionary d, Junction n)
          DOCUMENT ME!
protected  void addAlphaRoads(java.util.Dictionary d, SpecialNode n)
          DOCUMENT ME!
 void addNode(Node node)
          Adds a node to the infrastructure
 void cachInboundLanes()
          DOCUMENT ME!
protected  void copyJunctions()
          DOCUMENT ME!
protected  void copySpecialNodes()
          DOCUMENT ME!
 java.util.Vector getAllInboundLanes()
          DOCUMENT ME!
 Node[] getAllNodes()
          Returns all nodes (including edge nodes)
 java.lang.String getAuthor()
          Returns the author.
 java.util.Enumeration getChildren()
          DOCUMENT ME!
 java.lang.String getComments()
          Returns the comments.
 int getCurCycle()
          Returns the current cycle
 EdgeNode[] getEdgeNodes_()
          Gets the EdgeNodes in this Infrastructure.
 Node.NodeStatistics[][] getEdgeNodeStatistics()
          Returns an array containing all statistics of all EdgeNodes.
 Junction[] getJunctions()
          Returns the Junctions of this infrastructure.
 Node.NodeStatistics[][] getJunctionStatistics()
          Returns an array containing all statistics of all Junctions.
protected  java.util.Dictionary getLaneSignDictionary()
          DOCUMENT ME!
 java.util.Dictionary getMainDictionary()
          DOCUMENT ME!
protected  java.util.Dictionary getNodeDictionary()
          DOCUMENT ME!
 Node.NodeStatistics[][] getNodeStatistics()
          Returns an array containing all statistics of the infrastructure.
 int getNumEdgeNodes_()
          Gets the number of EdgeNodes in the infrastructure
 int getNumJunctions()
          Returns the number of junctions
 int getNumNodes()
          Returns the number of nodes
 int getNumSpecialNodes()
          Returns the number of edgenodes
protected  java.util.Dictionary getRoadDictionary()
          DOCUMENT ME!
 java.awt.Dimension getSize()
          Returns the size of this infrastructure in pixels
 SpecialNode[] getSpecialNodes()
          Returns all exit/entry nodes
 java.lang.String getTitle()
          Returns the title.
 int getTotalNumSigns()
          Returns the total number of signs in the infrastructure
 java.lang.String getXMLName()
          DOCUMENT ME!
 boolean hasChildren()
          Returns true if this Selectable has any children
 void load(XMLElement myElement, XMLLoader loader)
          DOCUMENT ME!
 void prepareSave()
           
 void remNode(Node node)
          Removes a node from the infrastructure
 void reset()
          Resets the entire data structure to allow a new simulation to start This will remove all Roadusers and set all Signs to their default positions, as well as reset all cycleMoved and cycleAsked counters.
 void saveChilds(XMLSaver saver)
          DOCUMENT ME!
 XMLElement saveSelf()
          DOCUMENT ME!
 void setAllNodes(Node[] nodes)
          Sets all nodes (including edge nodes)
 void setAuthor(java.lang.String s)
          Sets the author.
 void setComments(java.lang.String s)
          Sets the comments.
 void setCurCycle(int c)
          Sets the current cycle
 void setJunctions(Junction[] _junctions)
          Sets all junctions.
 void setParentName(java.lang.String parentName)
          DOCUMENT ME!
 void setSize(java.awt.Dimension s)
          Sets the size of this infrastructure in pixels
 void setSpecialNodes(SpecialNode[] nodes)
          Sets all exit/entry nodes
 void setTitle(java.lang.String s)
          Sets the title.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

blockLength

public static final int blockLength
DOCUMENT ME!

See Also:
Constant Field Values

blockWidth

public static final int blockWidth
DOCUMENT ME!

See Also:
Constant Field Values

laneDictionary

public static java.util.Hashtable laneDictionary
DOCUMENT ME!


allNodes

protected Node[] allNodes
All nodes in this infrastructure, including edge nodes


specialNodes

protected SpecialNode[] specialNodes
All exit/entry nodes in this infrastructure


junctions

protected Junction[] junctions
All nodes that are not EdgeNodes


title

protected java.lang.String title
Meta-data provided by the user


author

protected java.lang.String author
Meta-data provided by the user


comments

protected java.lang.String comments
Meta-data provided by the user


version

protected final int version
The infrastructure version of this implementation. For debugging.

See Also:
Constant Field Values

size

protected java.awt.Dimension size
The size of this infrastructure, in pixels


allLanes

protected java.util.Vector allLanes
All the inbound lanes on all the Nodes in our Infrastructure


signNumbers

protected NumberDispenser signNumbers
Number dispenser for sign id's


curCycle

protected int curCycle
The current cycle we're in, manely for Nodes to have access to this data


parentName

protected java.lang.String parentName
DOCUMENT ME!

Constructor Detail

Infrastructure

public Infrastructure(java.awt.Dimension dim)
Creates a new infrastructure object.

Parameters:
dim - The dimension of the new infrastructure

Infrastructure

public Infrastructure(Node[] nodes,
                      SpecialNode[] special,
                      java.awt.Dimension new_size)
Creates a new infrastructure object.

Parameters:
nodes - The Nodes this Infrastructure should contain.
special - The exit/entry nodes this Infrastructure should contain.
new_size - The size of this Infrastructure in pixels x pixels

Infrastructure

public Infrastructure()
Constructor for loading

Method Detail

getTitle

public java.lang.String getTitle()
Returns the title.

Returns:
DOCUMENT ME!

setTitle

public void setTitle(java.lang.String s)
Sets the title.

Parameters:
s - DOCUMENT ME!

getAuthor

public java.lang.String getAuthor()
Returns the author.

Returns:
DOCUMENT ME!

setAuthor

public void setAuthor(java.lang.String s)
Sets the author.

Parameters:
s - DOCUMENT ME!

getComments

public java.lang.String getComments()
Returns the comments.

Returns:
DOCUMENT ME!

setComments

public void setComments(java.lang.String s)
Sets the comments.

Parameters:
s - DOCUMENT ME!

getSpecialNodes

public SpecialNode[] getSpecialNodes()
Returns all exit/entry nodes

Returns:
DOCUMENT ME!

setSpecialNodes

public void setSpecialNodes(SpecialNode[] nodes)
Sets all exit/entry nodes

Parameters:
nodes - DOCUMENT ME!

getJunctions

public Junction[] getJunctions()
Returns the Junctions of this infrastructure.

Returns:
DOCUMENT ME!

setJunctions

public void setJunctions(Junction[] _junctions)
Sets all junctions.

Parameters:
_junctions - DOCUMENT ME!

getAllNodes

public Node[] getAllNodes()
Returns all nodes (including edge nodes)

Returns:
DOCUMENT ME!

setAllNodes

public void setAllNodes(Node[] nodes)
Sets all nodes (including edge nodes)

Parameters:
nodes - DOCUMENT ME!

getSize

public java.awt.Dimension getSize()
Returns the size of this infrastructure in pixels

Returns:
DOCUMENT ME!

setSize

public void setSize(java.awt.Dimension s)
Sets the size of this infrastructure in pixels

Parameters:
s - DOCUMENT ME!

getNumNodes

public int getNumNodes()
Returns the number of nodes

Returns:
DOCUMENT ME!

getNumSpecialNodes

public int getNumSpecialNodes()
Returns the number of edgenodes

Returns:
DOCUMENT ME!

getNumJunctions

public int getNumJunctions()
Returns the number of junctions

Returns:
DOCUMENT ME!

setCurCycle

public void setCurCycle(int c)
Sets the current cycle

Parameters:
c - DOCUMENT ME!

getCurCycle

public int getCurCycle()
Returns the current cycle

Returns:
DOCUMENT ME!

getTotalNumSigns

public int getTotalNumSigns()
Returns the total number of signs in the infrastructure

Returns:
DOCUMENT ME!

getNodeStatistics

public Node.NodeStatistics[][] getNodeStatistics()
Returns an array containing all statistics of the infrastructure. The index in the array corresponds to the Node id.

Returns:
DOCUMENT ME!

getEdgeNodeStatistics

public Node.NodeStatistics[][] getEdgeNodeStatistics()
Returns an array containing all statistics of all EdgeNodes. The index in the array corresponds to the EdgeNode id.

Returns:
DOCUMENT ME!

getJunctionStatistics

public Node.NodeStatistics[][] getJunctionStatistics()
Returns an array containing all statistics of all Junctions. The index in the array corresponds to (Junction_id - edgeNodes.length).

Returns:
DOCUMENT ME!

getEdgeNodes_

public EdgeNode[] getEdgeNodes_()
Gets the EdgeNodes in this Infrastructure. Before using this method think twice if you don't actually need the getSpecialNodes() method. The underscore in the function name was added to emphasize that you probably need another method now.

Returns:
DOCUMENT ME!

getNumEdgeNodes_

public int getNumEdgeNodes_()
Gets the number of EdgeNodes in the infrastructure

Returns:
DOCUMENT ME!

hasChildren

public boolean hasChildren()
Description copied from interface: SelectionStarter
Returns true if this Selectable has any children

Specified by:
hasChildren in interface SelectionStarter
Returns:
DOCUMENT ME!

getChildren

public java.util.Enumeration getChildren()
DOCUMENT ME!

Specified by:
getChildren in interface SelectionStarter
Returns:
DOCUMENT ME!

addNode

public void addNode(Node node)
Adds a node to the infrastructure

Parameters:
node - DOCUMENT ME!

remNode

public void remNode(Node node)
             throws InfraException
Removes a node from the infrastructure

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

reset

public void reset()
Resets the entire data structure to allow a new simulation to start This will remove all Roadusers and set all Signs to their default positions, as well as reset all cycleMoved and cycleAsked counters.

See Also:
Node.reset()

cachInboundLanes

public void cachInboundLanes()
                      throws InfraException
DOCUMENT ME!

Throws:
InfraException - DOCUMENT ME!

getAllInboundLanes

public java.util.Vector getAllInboundLanes()
                                    throws InfraException
DOCUMENT ME!

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

prepareSave

public void prepareSave()
                 throws TrafficException
Throws:
TrafficException

load

public void load(XMLElement myElement,
                 XMLLoader loader)
          throws XMLTreeException,
                 java.io.IOException,
                 XMLInvalidInputException
DOCUMENT ME!

Specified by:
load in interface XMLSerializable
Parameters:
myElement - DOCUMENT ME!
loader - DOCUMENT ME!
Throws:
XMLTreeException - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
XMLInvalidInputException - DOCUMENT ME!

saveSelf

public XMLElement saveSelf()
DOCUMENT ME!

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

saveChilds

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

Specified by:
saveChilds in interface XMLSerializable
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!

setParentName

public void setParentName(java.lang.String parentName)
DOCUMENT ME!

Specified by:
setParentName in interface XMLSerializable
Parameters:
parentName - DOCUMENT ME!

getMainDictionary

public java.util.Dictionary getMainDictionary()
                                       throws InfraException
DOCUMENT ME!

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

getLaneSignDictionary

protected java.util.Dictionary getLaneSignDictionary()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getNodeDictionary

protected java.util.Dictionary getNodeDictionary()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getRoadDictionary

protected java.util.Dictionary getRoadDictionary()
                                          throws InfraException
DOCUMENT ME!

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

copySpecialNodes

protected void copySpecialNodes()
DOCUMENT ME!


copyJunctions

protected void copyJunctions()
DOCUMENT ME!


addAlphaRoads

protected void addAlphaRoads(java.util.Dictionary d,
                             SpecialNode n)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!
n - DOCUMENT ME!

addAlphaRoads

protected void addAlphaRoads(java.util.Dictionary d,
                             Junction n)
DOCUMENT ME!

Parameters:
d - DOCUMENT ME!
n - DOCUMENT ME!