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-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static enum 
    Commands used in RouteStep.
    (package private) static enum 
    Types of lanes.
    (package private) class 
    Step in a schematic route through the intersection.
    (package private) class 
    Pack two integer coordinates in one object.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final int
    Bicycle lane.
    (package private) static final int
    Boundary of schematic intersection.
    (package private) static final int
    No turn (center) lane(s).
    (package private) static final int
    Left turn lane(s).
    (package private) static final int
    Right turn lane(s).
    (package private) static final int
    Left turn area on roundabout.
    (package private) static final int
    Central divider.
    (package private) static final int
    Divider between center public transit and left turn lane.
    (package private) static final int
    Divider between right turn lane and bicycle lane.
    (package private) static final int
    Divider.
    (package private) static final int
    Divider.
    (package private) static final int
    Divider.
    (package private) static final int
    Divider.
    (package private) static final int
    Public transit between bicycle lane and right sidewalk.
    (package private) static final int
    Public transit between divider and left turn lane.
    (package private) static final int
    Public transit between right turn lane and bicycle lane.
    (package private) static final int
    Public transit right of right sidewalk.
    (package private) static final int
    Shoulder right of right sidewalk.
    (package private) static final int
    Sidewalk.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Diagram(Set<Short> streams)
    Construct a new diagram.
  • Method Summary

    Modifier and Type
    Method
    Description
    static final boolean
    isGrass(int i)
    Report if object is inaccessible to all traffic.
    (package private) final 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
    Render the intersection.
    Create a BufferedImage and render the schematic on it.
    (package private) final int
    rotatedX(Diagram.XYPair xyPair, int rotation)
    Return the rotated x value.
    (package private) final int
    rotatedY(Diagram.XYPair xyPair, int rotation)
    Return the rotated y value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Diagram

      public Diagram(Set<Short> streams) throws TrafficControlException
      Construct a new diagram.
      Parameters:
      streams - Set<Short>; the streams (numbered according to the Dutch standard) that cross the intersection.
      Throws:
      TrafficControlException - when a route is invalid
  • Method Details

    • 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 XYPair
      rotation - 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 XYPair
      rotation - 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 number
      initialState - boolean; if true; the check box will be checked
      Returns:
      JCheckBox
    • rebuildTestPanel

      static void rebuildTestPanel()
      Render the intersection.