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