View Javadoc
1   package org.opentrafficsim.animation.data;
2   
3   import org.djutils.draw.line.Polygon2d;
4   import org.djutils.draw.point.OrientedPoint2d;
5   import org.opentrafficsim.core.network.Node;
6   import org.opentrafficsim.draw.network.NodeAnimation.NodeData;
7   
8   /**
9    * Animation data of a Node.
10   * <p>
11   * Copyright (c) 2023-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
12   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
13   * </p>
14   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
15   */
16  public class AnimationNodeData implements NodeData
17  {
18  
19      /** Node. */
20      private final Node node;
21  
22      /**
23       * Constructor.
24       * @param node node.
25       */
26      public AnimationNodeData(final Node node)
27      {
28          this.node = node;
29      }
30  
31      @Override
32      public Polygon2d getContour()
33      {
34          throw new UnsupportedOperationException("Nodes do not have a drawable contour.");
35      }
36  
37      @Override
38      public String getId()
39      {
40          return this.node.getId();
41      }
42  
43      @Override
44      public OrientedPoint2d getLocation()
45      {
46          return this.node.getLocation();
47      }
48  
49      /**
50       * Returns the node.
51       * @return node.
52       */
53      public Node getNode()
54      {
55          return this.node;
56      }
57  
58      @Override
59      public String toString()
60      {
61          return "Node " + this.node.getId();
62      }
63  
64  }