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  
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 TJunctionDemo extends OtsWebServer
26  {
27      /**
28       * Create a T-Junction demo.
29       * @param title the tile for the model
30       * @param simulator DevsRealTimeAnimator.TimeDouble; the simulator
31       * @param model the model
32       * @throws Exception on jetty error
33       */
34      public TJunctionDemo(final String title, final OtsSimulatorInterface simulator, final OtsModelInterface model)
35              throws Exception
36      {
37          super(title, simulator, new Bounds2d(-200, 200, -200, 200));
38          DefaultAnimationFactory.animateNetwork(model.getNetwork(), model.getNetwork().getSimulator(),
39                  getAnimationPanel().getGtuColorerManager(), Collections.emptyMap());
40      }
41  
42      /**
43       * Start the demo.
44       * @param args args
45       * @throws Exception on error
46       */
47      public static void main(final String[] args) throws Exception
48      {
49          OtsAnimator simulator = new OtsAnimator("TJunctionDemo");
50          simulator.setAnimation(false);
51          TJunctionModel junctionModel = new TJunctionModel(simulator);
52          simulator.initialize(Time.ZERO, Duration.ZERO, Duration.instantiateSI(3600.0), junctionModel,
53                  HistoryManagerDevs.noHistory(simulator));
54          new TJunctionDemo("T-Junction demo", simulator, junctionModel);
55      }
56  }