AnyLogic AnyLogic
Expand
Font size
All Implemented Interfaces:
AggregatableAnimationElement, HasLevel, LevelElement, LevelMarkup, java.io.Serializable

public class RoadNetwork
extends AbstractDrawableMarkupAggregator
implements LevelMarkup, AggregatableAnimationElement
CarNetwork
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Constructor Summary

Constructors 
RoadNetwork​(Agent owner, java.lang.String name, ShapeDrawMode drawMode)
Creates empty RoadNetwork with all parameters set by default.
RoadNetwork​(Agent owner, java.lang.String name, ShapeDrawMode drawMode, boolean isPublic, boolean visible, RoadDrivingDirection drivingDirection, double laneWidthInMeters, java.awt.Paint roadBackgroundColor, java.awt.Paint lanesDelimitingLineColor, RoadLineStyle lanesDelimitingLineStyle, java.awt.Paint directionsDelimitingLineColor, RoadLineStyle directionsDelimitingLineStyle, boolean isSignalStateAnimationVisible)
Creates RoadNetwork but doesn't initialize it
RoadNetwork​(Agent owner, java.lang.String name, ShapeDrawMode drawMode, boolean isPublic, boolean visible, RoadDrivingDirection drivingDirection, double laneWidthInMeters, java.awt.Paint roadBackgroundColor, java.awt.Paint lanesDelimitingLineColor, RoadLineStyle lanesDelimitingLineStyle, java.awt.Paint directionsDelimitingLineColor, RoadLineStyle directionsDelimitingLineStyle, boolean isSignalStateAnimationVisible, TrafficLight<?>[] trafficLights, AbstractRoadMarkup... markupElements)
Creates RoadNetwork and initializes it
Constructor Description

Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods 
void add​(BusStop element)
Adds a specified bus stop to the network.
void add​(Intersection element)
Adds a specified intersection to the network.
void add​(ParkingLot element)
Adds a specified parking lot to the network.
void add​(Road element)
Adds a specified road to the network.
void add​(StopLine element)
Adds a specified StopLine to the network.
void add​(TrafficLight<?> element)
Adds a specified traffic light to the network.
void addAll​(AbstractRoadMarkup... contents)
Adds all arguments to the network
java.util.stream.Stream<? extends AbstractRoadMarkup> elementsInternal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
java.util.List<BusStop> getBusStops()
Returns all bus stops contained in this RoadNetwork
java.awt.Color getDirectionsDelimitingLineColor()
Returns the color of the directions delimiting line color, or null if directions delimiting line color has no color or has textured (in this case #getFillTexture() should be used instead)
RoadLineStyle getDirectionsDelimitingLineStyle()
Returns style of the directions delimiting line
Texture getDirectionsDelimitingLineTexture()
Returns the texture of the directions delimiting line color, if the directions delimiting line color has texture
ShapeDrawMode getDrawMode()
Returns the drawing mode of the shape (where to draw this shape: 2D, 3D or 2D+3D).
If the shape has been created with no-argument constructor, and has no specific limitations (like 2D-only), and drawing mode hasn't yet been set, then it is initialized to default (2D + 3D).
RoadDrivingDirection getDrivingDirection()
Returns driving direction
java.util.List<Intersection> getIntersections()
Returns all intersections and lane mergings contained in this RoadNetwork
java.awt.Color getLanesDelimitingLineColor()
Returns the color of the road lanes delimiting line color, or null if road lanes delimiting line color has no color or has textured (in this case #getFillTexture() should be used instead)
RoadLineStyle getLanesDelimitingLineStyle()
Returns style of the road lanes delimiting line
Texture getLanesDelimitingLineTexture()
Returns the texture of the road lanes delimiting line color, if the road lanes delimiting line color has texture
double getLaneWidth()
Returns lane width
double getLaneWidth​(LengthUnits units)
Returns lane width
Level getLevel()
Returns level associated with this space markup element or null if this element has no level
java.util.List<ParkingLot> getParkingLots()
Returns all parking lots contained in this RoadNetwork
java.awt.Color getRoadBackgroundColor()
Returns the road background color, or null if road has no background color or has texture (in this case #getFillTexture() should be used instead)
Texture getRoadBackgroundTexture()
Returns the texture of the road background, if the road has background texture
java.util.List<Road> getRoads()
Returns all roads contained in this RoadNetwork
java.util.List<StopLine> getStopLines()
Returns all stop lines contained in this RoadNetwork
java.util.List<TrafficLight<?>> getTrafficLights()
Returns all Traffic Lights contained in this RoadNetwork
boolean isSignalStateAnimationVisible()
Returns true if configured to animate signal states of stop lines and lane connectors
void setDebugInfoVisible​(boolean debugInfoVisible)
Deprecated.
TODO remove in release
void setDirectionsDelimitingLineColor​(java.awt.Color directionsDelimitingLineColor)
Sets the color of the directions delimiting line.
void setDirectionsDelimitingLineColor​(java.awt.Paint directionsDelimitingLineColor)
Sets the color (or Texture) of the directions delimiting line.
void setDirectionsDelimitingLineStyle​(RoadLineStyle directionsDelimitingLineStyle)
Sets style of the directions delimiting line
void setDrivingDirection​(RoadDrivingDirection drivingDirection)
Sets driving direction
void setLanesDelimitingLineColor​(java.awt.Color lanesDelimitingLineColor)
Sets the color of the road lanes delimiting line color.
void setLanesDelimitingLineColor​(java.awt.Paint lanesDelimitingLineColor)
Sets the color (or Texture) of the road lanes delimiting line color.
void setLanesDelimitingLineStyle​(RoadLineStyle lanesDelimitingLineStyle)
Sets style of the road lanes delimiting line
void setLaneWidth​(double laneWidthInPixels)
Sets lane width
void setLaneWidth​(double laneWidth, LengthUnits units)
Sets lane width
void setLevel​(Level level)  
void setRoadBackgroundColor​(java.awt.Color roadBackgroundColor)
Sets the color of the road background color.
void setRoadBackgroundColor​(java.awt.Paint roadBackgroundColor)
Sets the background color (or Texture) of the road.
void setSignalStateAnimationVisible​(boolean visible)
Sets debug animation visibility.
Modifier and Type Method Description

Methods inherited from class com.anylogic.engine.markup.AbstractDrawableMarkupAggregator

setDrawMode

Methods inherited from class com.anylogic.engine.markup.AbstractMarkupAggregator

error, getName, getOwner, initializeInternal, isVisible, onAggregatorVisibilityChanged, setVisible

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface com.anylogic.engine.markup.AggregatableAnimationElement

initializeInternal, onAggregatorVisibilityChanged, postInitialize

Constructor Detail

RoadNetwork

public RoadNetwork​(Agent owner,
                   java.lang.String name,
                   ShapeDrawMode drawMode)
Creates empty RoadNetwork with all parameters set by default.

RoadNetwork

public RoadNetwork​(Agent owner,
                   java.lang.String name,
                   ShapeDrawMode drawMode,
                   boolean isPublic,
                   boolean visible,
                   RoadDrivingDirection drivingDirection,
                   double laneWidthInMeters,
                   java.awt.Paint roadBackgroundColor,
                   java.awt.Paint lanesDelimitingLineColor,
                   RoadLineStyle lanesDelimitingLineStyle,
                   java.awt.Paint directionsDelimitingLineColor,
                   RoadLineStyle directionsDelimitingLineStyle,
                   boolean isSignalStateAnimationVisible)
Creates RoadNetwork but doesn't initialize it
Parameters:
drivingDirection - driving direction, one of the following constants: RIGHT_HAND or LEFT_HAND
laneWidthInMeters - lane width, measured in meters
roadBackgroundColor - road background color
lanesDelimitingLineColor - lanes delimiting line color
lanesDelimitingLineStyle - line style, one of RoadConstants.RoadLineStyle constants
directionsDelimitingLineColor - directions delimiting line color
directionsDelimitingLineStyle - line style, one of RoadConstants.RoadLineStyle constants
isSignalStateAnimationVisible - animate signal states of stop lines and lane connectors

RoadNetwork

public RoadNetwork​(Agent owner,
                   java.lang.String name,
                   ShapeDrawMode drawMode,
                   boolean isPublic,
                   boolean visible,
                   RoadDrivingDirection drivingDirection,
                   double laneWidthInMeters,
                   java.awt.Paint roadBackgroundColor,
                   java.awt.Paint lanesDelimitingLineColor,
                   RoadLineStyle lanesDelimitingLineStyle,
                   java.awt.Paint directionsDelimitingLineColor,
                   RoadLineStyle directionsDelimitingLineStyle,
                   boolean isSignalStateAnimationVisible,
                   TrafficLight<?>[] trafficLights,
                   AbstractRoadMarkup... markupElements)
Creates RoadNetwork and initializes it
Parameters:
drivingDirection - driving direction, one of the following constants: RIGHT_HAND or LEFT_HAND
laneWidthInMeters - lane width, measured in meters
roadBackgroundColor - road background color
lanesDelimitingLineColor - lanes delimiting line color
lanesDelimitingLineStyle - line style, one of RoadConstants.RoadLineStyle constants
directionsDelimitingLineColor - directions delimiting line color
directionsDelimitingLineStyle - line style, one of RoadConstants.RoadLineStyle constants
isSignalStateAnimationVisible - animate signal states of stop lines and lane connectors
markupElements - array of markup elements

Method Detail

addAll

public void addAll​(AbstractRoadMarkup... contents)
Adds all arguments to the network
Parameters:
contents - - an instance of any of the following classes: Road, Intersection, StopLine, ParkingLot, BusStop

add

public void add​(Road element)
Adds a specified road to the network. The network should be uninitialized
Parameters:
element - element to be added

add

public void add​(Intersection element)
Adds a specified intersection to the network. The network should be uninitialized
Parameters:
element - element to be added

add

public void add​(StopLine element)
Adds a specified StopLine to the network. The network should be uninitialized
Parameters:
element - element to be added

add

public void add​(ParkingLot element)
Adds a specified parking lot to the network. The network should be uninitialized
Parameters:
element - element to be added

add

public void add​(BusStop element)
Adds a specified bus stop to the network. The network should be uninitialized
Parameters:
element - element to be added

add

public void add​(TrafficLight<?> element)
Adds a specified traffic light to the network. The network should be uninitialized
Parameters:
element - element to be added

getRoads

public java.util.List<Road> getRoads()
Returns all roads contained in this RoadNetwork
Returns:
unmodifiable list of roads

getStopLines

public java.util.List<StopLine> getStopLines()
Returns all stop lines contained in this RoadNetwork
Returns:
unmodifiable list of stop lines (positions on roads)

getIntersections

public java.util.List<Intersection> getIntersections()
Returns all intersections and lane mergings contained in this RoadNetwork
Returns:
unmodifiable list of Intersection elements

getParkingLots

public java.util.List<ParkingLot> getParkingLots()
Returns all parking lots contained in this RoadNetwork
Returns:
unmodifiable list of parking lots

getBusStops

public java.util.List<BusStop> getBusStops()
Returns all bus stops contained in this RoadNetwork
Returns:
unmodifiable list of bus stops

getTrafficLights

public java.util.List<TrafficLight<?>> getTrafficLights()
Returns all Traffic Lights contained in this RoadNetwork
Returns:
unmodifiable list of Traffic Lights contained in this RoadNetwork

getDrivingDirection

public RoadDrivingDirection getDrivingDirection()
Returns driving direction
Returns:
driving direction, RoadConstants.DrivingDirection.RIGHT_HAND or RoadConstants.DrivingDirection.LEFT_HAND

setDrivingDirection

public void setDrivingDirection​(RoadDrivingDirection drivingDirection)
Sets driving direction
Parameters:
drivingDirection - driving direction, RoadConstants.DrivingDirection.RIGHT_HAND or RoadConstants.DrivingDirection.LEFT_HAND

getLaneWidth

public double getLaneWidth()
Returns lane width
Returns:
lane width, measured in pixels

getLaneWidth

public double getLaneWidth​(LengthUnits units)
Returns lane width
Parameters:
units - length units
Returns:
lane width, measured in the given units

setLaneWidth

public void setLaneWidth​(double laneWidthInPixels)
Sets lane width
Parameters:
laneWidthInPixels - lane width, measured in pixels

setLaneWidth

public void setLaneWidth​(double laneWidth,
                         LengthUnits units)
Sets lane width
Parameters:
laneWidth - lane width, measured in the given units
units - length units

setRoadBackgroundColor

public void setRoadBackgroundColor​(java.awt.Color roadBackgroundColor)
Sets the color of the road background color.
Parameters:
color - the new color, null = do not draw the road background color

setRoadBackgroundColor

public void setRoadBackgroundColor​(java.awt.Paint roadBackgroundColor)
Sets the background color (or Texture) of the road.
Parameters:
color - the new color, null = do not draw the road background

getRoadBackgroundColor

public java.awt.Color getRoadBackgroundColor()
Returns the road background color, or null if road has no background color or has texture (in this case #getFillTexture() should be used instead)
Returns:
the road background color

getRoadBackgroundTexture

public Texture getRoadBackgroundTexture()
Returns the texture of the road background, if the road has background texture
Returns:
the texture of the road background

setLanesDelimitingLineColor

public void setLanesDelimitingLineColor​(java.awt.Color lanesDelimitingLineColor)
Sets the color of the road lanes delimiting line color.
Parameters:
color - the new color, null = do not draw the road lanes delimiting line color

setLanesDelimitingLineColor

public void setLanesDelimitingLineColor​(java.awt.Paint lanesDelimitingLineColor)
Sets the color (or Texture) of the road lanes delimiting line color.
Parameters:
color - the new color, null = do not draw the road lanes delimiting line color

getLanesDelimitingLineColor

public java.awt.Color getLanesDelimitingLineColor()
Returns the color of the road lanes delimiting line color, or null if road lanes delimiting line color has no color or has textured (in this case #getFillTexture() should be used instead)
Returns:
the color of the road lanes delimiting line color

getLanesDelimitingLineTexture

public Texture getLanesDelimitingLineTexture()
Returns the texture of the road lanes delimiting line color, if the road lanes delimiting line color has texture
Returns:
the texture of the road lanes delimiting line color

setLanesDelimitingLineStyle

public void setLanesDelimitingLineStyle​(RoadLineStyle lanesDelimitingLineStyle)
Sets style of the road lanes delimiting line
Parameters:
lanesDelimitingLineStyle - line style, one of RoadConstants.RoadLineStyle constants

getLanesDelimitingLineStyle

public RoadLineStyle getLanesDelimitingLineStyle()
Returns style of the road lanes delimiting line
Returns:
line style, one of RoadConstants.RoadLineStyle constants

setDirectionsDelimitingLineColor

public void setDirectionsDelimitingLineColor​(java.awt.Color directionsDelimitingLineColor)
Sets the color of the directions delimiting line.
Parameters:
color - the new color, null = do not draw the directions delimiting line

setDirectionsDelimitingLineColor

public void setDirectionsDelimitingLineColor​(java.awt.Paint directionsDelimitingLineColor)
Sets the color (or Texture) of the directions delimiting line.
Parameters:
color - the new color or texture, null = do not draw the directions delimiting line

getDirectionsDelimitingLineColor

public java.awt.Color getDirectionsDelimitingLineColor()
Returns the color of the directions delimiting line color, or null if directions delimiting line color has no color or has textured (in this case #getFillTexture() should be used instead)
Returns:
the color of the directions delimiting line color

getDirectionsDelimitingLineTexture

public Texture getDirectionsDelimitingLineTexture()
Returns the texture of the directions delimiting line color, if the directions delimiting line color has texture
Returns:
the texture of the directions delimiting line color

setDirectionsDelimitingLineStyle

public void setDirectionsDelimitingLineStyle​(RoadLineStyle directionsDelimitingLineStyle)
Sets style of the directions delimiting line
Parameters:
directionsDelimitingLineStyle - line style, one of RoadConstants.RoadLineStyle constants

getDirectionsDelimitingLineStyle

public RoadLineStyle getDirectionsDelimitingLineStyle()
Returns style of the directions delimiting line
Returns:
line style, one of RoadConstants.RoadLineStyle constants

isSignalStateAnimationVisible

public boolean isSignalStateAnimationVisible()
Returns true if configured to animate signal states of stop lines and lane connectors

setSignalStateAnimationVisible

public void setSignalStateAnimationVisible​(boolean visible)
Sets debug animation visibility.
Parameters:
visible - to animate (true) or not (false) signal states of stop lines and lane connectors

elementsInternal

@AnyLogicInternalAPI
public java.util.stream.Stream<? extends AbstractRoadMarkup> elementsInternal()
Description copied from class: AbstractMarkupAggregator
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
Specified by:
elementsInternal in class AbstractMarkupAggregator<Agent>

setDebugInfoVisible

@Deprecated
public void setDebugInfoVisible​(boolean debugInfoVisible)
Deprecated.
TODO remove in release

getLevel

public Level getLevel()
Description copied from interface: HasLevel
Returns level associated with this space markup element or null if this element has no level
Specified by:
getLevel in interface HasLevel
Returns:
the level associated with this space markup element

getDrawMode

public ShapeDrawMode getDrawMode()
Description copied from class: AbstractDrawableMarkupAggregator
Returns the drawing mode of the shape (where to draw this shape: 2D, 3D or 2D+3D).
If the shape has been created with no-argument constructor, and has no specific limitations (like 2D-only), and drawing mode hasn't yet been set, then it is initialized to default (2D + 3D).
Overrides:
getDrawMode in class AbstractDrawableMarkupAggregator

setLevel

@AnyLogicInternalAPI
public void setLevel​(Level level)
Specified by:
setLevel in interface LevelElement
How can we improve this article?