1 package org.opentrafficsim.demo.geometry;
2
3 import java.awt.Dimension;
4 import java.awt.geom.Rectangle2D;
5 import java.rmi.RemoteException;
6
7 import nl.tudelft.simulation.dsol.SimRuntimeException;
8 import nl.tudelft.simulation.dsol.animation.D2.AnimationPanel;
9 import nl.tudelft.simulation.dsol.experiment.ReplicationMode;
10 import nl.tudelft.simulation.dsol.gui.swing.DSOLApplication;
11 import nl.tudelft.simulation.dsol.gui.swing.DSOLPanel;
12 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
13 import nl.tudelft.simulation.event.Event;
14
15 import org.opentrafficsim.core.dsol.OTSDEVSAnimator;
16 import org.opentrafficsim.core.dsol.OTSModelInterface;
17 import org.opentrafficsim.core.dsol.OTSReplication;
18 import org.opentrafficsim.core.dsol.OTSSimTimeDouble;
19 import org.opentrafficsim.core.unit.TimeUnit;
20 import org.opentrafficsim.core.value.vdouble.scalar.DoubleScalar;
21
22
23
24
25
26
27
28
29
30 public class TestGeometry extends DSOLApplication
31 {
32
33 private static final long serialVersionUID = 1L;
34
35
36
37
38
39 public TestGeometry(final String title,
40 final DSOLPanel<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> panel)
41 {
42 super(title, panel);
43 }
44
45
46
47
48
49
50 public static void main(final String[] args) throws RemoteException, SimRuntimeException
51 {
52 OTSModelInterface model = new TestModel();
53 OTSDEVSAnimator simulator = new OTSDEVSAnimator();
54 OTSReplication replication =
55 new OTSReplication("rep1", new OTSSimTimeDouble(new DoubleScalar.Abs<TimeUnit>(0.0, TimeUnit.SECOND)),
56 new DoubleScalar.Rel<TimeUnit>(0.0, TimeUnit.SECOND),
57 new DoubleScalar.Rel<TimeUnit>(1800.0, TimeUnit.SECOND), model);
58 simulator.initialize(replication, ReplicationMode.TERMINATING);
59 DSOLPanel<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble> panel =
60 new DSOLPanel<DoubleScalar.Abs<TimeUnit>, DoubleScalar.Rel<TimeUnit>, OTSSimTimeDouble>(model, simulator);
61
62 Rectangle2D extent = new Rectangle2D.Double(-50, -50, 300, 100);
63 Dimension size = new Dimension(1024, 768);
64 AnimationPanel animationPanel = new AnimationPanel(extent, size, simulator);
65 panel.getTabbedPane().addTab(0, "animation", animationPanel);
66
67
68 animationPanel.notify(new Event(SimulatorInterface.START_REPLICATION_EVENT, simulator, null));
69
70 new TestGeometry("TestGeometry", panel);
71 }
72
73 }