org.jscience.architecture.traffic.infrastructure
Class Roaduser

java.lang.Object
  extended by org.jscience.architecture.traffic.infrastructure.Roaduser
All Implemented Interfaces:
java.lang.Cloneable, Selectable, SelectionStarter, TwoStageLoader, XMLSerializable
Direct Known Subclasses:
Automobile, Bicycle, CustomRoaduser

public abstract class Roaduser
extends java.lang.Object
implements Selectable, XMLSerializable, TwoStageLoader, java.lang.Cloneable

Basic Roaduser


Field Summary
protected  java.awt.Color color
          The color of this Roaduser
protected  int cycleAsked
          The last cycle this Roaduser was asked when it had last moved
protected  int cycleMoved
          The last cycle this Roaduser moved
protected  int delay
          The delay experienced so far
protected  Node destNode
          The node that is the destination of this Roaduser
protected  int drivelaneStartTime
          The starttime on this lane
protected  boolean inQueueForSign
          DOCUMENT ME!
protected  org.jscience.architecture.traffic.infrastructure.Roaduser.TwoStageLoaderData loadData
          Stuff to transfer between the first and second stage loader
protected  java.lang.String parentName
          The name of the parent of this Roaduser
protected  int position
          The position of this Roaduser on the drivelane.
protected  int prevSign
          The SignID of the lane this Roaduser came from
protected  int prevWaitPos
          The id of the sign this roaduser last passed
protected  int prevWaitTl
          The id of the sign this roaduser last passed
protected  boolean prevWaitTlColor
          The id of the sign this roaduser last passed
protected  Node startNode
          The node this Roaduser spawned at
protected  boolean voted
          DOCUMENT ME!
protected  int waitPos
          The id of the sign this roaduser last passed
protected  int waitTl
          The id of the sign this roaduser last passed
protected  boolean waitTlColor
          The id of the sign this roaduser last passed
 
Constructor Summary
Roaduser()
          Creates a new Roaduser object.
Roaduser(Node _startNode, Node _destNode, int pos)
          Creates a new Roaduser object.
 
Method Summary
 void addDelay(int d)
          Add a given delay to the total delay already experienced
 java.lang.Object clone()
          DOCUMENT ME!
 boolean didMove(int cycleNow)
          DOCUMENT ME!
 boolean didVote()
          DOCUMENT ME!
 java.awt.Rectangle getBounds()
          Returns the bounding box of this Selectable
 java.awt.Point getCenterPoint()
          DOCUMENT ME!
 java.util.Enumeration getChildren()
          DOCUMENT ME!
 java.awt.Color getColor()
          Returns the color of this Roaduser
 java.awt.Shape getComplexBounds()
          DOCUMENT ME!
 int getCurrentWaitPos()
          Gets the current waiting point's position relative to the sign
 int getCurrentWaitTl()
          Gets the current waiting point's sign
 boolean getCurrentWaitTlColor()
          Gets the current waiting point's sign
 int getCycleAsked()
          Returns the last cycle this Roaduser was asked about its movements
 int getCycleMoved()
          Returns the last cycle this Roaduser moved
 int getDelay()
          Returns the distance experienced so far
 java.lang.String getDescription()
          DOCUMENT ME!
 Node getDestNode()
          Returns the destination Node of this Roaduser
 int getDistance(java.awt.Point p)
          DOCUMENT ME!
 int getDrivelaneStartTime()
          Returns the start time of this Roaduser in the current drivelane
 java.lang.String getDriverName()
          DOCUMENT ME!
 boolean getInQueueForSign()
          DOCUMENT ME!
abstract  int getLength()
          DOCUMENT ME!
abstract  java.lang.String getName()
          DOCUMENT ME!
abstract  int getNumPassengers()
          DOCUMENT ME!
 java.lang.String getPicture()
          DOCUMENT ME!
 int getPosition()
          Returns the position of this Roaduser on the current Drivelane
 int getPrevSign()
          Returns the Id of the previous lane this Roaduser hit
 int getPrevWaitPos()
          Gets the last waiting point's position relative to the sign
 int getPrevWaitTl()
          Gets the last waiting point's sign
 boolean getPrevWaitTlColor()
          Gets the last waiting point's sign
 java.awt.Point getSelectionPoint()
          DOCUMENT ME!
 java.awt.Point[] getSelectionPoints()
          DOCUMENT ME!
 java.lang.String getSound()
          DOCUMENT ME!
