|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.architecture.traffic.infrastructure.Drivelane
public class Drivelane
The basic lane.
| Field Summary | |
|---|---|
protected java.awt.Shape[] |
bounds
A Shape array holding this drivelane's boundaries |
protected int |
cycleAsked
The last cycle this Drivelane was asked if it had moved its Roadusers yet |
protected int |
cycleMoved
The last cycle this Drivelane moved its Roadusers |
protected int |
Id
The Id of this drivelane. |
protected org.jscience.architecture.traffic.infrastructure.Drivelane.TwoStageLoaderData |
loadData
Data for loading the second stage |
protected java.lang.String |
parentName
DOCUMENT ME! |
protected java.util.LinkedList |
queue
The roadusers currently on this Drivelane |
protected Road |
road
The Road this Drivelane is part of |
protected Sign |
sign
The Sign at the end of this Drivelane |
protected boolean[] |
targets
The directions Roadusers switch lanes to: left, straight ahead and right. |
protected int |
type
The type of drivelane. |
| Constructor Summary | |
|---|---|
Drivelane()
Empty constructor for loading |
|
Drivelane(Road _road)
Creates a new Drivelane object. |
|
| Method Summary | |
|---|---|
void |
addCurveBounds(java.awt.Shape s)
Adds new bounds to the bounds of this drivelane |
void |
addRoaduser(Roaduser ru,
int pos)
Adds a Roaduser at a given position to the lane |
void |
addRoaduserAtEnd(Roaduser ru)
Adds a Roaduser at the end of this lane |
void |
addRoaduserAtEnd(Roaduser ru,
int pos)
Adds a Roaduser at the end of this lane |
void |
clearCurveBounds()
Clears the bounds of this drivelane |
boolean |
contains(java.awt.Point p)
|
java.awt.Rectangle |
getBounds()
Returns the bounding box of this Selectable |
java.awt.Point |
getCenterPoint()
DOCUMENT ME! |
java.util.Enumeration |
getChildren()
DOCUMENT ME! |
int |
getCompleteLength()
Returns the length of this Drivelane including tail |
java.util.LinkedList |
getCompleteQueue()
DOCUMENT ME! |
java.awt.Shape |
getComplexBounds()
DOCUMENT ME! |
int |
getCycleAsked()
Return the last cycle this Drivelane was last asked about the movements of its Roadusers |
int |
getCycleMoved()
Return the last cycle this Drivelane has moved its Roadusers |
int |
getDistance(java.awt.Point p)
DOCUMENT ME! |
Roaduser |
getFirstRoaduser()
Returns the first Roaduser on this Drivelane |
int |
getFreeUnitsInFront(Roaduser ru)
DOCUMENT ME! |
int |
getId()
Returns the Id of this drivelane. |
int |
getLength()
Returns the length of the Road of this Drivelane |
java.lang.String |
getName()
Returns the name of this drivelane. |
Node |
getNodeComesFrom()
Returns the Node that this Drivelane comes from |
Node |
getNodeLeadsTo()
Returns Node that this Drivelane leads to |
int |
getNumBlocksTaken()
Returns the number of blocks taken by Roadusers on this Drivelane |
int |
getNumBlocksWaiting()
Returns the number of blocks taken by Roadusers that are waiting for the Sign of this Drivelane |
int |
getNumPassengersWaiting()
Returns the number of Passengers in the Roadusers that are waiting for the Sign of this Drivelane |
int |
getNumRoadusersWaiting()
Returns the number of Roadusers that are waiting for the Sign of this Drivelane |
int |
getPosFree(java.util.ListIterator li,
int position,
int length,
int speed_left,
Roaduser ru)
Returns the best reacheable position for the supplied Roaduser on the Queue given in the ListIterator |
java.util.LinkedList |
getQueue()
Returns the queue of this Drivelane |
Road |
getRoad()
Returns the Road that this Drivelane belongs to |
java.awt.Point |
getSelectionPoint()
DOCUMENT ME! |
java.awt.Point[] |
getSelectionPoints()
DOCUMENT ME! |
Sign |
getSign()
Returns the Sign that regulates the traffic on this Drivelane |
int |
getTailLength()
Returns the length of the tail of this Drivelane |
boolean |
getTarget(int target)
Returns the state of given target |
boolean[] |
getTargets()
Returns the roads users can move to when crossing the Node this lane leads to |
int |
getType()
Returns the type of this Drivelane |
int[] |
getTypes()
Returns an array of primitive Roaduser types that may roam this Drivelane |
java.lang.String |
getXMLName()
DOCUMENT ME! |
boolean |
hasChildren()
DOCUMENT ME! |
boolean |
isFull()
Returns true when this drivelane is completely full @ author Chaim Z |
boolean |
isLastPosFree(int length)
DOCUMENT ME! |
boolean |
isPosFree(int position,
int length)
Checks whether length blocks from the given position are free. |
boolean |
isPosFree(int position,
int length,
Roaduser me)
Checks whether length blocks from the given position, before the given roaduser, are free. |
boolean |
isSelectable()
DOCUMENT ME! |
boolean |
isTailFree()
Returns whether or not the 'tail' of this Drivelane has any Roadusers on it. |
void |
load(XMLElement myElement,
XMLLoader loader)
Load this XMLSerializable |
void |
loadSecondStage(java.util.Dictionary dictionaries)
DOCUMENT ME! |
boolean |
mayUse(int ruType)
Returns if a Roaduser of type ruType may use this Drivelane |
Roaduser |
remRoaduserAtStart()
Removes Roaduser at start of this lane |
void |
reset()
Resets this Drivelane. |
void |
saveChilds(XMLSaver saver)
DOCUMENT ME! |
XMLElement |
saveSelf()
DOCUMENT ME! |
void |
setCycleAsked(int cycle)
Sets the last cycle this Drivelane was last asked about the movements of its Roadusers |
void |
setCycleMoved(int cycle)
Sets the last cycle this Drivelane has moved its Roadusers |
void |
setId(int newid)
Sets the Id of this drivelane. |
void |
setParentName(java.lang.String parentName)
DOCUMENT ME! |
void |
setQueue(java.util.LinkedList q)
Sets the queue of this Drivelane |
void |
setRoad(Road r)
Sets the Road that this Drivelane belongs to |
void |
setSign(Sign s)
Sets the Sign that regulates the traffic on this Drivelane |
void |
setTarget(int target,
boolean state)
Sets the state of given target |
void |
setTargets(boolean[] r)
Sets the roads users can move to when crossing the Node this lane leads to |
void |
setType(int t)
Sets the type of this Drivelane |
boolean |
updateWaitingPosition(Roaduser current_ru)
Returns if this ru is waiting, if so it will update the waiting position of this RoadUser |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int Id
protected int type
protected Road road
protected java.util.LinkedList queue
protected Sign sign
protected boolean[] targets
protected int cycleAsked
protected int cycleMoved
protected org.jscience.architecture.traffic.infrastructure.Drivelane.TwoStageLoaderData loadData
protected java.lang.String parentName
protected java.awt.Shape[] bounds
| Constructor Detail |
|---|
public Drivelane(Road _road)
_road - DOCUMENT ME!public Drivelane()
| Method Detail |
|---|
public int getId()
public void setId(int newid)
newid - DOCUMENT ME!public java.util.LinkedList getQueue()
public void setQueue(java.util.LinkedList q)
q - DOCUMENT ME!public int getType()
public void setType(int t)
t - DOCUMENT ME!public Road getRoad()
public void setRoad(Road r)
r - DOCUMENT ME!public Sign getSign()
public void setSign(Sign s)
s - DOCUMENT ME!public boolean[] getTargets()
public void setTargets(boolean[] r)
r - DOCUMENT ME!public int getCycleMoved()
public void setCycleMoved(int cycle)
cycle - DOCUMENT ME!public int getCycleAsked()
public void setCycleAsked(int cycle)
cycle - DOCUMENT ME!public int getTailLength()
public java.lang.String getName()
public int getCompleteLength()
public int getFreeUnitsInFront(Roaduser ru)
ru - DOCUMENT ME!
public java.awt.Rectangle getBounds()
Selectable
getBounds in interface Selectablepublic java.awt.Shape getComplexBounds()
getComplexBounds in interface Selectablepublic int getDistance(java.awt.Point p)
getDistance in interface Selectablep - DOCUMENT ME!
public java.awt.Point getSelectionPoint()
getSelectionPoint in interface Selectablepublic java.awt.Point[] getSelectionPoints()
getSelectionPoints in interface Selectablepublic java.awt.Point getCenterPoint()
getCenterPoint in interface Selectablepublic boolean isSelectable()
isSelectable in interface Selectablepublic boolean hasChildren()
hasChildren in interface SelectionStarterpublic java.util.Enumeration getChildren()
getChildren in interface SelectionStarter
public void load(XMLElement myElement,
XMLLoader loader)
throws XMLTreeException,
java.io.IOException,
XMLInvalidInputException
XMLSerializable
load in interface XMLSerializablemyElement - 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.
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.
public XMLElement saveSelf()
throws XMLCannotSaveException
saveSelf in interface XMLSerializableXMLCannotSaveException - DOCUMENT ME!
public void saveChilds(XMLSaver saver)
throws XMLTreeException,
java.io.IOException,
XMLCannotSaveException
saveChilds in interface XMLSerializablesaver - DOCUMENT ME!
XMLTreeException - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
XMLCannotSaveException - DOCUMENT ME!public java.lang.String getXMLName()
getXMLName in interface XMLSerializablepublic void setParentName(java.lang.String parentName)
setParentName in interface XMLSerializableparentName - DOCUMENT ME!
public void loadSecondStage(java.util.Dictionary dictionaries)
throws XMLInvalidInputException,
XMLTreeException
loadSecondStage in interface TwoStageLoaderdictionaries - DOCUMENT ME!
XMLInvalidInputException - DOCUMENT ME!
XMLTreeException - DOCUMENT ME!public void reset()
Sign.reset()
public void addRoaduserAtEnd(Roaduser ru)
throws InfraException
ru - The roaduser to add
InfraException - if the roaduser could not be added
public void addRoaduserAtEnd(Roaduser ru,
int pos)
throws InfraException
ru - The roaduser to addpos - The position where the roadusers should be added
InfraException - if the roaduser could not be added
public void addRoaduser(Roaduser ru,
int pos)
throws InfraException
ru - The roaduser to addpos - The position at which to add the roaduser
InfraException - if the position is taken by another roaduser
public Roaduser remRoaduserAtStart()
throws InfraException
InfraException - if there are no roadusers on this lanepublic int[] getTypes()
public boolean mayUse(int ruType)
ruType - DOCUMENT ME!
public int getLength()
public Roaduser getFirstRoaduser()
public int getNumRoadusersWaiting()
public boolean updateWaitingPosition(Roaduser current_ru)
current_ru - DOCUMENT ME!
public int getNumPassengersWaiting()
public int getNumBlocksWaiting()
public int getNumBlocksTaken()
public Node getNodeComesFrom()
public Node getNodeLeadsTo()
public boolean getTarget(int target)
throws InfraException
target - DOCUMENT ME!
InfraException - DOCUMENT ME!
public void setTarget(int target,
boolean state)
throws InfraException
target - DOCUMENT ME!state - DOCUMENT ME!
InfraException - DOCUMENT ME!
public boolean isPosFree(int position,
int length)
position - The position in the Queue of this Drivelane.length - The amount of blocks that need to be free.
public boolean isPosFree(int position,
int length,
Roaduser me)
position - The position in the Queue of this Drivelanelength - The amount of blocks that need to be free.me - The roaduser
length
blocks are free for the supplied RUpublic boolean isTailFree()
public boolean isLastPosFree(int length)
length - DOCUMENT ME!
public boolean isFull()
public int getPosFree(java.util.ListIterator li,
int position,
int length,
int speed_left,
Roaduser ru)
li - The Queue of this Drivelane represented in a ListIterator.
li.previous() is the current RoadUserposition - The position on the Drivelane of the Roaduserlength - The amount of blocks that have to be freespeed_left - the number of 'moves' this Roaduser has left in this
turnru - The Roaduser to be checked
public java.util.LinkedList getCompleteQueue()
public void clearCurveBounds()
public void addCurveBounds(java.awt.Shape s)
s - DOCUMENT ME!public boolean contains(java.awt.Point p)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||