package nl.tudelft.simulation.dsol.animation.D2; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import nl.tudelft.simulation.dsol.simulators.SimulatorInterface; /** *
* Copyright (c) 2014 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. * The MEDLABS project (Modeling Epidemic Disease with Large-scale Agent-Based Simulation) is aimed at providing policy * analysis tools to predict and help contain the spread of epidemics. It makes use of the DSOL simulation engine and * the agent-based modeling formalism. See for project information * www.simulation.tudelft.nl. The project is a co-operation between TU Delft, Systems Engineering and Simulation * Department (Netherlands) and NUDT, Simulation Engineering Department (China). This software is licensed under the BSD * license. See license.txt in the main project. * @version Apr 30, 2014
* @author Mingxin Zhang * @author Alexander Verbraeck */ public class Animation { /** the logger. */ private static Logger logger = LogManager.getLogger(Animation.class); /** * @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) { logger.warn("actionPerformed", exception); } } }