View Javadoc
1   package org.opentrafficsim.animation.data;
2   
3   import java.awt.Color;
4   
5   import org.opentrafficsim.draw.road.ConflictAnimation.ConflictData;
6   import org.opentrafficsim.road.network.lane.conflict.Conflict;
7   
8   /**
9    * Animation data of a Conflict.
10   * <p>
11   * Copyright (c) 2023-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
12   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
13   * </p>
14   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
15   */
16  public class AnimationConflictData extends AnimationLaneBasedObjectData<Conflict> implements ConflictData
17  {
18  
19      /**
20       * Constructor.
21       * @param conflict conflict.
22       */
23      public AnimationConflictData(final Conflict conflict)
24      {
25          super(conflict);
26      }
27  
28      @Override
29      public Color getColor()
30      {
31          switch (getObject().conflictPriority())
32          {
33              case SPLIT:
34                  return Color.BLUE;
35              case PRIORITY:
36                  return Color.GREEN;
37              case YIELD:
38                  return Color.ORANGE;
39              default:
40                  return Color.RED;
41          }
42      }
43  
44      @Override
45      public boolean isCrossing()
46      {
47          return getObject().getConflictType().isCrossing();
48      }
49  
50      @Override
51      public boolean isPermitted()
52      {
53          return getObject().isPermitted();
54      }
55  
56      @Override
57      public String toString()
58      {
59          return "Conflict " + getObject().getLane().getFullId() + " " + getObject().getLongitudinalPosition();
60      }
61  
62  }