Class Diagram
- java.lang.Object
-
- org.opentrafficsim.trafficcontrol.trafcod.Diagram
-
public class Diagram extends Object
Functions that can draw a schematic diagram of an intersection given the list of traffic streams. The traffic stream numbers must follow the Dutch conventions.Copyright (c) 2013-2022 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.- Version:
- $Revision$, $LastChangedDate$, by $Author$, initial version Dec 1, 2016
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
Diagram.Command
Commands used in RouteStep.(package private) static class
Diagram.LaneType
Types of lanes.(package private) class
Diagram.RouteStep
Step in a schematic route through the intersection.(package private) class
Diagram.XYPair
Pack two integer coordinates in one object.
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
BICYCLE
Bicycle lane.(package private) static int
BOUNDARY
Boundary of schematic intersection.(package private) static int
CAR_CENTER
No turn (center) lane(s).(package private) static int
CAR_LEFT
Left turn lane(s).(package private) static int
CAR_RIGHT
Right turn lane(s).(package private) static int
CAR_ROUNDABOUT_LEFT
Left turn area on roundabout.(package private) static int
DIVIDER_1
Central divider.(package private) static int
DIVIDER_2
Divider between center public transit and left turn lane.(package private) static int
DIVIDER_3
Divider between right turn lane and bicycle lane.(package private) static int
DIVIDER_4
Divider.(package private) static int
DIVIDER_5
Divider.(package private) static int
DIVIDER_6
Divider.(package private) static int
DIVIDER_7
Divider.(package private) static int
PT_BICYCLE_SIDEWALK
Public transit between bicycle lane and right sidewalk.(package private) static int
PT_DIV_L
Public transit between divider and left turn lane.(package private) static int
PT_RIGHT_BICYCLE
Public transit between right turn lane and bicycle lane.(package private) static int
PT_SIDEWALK_SHOULDER
Public transit right of right sidewalk.(package private) static int
SHOULDER
Shoulder right of right sidewalk.(package private) static int
SIDEWALK
Sidewalk.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
isGrass(int i)
Report if object is inaccessible to all traffic.(package private) Diagram.LaneType
laneType(int streamNumber)
Return the LaneType for a stream number.static void
main(String[] args)
Test the Diagram code.static JCheckBox
makeCheckBox(int stream, boolean initialState)
Make a check box to switch a particular stream number on or off.(package private) static void
rebuildTestPanel()
Render the intersection.BufferedImage
render()
Create a BufferedImage and render the schematic on it.(package private) int
rotatedX(Diagram.XYPair xyPair, int rotation)
Return the rotated x value.(package private) int
rotatedY(Diagram.XYPair xyPair, int rotation)
Return the rotated y value.
-
-
-
Field Detail
-
DIVIDER_1
static final int DIVIDER_1
Central divider.- See Also:
- Constant Field Values
-
CAR_ROUNDABOUT_LEFT
static final int CAR_ROUNDABOUT_LEFT
Left turn area on roundabout.- See Also:
- Constant Field Values
-
PT_DIV_L
static final int PT_DIV_L
Public transit between divider and left turn lane.- See Also:
- Constant Field Values
-
DIVIDER_2
static final int DIVIDER_2
Divider between center public transit and left turn lane.- See Also:
- Constant Field Values
-
CAR_LEFT
static final int CAR_LEFT
Left turn lane(s).- See Also:
- Constant Field Values
-
CAR_CENTER
static final int CAR_CENTER
No turn (center) lane(s).- See Also:
- Constant Field Values
-
CAR_RIGHT
static final int CAR_RIGHT
Right turn lane(s).- See Also:
- Constant Field Values
-
DIVIDER_3
static final int DIVIDER_3
Divider between right turn lane and bicycle lane.- See Also:
- Constant Field Values
-
PT_RIGHT_BICYCLE
static final int PT_RIGHT_BICYCLE
Public transit between right turn lane and bicycle lane.- See Also:
- Constant Field Values
-
DIVIDER_4
static final int DIVIDER_4
Divider.- See Also:
- Constant Field Values
-
BICYCLE
static final int BICYCLE
Bicycle lane.- See Also:
- Constant Field Values
-
DIVIDER_5
static final int DIVIDER_5
Divider.- See Also:
- Constant Field Values
-
PT_BICYCLE_SIDEWALK
static final int PT_BICYCLE_SIDEWALK
Public transit between bicycle lane and right sidewalk.- See Also:
- Constant Field Values
-
DIVIDER_6
static final int DIVIDER_6
Divider.- See Also:
- Constant Field Values
-
SIDEWALK
static final int SIDEWALK
Sidewalk.- See Also:
- Constant Field Values
-
DIVIDER_7
static final int DIVIDER_7
Divider.- See Also:
- Constant Field Values
-
PT_SIDEWALK_SHOULDER
static final int PT_SIDEWALK_SHOULDER
Public transit right of right sidewalk.- See Also:
- Constant Field Values
-
SHOULDER
static final int SHOULDER
Shoulder right of right sidewalk.- See Also:
- Constant Field Values
-
BOUNDARY
static final int BOUNDARY
Boundary of schematic intersection.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Diagram
public Diagram(Set<Short> streams) throws TrafficLightException
Construct a new diagram.- Parameters:
streams
- Set<Short>; the streams (numbered according to the Dutch standard) that cross the intersection.- Throws:
TrafficLightException
- when a route is invalid
-
-
Method Detail
-
isGrass
public static final boolean isGrass(int i)
Report if object is inaccessible to all traffic.- Parameters:
i
- int; the number of the object- Returns:
- boolean; true if the object is inaccessible to all traffic
-
laneType
final Diagram.LaneType laneType(int streamNumber)
Return the LaneType for a stream number.- Parameters:
streamNumber
- int; the standard Dutch traffic stream number- Returns:
- LaneType; the lane type of the stream; or null if the stream number is reserved or invalid
-
rotatedX
final int rotatedX(Diagram.XYPair xyPair, int rotation)
Return the rotated x value.- Parameters:
xyPair
- XYPair; the XYPairrotation
- int; rotation in multiples of 90 degrees- Returns:
- int; the x component of the rotated coordinates
-
rotatedY
final int rotatedY(Diagram.XYPair xyPair, int rotation)
Return the rotated y value.- Parameters:
xyPair
- XYPair; the XYPairrotation
- int; rotation in multiples of 90 degrees- Returns:
- int; the y component of the rotated coordinates
-
render
public BufferedImage render()
Create a BufferedImage and render the schematic on it.- Returns:
- BufferedImage
-
main
public static void main(String[] args)
Test the Diagram code.- Parameters:
args
- String[]; the command line arguments (not used)
-
makeCheckBox
public static JCheckBox makeCheckBox(int stream, boolean initialState)
Make a check box to switch a particular stream number on or off.- Parameters:
stream
- int; the stream numberinitialState
- boolean; if true; the check box will be checked- Returns:
- JCheckBox
-
rebuildTestPanel
static void rebuildTestPanel()
Render the intersection.
-
-