View Javadoc
1   package org.opentrafficsim.editor.extensions.map;
2   
3   import org.djutils.draw.bounds.Bounds2d;
4   import org.opentrafficsim.draw.DrawLevel;
5   import org.opentrafficsim.draw.road.GtuGeneratorPositionAnimation.GtuGeneratorPositionData;
6   import org.opentrafficsim.editor.OtsEditor;
7   import org.opentrafficsim.editor.XsdTreeNode;
8   
9   /**
10   * Generator data for the editor Map.
11   * <p>
12   * Copyright (c) 2024-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 MapGeneratorData extends MapLaneBasedObjectData implements GtuGeneratorPositionData
18  {
19  
20      /** */
21      private static final long serialVersionUID = 20240310L;
22  
23      /** Type, 'Generator' or 'List generator'. */
24      private final String type;
25  
26      /** Bounds. */
27      private Bounds2d bounds = new Bounds2d(0.0, 4.75, -1.0, 1.0);
28  
29      /**
30       * Constructor.
31       * @param map map.
32       * @param node node.
33       * @param editor editor.
34       */
35      public MapGeneratorData(final EditorMap map, final XsdTreeNode node, final OtsEditor editor)
36      {
37          super(map, node, editor);
38          this.type = node.getNodeName().equals("Generator") ? "Generator " : "List generator ";
39      }
40  
41      @Override
42      public Bounds2d getBounds()
43      {
44          return this.bounds;
45      }
46  
47      @Override
48      public int getQueueCount()
49      {
50          return 0;
51      }
52  
53      @Override
54      public double getZ()
55      {
56          return DrawLevel.OBJECT.getZ();
57      }
58  
59      @Override
60      public String toString()
61      {
62          return this.type + getLinkLanePositionId();
63      }
64  
65  }