View Javadoc
1   package org.opentrafficsim.web.test;
2   
3   import java.util.Collections;
4   
5   import org.djunits.value.vdouble.scalar.Duration;
6   import org.djunits.value.vdouble.scalar.Time;
7   import org.djutils.draw.bounds.Bounds2d;
8   import org.opentrafficsim.animation.DefaultAnimationFactory;
9   import org.opentrafficsim.core.dsol.OtsAnimator;
10  import org.opentrafficsim.core.dsol.OtsModelInterface;
11  import org.opentrafficsim.core.dsol.OtsSimulatorInterface;
12  import org.opentrafficsim.core.perception.HistoryManagerDevs;
13  
14  import nl.tudelft.simulation.dsol.jetty.sse.OtsWebServer;
15  import nl.tudelft.simulation.dsol.swing.gui.inputparameters.TabbedParameterDialog;
16  
17  /**
18   * Test4DCrossing.java.
19   * <p>
20   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
21   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
22   * </p>
23   * @author <a href="https://github.com/averbraeck" target="_blank">Alexander Verbraeck</a>
24   */
25  public class CircularModelWeb extends OtsWebServer
26  {
27      /**
28       * @param title the tile for the model
29       * @param simulator DevsRealTimeAnimator.TimeDouble; the simulator
30       * @param model the model
31       * @throws Exception on jetty error
32       */
33      public CircularModelWeb(final String title, final OtsSimulatorInterface simulator, final OtsModelInterface model)
34              throws Exception
35      {
36          super(title, simulator, new Bounds2d(-200, 200, -200, 200));
37          DefaultAnimationFactory.animateNetwork(model.getNetwork(), model.getNetwork().getSimulator(),
38                  getAnimationPanel().getGtuColorerManager(), Collections.emptyMap());
39      }
40  
41      /**
42       * @param args arguments, expected to be empty
43       * @throws Exception on error
44       */
45      public static void main(final String[] args) throws Exception
46      {
47          OtsAnimator simulator = new OtsAnimator("CircularModelWeb");
48          simulator.setAnimation(false);
49          CircularRoadModel model = new CircularRoadModel(simulator);
50          if (TabbedParameterDialog.process(model.getInputParameterMap()))
51          {
52              simulator.initialize(Time.ZERO, Duration.ZERO, Duration.instantiateSI(3600.0), model,
53                      HistoryManagerDevs.noHistory(simulator));
54              new CircularModelWeb("Circular Road", simulator, model);
55          }
56      }
57  }