1 package org.opentrafficsim.demo.conflict;
2
3 import java.rmi.RemoteException;
4
5 import org.opentrafficsim.core.dsol.OtsAnimator;
6 import org.opentrafficsim.core.dsol.OtsSimulatorInterface;
7 import org.opentrafficsim.demo.DefaultsFactory;
8 import org.opentrafficsim.demo.conflict.TurboRoundaboutDemo.TurboRoundaboutModel;
9 import org.opentrafficsim.road.network.factory.xml.OtsXmlModel;
10 import org.opentrafficsim.swing.gui.OtsAnimationPanel;
11 import org.opentrafficsim.swing.gui.OtsSimulationApplication;
12
13 import nl.tudelft.simulation.dsol.SimRuntimeException;
14 import nl.tudelft.simulation.language.DsolException;
15
16
17
18
19
20
21
22
23
24
25 public class TurboRoundaboutDemo extends OtsSimulationApplication<TurboRoundaboutModel>
26 {
27
28 private static final long serialVersionUID = 20161211L;
29
30
31
32
33
34
35
36 public TurboRoundaboutDemo(final String title, final OtsAnimationPanel panel, final TurboRoundaboutModel model)
37 {
38 super(model, panel, DefaultsFactory.GTU_TYPE_MARKERS.toMap());
39 }
40
41
42
43
44
45 public static void main(final String[] args)
46 {
47 demo(true);
48 }
49
50
51
52
53
54 public static void demo(final boolean exitOnClose)
55 {
56 try
57 {
58 OtsAnimator simulator = new OtsAnimator("TurboRoundaboutDemo");
59 final TurboRoundaboutModel junctionModel = new TurboRoundaboutModel(simulator);
60 OtsAnimationPanel animationPanel = new OtsAnimationPanel(junctionModel.getNetwork().getExtent(), simulator,
61 junctionModel, DEFAULT_GTU_COLORERS, junctionModel.getNetwork());
62 TurboRoundaboutDemo app = new TurboRoundaboutDemo("Turbo-Roundabout demo", animationPanel, junctionModel);
63 app.setExitOnClose(exitOnClose);
64 animationPanel.enableSimulationControlButtons();
65 }
66 catch (SimRuntimeException | RemoteException | DsolException exception)
67 {
68 exception.printStackTrace();
69 }
70 }
71
72
73
74
75 public static class TurboRoundaboutModel extends OtsXmlModel
76 {
77
78
79
80
81 public TurboRoundaboutModel(final OtsSimulatorInterface simulator)
82 {
83 super(simulator, "/resources/conflict/TurboRoundabout.xml");
84 }
85 }
86 }