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  
14  /**
15   * <p>
16   * Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
17   * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
18   * </p>
19   * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
20   * @author <a href="https://tudelft.nl/staff/p.knoppers-1">Peter Knoppers</a>
21   * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
22   */
23  public class TJunctionDemo extends OtsWebServer
24  {
25      /**
26       * Create a T-Junction demo.
27       * @param title String; the tile for the model
28       * @param simulator DevsRealTimeAnimator.TimeDouble; the simulator
29       * @param model the model
30       * @throws Exception on jetty error
31       */
32      public TJunctionDemo(final String title, final OtsSimulatorInterface simulator, final OtsModelInterface model)
33              throws Exception
34      {
35          super(title, simulator, new Bounds2d(-200, 200, -200, 200));
36          DefaultAnimationFactory.animateNetwork(model.getNetwork(), model.getNetwork().getSimulator(),
37                  new DefaultSwitchableGtuColorer());
38      }
39  
40      /**
41       * Start the demo.
42       * @param args args
43       * @throws Exception on error
44       */
45      public static void main(final String[] args) throws Exception
46      {
47          OtsAnimator simulator = new OtsAnimator("TJunctionDemo");
48          simulator.setAnimation(false);
49          TJunctionModel junctionModel = new TJunctionModel(simulator);
50          simulator.initialize(Time.ZERO, Duration.ZERO, Duration.instantiateSI(3600.0), junctionModel);
51          new TJunctionDemo("T-Junction demo", simulator, junctionModel);
52      }
53  }