abstract  int getSpeed()
          DOCUMENT ME!
 Node getStartNode()
          Returns the start Node of this Roaduser
abstract  int getType()
          DOCUMENT ME!
 java.lang.String getVehicleName()
          DOCUMENT ME!
 boolean hasChildren()
          DOCUMENT ME!
 boolean isSelectable()
          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 dx, int dy, double angle)
          DOCUMENT ME!
abstract  void paint(java.awt.Graphics g, int dx, int dy, float zf)
          DOCUMENT ME!
abstract  void paint(java.awt.Graphics g, int dx, int dy, float zf, double angle)
          DOCUMENT ME!
 void resetStats()
          DOCUMENT ME!
 void saveChilds(XMLSaver saver)
          DOCUMENT ME!
 XMLElement saveSelf()
          DOCUMENT ME!
 void setColor(java.awt.Color c)
          Sets the color of this Roaduser
 void setCycleAsked(int cycle)
          Sets the last cycle this Roaduser was asked its movements
 void setCycleMoved(int cycle)
          Sets the last cycle this Roaduser moved
 void setDelay(int delay)
          Sets a new delay
 void setDestNode(Node n)
          Sets the destination Node of this Roaduser
 void setDrivelaneStartTime(int time)
          Sets the start time of this Roaduser on the current Drivelane
 void setInQueueForSign(boolean b)
          DOCUMENT ME!
 void setParentName(java.lang.String parentName)
          DOCUMENT ME!
 void setPosition(int pos)
          Sets the position of this Roaduser on the current Drivelane
 void setPrevSign(int _prevSign)
          Sets the Id of the previous lane this Roaduser hit
 void setStartNode(Node n)
          Sets the start Node of this Roaduser
 void setVoted(boolean v)
          DOCUMENT ME!
 void setWaitPos(int tlId, boolean b, int pos)
          Sets the last waiting point's position relative to the sign
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jscience.architecture.traffic.xml.XMLSerializable
getXMLName
 

Field Detail

startNode

protected Node startNode
The node this Roaduser spawned at


destNode

protected Node destNode
The node that is the destination of this Roaduser


cycleMoved

protected int cycleMoved
The last cycle this Roaduser moved


cycleAsked

protected int cycleAsked
The last cycle this Roaduser was asked when it had last moved


position

protected int position
The position of this Roaduser on the drivelane. Zero based.


prevSign

protected int prevSign
The SignID of the lane this Roaduser came from


drivelaneStartTime

protected int drivelaneStartTime
The starttime on this lane


delay

protected int delay
The delay experienced so far


loadData

protected org.jscience.architecture.traffic.infrastructure.Roaduser.TwoStageLoaderData loadData
Stuff to transfer between the first and second stage loader


color

protected java.awt.Color color
The color of this Roaduser


parentName

protected java.lang.String parentName
The name of the parent of this Roaduser


waitTl

protected int waitTl
The id of the sign this roaduser last passed


waitPos

protected int waitPos
The id of the sign this roaduser last passed


waitTlColor

protected boolean waitTlColor
The id of the sign this roaduser last passed


prevWaitTl

protected int prevWaitTl
The id of the sign this roaduser last passed


prevWaitPos

protected int prevWaitPos
The id of the sign this roaduser last passed


prevWaitTlColor

protected boolean prevWaitTlColor
The id of the sign this roaduser last passed


voted

protected boolean voted
DOCUMENT ME!


inQueueForSign

protected boolean inQueueForSign
DOCUMENT ME!

Constructor Detail

Roaduser

public Roaduser(Node _startNode,
                Node _destNode,
                int pos)
Creates a new Roaduser object.

Parameters:
_startNode - DOCUMENT ME!
_destNode - DOCUMENT ME!
pos - DOCUMENT ME!

