Class OtsWebModel

java.lang.Object
org.opentrafficsim.web.OtsWebModel
All Implemented Interfaces:
EventListener, EventListener

public class OtsWebModel extends Object implements EventListener
OtsWebModel.java.

Copyright (c) 2003-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. BSD-style license. See OpenTrafficSim License.

Author:
Alexander Verbraeck
  • Constructor Details

    • OtsWebModel

      public OtsWebModel(String title, OtsSimulatorInterface simulator) throws Exception
      Constructor.
      Parameters:
      title - the title for the model window
      simulator - the simulator
      Throws:
      Exception - in case jetty crashes
  • Method Details

    • getTitle

      public final String getTitle()
      Return title.
      Returns:
      title
    • getSimulator

      public final OtsSimulatorInterface getSimulator()
      Return simulator.
      Returns:
      simulator
    • getAnimationPanel

      public final HtmlAnimationPanel getAnimationPanel()
      Return animation panel.
      Returns:
      animationPanel
    • isKilled

      public final boolean isKilled()
      Return killed.
      Returns:
      killed
    • setKilled

      public final void setKilled(boolean killed)
      Set killed.
      Parameters:
      killed - set killed
    • startSimulator

      protected boolean startSimulator()
      Try to start the simulator, and return whether the simulator has been started.
      Returns:
      whether the simulator has been started or not
    • stopSimulator

      protected boolean stopSimulator()
      Try to stop the simulator, and return whether the simulator has been stopped.
      Returns:
      whether the simulator has been stopped or not
    • setSpeedFactor

      protected void setSpeedFactor(double speedFactor)
      Set speed factor.
      Parameters:
      speedFactor - the new speed factor
    • notify

      public void notify(Event event)
      Specified by:
      notify in interface EventListener
    • handle

      public boolean handle(org.eclipse.jetty.server.Request request, org.eclipse.jetty.server.Response response, org.eclipse.jetty.util.Callback callback) throws Exception
      Delegate handle method from the main web server for this particular model.
      Parameters:
      request - the HTTP request to handle
      response - the HTTP response to handle
      callback - the callback to complete when the handling is complete
      Returns:
      whether the request was handled
      Throws:
      Exception - exception