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.OTSDEVSAnimator;
13  import org.opentrafficsim.core.dsol.OTSReplication;
14  import org.opentrafficsim.core.dsol.OTSSimTimeDouble;
15  
16  import nl.tudelft.simulation.dsol.SimRuntimeException;
17  import nl.tudelft.simulation.dsol.animation.D2.AnimationPanel;
18  import nl.tudelft.simulation.dsol.experiment.ReplicationMode;
19  import nl.tudelft.simulation.dsol.gui.swing.DSOLApplication;
20  import nl.tudelft.simulation.dsol.gui.swing.DSOLPanel;
21  import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
22  import nl.tudelft.simulation.event.Event;
23  
24  /**
25   * <p>
26   * Copyright (c) 2013-2017 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: 2017-04-28 03:35:59 +0200 (Fri, 28 Apr 2017) $, @version $Revision: 3569 $, 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, OTSSimTimeDouble> 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          OTSDEVSAnimator simulator = new OTSDEVSAnimator();
57          OTSReplication replication = new OTSReplication("rep1", new OTSSimTimeDouble(Time.ZERO),
58                  Duration.ZERO, new Duration(7200.0, SECOND), model);
59          simulator.initialize(replication, ReplicationMode.TERMINATING);
60  
61          DSOLPanel<Time, Duration, OTSSimTimeDouble> panel = new DSOLPanel<Time, Duration, OTSSimTimeDouble>(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  }