Roaduser

public Roaduser()
Creates a new Roaduser object.

Method Detail

setInQueueForSign

public void setInQueueForSign(boolean b)
DOCUMENT ME!

Parameters:
b - DOCUMENT ME!

getInQueueForSign

public boolean getInQueueForSign()
DOCUMENT ME!

Returns:
DOCUMENT ME!

resetStats

public void resetStats()
DOCUMENT ME!


clone

public java.lang.Object clone()
DOCUMENT ME!

Overrides:
clone in class java.lang.Object
Returns:
DOCUMENT ME!

getStartNode

public Node getStartNode()
Returns the start Node of this Roaduser

Returns:
DOCUMENT ME!

setStartNode

public void setStartNode(Node n)
Sets the start Node of this Roaduser

Parameters:
n - DOCUMENT ME!

getDestNode

public Node getDestNode()
Returns the destination Node of this Roaduser

Returns:
DOCUMENT ME!

setDestNode

public void setDestNode(Node n)
Sets the destination Node of this Roaduser

Parameters:
n - DOCUMENT ME!

getPosition

public int getPosition()
Returns the position of this Roaduser on the current Drivelane

Returns:
DOCUMENT ME!

setPosition

public void setPosition(int pos)
Sets the position of this Roaduser on the current Drivelane

Parameters:
pos - DOCUMENT ME!

getCycleMoved

public int getCycleMoved()
Returns the last cycle this Roaduser moved

Returns:
DOCUMENT ME!

setCycleMoved

public void setCycleMoved(int cycle)
Sets the last cycle this Roaduser moved

Parameters:
cycle - DOCUMENT ME!

getCycleAsked

public int getCycleAsked()
Returns the last cycle this Roaduser was asked about its movements

Returns:
DOCUMENT ME!

setCycleAsked

public void setCycleAsked(int cycle)
Sets the last cycle this Roaduser was asked its movements

Parameters:
cycle - DOCUMENT ME!

getDrivelaneStartTime

public int getDrivelaneStartTime()
Returns the start time of this Roaduser in the current drivelane

Returns:
DOCUMENT ME!

setDrivelaneStartTime

public void setDrivelaneStartTime(int time)
Sets the start time of this Roaduser on the current Drivelane

Parameters:
time - DOCUMENT ME!

getDelay

public int getDelay()
Returns the distance experienced so far

Returns:
DOCUMENT ME!

addDelay

public void addDelay(int d)
Add a given delay to the total delay already experienced

Parameters:
d - DOCUMENT ME!

setDelay

public void setDelay(int delay)
Sets a new delay

Parameters:
delay - DOCUMENT ME!

getPrevSign

public int getPrevSign()
Returns the Id of the previous lane this Roaduser hit

Returns:
DOCUMENT ME!

setPrevSign

public void setPrevSign(int _prevSign)
Sets the Id of the previous lane this Roaduser hit

Parameters:
_prevSign - DOCUMENT ME!

getColor

public java.awt.Color getColor()
Returns the color of this Roaduser

Returns:
DOCUMENT ME!

setColor

public void setColor(java.awt.Color c)
Sets the color of this Roaduser

Parameters:
c - DOCUMENT ME!

setWaitPos

public void setWaitPos(int tlId,
                       boolean b,
                       int pos)
Sets the last waiting point's position relative to the sign

Parameters:
tlId - DOCUMENT ME!
b - DOCUMENT ME!
pos - DOCUMENT ME!

getPrevWaitPos

public int getPrevWaitPos()
Gets the last waiting point's position relative to the sign

Returns:
DOCUMENT ME!

getPrevWaitTl

public int getPrevWaitTl()
Gets the last waiting point's sign

Returns:
DOCUMENT ME!

getPrevWaitTlColor

public boolean getPrevWaitTlColor()
Gets the last waiting point's sign

Returns:
DOCUMENT ME!

getCurrentWaitTl

public int getCurrentWaitTl()
Gets the current waiting point's sign

Returns:
DOCUMENT ME!

getCurrentWaitPos

public int getCurrentWaitPos()
Gets the current waiting point's position relative to the sign

