Record Class StripeElement

java.lang.Object
java.lang.Record
org.opentrafficsim.base.StripeElement
Record Components:
width - width
color - color
dashes - dashes

public record StripeElement(Length width, Color color, LengthVector dashes) extends Record
Data container for an element of a stripe road marking. Elements can be continuous lines, dashed lines, or gaps between lines. For example, this can entail a complicated road marking consisting of a continuous line, a narrow gap, a colored wide area (included as a wide line), a narrow gap, and a dashed line.

Copyright (c) 2024-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Wouter Schakel
  • Constructor Details

    • StripeElement

      public StripeElement(Length width, Color color, LengthVector dashes)
      Constructor checks.
      Parameters:
      width - width
      color - color
      dashes - dashes
  • Method Details

    • continuous

      public static StripeElement continuous(Length width, Color color)
      Creates a continuous stripe element.
      Parameters:
      width - width
      color - color
      Returns:
      continuous stripe element
    • dashed

      public static StripeElement dashed(Length width, Color color, LengthVector dashes)
      Creates a dashed stripe element.
      Parameters:
      width - width
      color - color
      dashes - dashes (gap, dash, gap, dash, ...)
      Returns:
      dashed stripe element
    • gap

      public static StripeElement gap(Length width)
      Creates a gap stripe element.
      Parameters:
      width - width
      Returns:
      gap stripe element
    • isContinuous

      public boolean isContinuous()
      Returns whether this is a continuous stripe element (i.e. a line without dashes).
      Returns:
      whether this is a continuous stripe element
    • isGap

      public boolean isGap()
      Returns whether this is a gap stripe element.
      Returns:
      whether this is a gap stripe element
    • isDashed

      public boolean isDashed()
      Returns whether this is a dashed stripe element.
      Returns:
      whether this is a dashed stripe element
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • width

      public Length width()
      Returns the value of the width record component.
      Returns:
      the value of the width record component
    • color

      public Color color()
      Returns the value of the color record component.
      Returns:
      the value of the color record component
    • dashes

      public LengthVector dashes()
      Returns the value of the dashes record component.
      Returns:
      the value of the dashes record component