View Javadoc
1   package org.opentrafficsim.demo.geometry.shape;
2   
3   import java.awt.Dimension;
4   import java.awt.geom.Rectangle2D;
5   import java.io.IOException;
6   
7   import javax.naming.NamingException;
8   
9   import org.djunits.unit.UNITS;
10  import org.djunits.value.vdouble.scalar.Duration;
11  import org.djunits.value.vdouble.scalar.Time;
12  import org.opentrafficsim.core.dsol.OTSReplication;
13  
14  import nl.tudelft.simulation.dsol.SimRuntimeException;
15  import nl.tudelft.simulation.dsol.animation.D2.AnimationPanel;
16  import nl.tudelft.simulation.dsol.experiment.ReplicationMode;
17  import nl.tudelft.simulation.dsol.gui.swing.DSOLApplication;
18  import nl.tudelft.simulation.dsol.gui.swing.DSOLPanel;
19  import nl.tudelft.simulation.dsol.simtime.SimTimeDoubleUnit;
20  import nl.tudelft.simulation.dsol.simulators.DEVSAnimator;
21  import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
22  import nl.tudelft.simulation.event.Event;
23  
24  /**
25   * <p>
26   * Copyright (c) 2013-2018 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
27   * BSD-style license. See <a href="http://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
28   * <p>
29   * $LastChangedDate: 2018-09-19 13:55:45 +0200 (Wed, 19 Sep 2018) $, @version $Revision: 4006 $, by $Author: averbraeck $,
30   * initial version Aug 15, 2014 <br>
31   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
32   */
33  public class ShapeTestApplication extends DSOLApplication implements UNITS
34  {
35      /**
36       * @param title String title of the application window
37       * @param panel DSOLPanel
38       */
39      public ShapeTestApplication(final String title, final DSOLPanel<Time, Duration, SimTimeDoubleUnit> panel)
40      {
41          super(title, panel);
42      }
43  
44      /** */
45      private static final long serialVersionUID = 20140819L;
46  
47      /**
48       * @param args String[]; command line arguments
49       * @throws SimRuntimeException on ???
50       * @throws NamingException on ???
51       * @throws IOException on ???
52       */
53      public static void main(final String[] args) throws SimRuntimeException, NamingException, IOException
54      {
55          ShapeModel model = new ShapeModel();
56          DEVSAnimator simulator = new DEVSAnimator();
57          OTSReplication replication = new OTSReplication("rep1", new SimTimeDoubleUnit(Time.ZERO), Duration.ZERO,
58                  new Duration(7200.0, SECOND), model);
59          simulator.initialize(replication, ReplicationMode.TERMINATING);
60  
61          DSOLPanel<Time, Duration, SimTimeDoubleUnit> panel = new DSOLPanel<Time, Duration, SimTimeDoubleUnit>(model, simulator);
62  
63          Rectangle2D extent = new Rectangle2D.Double(65000.0, 440000.0, 55000.0, 30000.0);
64          Dimension size = new Dimension(1024, 768);
65          AnimationPanel animationPanel = new AnimationPanel(extent, size, simulator);
66          panel.getTabbedPane().addTab(0, "animation", animationPanel);
67  
68          // tell the animation panel to update its statistics
69          // TODO should be done automatically in DSOL!
70          animationPanel.notify(new Event(SimulatorInterface.START_REPLICATION_EVENT, simulator, null));
71  
72          new ShapeTestApplication("Network Transmission Model", panel);
73      }
74  
75  }