Package org.opentrafficsim.animation
Class OtsRenderableLabeled<L extends OtsShape,T extends RenderableTextSource<L,T>>
java.lang.Object
nl.tudelft.simulation.dsol.animation.d2.Renderable2d<L>
org.opentrafficsim.animation.OtsRenderable<L>
org.opentrafficsim.animation.OtsRenderableLabeled<L,T>
- Type Parameters:
L- source typeT- text renderable type
- All Implemented Interfaces:
Renderable2dInterface<L>
- Direct Known Subclasses:
AbstractLineAnimation,LinkAnimation,NodeAnimation
public abstract class OtsRenderableLabeled<L extends OtsShape,T extends RenderableTextSource<L,T>>
extends OtsRenderable<L>
Renderable with label.
Copyright (c) 2026-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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classOtsRenderableLabeled.NoText<L extends OtsShape>Convenience class to use when the renderable wants to omit having a label. -
Field Summary
Fields inherited from interface nl.tudelft.simulation.dsol.animation.d2.Renderable2dInterface
ANIMATION_OBJECT_COUNTER, FLIP_FLAG, ROTATE_FLAG, SCALE_FLAG, SCALE_OBJECT_FLAG, SCALE_Y_FLAG, TRANSLATE_FLAG -
Constructor Summary
ConstructorsConstructorDescriptionOtsRenderableLabeled(L source, nl.tudelft.simulation.naming.context.Contextualized contextualized) Constructor.OtsRenderableLabeled(L source, nl.tudelft.simulation.naming.context.Contextualized contextualized, String prefix) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TcreateText(L source, nl.tudelft.simulation.naming.context.Contextualized contextualized, String prefix) Returns a text object that is co-animated with the object itself.voiddestroy(nl.tudelft.simulation.naming.context.Contextualized contextProvider) setDynamic(boolean dynamic) Sets the animation as dynamic, obtaining geometry at each draw.Methods inherited from class org.opentrafficsim.animation.OtsRenderable
contains, contains, isDynamic, resetRendering, setRenderingMethods inherited from class nl.tudelft.simulation.dsol.animation.d2.Renderable2d
bind2Context, contains, getId, getSource, isFlip, isRotate, isScale, isScaleObject, isScaleY, isTranslate, paint, paint, paintComponent, setFlip, setRotate, setScale, setScaleObject, setScaleY, setTranslate, toString
-
Constructor Details
-
OtsRenderableLabeled
public OtsRenderableLabeled(L source, nl.tudelft.simulation.naming.context.Contextualized contextualized) Constructor. This constructor uses no label prefix.- Parameters:
source- the sourcecontextualized- the object that can provide the context to store the animation objects
-
OtsRenderableLabeled
public OtsRenderableLabeled(L source, nl.tudelft.simulation.naming.context.Contextualized contextualized, String prefix) Constructor.- Parameters:
source- the sourcecontextualized- the object that can provide the context to store the animation objectsprefix- prefix for the label
-
-
Method Details
-
setDynamic
Sets the animation as dynamic, obtaining geometry at each draw.- Overrides:
setDynamicin classOtsRenderable<L extends OtsShape>- Parameters:
dynamic- whether the animation is dynamic,falseby default- Returns:
- this animation for method chaining
-
destroy
public void destroy(nl.tudelft.simulation.naming.context.Contextualized contextProvider) - Specified by:
destroyin interfaceRenderable2dInterface<L extends OtsShape>- Overrides:
destroyin classRenderable2d<L extends OtsShape>
-
createText
protected abstract T createText(L source, nl.tudelft.simulation.naming.context.Contextualized contextualized, String prefix) Returns a text object that is co-animated with the object itself. Sub-classes ofOtsRenderableLabeledtypically define a.Textclass that extendsRenderableTextSourcesuch that a separate class exists that can be toggled on/off. In this way labels of renderables can be show separately from the object itself. Theprefixmay be ignore depending on the sub-class knowing it provided no prefix to this class, its super class.- Parameters:
source- the object for which the text is displayedcontextualized- context providerprefix- prefix for the label- Returns:
- text renderable, may be
nullto omit a label
-