View Javadoc
1   package org.opentrafficsim.editor.extensions.map;
2   
3   import org.djunits.value.vdouble.scalar.Length;
4   import org.djutils.draw.line.PolyLine2d;
5   import org.djutils.draw.line.Polygon2d;
6   import org.opentrafficsim.draw.road.StripeAnimation.StripeData;
7   import org.opentrafficsim.editor.XsdTreeNode;
8   import org.opentrafficsim.road.network.lane.SliceInfo;
9   
10  /**
11   * Stripe data for in the editor.
12   * <p>
13   * Copyright (c) 2023-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
14   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
15   * </p>
16   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
17   */
18  public class MapStripeData extends MapCrossSectionData implements StripeData
19  {
20  
21      /** Stripe type. */
22      private final Type type;
23  
24      /** Width. */
25      private final Length width;
26  
27      /** Start offset. */
28      private final Length startOffset;
29  
30      /**
31       * Constructor.
32       * @param type Type; stripe type.
33       * @param width Length; width.
34       * @param startOffset Length; start offset.
35       * @param linkNode XsdTreeNode; node representing the element.
36       * @param centerLine PolyLine2d; center line.
37       * @param contour PolyLine2d; contour.
38       * @param sliceInfo SliceInfo; slice info.
39       */
40      public MapStripeData(final Type type, final Length width, final Length startOffset, final XsdTreeNode linkNode,
41              final PolyLine2d centerLine, final Polygon2d contour, final SliceInfo sliceInfo)
42      {
43          super(linkNode, centerLine, contour, sliceInfo);
44          this.type = type;
45          this.width = width;
46          this.startOffset = startOffset;
47      }
48  
49      /** {@inheritDoc} */
50      @Override
51      public PolyLine2d getCenterLine()
52      {
53          return this.centerLine;
54      }
55  
56      /** {@inheritDoc} */
57      @Override
58      public Type getType()
59      {
60          return this.type;
61      }
62  
63      /** {@inheritDoc} */
64      @Override
65      public Length getWidth()
66      {
67          return this.width;
68      }
69  
70      /** {@inheritDoc} */
71      @Override
72      public String toString()
73      {
74          return "Stripe " + getLinkId() + " " + this.startOffset;
75      }
76  
77  }