Class 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 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 clone
        newId - String; the new id of the network
        oldSimulator - SimulatorInterface.TimeDoubleUnit; the old simulator for this network
        newSimulator - 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 it
        newSource - T; the new source object to attach the cloned animation objects to
        oldSimulator - SimulatorInterface.TimeDoubleUnit; the old simulator when the old objects can be found
        newSimulator - 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 destroy
        simulator - 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 for
        oldSimulator - SimulatorInterface.TimeDoubleUnit; the old simulator