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

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

Constructor Summary

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

Method Summary

Modifier and TypeMethodDescription
voidadd(BusStop element)
Adds a specified bus stop to the network.
voidadd(Intersection element)
Adds a specified intersection to the network.
voidadd(ParkingLot element)
Adds a specified parking lot to the network.
voidadd(Road element)
Adds a specified road to the network.
voidadd(StopLine element)
Adds a specified StopLine to the network.
voidadd(TrafficLight<?> element)
Adds a specified traffic light to the network.
voidaddAll(AbstractRoadMarkup... contents)
Adds all arguments to the network
Stream<? extends AbstractRoadMarkup>elementsInternal()
This method is internal and shouldn't be called by user.
it may be removed/renamed in future.
List<BusStop>getBusStops()
Returns all bus stops contained in this RoadNetwork
ColorgetDirectionsDelimitingLineColor()
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)
RoadLineStylegetDirectionsDelimitingLineStyle()
Returns style of the directions delimiting line
TexturegetDirectionsDelimitingLineTexture()
Returns the texture of the directions delimiting line color, if the directions delimiting line color has texture
ShapeDrawModegetDrawMode()
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).
RoadDrivingDirectiongetDrivingDirection()
Returns driving direction
List<Intersection>getIntersections()
Returns all intersections and lane mergings contained in this RoadNetwork
ColorgetLanesDelimitingLineColor()
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)
RoadLineStylegetLanesDelimitingLineStyle()
Returns style of the road lanes delimiting line
TexturegetLanesDelimitingLineTexture()
Returns the texture of the road lanes delimiting line color, if the road lanes delimiting line color has texture
doublegetLaneWidth()
Returns lane width
doublegetLaneWidth(LengthUnits units)
Returns lane width
LevelgetLevel()
Returns level associated with this space markup element or null if this element has no level
List<ParkingLot>getParkingLots()
Returns all parking lots contained in this RoadNetwork
ColorgetRoadBackgroundColor()
Returns the road background color, or null if road has no background color or has texture (in this case #getFillTexture() should be used instead)
TexturegetRoadBackgroundTexture()
Returns the texture of the road background, if the road has background texture
List<Road>getRoads()
Returns all roads contained in this RoadNetwork
List<StopLine>getStopLines()
Returns all stop lines contained in this RoadNetwork
List<TrafficLight<?>>getTrafficLights()
Returns all Traffic Lights contained in this RoadNetwork
booleanisSignalStateAnimationVisible()
Returns true if configured to animate signal states of stop lines and lane connectors
voidsetDebugInfoVisible(boolean debugInfoVisible)
Deprecated.
TODO remove in release
voidsetDirectionsDelimitingLineColor(Color directionsDelimitingLineColor)
Sets the color of the directions delimiting line.
voidsetDirectionsDelimitingLineColor(Paint directionsDelimitingLineColor)
Sets the color (or Texture) of the directions delimiting line.
voidsetDirectionsDelimitingLineStyle(RoadLineStyle directionsDelimitingLineStyle)
Sets style of the directions delimiting line
voidsetDrivingDirection(RoadDrivingDirection drivingDirection)
Sets driving direction
voidsetLanesDelimitingLineColor(Color lanesDelimitingLineColor)
Sets the color of the road lanes delimiting line color.
voidsetLanesDelimitingLineColor(Paint lanesDelimitingLineColor)
Sets the color (or Texture) of the road lanes delimiting line color.
voidsetLanesDelimitingLineStyle(RoadLineStyle lanesDelimitingLineStyle)
Sets style of the road lanes delimiting line
voidsetLaneWidth(double laneWidthInPixels)
Sets lane width
voidsetLaneWidth(double laneWidth, LengthUnits units)
Sets lane width
voidsetLevel(Level level) 
voidsetRoadBackgroundColor(Color roadBackgroundColor)
Sets the color of the road background color.
voidsetRoadBackgroundColor(Paint roadBackgroundColor)
Sets the background color (or Texture) of the road.
voidsetSignalStateAnimationVisible(boolean visible)
Sets debug animation visibility.

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 Details

RoadNetwork

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

RoadNetwork

public RoadNetwork(Agent owner,
 String name,
 ShapeDrawMode drawMode,
 boolean isPublic,
 boolean visible,
 RoadDrivingDirection drivingDirection,
 double laneWidthInMeters,
 Paint roadBackgroundColor,
 Paint lanesDelimitingLineColor,
 RoadLineStyle lanesDelimitingLineStyle,
 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,
 String name,
 ShapeDrawMode drawMode,
 boolean isPublic,
 boolean visible,
 RoadDrivingDirection drivingDirection,
 double laneWidthInMeters,
 Paint roadBackgroundColor,
 Paint lanesDelimitingLineColor,
 RoadLineStyle lanesDelimitingLineStyle,
 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 Details

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 List<Road> getRoads()
Returns all roads contained in this RoadNetwork
Returns:
unmodifiable list of roads

getStopLines

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

getIntersections

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

getParkingLots

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

getBusStops

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

getTrafficLights

public 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(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(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 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(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(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 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(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(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 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 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