java.lang.Object
org.opentrafficsim.editor.extensions.map.MapData
All Implemented Interfaces:
EvalWrapper.EvalListener
Direct Known Subclasses:
MapLaneBasedObjectData, MapLinkData, MapNodeData

public abstract class MapData extends Object implements EvalWrapper.EvalListener
Part of the map data structure.

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

    • MapData

      public MapData(EditorMap map, XsdTreeNode node, OtsEditor editor)
      Constructor.
      Parameters:
      map - Map; map.
      node - XsdTreeNode; tree node.
      editor - OtsEditor; editor.
  • Method Details

    • getNode

      public XsdTreeNode getNode()
      Returns the tree node.
      Returns:
      XsdTreeNode; tree node.
    • getEval

      public org.djutils.eval.Eval getEval()
      Returns the evaluator for expressions.
      Returns:
      Eval; evaluator for expressions.
    • destroy

      public void destroy()
      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.
    • setValid

      void setValid()
      Notify the map that the element can be drawn.
    • setInvalid

      void setInvalid()
      Notify the map that the element cannot be drawn.
    • getMap

      protected EditorMap getMap()
      Returns the map.
      Returns:
      Map; map.
    • setValue

      protected <T> void setValue(Consumer<T> setter, ExpressionAdapter<T,?> adapter, XsdTreeNode node, String attribute)
      Generic method to set a value based on a changed attribute. If the new value is null, the setter is invoked to set a null value. If the value is an invalid expression, or the value cannot be unmarshalled by the adapter, no change is made.
      Type Parameters:
      T - type of the value to set.
      Parameters:
      setter - Consumer<T>; setter that receives a successfully derived value.
      adapter - ExpressionAdapter<T, ?>; adapter.
      node - XsdTreeNode; node that has the attribute, will often be getNode().
      attribute - String; name of the attribute.