View Javadoc
1   package org.opentrafficsim.animation.data;
2   
3   import org.djutils.draw.line.PolyLine2d;
4   import org.djutils.draw.point.OrientedPoint2d;
5   import org.opentrafficsim.base.geometry.OtsBounds2d;
6   import org.opentrafficsim.draw.road.TrafficLightDetectorAnimation.TrafficLightDetectorData;
7   import org.opentrafficsim.road.network.lane.object.detector.TrafficLightDetector;
8   
9   /**
10   * Animation data of a TrafficLightDetector.
11   * <p>
12   * Copyright (c) 2023-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
13   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
14   * </p>
15   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
16   */
17  public class AnimationTrafficLightDetectorData implements TrafficLightDetectorData
18  {
19  
20      /** Traffic light detector. */
21      private final TrafficLightDetector trafficLigthDetector;
22  
23      /**
24       * Constructor.
25       * @param trafficLigthDetector TrafficLightDetector; traffic light detector.
26       */
27      public AnimationTrafficLightDetectorData(final TrafficLightDetector trafficLigthDetector)
28      {
29          this.trafficLigthDetector = trafficLigthDetector;
30      }
31  
32      /** {@inheritDoc} */
33      @Override
34      public OrientedPoint2d getLocation()
35      {
36          return this.trafficLigthDetector.getLocation();
37      }
38  
39      /** {@inheritDoc} */
40      @Override
41      public OtsBounds2d getBounds()
42      {
43          return this.trafficLigthDetector.getBounds();
44      }
45  
46      /** {@inheritDoc} */
47      @Override
48      public PolyLine2d getGeometry()
49      {
50          return this.trafficLigthDetector.getGeometry();
51      }
52  
53      /** {@inheritDoc} */
54      @Override
55      public boolean getOccupancy()
56      {
57          return this.trafficLigthDetector.getOccupancy();
58      }
59  
60      /** {@inheritDoc} */
61      @Override
62      public String getId()
63      {
64          return this.trafficLigthDetector.getId();
65      }
66  
67      /**
68       * Returns the traffic light detector.
69       * @return TrafficLightDetector; traffic light detector.
70       */
71      public TrafficLightDetector getTrafficLightDetector()
72      {
73          return this.trafficLigthDetector;
74      }
75  
76      /** {@inheritDoc} */
77      @Override
78      public String toString()
79      {
80          return "Traffic light detector " + this.trafficLigthDetector.getId();
81      }
82  
83  }