View Javadoc
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   * <p>
18   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
19   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
20   * </p>
21   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
22   * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
23   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
24   */
25  public class TurboRoundaboutDemo extends OtsSimulationApplication<TurboRoundaboutModel>
26  {
27      /** */
28      private static final long serialVersionUID = 20161211L;
29  
30      /**
31       * Create a T-Junction demo.
32       * @param title the title of the Frame
33       * @param panel the tabbed panel to display
34       * @param model the model
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       * Main program.
43       * @param args the command line arguments (not used)
44       */
45      public static void main(final String[] args)
46      {
47          demo(true);
48      }
49  
50      /**
51       * Start the demo.
52       * @param exitOnClose when running stand-alone: true; when running as part of a demo: false
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       * The simulation model.
74       */
75      public static class TurboRoundaboutModel extends OtsXmlModel
76      {
77          /**
78           * Constructor.
79           * @param simulator the simulator for this model
80           */
81          public TurboRoundaboutModel(final OtsSimulatorInterface simulator)
82          {
83              super(simulator, "/resources/conflict/TurboRoundabout.xml");
84          }
85      }
86  }