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