Class MapLaneBasedObjectData

java.lang.Object
org.opentrafficsim.editor.extensions.map.MapData
org.opentrafficsim.editor.extensions.map.MapLaneBasedObjectData
All Implemented Interfaces:
EventListener, nl.tudelft.simulation.dsol.animation.Locatable, Identifiable, EventListener, OtsShape, LineLocatable, AbstractLineAnimation.LaneBasedObjectData, EvalWrapper.EvalListener
Direct Known Subclasses:
MapGeneratorData, MapSinkData, MapTrafficLightData

public abstract class MapLaneBasedObjectData extends MapData implements AbstractLineAnimation.LaneBasedObjectData, EventListener
Data class for objects that are drawn at a lane position. Implementations must call setLinkNode() in their constructor or by some other dynamic means, or the XSD node must have a Link attribute that points to the XSD node of a link by a keyref. This class will listen to attributes Id, Link, Lane and Position, and update visualization as needed. Attributes Id and Link are optional.

Copyright (c) 2023-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

    • MapLaneBasedObjectData

      public MapLaneBasedObjectData(EditorMap map, XsdTreeNode node, OtsEditor editor)
      Constructor.
      Parameters:
      map - map.
      node - node.
      editor - editor.
  • Method Details

    • setLinkNode

      protected void setLinkNode(XsdTreeNode linkNode)
      Sets a node as link. Sub-classes may call this in their constructor if it is a fixed node. This class will listen to changes in the Link attribute, and set a coupled node as link node if it exists.
      Parameters:
      linkNode - link node.
    • destroy

      public void destroy()
      Description copied from class: MapData
      Destroy this data object, e.g. remove self as listener. Override and call super if subclasses remove their own listeners. Using weak references for listeners is another option to deal with obsolete listening.
      Overrides:
      destroy in class MapData
    • getLaneWidth

      public Length getLaneWidth()
      Specified by:
      getLaneWidth in interface AbstractLineAnimation.LaneBasedObjectData
    • getLocation

      public DirectedPoint2d getLocation()
      Specified by:
      getLocation in interface AbstractLineAnimation.LaneBasedObjectData
      Specified by:
      getLocation in interface nl.tudelft.simulation.dsol.animation.Locatable
      Specified by:
      getLocation in interface OtsShape
    • getRelativeBounds

      public Bounds2d getRelativeBounds()
      Specified by:
      getRelativeBounds in interface nl.tudelft.simulation.dsol.animation.Locatable
      Specified by:
      getRelativeBounds in interface OtsShape
    • getAbsoluteContour

      public Polygon2d getAbsoluteContour()
      Specified by:
      getAbsoluteContour in interface OtsShape
    • getRelativeContour

      public Polygon2d getRelativeContour()
      Specified by:
      getRelativeContour in interface OtsShape
    • getLine

      public PolyLine2d getLine()
      Specified by:
      getLine in interface LineLocatable
    • getId

      public String getId()
      Specified by:
      getId in interface Identifiable
    • getLinkLanePositionId

      protected String getLinkLanePositionId()
      Returns an id in the form {linkId}.{laneId}.{id} or {linkId}.{laneId}@{position} if the id is empty.
      Returns:
      id in link/lane/position form.
    • evalChanged

      public void evalChanged()
      Description copied from interface: EvalWrapper.EvalListener
      Notifies the listener that evaluation results may have changed.
      Specified by:
      evalChanged in interface EvalWrapper.EvalListener
    • notify

      public void notify(Event event)
      Specified by:
      notify in interface EventListener