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
26
27
28
29
30
31
32
33 public class ShapeTestApplication extends DSOLApplication implements UNITS
34 {
35
36
37
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
49
50
51
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(new Time(0.0, SECOND)),
58 new Duration(0.0, SECOND), 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
69
70 animationPanel.notify(new Event(SimulatorInterface.START_REPLICATION_EVENT, simulator, null));
71
72 new ShapeTestApplication("Network Transmission Model", panel);
73 }
74
75 }