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.animation.gtu.colorer.DefaultSwitchableGTUColorer;
13 import org.opentrafficsim.core.dsol.OTSAnimator;
14 import org.opentrafficsim.core.dsol.OTSReplication;
15 import org.opentrafficsim.draw.core.OTSDrawingException;
16 import org.opentrafficsim.draw.factory.DefaultAnimationFactory;
17 import org.opentrafficsim.swing.gui.AnimationToggles;
18 import org.opentrafficsim.swing.gui.OTSAnimationPanel;
19 import org.opentrafficsim.swing.gui.OTSSwingApplication;
20
21 import nl.tudelft.simulation.dsol.SimRuntimeException;
22 import nl.tudelft.simulation.dsol.experiment.ReplicationMode;
23 import nl.tudelft.simulation.dsol.simtime.SimTimeDoubleUnit;
24 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
25 import nl.tudelft.simulation.dsol.swing.gui.DSOLApplication;
26 import nl.tudelft.simulation.dsol.swing.gui.DSOLPanel;
27 import nl.tudelft.simulation.event.Event;
28
29
30
31
32
33
34
35
36
37
38 public class ShapeTestApplication extends DSOLApplication implements UNITS
39 {
40
41
42
43
44 public ShapeTestApplication(final String title, final DSOLPanel<Time, Duration, SimTimeDoubleUnit> panel)
45 {
46 super(title, panel);
47 }
48
49
50 private static final long serialVersionUID = 20140819L;
51
52
53
54
55
56
57
58
59 public static void main(final String[] args) throws SimRuntimeException, NamingException, IOException, OTSDrawingException
60 {
61 OTSAnimator simulator = new OTSAnimator();
62 ShapeModel model = new ShapeModel(simulator);
63 OTSReplication replication =
64 OTSReplication.create("rep1", Time.ZERO, Duration.ZERO, new Duration(7200.0, SECOND), model);
65 simulator.initialize(replication, ReplicationMode.TERMINATING);
66
67 DSOLPanel<Time, Duration, SimTimeDoubleUnit> panel = new DSOLPanel<Time, Duration, SimTimeDoubleUnit>(model, simulator);
68
69 Rectangle2D extent = new Rectangle2D.Double(65000.0, 440000.0, 55000.0, 30000.0);
70 Dimension size = new Dimension(1024, 768);
71 OTSAnimationPanel animationPanel =
72 new OTSAnimationPanel(extent, size, simulator, model, new DefaultSwitchableGTUColorer(), model.getNetwork());
73 panel.getTabbedPane().addTab(0, "animation", animationPanel);
74
75 DefaultAnimationFactory.animateNetwork(model.getNetwork(), model.getSimulator(), OTSSwingApplication.DEFAULT_COLORER);
76 AnimationToggles.setTextAnimationTogglesStandard(animationPanel);
77
78
79
80 animationPanel.notify(new Event(SimulatorInterface.START_REPLICATION_EVENT, simulator, null));
81
82 new ShapeTestApplication("Network Transmission Model", panel);
83 }
84
85 }