Class OtsSwingApplication<T extends org.opentrafficsim.core.dsol.OtsModelInterface>

Type Parameters:
T - model type
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
Direct Known Subclasses:
OtsSimulationApplication

public class OtsSwingApplication<T extends org.opentrafficsim.core.dsol.OtsModelInterface> extends AppearanceApplication
Wrap a DSOL simulation model, or any (descendant of a) JPanel in a JFrame (wrap it in a window). The window will be maximized.

Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Alexander Verbraeck, Peter Knoppers
See Also:
  • Field Details

    • DEFAULT_COLORER

      public static final GtuColorer DEFAULT_COLORER
      Single instance of default colorer, reachable from various places.
    • closed

      protected boolean closed
      whether the application has been closed or not.
  • Constructor Details

    • OtsSwingApplication

      public OtsSwingApplication(T model, JPanel panel)
      Wrap an OtsModel in a JFrame. Uses a default GTU colorer.
      Parameters:
      model - T; the model that will be shown in the JFrame
      panel - JPanel; this should be the JPanel of the simulation
  • Method Details

    • makeAnimationRectangle

      protected Rectangle2D makeAnimationRectangle()
      Return the initial 'home' extent for the animation. The 'Home' button returns to this extent. Override this method when a smaller or larger part of the infra should be shown. In the default setting, all currently visible objects are shown.
      Returns:
      the initial and 'home' rectangle for the animation.
    • setExitOnClose

      public final void setExitOnClose(boolean exitOnClose)
      Parameters:
      exitOnClose - boolean; set exitOnClose
    • isClosed

      public final boolean isClosed()
      Returns:
      closed
    • getModel

      public final T getModel()
      Returns:
      model