Package org.opentrafficsim.draw.factory
Class DefaultAnimationFactory
- java.lang.Object
-
- org.opentrafficsim.draw.factory.DefaultAnimationFactory
-
- All Implemented Interfaces:
java.io.Serializable
,java.util.EventListener
,EventListenerInterface
public class DefaultAnimationFactory extends java.lang.Object implements EventListenerInterface
DefaultAnimationFactory.java.
Copyright (c) 2003-2020 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information www.simulation.tudelft.nl. The source code and binary code of this software is proprietary information of Delft University of Technology.- Author:
- Alexander Verbraeck
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description java.util.Map<ObjectInterface,Renderable2D<?>>
animatedObjects
rendered static objects.
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultAnimationFactory(OTSNetwork network, GTUColorer gtuColorer, boolean animateNetwork)
Creates animations for nodes, links and lanes.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
animateGTU(LaneBasedGTU gtu)
Draw the GTU (scheduled method).protected void
animateGTUGenerator(GtuGenerator gtuGenerator)
Draw the GTUGenerator.static DefaultAnimationFactory
animateNetwork(OTSNetwork network, OTSSimulatorInterface simulator, GTUColorer gtuColorer)
Creates animations for nodes, links, lanes and GTUs.protected void
animateStaticObject(ObjectInterface object)
Draw the static object.static DefaultAnimationFactory
animateXmlNetwork(OTSNetwork network, GTUColorer gtuColorer)
Creates animations for nodes, links, lanes and GTUs.void
notify(EventInterface event)
-
-
-
Field Detail
-
animatedObjects
public java.util.Map<ObjectInterface,Renderable2D<?>> animatedObjects
rendered static objects.
-
-
Constructor Detail
-
DefaultAnimationFactory
protected DefaultAnimationFactory(OTSNetwork network, GTUColorer gtuColorer, boolean animateNetwork) throws OTSDrawingException
Creates animations for nodes, links and lanes. The class will subscribe to the network and listen to changes, so the adding and removing of GTUs and Objects is animated correctly.- Parameters:
network
- OTSNetwork; the networkgtuColorer
- GTUColorer; GTU coloreranimateNetwork
- boolean; whether to animate the current network objects- Throws:
OTSDrawingException
- on drawing error
-
-
Method Detail
-
animateNetwork
public static DefaultAnimationFactory animateNetwork(OTSNetwork network, OTSSimulatorInterface simulator, GTUColorer gtuColorer) throws OTSDrawingException
Creates animations for nodes, links, lanes and GTUs. This can be used if the network is not read from XML. The class will subscribe to the network and listen to changes, so the adding and removing of GTUs and Objects is animated correctly.- Parameters:
network
- OTSNetwork; the networksimulator
- OTSSimulatorInterface; the simulatorgtuColorer
- GTUColorer; GTU colorer- Returns:
- the DefaultAnimationFactory
- Throws:
OTSDrawingException
- on drawing error
-
animateXmlNetwork
public static DefaultAnimationFactory animateXmlNetwork(OTSNetwork network, GTUColorer gtuColorer) throws OTSDrawingException
Creates animations for nodes, links, lanes and GTUs. This can be used if the network is read from XML. The class will subscribe to the network and listen to changes, so the adding and removing of GTUs and Objects is animated correctly.- Parameters:
network
- OTSNetwork; the networkgtuColorer
- GTUColorer; GTU colorer- Returns:
- the DefaultAnimationFactory
- Throws:
OTSDrawingException
- on drawing error
-
notify
public void notify(EventInterface event) throws java.rmi.RemoteException
- Specified by:
notify
in interfaceEventListenerInterface
- Throws:
java.rmi.RemoteException
-
animateGTU
protected void animateGTU(LaneBasedGTU gtu)
Draw the GTU (scheduled method).- Parameters:
gtu
- LaneBasedGTU; the GTU to draw
-
animateStaticObject
protected void animateStaticObject(ObjectInterface object)
Draw the static object.- Parameters:
object
- ObjectInterface; the object to draw
-
animateGTUGenerator
protected void animateGTUGenerator(GtuGenerator gtuGenerator)
Draw the GTUGenerator.- Parameters:
gtuGenerator
- GtuGenerator; the GTUGenerator to draw
-
-