View Javadoc
1   package org.opentrafficsim.core.network.factory;
2   
3   import java.awt.Dimension;
4   import java.awt.geom.Rectangle2D;
5   import java.rmi.RemoteException;
6   
7   import nl.tudelft.simulation.dsol.ModelInterface;
8   import nl.tudelft.simulation.dsol.SimRuntimeException;
9   import nl.tudelft.simulation.dsol.animation.D2.AnimationPanel;
10  import nl.tudelft.simulation.dsol.experiment.ReplicationMode;
11  import nl.tudelft.simulation.dsol.gui.swing.DSOLApplication;
12  import nl.tudelft.simulation.dsol.gui.swing.DSOLPanel;
13  import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
14  import nl.tudelft.simulation.event.Event;
15  
16  import org.opentrafficsim.core.dsol.OTSDEVSAnimator;
17  import org.opentrafficsim.core.dsol.OTSModelInterface;
18  import org.opentrafficsim.core.dsol.OTSReplication;
19  import org.opentrafficsim.core.dsol.OTSSimTimeDouble;
20  import org.opentrafficsim.core.unit.TimeUnit;
21  import org.opentrafficsim.core.value.vdouble.scalar.DoubleScalar;
22  
23  /**
24   * <p>
25   * Copyright (c) 2013-2014 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
26   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
27   * <p>
28   * @version Oct 16, 2014 <br>
29   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
30   */
31  public class TestXMLParser extends DSOLApplication
32  {
33      /** */
34      private static final long serialVersionUID = 1L;
35  
36      /**
37       * @param title t
38       * @param panel p
39       */
40      public TestXMLParser(final String title,
41          final DSOLPanel<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> panel)
42      {
43          super(title, panel);
44      }
45  
46      /**
47       * @param args args
48       * @throws RemoteException if error
49       * @throws SimRuntimeException if error
50       */
51      public static void main(final String[] args) throws RemoteException, SimRuntimeException
52      {
53          OTSModelInterface model = new TestXMLModel();
54          OTSDEVSAnimator simulator = new OTSDEVSAnimator();
55          OTSReplication replication =
56              new OTSReplication("rep1", new OTSSimTimeDouble(new DoubleScalar.Abs<TimeUnit>(0.0, TimeUnit.SECOND)),
57                  new DoubleScalar.Rel<TimeUnit>(0.0, TimeUnit.SECOND),
58                  new DoubleScalar.Rel<TimeUnit>(1800.0, TimeUnit.SECOND), model);
59          simulator.initialize(replication, ReplicationMode.TERMINATING);
60          DSOLPanel<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> panel =
61              new DSOLPanel<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble>(model, simulator);
62  
63          Rectangle2D extent = new Rectangle2D.Double(-50, -50, 300, 100);
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          animationPanel.notify(new Event(SimulatorInterface.START_REPLICATION_EVENT, simulator, null));
70  
71          new TestXMLParser("TestXMLParser", panel);
72      }
73  
74  }