package nl.tudelft.simulation.dsol.animation.D2; import nl.tudelft.simulation.dsol.logger.SimLogger; import nl.tudelft.simulation.dsol.simulators.SimulatorInterface; /** *

* Copyright (c) 2002-2018 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights * reserved. See for project information * https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can * be found at * https://simulation.tudelft.nl/dsol/3.0/license.html. *

* @author Mingxin Zhang * @author Alexander Verbraeck */ public class Animation { /** * @param frameName the name to use for the frame * @param simulator the simulator. */ public Animation(final String frameName, final SimulatorInterface simulator) { try { boolean running = false; try { if (simulator.isRunning()) { running = true; simulator.stop(); } } catch (NullPointerException nullPointerException) { // This was meant to happen nullPointerException = null; } new AnimationFrame(frameName, simulator); if (running) { simulator.start(); } } catch (Exception exception) { SimLogger.always().warn(exception, "actionPerformed"); } } }