org.jscience.architecture.traffic.tools
Class RoadAction

java.lang.Object
  extended by org.jscience.architecture.traffic.tools.RoadAction
All Implemented Interfaces:
ToolAction

public class RoadAction
extends java.lang.Object
implements ToolAction

This implements create road user action


Field Summary
protected  int alphaConPos
          DOCUMENT ME!
protected  Node alphaNode
          DOCUMENT ME!
protected  java.awt.Point alphaPoint
          DOCUMENT ME!
protected  int betaConPos
          DOCUMENT ME!
protected static int MIN_TURN_DISTANCE
          DOCUMENT ME!
protected  EditModel model
          DOCUMENT ME!
protected  java.awt.Point mousePoint
          DOCUMENT ME!
protected  java.awt.Point startPoint
          DOCUMENT ME!
protected  java.util.Vector turnPoints
          DOCUMENT ME!
 
Constructor Summary
RoadAction(EditModel em)
          Creates a new RoadAction object.
 
Method Summary
 boolean beingUsed()
          DOCUMENT ME!
protected  Road createRoad(Node alpha, Node beta)
          DOCUMENT ME!
protected  int getBestConPosition(Node node, java.awt.Point pa, java.awt.Point pb)
          DOCUMENT ME!
 void moveAction(View view, java.awt.Point p)
          Moves the current mouse point
 boolean nextAction(View view, java.awt.Point p)
          Performs a step in creating a road at given point.
 void paint(java.awt.Graphics g)
          Paints a graphical representation of the status of this action
 void reset()
          DOCUMENT ME!
 boolean startAction(View view, java.awt.Point p)
          Starts creating a road at given point
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_TURN_DISTANCE

protected static final int MIN_TURN_DISTANCE
DOCUMENT ME!

See Also:
Constant Field Values

model

protected EditModel model
DOCUMENT ME!


alphaNode

protected Node alphaNode
DOCUMENT ME!


startPoint

protected java.awt.Point startPoint
DOCUMENT ME!


mousePoint

protected java.awt.Point mousePoint
DOCUMENT ME!


alphaPoint

protected java.awt.Point alphaPoint
DOCUMENT ME!


turnPoints

protected java.util.Vector turnPoints
DOCUMENT ME!


alphaConPos

protected int alphaConPos
DOCUMENT ME!


betaConPos

protected int betaConPos
DOCUMENT ME!

Constructor Detail

RoadAction

public RoadAction(EditModel em)
Creates a new RoadAction object.

Parameters:
em - DOCUMENT ME!
Method Detail

beingUsed

public boolean beingUsed()
DOCUMENT ME!

Specified by:
beingUsed in interface ToolAction
Returns:
DOCUMENT ME!

reset

public void reset()
DOCUMENT ME!


startAction

public boolean startAction(View view,
                           java.awt.Point p)
Starts creating a road at given point

Parameters:
view - The main view. Needed to convert coordinates
p - The point to start the new road at
Returns:
False if no node was found at the given point (and the action could not be started consequently)

nextAction

public boolean nextAction(View view,
                          java.awt.Point p)
Performs a step in creating a road at given point. If a node was found at the given point, the road is created and the action ends. Otherwise a turn is added using the given point.

Parameters:
view - DOCUMENT ME!
p - The point
Returns:
False if the action was ended without creating a road.

moveAction

public void moveAction(View view,
                       java.awt.Point p)
Moves the current mouse point

Parameters:
view - DOCUMENT ME!
p - The new position of the mouse cursor

paint

public void paint(java.awt.Graphics g)
Paints a graphical representation of the status of this action

Parameters:
g - The Graphics object to paint on

getBestConPosition

protected int getBestConPosition(Node node,
                                 java.awt.Point pa,
                                 java.awt.Point pb)
                          throws CannotConnectException,
                                 InfraException
DOCUMENT ME!

Parameters:
node - DOCUMENT ME!
pa - DOCUMENT ME!
pb - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
CannotConnectException - DOCUMENT ME!
InfraException - DOCUMENT ME!

createRoad

protected Road createRoad(Node alpha,
                          Node beta)
                   throws InfraException
DOCUMENT ME!

Parameters:
alpha - DOCUMENT ME!
beta - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
InfraException - DOCUMENT ME!