Class TrafficLightAnimation
java.lang.Object
nl.tudelft.simulation.dsol.animation.d2.Renderable2d<L>
org.opentrafficsim.animation.OtsRenderable<L>
org.opentrafficsim.animation.OtsRenderableLabeled<L,T>
org.opentrafficsim.animation.road.AbstractLineAnimation<TrafficLightAnimation.TrafficLightData,TrafficLightAnimation.Text>
org.opentrafficsim.animation.road.TrafficLightAnimation
- All Implemented Interfaces:
Renderable2dInterface<TrafficLightAnimation.TrafficLightData>
public class TrafficLightAnimation
extends AbstractLineAnimation<TrafficLightAnimation.TrafficLightData,TrafficLightAnimation.Text>
Draw a traffic light on the road at th place where the cars are expected to stop.
Copyright (c) 2013-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classText animation for the TrafficLight.static interfaceTrafficLightData provides the information required to draw a traffic light.Nested classes/interfaces inherited from class org.opentrafficsim.animation.road.AbstractLineAnimation
AbstractLineAnimation.LaneBasedObjectDataNested classes/interfaces inherited from class org.opentrafficsim.animation.OtsRenderableLabeled
OtsRenderableLabeled.NoText<L extends OtsShape> -
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
ConstructorsConstructorDescriptionTrafficLightAnimation(TrafficLightAnimation.TrafficLightData trafficLight, nl.tudelft.simulation.naming.context.Contextualized contextualized) Construct the DefaultCarAnimation for a LaneBlock (road block). -
Method Summary
Modifier and TypeMethodDescriptionprotected TrafficLightAnimation.TextcreateText(TrafficLightAnimation.TrafficLightData source, nl.tudelft.simulation.naming.context.Contextualized contextualized, String prefix) Returns a text object that is co-animated with the object itself.final voidpaint(Graphics2D graphics, ImageObserver observer) final StringtoString()Methods inherited from class org.opentrafficsim.animation.OtsRenderableLabeled
destroy, setDynamicMethods 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, paintComponent, setFlip, setRotate, setScale, setScaleObject, setScaleY, setTranslate
-
Constructor Details
-
TrafficLightAnimation
public TrafficLightAnimation(TrafficLightAnimation.TrafficLightData trafficLight, nl.tudelft.simulation.naming.context.Contextualized contextualized) Construct the DefaultCarAnimation for a LaneBlock (road block).- Parameters:
trafficLight- the traffic lightcontextualized- context provider
-
-
Method Details
-
createText
protected TrafficLightAnimation.Text createText(TrafficLightAnimation.TrafficLightData source, nl.tudelft.simulation.naming.context.Contextualized contextualized, String prefix) Description copied from class:OtsRenderableLabeledReturns 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.- Specified by:
createTextin classOtsRenderableLabeled<TrafficLightAnimation.TrafficLightData,TrafficLightAnimation.Text> - 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
-
paint
- Overrides:
paintin classAbstractLineAnimation<TrafficLightAnimation.TrafficLightData,TrafficLightAnimation.Text>
-
toString
- Overrides:
toStringin classRenderable2d<TrafficLightAnimation.TrafficLightData>
-