Returns:
DOCUMENT ME!

getCurrentWaitTlColor

public boolean getCurrentWaitTlColor()
Gets the current waiting point's sign

Returns:
DOCUMENT ME!

didVote

public boolean didVote()
DOCUMENT ME!

Returns:
DOCUMENT ME!

setVoted

public void setVoted(boolean v)
DOCUMENT ME!

Parameters:
v - DOCUMENT ME!

didMove

public boolean didMove(int cycleNow)
DOCUMENT ME!

Parameters:
cycleNow - DOCUMENT ME!
Returns:
DOCUMENT ME!

getName

public abstract java.lang.String getName()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getNumPassengers

public abstract int getNumPassengers()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getLength

public abstract int getLength()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getSpeed

public abstract int getSpeed()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getType

public abstract int getType()
DOCUMENT ME!

Returns:
DOCUMENT ME!

getVehicleName

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

Returns:
DOCUMENT ME!

getDriverName

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

Returns:
DOCUMENT ME!

getDescription

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

Returns:
DOCUMENT ME!

getPicture

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

Returns:
DOCUMENT ME!

getSound

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

Returns:
DOCUMENT ME!

getBounds

public java.awt.Rectangle getBounds()
Description copied from interface: Selectable
Returns the bounding box of this Selectable

Specified by:
getBounds in interface Selectable
Returns:
DOCUMENT ME!

getComplexBounds

public java.awt.Shape getComplexBounds()
DOCUMENT ME!

Specified by:
getComplexBounds in interface Selectable
Returns:
DOCUMENT ME!

getDistance

public int getDistance(java.awt.Point p)
DOCUMENT ME!

Specified by:
getDistance in interface Selectable
Parameters:
p - DOCUMENT ME!
Returns:
DOCUMENT ME!

getSelectionPoint

public java.awt.Point getSelectionPoint()
DOCUMENT ME!

Specified by:
getSelectionPoint in interface Selectable
Returns:
DOCUMENT ME!

getSelectionPoints

public java.awt.Point[] getSelectionPoints()
DOCUMENT ME!

Specified by:
getSelectionPoints in interface Selectable
Returns:
DOCUMENT ME!

getCenterPoint

public java.awt.Point getCenterPoint()
DOCUMENT ME!

Specified by:
getCenterPoint in interface Selectable
Returns:
DOCUMENT ME!

isSelectable

public boolean isSelectable()
DOCUMENT ME!

Specified by:
isSelectable in interface Selectable
Returns:
DOCUMENT ME!

hasChildren

public boolean hasChildren()
DOCUMENT ME!

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!

paint

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

Parameters:
g - DOCUMENT ME!
Throws:
TrafficException - DOCUMENT ME!

paint

public void paint(java.awt.Graphics g,
                  int dx,
                  int dy,
                  double angle)
           throws TrafficException
DOCUMENT ME!

Parameters:
g - DOCUMENT ME!
dx - DOCUMENT ME!
dy - DOCUMENT ME!
angle - DOCUMENT ME!
Throws:
TrafficException - DOCUMENT ME!

paint

public abstract void paint(java.awt.Graphics g,
                           int dx,
                           int dy,
                           float zf)
                    throws TrafficException
DOCUMENT ME!

Parameters:
g - DOCUMENT ME!
dx - DOCUMENT ME!
dy - DOCUMENT ME!
zf - DOCUMENT ME!
Throws:
TrafficException - DOCUMENT ME!

paint

public abstract void paint(java.awt.Graphics g,
                           int dx,
                           int dy,
                           float zf,
                           double angle)
                    throws TrafficException
DOCUMENT ME!

Parameters:
g - DOCUMENT ME!
dx - DOCUMENT ME!
dy - DOCUMENT ME!
zf - DOCUMENT ME!
angle - DOCUMENT ME!
Throws:
TrafficException - DOCUMENT ME!

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
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
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
Parameters:
saver - DOCUMENT ME!
Throws:
XMLTreeException - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
XMLCannotSaveException - DOCUMENT ME!

setParentName

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

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

loadSecondStage

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

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