View Javadoc
1   package org.opentrafficsim.animation.data;
2   
3   import org.djutils.draw.point.Point2d;
4   import org.opentrafficsim.draw.road.PriorityAnimation.PriorityData;
5   import org.opentrafficsim.road.network.lane.CrossSectionLink;
6   
7   /**
8    * Priority data for animation.
9    * <p>
10   * Copyright (c) 2024-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
11   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
12   * </p>
13   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
14   */
15  public class AnimationPriorityData implements PriorityData
16  {
17  
18      /** Link. */
19      final private CrossSectionLink link;
20  
21      /**
22       * Constructor.
23       * @param link CrossSectionLink; link.
24       */
25      public AnimationPriorityData(final CrossSectionLink link)
26      {
27          this.link = link;
28      }
29  
30      /** {@inheritDoc} */
31      @Override
32      public Point2d getLocation()
33      {
34          return this.link.getDesignLine().getLocationFractionExtended(0.5);
35      }
36  
37      /** {@inheritDoc} */
38      @Override
39      public boolean isAllStop()
40      {
41          return this.link.getPriority().isAllStop();
42      }
43  
44      /** {@inheritDoc} */
45      @Override
46      public boolean isBusStop()
47      {
48          return this.link.getPriority().isBusStop();
49      }
50  
51      /** {@inheritDoc} */
52      @Override
53      public boolean isNone()
54      {
55          return this.link.getPriority().isNone();
56      }
57  
58      /** {@inheritDoc} */
59      @Override
60      public boolean isPriority()
61      {
62          return this.link.getPriority().isPriority();
63      }
64  
65      /** {@inheritDoc} */
66      @Override
67      public boolean isStop()
68      {
69          return this.link.getPriority().isStop();
70      }
71  
72      /** {@inheritDoc} */
73      @Override
74      public boolean isYield()
75      {
76          return this.link.getPriority().isYield();
77      }
78  
79      /** {@inheritDoc} */
80      @Override
81      public String toString()
82      {
83          return "Priority " + this.link.getId();
84      }
85  
86  }