Package org.opentrafficsim.draw.network
Class OTSNetworkAnimationUtils
- java.lang.Object
-
- org.opentrafficsim.draw.network.OTSNetworkAnimationUtils
-
public final class OTSNetworkAnimationUtils extends Object
OTSNetworkAnimationUtils can make a deep clone of a network, including animation, and can destroy the animation.
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
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static OTSNetwork
clone(OTSNetwork network, String newId, SimulatorInterface.TimeDoubleUnit oldSimulator, OTSSimulatorInterface newSimulator)
Clone the OTSNetwork, including animation.static <T extends Locatable>
voidcloneAnimation(Locatable oldSource, T newSource, SimulatorInterface.TimeDoubleUnit oldSimulator, SimulatorInterface.TimeDoubleUnit newSimulator)
Clone all animation objects for the given class.static void
destroy(OTSNetwork network, SimulatorInterface.TimeDoubleUnit simulator)
Remove all objects and animation in the network.static void
removeAnimation(Class<?> clazz, SimulatorInterface.TimeDoubleUnit oldSimulator)
Remove all animation objects of the given class.
-
-
-
Method Detail
-
clone
public static OTSNetwork clone(OTSNetwork network, String newId, SimulatorInterface.TimeDoubleUnit oldSimulator, OTSSimulatorInterface newSimulator) throws NetworkException
Clone the OTSNetwork, including animation.- Parameters:
network
- OTSNetwork; the network to clonenewId
- String; the new id of the networkoldSimulator
- SimulatorInterface.TimeDoubleUnit; the old simulator for this networknewSimulator
- OTSSimulatorInterface; the new simulator for this network- Returns:
- a clone of this network
- Throws:
NetworkException
- in case the cloning fails
-
cloneAnimation
public static <T extends Locatable> void cloneAnimation(Locatable oldSource, T newSource, SimulatorInterface.TimeDoubleUnit oldSimulator, SimulatorInterface.TimeDoubleUnit newSimulator)
Clone all animation objects for the given class. The given class is the source of the animation objects, as it is not known on beforehand which objects need to be cloned. It is important for cloning that the animation objects implement the CloneableRenderable2DInterface, so they can be cloned with their properties. If not, they will not be taken into account for cloning by this method.- Type Parameters:
T
- locatable type- Parameters:
oldSource
- Locatable; the old source object that might have one or more animation objects attached to itnewSource
- T; the new source object to attach the cloned animation objects tooldSimulator
- SimulatorInterface.TimeDoubleUnit; the old simulator when the old objects can be foundnewSimulator
- SimulatorInterface.TimeDoubleUnit; the new simulator where the new simulation objects need to be registered
-
destroy
public static void destroy(OTSNetwork network, SimulatorInterface.TimeDoubleUnit simulator)
Remove all objects and animation in the network.- Parameters:
network
- OTSNetwork; the network to destroysimulator
- SimulatorInterface.TimeDoubleUnit; the simulator of the old network
-
removeAnimation
public static void removeAnimation(Class<?> clazz, SimulatorInterface.TimeDoubleUnit oldSimulator)
Remove all animation objects of the given class.- Parameters:
clazz
- Class<?>; the class to remove the animation objects foroldSimulator
- SimulatorInterface.TimeDoubleUnit; the old simulator
-
-