package nl.tudelft.simulation.examples.dsol.animation; import java.awt.Dimension; import java.awt.geom.Rectangle2D; import java.rmi.RemoteException; import javax.naming.NamingException; import nl.tudelft.simulation.dsol.SimRuntimeException; import nl.tudelft.simulation.dsol.experiment.Replication; import nl.tudelft.simulation.dsol.experiment.ReplicationMode; import nl.tudelft.simulation.dsol.simtime.SimTimeDouble; import nl.tudelft.simulation.dsol.simulators.DEVSRealTimeClock; import nl.tudelft.simulation.dsol.simulators.DEVSSimulatorInterface; import nl.tudelft.simulation.dsol.swing.animation.D2.AnimationPanel; import nl.tudelft.simulation.dsol.swing.gui.DSOLApplication; import nl.tudelft.simulation.dsol.swing.gui.DSOLPanel; import nl.tudelft.simulation.language.DSOLException; /** *

* Copyright (c) 2002-2020 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 Alexander Verbraeck */ public class BallSwingApplication extends DSOLApplication { /** * @param title String; the title * @param panel DSOLPanel<Double,Double,SimTimeDouble>; the panel */ public BallSwingApplication(final String title, final DSOLPanel panel) { super(title, panel); } /** */ private static final long serialVersionUID = 1L; /** * @param args String[]; arguments, expected to be empty * @throws SimRuntimeException on error * @throws RemoteException on error * @throws NamingException on error * @throws DSOLException when simulator is not an animator */ public static void main(final String[] args) throws SimRuntimeException, RemoteException, NamingException, DSOLException { DEVSRealTimeClock.TimeDouble simulator = new DEVSRealTimeClock.TimeDouble("BallSwingApplication", 0.001); BallModel model = new BallModel(simulator); Replication.TimeDouble replication = Replication.TimeDouble.create("rep1", 0.0, 0.0, 1000000.0, model); DSOLPanel panel = new DSOLPanel(model, simulator); panel.getTabbedPane().add("animation", new AnimationPanel(new Rectangle2D.Double(-100, -100, 200, 200), new Dimension(200, 200), simulator)); panel.getTabbedPane().setSelectedIndex(1); simulator.initialize(replication, ReplicationMode.TERMINATING); new BallSwingApplication("Ball Animation model", panel); } }