Class MapData
java.lang.Object
org.opentrafficsim.editor.extensions.map.MapData
- All Implemented Interfaces:
EvalWrapper.EvalListener
- Direct Known Subclasses:
MapLaneBasedObjectData
,MapLinkData
,MapNodeData
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Destroy this data object, e.g. remove self as listener.org.djutils.eval.Eval
getEval()
Returns the evaluator for expressions.protected EditorMap
getMap()
Returns the map.getNode()
Returns the tree node.(package private) void
Notify the map that the element cannot be drawn.(package private) void
setValid()
Notify the map that the element can be drawn.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opentrafficsim.editor.EvalWrapper.EvalListener
evalChanged
-
Constructor Details
-
MapData
Constructor.- Parameters:
map
- Map; map.node
- XsdTreeNode; tree node.editor
- OtsEditor; editor.
-
-
Method Details
-
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
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 isnull
, the setter is invoked to set anull
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 begetNode()
.attribute
- String; name of the attribute.
-