vanetsim.map
Class Street

java.lang.Object
  extended by vanetsim.map.Street

public final class Street
extends java.lang.Object

A street on the map.


Constructor Summary
Street(java.lang.String name, Node startNode, Node endNode, java.lang.String streetType, int oneway, int lanes, java.awt.Color displayColor, Region mainRegion, int maxSpeed)
          Instantiates a new street.
 
Method Summary
 void addBridgePaintLine(double x1, double y1, double x2, double y2)
          Adds a line for painting a bridge.
 void addBridgePaintPolygon(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
          Adds a polygon for painting a bridge.
 void addLaneObject(LaneObject object, boolean direction)
          Adds a lane object.
 void changeOneWay(int oneway)
          Changes if this street is a oneway street or not.
 void clearLanes()
          Clears all objects from the lanes container.
 void delLaneObject(LaneObject object, boolean direction)
          Removes a lane object.
 boolean equals(java.lang.Object other)
          Checks if this object is equal to another.
 java.util.ArrayList<java.awt.geom.Point2D.Double> getBridgePaintLines()
          Gets the lines to paint a bridge.
 java.util.ArrayList<java.awt.geom.Point2D.Double> getBridgePaintPolygons()
          Gets the polygons to paint a bridge.
 java.awt.Color getDisplayColor()
          Gets the display color of this street.
 Node getEndNode()
          Gets the end node of this street.
 int getEndNodeTrafficLightState()
          Gets the state of the traffic light.
 LaneObject getFirstLaneObject(boolean direction)
          Gets the first lane object.
 int getLanesCount()
          Gets the amount of lanes in one direction.
 LaneObject getLastLaneObject(boolean direction)
          Gets the last lane object.
 double getLength()
          Gets the length of the street.
 Region getMainRegion()
          Gets the region to which this street is primarily assigned to.
 java.lang.String getName()
          Gets the name of this street.
 int getSpeed()
          Gets the speed.
 Node getStartNode()
          Gets the start node of this street.
 int getStartNodeTrafficLightState()
          Gets the state of the traffic light.
 java.lang.String getStreetType_()
          Gets the type of this street.
 int getTrafficLightEndX_()
           
 int getTrafficLightEndY_()
           
 int getTrafficLightStartX_()
           
 int getTrafficLightStartY_()
           
 double getXFactor()
          Gets the x correction factor of one lane for position calculation (in cm).
 double getYFactor()
          Gets the x correction factor of one lane for position calculation (in cm).
 int hashCode()
          Creates a hash code (needed for HashMaps or similar structures).
 boolean isOneway()
          Indicates if this is a oneway-street or not.
 boolean isPriorityOnEndNode()
           
 boolean isPriorityOnStartNode()
           
 void setDisplayColor(java.awt.Color displayColor)
          Sets the display color of this street.
 void setEndNode(Node endNode)
           
 void setEndNodeTrafficLightState(int endNodeTrafficLightState_)
          Sets the status of the traffic light
 void setLanesCount(int laneCount)
          Sets the amount of lanes.
 void setName(java.lang.String name)
          Sets the name of this street.
 void setPriorityOnEndNode(boolean priorityOnEndNode)
           
 void setPriorityOnStartNode(boolean priorityOnStartNode)
           
 void setSpeed(int maxSpeed)
          Sets the maximum speed.
 void setStartNode(Node startNode)
           
 void setStartNodeTrafficLightState(int startNodeTrafficLightState_)
          Sets the status of the traffic light
 void setStreetType_(java.lang.String streetType_)
          Sets the type of this street.
 void setTrafficLightEndX_(int trafficLightEndX_)
           
 void setTrafficLightEndY_(int trafficLightEndY_)
           
 void setTrafficLightStartX_(int trafficLightStartX_)
           
 void setTrafficLightStartY_(int trafficLightStartY_)
           
 void updateEndNodeTrafficLightState()
          Updates the state of the traffic light.
 void updateLaneObject(LaneObject object, boolean direction, double newPosition)
          Updates a lane object.
 void updateStartNodeTrafficLightState()
          Updates the state of the traffic light.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Street

public Street(java.lang.String name,
              Node startNode,
              Node endNode,
              java.lang.String streetType,
              int oneway,
              int lanes,
              java.awt.Color displayColor,
              Region mainRegion,
              int maxSpeed)
Instantiates a new street.

Parameters:
name - the name of this street
startNode - the start node
endNode - the end node
streetType - type of the street
oneway - 0=twoway-street, 1=oneway from startNode to endNode, else: oneway from endNode to startNode
lanes - the number of lanes on this street in one direction (!). Normal streets should have 1 here, motorways 2 or more!
displayColor - the color in which to paint this street
mainRegion - the main region
maxSpeed - the maximum speed allowed on this street
Method Detail

getLength

public double getLength()
Gets the length of the street.

Returns:
the length of the street

getXFactor

public double getXFactor()
Gets the x correction factor of one lane for position calculation (in cm). Only valid if going from startNode to endNode (else you need to take the negative).

Returns:
the x correction factor

getYFactor

public double getYFactor()
Gets the x correction factor of one lane for position calculation (in cm). Only valid if going from startNode to endNode (else you need to take the negative).

Returns:
the y correction factor

getSpeed

public int getSpeed()
Gets the speed.

Returns:
the speed

setSpeed

public void setSpeed(int maxSpeed)
Sets the maximum speed.

Parameters:
maxSpeed - the new speed

changeOneWay

public void changeOneWay(int oneway)
Changes if this street is a oneway street or not.

Parameters:
oneway - 0=twoway-street, 1=oneway from startNode to endNode, else: oneway from endNode to startNode

getLanesCount

public int getLanesCount()
Gets the amount of lanes in one direction. If this is a twoway street, you need to multiply by 2 to get the total amount of lanes.

Returns:
the number of lanes per direction

setLanesCount

public void setLanesCount(int laneCount)
Sets the amount of lanes.

Parameters:
laneCount - the number of lanes per direction

getFirstLaneObject

public LaneObject getFirstLaneObject(boolean direction)
Gets the first lane object. You may iterate through the objects using getNext() and getPrevious(). Note that the lane might change while you're iterating as it's not synchronized!

Parameters:
direction - true in the direction from startNode to endNode, false seen from endNode to startNode
Returns:
the first lane object

getLastLaneObject

public LaneObject getLastLaneObject(boolean direction)
Gets the last lane object. You may iterate through the objects using getNext() and getPrevious(). Note that the lane might change while you're iterating as it's not synchronized!

Parameters:
direction - true in the direction from startNode to endNode, false seen from endNode to startNode
Returns:
the last lane object

addLaneObject

public void addLaneObject(LaneObject object,
                          boolean direction)
Adds a lane object. The underlying lane container is synchronized during this operation.

Parameters:
object - the object to add
direction - true in the direction from startNode to endNode, false seen from endNode to startNode

delLaneObject

public void delLaneObject(LaneObject object,
                          boolean direction)
Removes a lane object. The underlying lane container is synchronized during this operation.

Parameters:
object - the object to remove
direction - true in the direction from startNode to endNode, false seen from endNode to startNode

updateLaneObject

public void updateLaneObject(LaneObject object,
                             boolean direction,
                             double newPosition)
Updates a lane object. The underlying lane container is synchronized during this operation.

Parameters:
object - the object to check for updates
direction - true in the direction from startNode to endNode, false seen from endNode to startNode
newPosition - the new position of the object

clearLanes

public void clearLanes()
Clears all objects from the lanes container.


addBridgePaintLine

public void addBridgePaintLine(double x1,
                               double y1,
                               double x2,
                               double y2)
Adds a line for painting a bridge.

Parameters:
x1 - the x coordinate of the start point
y1 - the y coordinate of the start point
x2 - the x coordinate of the end point
y2 - the y coordinate of the end point

addBridgePaintPolygon

public void addBridgePaintPolygon(double x1,
                                  double y1,
                                  double x2,
                                  double y2,
                                  double x3,
                                  double y3,
                                  double x4,
                                  double y4)
Adds a polygon for painting a bridge.

Parameters:
x1 - the x coordinate of the first point
y1 - the y coordinate of the first point
x2 - the x coordinate of the second point
y2 - the y coordinate of the second point
x3 - the x coordinate of the third point
y3 - the y coordinate of the third point
x4 - the x coordinate of the fourth point
y4 - the y coordinate of the fourth point

getBridgePaintLines

public java.util.ArrayList<java.awt.geom.Point2D.Double> getBridgePaintLines()
Gets the lines to paint a bridge.

Returns:
the ArrayList with all lines to paint (two successive points are a line)

getBridgePaintPolygons

public java.util.ArrayList<java.awt.geom.Point2D.Double> getBridgePaintPolygons()
Gets the polygons to paint a bridge.

Returns:
the ArrayList with all lines to paint (two successive points are a line)

getStartNode

public Node getStartNode()
Gets the start node of this street.

Returns:
the start node

setStartNode

public void setStartNode(Node startNode)

getEndNode

public Node getEndNode()
Gets the end node of this street.

Returns:
the end node

setEndNode

public void setEndNode(Node endNode)

getDisplayColor

public java.awt.Color getDisplayColor()
Gets the display color of this street.

Returns:
the display color

setDisplayColor

public void setDisplayColor(java.awt.Color displayColor)
Sets the display color of this street.

Parameters:
displayColor - the new display color

getMainRegion

public Region getMainRegion()
Gets the region to which this street is primarily assigned to.

Returns:
the region

setName

public void setName(java.lang.String name)
Sets the name of this street.

Parameters:
name - the new name

getName

public java.lang.String getName()
Gets the name of this street.

Returns:
the name

isOneway

public boolean isOneway()
Indicates if this is a oneway-street or not. Oneway-streets always go from the StartNode to the EndNode!

Returns:
true if it's oneway, else false

equals

public boolean equals(java.lang.Object other)
Checks if this object is equal to another.

Overrides:
equals in class java.lang.Object
Parameters:
other - the object to compare to
Returns:
true, if equals
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Creates a hash code (needed for HashMaps or similar structures).

Overrides:
hashCode in class java.lang.Object
Returns:
an Integer
See Also:
Object.hashCode()

getStreetType_

public java.lang.String getStreetType_()
Gets the type of this street.

Returns:
the street-type

setStreetType_

public void setStreetType_(java.lang.String streetType_)
Sets the type of this street.

Parameters:
streetType_ - the type of the street

getStartNodeTrafficLightState

public int getStartNodeTrafficLightState()
Gets the state of the traffic light.

Returns:
the state of the traffic light

setStartNodeTrafficLightState

public void setStartNodeTrafficLightState(int startNodeTrafficLightState_)
Sets the status of the traffic light

Parameters:
startNodeTrafficLightState_ - the status of the traffic light

getEndNodeTrafficLightState

public int getEndNodeTrafficLightState()
Gets the state of the traffic light.

Returns:
the state of the traffic light

setEndNodeTrafficLightState

public void setEndNodeTrafficLightState(int endNodeTrafficLightState_)
Sets the status of the traffic light

Parameters:
endNodeTrafficLightState_ - the status of the traffic light

updateStartNodeTrafficLightState

public void updateStartNodeTrafficLightState()
Updates the state of the traffic light.


updateEndNodeTrafficLightState

public void updateEndNodeTrafficLightState()
Updates the state of the traffic light.


setTrafficLightEndX_

public void setTrafficLightEndX_(int trafficLightEndX_)
Parameters:
trafficLightEndX_ - the trafficLightEndX_ to set

getTrafficLightEndX_

public int getTrafficLightEndX_()
Returns:
the trafficLightEndX_

setTrafficLightStartX_

public void setTrafficLightStartX_(int trafficLightStartX_)
Parameters:
trafficLightStartX_ - the trafficLightStartX_ to set

getTrafficLightStartX_

public int getTrafficLightStartX_()
Returns:
the trafficLightStartX_

setTrafficLightStartY_

public void setTrafficLightStartY_(int trafficLightStartY_)
Parameters:
trafficLightStartY_ - the trafficLightStartY_ to set

getTrafficLightStartY_

public int getTrafficLightStartY_()
Returns:
the trafficLightStartY_

setTrafficLightEndY_

public void setTrafficLightEndY_(int trafficLightEndY_)
Parameters:
trafficLightEndY_ - the trafficLightEndY_ to set

getTrafficLightEndY_

public int getTrafficLightEndY_()
Returns:
the trafficLightEndY_

setPriorityOnEndNode

public void setPriorityOnEndNode(boolean priorityOnEndNode)
Parameters:
priorityOnEndNode - the priorityOnEndNode to set

isPriorityOnEndNode

public boolean isPriorityOnEndNode()
Returns:
the priorityOnEndNode

setPriorityOnStartNode

public void setPriorityOnStartNode(boolean priorityOnStartNode)
Parameters:
priorityOnStartNode - the priorityOnStartNode to set

isPriorityOnStartNode

public boolean isPriorityOnStartNode()
Returns:
the priorityOnStartNode