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.djutils.draw.bounds.Bounds2d;
7   import org.opentrafficsim.animation.data.util.DefaultAnimationFactory;
8   import org.opentrafficsim.core.dsol.OtsAnimator;
9   import org.opentrafficsim.core.dsol.OtsModelInterface;
10  import org.opentrafficsim.core.dsol.OtsSimulatorInterface;
11  import org.opentrafficsim.core.perception.HistoryManagerDevs;
12  import org.opentrafficsim.web.OtsWebServer;
13  
14  import nl.tudelft.simulation.dsol.swing.gui.inputparameters.TabbedParameterDialog;
15  
16  /**
17   * Test4DCrossing.java.
18   * <p>
19   * Copyright (c) 2013-2026 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
20   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
21   * </p>
22   * @author Alexander Verbraeck
23   */
24  public class CircularModelWeb extends OtsWebServer
25  {
26      /**
27       * Constructor.
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       * Main method.
43       * @param args arguments, expected to be empty
44       * @throws Exception on error
45       */
46      public static void main(final String[] args) throws Exception
47      {
48          OtsAnimator simulator = new OtsAnimator("CircularModelWeb");
49          simulator.setAnimation(false);
50          CircularRoadModel model = new CircularRoadModel(simulator);
51          if (TabbedParameterDialog.process(model.getInputParameterMap()))
52          {
53              simulator.initialize(Duration.ZERO, Duration.ZERO, Duration.ofSI(3600.0), model,
54                      HistoryManagerDevs.noHistory(simulator));
55              new CircularModelWeb("Circular Road", simulator, model);
56          }
57      }
58  }