Class MapLaneBasedObjectData
java.lang.Object
org.opentrafficsim.editor.extensions.map.MapData
org.opentrafficsim.editor.extensions.map.MapLaneBasedObjectData
- All Implemented Interfaces:
Serializable
,Remote
,EventListener
,nl.tudelft.simulation.dsol.animation.Locatable
,org.djutils.base.Identifiable
,org.djutils.event.EventListener
,org.opentrafficsim.base.geometry.OtsLocatable
,AbstractLineAnimation.LaneBasedObjectData
,EvalWrapper.EvalListener
- Direct Known Subclasses:
MapGeneratorData
,MapSinkData
,MapTrafficLightData
public abstract class MapLaneBasedObjectData
extends MapData
implements AbstractLineAnimation.LaneBasedObjectData, org.djutils.event.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
- See Also:
-
Constructor Summary
ConstructorDescriptionMapLaneBasedObjectData
(EditorMap map, XsdTreeNode node, OtsEditor editor) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.opentrafficsim.base.geometry.OtsBounds2d
Calculates the bounds.void
destroy()
Destroy this data object, e.g. remove self as listener.void
Notifies the listener that evaluation results may have changed.org.opentrafficsim.base.geometry.OtsBounds2d
getId()
org.djunits.value.vdouble.scalar.Length
protected String
Returns an id in the form {linkId}.org.djutils.draw.point.OrientedPoint2d
void
notify
(org.djutils.event.Event event) protected void
setLinkNode
(XsdTreeNode linkNode) Sets a node as link.Methods inherited from class org.opentrafficsim.editor.extensions.map.MapData
getEval, getMap, getNode, setInvalid, setValid, setValue
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opentrafficsim.draw.road.AbstractLineAnimation.LaneBasedObjectData
getZ
Methods inherited from interface nl.tudelft.simulation.dsol.animation.Locatable
getDirZ
-
Constructor Details
-
MapLaneBasedObjectData
Constructor.- Parameters:
map
- Map; map.node
- XsdTreeNode; node.editor
- OtsEditor; editor.
-
-
Method Details
-
setLinkNode
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
- XsdTreeNode; link node.
-
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. -
getLaneWidth
public org.djunits.value.vdouble.scalar.Length getLaneWidth()- Specified by:
getLaneWidth
in interfaceAbstractLineAnimation.LaneBasedObjectData
-
getLocation
public org.djutils.draw.point.OrientedPoint2d getLocation()- Specified by:
getLocation
in interfaceAbstractLineAnimation.LaneBasedObjectData
- Specified by:
getLocation
in interfacenl.tudelft.simulation.dsol.animation.Locatable
- Specified by:
getLocation
in interfaceorg.opentrafficsim.base.geometry.OtsLocatable
-
getBounds
public org.opentrafficsim.base.geometry.OtsBounds2d getBounds()- Specified by:
getBounds
in interfacenl.tudelft.simulation.dsol.animation.Locatable
- Specified by:
getBounds
in interfaceorg.opentrafficsim.base.geometry.OtsLocatable
-
getId
- Specified by:
getId
in interfaceorg.djutils.base.Identifiable
-
getLinkLanePositionId
Returns an id in the form {linkId}.{laneId}.{id} or {linkId}.{laneId}@{position} if the id is empty.- Returns:
- String; id in link/lane/position form.
-
evalChanged
public void evalChanged()Notifies the listener that evaluation results may have changed.- Specified by:
evalChanged
in interfaceEvalWrapper.EvalListener
-
notify
- Specified by:
notify
in interfaceorg.djutils.event.EventListener
- Throws:
RemoteException
-
calculateBounds
protected org.opentrafficsim.base.geometry.OtsBounds2d calculateBounds()Calculates the bounds. Can be overridden for objects with non-line shapes.- Returns:
- OtsBounds2d; bounds of the object.
-