Class MapData
java.lang.Object
org.djutils.event.LocalEventProducer
org.opentrafficsim.editor.extensions.map.MapData
- All Implemented Interfaces:
nl.tudelft.simulation.dsol.animation.Locatable,EventProducer,OtsShape,EvalWrapper.EvalListener
- Direct Known Subclasses:
MapLaneBasedObjectData,MapLinkData,MapNodeData
public abstract class MapData
extends LocalEventProducer
implements EvalWrapper.EvalListener, OtsShape
Part of the map data structure.
Copyright (c) 2023-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Wouter Schakel
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EventTypeEvent for a change in data that entails a change in visualization.Fields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITIONFields inherited from interface org.opentrafficsim.base.geometry.OtsShape
DEFAULT_POLYGON_SEGMENTS, WORLD_MARGIN_LINE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Destroy this data object, e.g. remove self as listener.getEval()Returns the evaluator for expressions.protected EditorMapgetMap()Returns the map.getNode()Returns the tree node.booleanisValid()Returns whether this data is valid.protected <T> voidsetValue(Consumer<T> setter, ExpressionAdapter<T, ?> adapter, XsdTreeNode treeNode, String attribute) Generic method to set a value based on a changed attribute.Methods inherited from class org.djutils.event.LocalEventProducer
getEventListenerMapMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opentrafficsim.editor.EvalWrapper.EvalListener
evalChangedMethods inherited from interface org.djutils.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners, removeAllListeners, removeListenerMethods inherited from interface nl.tudelft.simulation.dsol.animation.Locatable
getZMethods inherited from interface org.opentrafficsim.base.geometry.OtsShape
contains, contains, getAbsoluteBounds, getAbsoluteContour, getAbsoluteContour, getDirZ, getLocation, getRelativeBounds, getRelativeContour, signedDistance, signedDistance
-
Field Details
-
MAP_DATA_CHANGED
Event for a change in data that entails a change in visualization.
-
-
Constructor Details
-
MapData
Constructor.- Parameters:
map- map.node- tree node.editor- editor.
-
-
Method Details
-
getNode
Returns the tree node.- Returns:
- tree node.
-
getEval
Returns the evaluator for expressions.- Returns:
- 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. -
isValid
public boolean isValid()Returns whether this data is valid.- Returns:
- whether this data is valid
-
getMap
Returns the map.- Returns:
- map.
-
setValue
protected <T> void setValue(Consumer<T> setter, ExpressionAdapter<T, ?> adapter, XsdTreeNode treeNode, String attribute) Generic method to set a value based on a changed attribute. If the new value isnull, the setter is invoked to set anullvalue. 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- setter that receives a successfully derived value.adapter- adapter.treeNode- node that has the attribute, will often begetNode().attribute- name of the attribute.
-