View Javadoc
1   package org.opentrafficsim.web.test;
2   
3   import org.djunits.value.vdouble.scalar.Duration;
4   import org.djunits.value.vdouble.scalar.Time;
5   import org.djutils.draw.bounds.Bounds2d;
6   import org.opentrafficsim.animation.DefaultAnimationFactory;
7   import org.opentrafficsim.animation.gtu.colorer.DefaultSwitchableGtuColorer;
8   import org.opentrafficsim.core.dsol.OtsAnimator;
9   import org.opentrafficsim.core.dsol.OtsModelInterface;
10  import org.opentrafficsim.core.dsol.OtsSimulatorInterface;
11  
12  import nl.tudelft.simulation.dsol.jetty.sse.OtsWebServer;
13  import nl.tudelft.simulation.dsol.swing.gui.inputparameters.TabbedParameterDialog;
14  
15  /**
16   * Test4DCrossing.java.
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" target="_blank">Alexander Verbraeck</a>
22   */
23  public class CircularModelWeb extends OtsWebServer
24  {
25      /**
26       * @param title String; the tile for the model
27       * @param simulator DevsRealTimeAnimator.TimeDouble; the simulator
28       * @param model the model
29       * @throws Exception on jetty error
30       */
31      public CircularModelWeb(final String title, final OtsSimulatorInterface simulator, final OtsModelInterface model)
32              throws Exception
33      {
34          super(title, simulator, new Bounds2d(-200, 200, -200, 200));
35          DefaultAnimationFactory.animateNetwork(model.getNetwork(), model.getNetwork().getSimulator(),
36                  new DefaultSwitchableGtuColorer());
37      }
38  
39      /**
40       * @param args String[]; arguments, expected to be empty
41       * @throws Exception on error
42       */
43      public static void main(final String[] args) throws Exception
44      {
45          OtsAnimator simulator = new OtsAnimator("CircularModelWeb");
46          simulator.setAnimation(false);
47          CircularRoadModel model = new CircularRoadModel(simulator);
48          if (TabbedParameterDialog.process(model.getInputParameterMap()))
49          {
50              simulator.initialize(Time.ZERO, Duration.ZERO, Duration.instantiateSI(3600.0), model);
51              new CircularModelWeb("Circular Road", simulator, model);
52          }
53      }
54  }