View Javadoc
1   package org.opentrafficsim.road.network.lane.object.trafficlight;
2   
3   /**
4    * The colors for a normal traffic light.
5    * <p>
6    * Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
7    * BSD-style license. See <a href="http://opentrafficsim.org/docs/current/license.html">OpenTrafficSim License</a>.
8    * </p>
9    * $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $,
10   * initial version Oct 6, 2016 <br>
11   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
12   * @author <a href="http://www.tudelft.nl/pknoppers">Peter Knoppers</a>
13   * @author <a href="http://www.transport.citg.tudelft.nl">Wouter Schakel</a>
14   */
15  public enum TrafficLightColor
16  {
17      /** GTU needs to stop. */
18      RED,
19  
20      /** GTU is allowed to continue if it cannot stop anymore. */
21      YELLOW,
22  
23      /** GTU is allowed to drive. */
24      GREEN,
25  
26      /** Pre-green indication. */
27      PREGREEN,
28  
29      /** Traffic light is not working. */
30      BLACK;
31  
32      /** @return whether the light is red or yellow. */
33      public final boolean isRedOrYellow()
34      {
35          return this.equals(RED) | this.equals(YELLOW);
36      }
37  
38      /** @return whether the light is red. */
39      public final boolean isRed()
40      {
41          return this.equals(RED);
42      }
43  
44      /** @return whether the light is yellow. */
45      public final boolean isYellow()
46      {
47          return this.equals(YELLOW);
48      }
49  
50      /** @return whether the light is green. */
51      public final boolean isGreen()
52      {
53          return this.equals(GREEN);
54      }
55  
56      /** @return whether the light is pre-green. */
57      public final boolean isPreGreen()
58      {
59          return this.equals(PREGREEN);
60      }
61  
62      /** @return whether the light is black (off). */
63      public final boolean isBlack()
64      {
65          return this.equals(BLACK);
66      }
67  
68  }