View Javadoc
1   package org.opentrafficsim.animation.data;
2   
3   import org.djutils.draw.point.Point2d;
4   import org.opentrafficsim.base.geometry.BoundingRectangle;
5   import org.opentrafficsim.base.geometry.OtsBounds2d;
6   import org.opentrafficsim.core.gtu.GtuGenerator.GtuGeneratorPosition;
7   import org.opentrafficsim.draw.road.GtuGeneratorPositionAnimation.GtuGeneratorPositionData;
8   
9   /**
10   * Animation data of a GtuGeneratorPosition.
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 AnimationGtuGeneratorPositionData implements GtuGeneratorPositionData
18  {
19  
20      /** Position. */
21      private final GtuGeneratorPosition position;
22  
23      /**
24       * Constructor.
25       * @param position GtuGeneratorPosition; position within a generator.
26       */
27      public AnimationGtuGeneratorPositionData(final GtuGeneratorPosition position)
28      {
29          this.position = position;
30      }
31  
32      /** {@inheritDoc} */
33      @Override
34      public Point2d getLocation()
35      {
36          return this.position.getLocation();
37      }
38  
39      /** {@inheritDoc} */
40      @Override
41      public OtsBounds2d getBounds()
42      {
43          // this correlates to how generators are drawn as three chevrons
44          return new BoundingRectangle(0.0, 4.75, -1.0, 1.0);
45      }
46  
47      /** {@inheritDoc} */
48      @Override
49      public int getQueueCount()
50      {
51          return this.position.getQueueCount();
52      }
53  
54      /**
55       * Returns the generator position.
56       * @return GtuGeneratorPosition; generator position.
57       */
58      public GtuGeneratorPosition getGeneratorPosition()
59      {
60          return this.position;
61      }
62  
63      /** {@inheritDoc} */
64      @Override
65      public String toString()
66      {
67          return "Generator position " + this.position.getId();
68      }
69  
70  }