Class OtsRenderableLabeled<L extends OtsShape,T extends RenderableTextSource<L,T>>

Type Parameters:
L - source type
T - 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
  • Constructor Details

    • OtsRenderableLabeled

      public OtsRenderableLabeled(L source, nl.tudelft.simulation.naming.context.Contextualized contextualized)
      Constructor. This constructor uses no label prefix.
      Parameters:
      source - the source
      contextualized - 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 source
      contextualized - the object that can provide the context to store the animation objects
      prefix - prefix for the label
  • Method Details

    • setDynamic

      public OtsRenderableLabeled<L,T> setDynamic(boolean dynamic)
      Sets the animation as dynamic, obtaining geometry at each draw.
      Overrides:
      setDynamic in class OtsRenderable<L extends OtsShape>
      Parameters:
      dynamic - whether the animation is dynamic, false by default
      Returns:
      this animation for method chaining
    • destroy

      public void destroy(nl.tudelft.simulation.naming.context.Contextualized contextProvider)
      Specified by:
      destroy in interface Renderable2dInterface<L extends OtsShape>
      Overrides:
      destroy in class Renderable2d<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 of OtsRenderableLabeled typically define a .Text class that extends RenderableTextSource such 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. The prefix may 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 displayed
      contextualized - context provider
      prefix - prefix for the label
      Returns:
      text renderable, may be null to omit a label