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-2022 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 org.opentrafficsim.core.network.OTSNetwork clone​(org.opentrafficsim.core.network.OTSNetwork network, String newId, org.opentrafficsim.core.dsol.OTSSimulatorInterface oldSimulator, org.opentrafficsim.core.dsol.OTSSimulatorInterface newSimulator)
      Clone the OTSNetwork, including animation.
      static <T extends Locatable>
      void
      cloneAnimation​(Locatable oldSource, T newSource, org.opentrafficsim.core.dsol.OTSSimulatorInterface oldSimulator, org.opentrafficsim.core.dsol.OTSSimulatorInterface newSimulator)
      Clone all animation objects for the given class.
      static void destroy​(org.opentrafficsim.core.network.OTSNetwork network, org.opentrafficsim.core.dsol.OTSSimulatorInterface simulator)
      Remove all objects and animation in the network.
      static void removeAnimation​(Class<?> clazz, org.opentrafficsim.core.dsol.OTSSimulatorInterface oldSimulator)
      Remove all animation objects of the given class.
    • Method Detail

      • clone

        public static org.opentrafficsim.core.network.OTSNetwork clone​(org.opentrafficsim.core.network.OTSNetwork network,
                                                                       String newId,
                                                                       org.opentrafficsim.core.dsol.OTSSimulatorInterface oldSimulator,
                                                                       org.opentrafficsim.core.dsol.OTSSimulatorInterface newSimulator)
                                                                throws org.opentrafficsim.core.network.NetworkException
        Clone the OTSNetwork, including animation.
        Parameters:
        network - OTSNetwork; the network to clone
        newId - String; the new id of the network
        oldSimulator - OTSSimulatorInterface; the old simulator for this network
        newSimulator - OTSSimulatorInterface; the new simulator for this network
        Returns:
        a clone of this network
        Throws:
        org.opentrafficsim.core.network.NetworkException - in case the cloning fails
      • cloneAnimation

        public static <T extends Locatable> void cloneAnimation​(Locatable oldSource,
                                                                T newSource,
                                                                org.opentrafficsim.core.dsol.OTSSimulatorInterface oldSimulator,
                                                                org.opentrafficsim.core.dsol.OTSSimulatorInterface 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 - OTSSimulatorInterface; the old simulator when the old objects can be found
        newSimulator - OTSSimulatorInterface; the new simulator where the new simulation objects need to be registered
      • destroy

        public static void destroy​(org.opentrafficsim.core.network.OTSNetwork network,
                                   org.opentrafficsim.core.dsol.OTSSimulatorInterface simulator)
        Remove all objects and animation in the network.
        Parameters:
        network - OTSNetwork; the network to destroy
        simulator - OTSSimulatorInterface; the simulator of the old network
      • removeAnimation

        public static void removeAnimation​(Class<?> clazz,
                                           org.opentrafficsim.core.dsol.OTSSimulatorInterface oldSimulator)
        Remove all animation objects of the given class.
        Parameters:
        clazz - Class<?>; the class to remove the animation objects for
        oldSimulator - OTSSimulatorInterface; the old simulator