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.core.network.Link;
7   import org.opentrafficsim.draw.network.LinkAnimation.LinkData;
8   
9   /**
10   * Animation data of a Link.
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 AnimationLinkData implements LinkData
18  {
19  
20      /** Link. */
21      private final Link link;
22  
23      /**
24       * Constructor.
25       * @param link Link; link.
26       */
27      public AnimationLinkData(final Link link)
28      {
29          this.link = link;
30      }
31  
32      /** {@inheritDoc} */
33      @Override
34      public OtsBounds2d getBounds()
35      {
36          return this.link.getBounds();
37      }
38  
39      /** {@inheritDoc} */
40      @Override
41      public String getId()
42      {
43          return this.link.getId();
44      }
45  
46      /** {@inheritDoc} */
47      @Override
48      public boolean isConnector()
49      {
50          return this.link.isConnector();
51      }
52  
53      /** {@inheritDoc} */
54      @Override
55      public PolyLine2d getDesignLine()
56      {
57          return this.link.getDesignLine().getLine2d();
58      }
59  
60      /** {@inheritDoc} */
61      @Override
62      public OrientedPoint2d getLocation()
63      {
64          return this.link.getLocation();
65      }
66  
67      /**
68       * Returns the link.
69       * @return Link; link.
70       */
71      public Link getLink()
72      {
73          return this.link;
74      }
75  
76      /** {@inheritDoc} */
77      @Override
78      public String toString()
79      {
80          return "Link " + this.link.getId();
81      }
82  
83  }