org.jscience.architecture.traffic.edit
Class EditModel

java.lang.Object
  extended by java.util.Observable
      extended by org.jscience.architecture.traffic.Model
          extended by org.jscience.architecture.traffic.edit.EditModel
All Implemented Interfaces:
XMLSerializable

public class EditModel
extends Model

The model for the editor.


Field Summary
 NumberDispenser laneNumbers
          Number dispenser for temporary drivelane ids
 NumberDispenser roadNumbers
          Number dispenser for temporary road ids
 
Fields inherited from class org.jscience.architecture.traffic.Model
infra, parentName, SAVE_STATS
 
Constructor Summary
EditModel()
          Creates a new model for the editor
EditModel(Infrastructure i)
          Creates a new model for the editor with the specified infrastructure
 
Method Summary
 void addLane(Drivelane lane, Road r, Node to)
          Adds a drivelane to a road.
 void addNode(java.awt.Point coords, int type)
          Adds a new node to the infrastructure
 void addRoad(Road r, Node alpha, int posa, Node beta, int posb)
          Adds a new road to the infrastructure
 void addRoad(Road road, Node alpha, int posa, Node beta, int posb, java.util.Vector turnPoints)
          Adds a new road to the infrastructure
 void load(XMLElement myElement, XMLLoader loader)
          DOCUMENT ME!
 void moveNode(Node node, java.awt.Point point)
          Moves a node to a new position on the map.
 void remLane(Drivelane lane)
          Removes a drivelane from the infrastructure
 void remNode(Node node)
          Removes a node from the infrastructure
 void remObjects(java.util.LinkedList list)
          Removes a list objects from the infrastructure
 void remRoad(Road road)
          Removes a road from the infrastructure
 void saveChilds(XMLSaver saver)
          DOCUMENT ME!
 XMLElement saveSelf()
          DOCUMENT ME!
 void setLaneTarget(Drivelane lane, int target, boolean state)
          Sets or clears a target for a drivelane.
 void setLaneType(Drivelane lane, int t)
          Sets the type of a drivelane.
 
Methods inherited from class org.jscience.architecture.traffic.Model
getInfrastructure, getXMLName, setInfrastructure, setParentName
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

laneNumbers

public NumberDispenser laneNumbers
Number dispenser for temporary drivelane ids


roadNumbers

public NumberDispenser roadNumbers
Number dispenser for temporary road ids

Constructor Detail

EditModel

public EditModel()
Creates a new model for the editor


EditModel

public EditModel(Infrastructure i)
Creates a new model for the editor with the specified infrastructure

Parameters:
i - DOCUMENT ME!
Method Detail

remObjects

public void remObjects(java.util.LinkedList list)
                throws InfraException
Removes a list objects from the infrastructure

Parameters:
list - The list of objects to remove
Throws:
InfraException - DOCUMENT ME!

addNode

public void addNode(java.awt.Point coords,
                    int type)
             throws InfraException
Adds a new node to the infrastructure

Parameters:
coords - The pixel coordinates of the new node
type - The type of the new node
Throws:
InfraException - DOCUMENT ME!

addRoad

public void addRoad(Road r,
                    Node alpha,
                    int posa,
                    Node beta,
                    int posb)
             throws InfraException
Adds a new road to the infrastructure

Parameters:
r - The road to add
alpha - The alpha node to connect the road to
posa - The connection-position to connect the road at the alpha node at
beta - The beta node to connect the road to
posb - The connection-position to connect the road at the beta node at
Throws:
InfraException - DOCUMENT ME!

addRoad

public void addRoad(Road road,
                    Node alpha,
                    int posa,
                    Node beta,
                    int posb,
                    java.util.Vector turnPoints)
             throws InfraException
Adds a new road to the infrastructure

Parameters:
road - The road to add
alpha - The alpha node to connect the road to
posa - The connection-position to connect the road at the alpha node at
beta - The beta node to connect the road to
posb - The connection-position to connect the road at the beta node at
turnPoints - The turn points. Angles are calculated.
Throws:
InfraException - DOCUMENT ME!

addLane

public void addLane(Drivelane lane,
                    Road r,
                    Node to)
             throws InfraException
Adds a drivelane to a road.

Parameters:
lane - The drivelane to add to the road.
r - The road to add the drivelane to.
to - Roadusers on the drivelane move towards this node.
Throws:
InfraException - If there are 4 drivelanes on that side of the road already.

setLaneType

public void setLaneType(Drivelane lane,
                        int t)
                 throws InfraException
Sets the type of a drivelane.

Parameters:
lane - The drivelane to set the type of.
t - The new type.
Throws:
InfraException - If the type could not be set.

setLaneTarget

public void setLaneTarget(Drivelane lane,
                          int target,
                          boolean state)
                   throws InfraException
Sets or clears a target for a drivelane. IE the arrow on the road. Target 0 is left, 1 is straight ahead, 2 is right.

Parameters:
lane - The drivelane to set a target of.
target - The target to set or clear.
state - True to set the target, false to clear it.
Throws:
InfraException - If the target could not be set.

moveNode

public void moveNode(Node node,
                     java.awt.Point point)
Moves a node to a new position on the map. This method will be disabled when turns are implemented.

Parameters:
node - The node to move.
point - The new coordinates of the node.

remNode

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

Parameters:
node - The node to remove
Throws:
InfraException - If anything bad happens.

remRoad

public void remRoad(Road road)
             throws InfraException
Removes a road from the infrastructure

Parameters:
road - The road to remove from the infrastructure
Throws:
InfraException - If something bad happens.

remLane

public void remLane(Drivelane lane)
             throws InfraException
Removes a drivelane from the infrastructure

Parameters:
lane - The drivelane to remove
Throws:
InfraException - If something bad happens.

load

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

Specified by:
load in interface XMLSerializable
Overrides:
load in class Model
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
Overrides:
saveSelf in class Model
Returns:
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 Model
Parameters:
saver - DOCUMENT ME!
Throws:
XMLTreeException - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
XMLCannotSaveException - DOCUMENT ME!