Class 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.
    • Constructor Summary

      Constructors 
      Constructor Description
      Diagram​(Set<Short> streams)
      Construct a new diagram.
    • 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 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.