View Javadoc
1   package org.opentrafficsim.animation.data;
2   
3   import org.djunits.value.vdouble.scalar.Length;
4   import org.djutils.draw.line.PolyLine2d;
5   import org.djutils.draw.point.OrientedPoint2d;
6   import org.opentrafficsim.draw.road.StripeAnimation.StripeData;
7   import org.opentrafficsim.road.network.lane.Stripe;
8   
9   /**
10   * Animation data of a Stripe.
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 AnimationStripeData extends AnimationCrossSectionElementData<Stripe> implements StripeData
18  {
19  
20      /**
21       * Constructor.
22       * @param stripe Stripe; stripe.
23       */
24      public AnimationStripeData(final Stripe stripe)
25      {
26          super(stripe);
27      }
28  
29      /** {@inheritDoc} */
30      @Override
31      public PolyLine2d getCenterLine()
32      {
33          return getElement().getCenterLine().getLine2d();
34      }
35  
36      /** {@inheritDoc} */
37      @Override
38      public Type getType()
39      {
40          return Type.valueOf(getElement().getType().name());
41      }
42  
43      /** {@inheritDoc} */
44      @Override
45      public OrientedPoint2d getLocation()
46      {
47          return getElement().getLocation();
48      }
49  
50      /** {@inheritDoc} */
51      @Override
52      public Length getWidth()
53      {
54          return getElement().getWidth(0.5);
55      }
56  
57      /** {@inheritDoc} */
58      @Override
59      public String toString()
60      {
61          return "Stripe " + getElement().getLink().getId() + " " + getElement().getOffsetAtBegin();
62      }
63  
64  }