Class OtsControlPanel

All Implemented Interfaces:
ActionListener, WindowListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, Remote, EventListener, Accessible, org.djutils.event.EventListener

public class OtsControlPanel extends JPanel implements ActionListener, PropertyChangeListener, WindowListener, org.djutils.event.EventListener
Peter's improved simulation control panel.

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

    • closeHandlerRegistered

      protected boolean closeHandlerRegistered
      Has the window close handler been registered?
  • Constructor Details

    • OtsControlPanel

      public OtsControlPanel(org.opentrafficsim.core.dsol.OtsSimulatorInterface simulator, org.opentrafficsim.core.dsol.OtsModelInterface model, OtsAnimationPanel otsAnimationPanel) throws RemoteException
      Decorate a SimpleSimulator with a different set of control buttons.
      Parameters:
      simulator - OtsSimulatorInterface; the simulator
      model - OtsModelInterface; if non-null, the restart button should work
      otsAnimationPanel - OtsAnimationPanel; the OTS animation panel
      Throws:
      RemoteException - when simulator cannot be accessed for listener attachment
  • Method Details

    • setSimulationControlButtons

      public void setSimulationControlButtons(boolean newState)
      Change the enabled/disabled state of the various simulation control buttons.
      Parameters:
      newState - boolean; true if the buttons should become enabled; false if the buttons should become disabled
    • getOtsSearchPanel

      public OtsSearchPanel getOtsSearchPanel()
      Provide access to the search panel.
      Returns:
      OtsSearchPanel; the OTS search panel
    • loadIcon

      public static final Icon loadIcon(String iconPath)
      Attempt to load and return an icon.
      Parameters:
      iconPath - String; the path that is used to load the icon
      Returns:
      Icon; or null if loading failed
    • loadGrayscaleIcon

      public static final Icon loadGrayscaleIcon(String iconPath)
      Attempt to load and return an icon, which will be made gray-scale.
      Parameters:
      iconPath - String; the path that is used to load the icon
      Returns:
      Icon; or null if loading failed
    • installWindowCloseHandler

      public final void installWindowCloseHandler()
      Install a handler for the window closed event that stops the simulator (if it is running).
    • actionPerformed

      public final void actionPerformed(ActionEvent actionEvent)
      Specified by:
      actionPerformed in interface ActionListener
    • fixButtons

      protected final void fixButtons()
      Update the enabled state of all the buttons.
    • autoPauseSimulator

      public final void autoPauseSimulator()
      Pause the simulator.
    • propertyChange

      public final void propertyChange(PropertyChangeEvent evt)
      Specified by:
      propertyChange in interface PropertyChangeListener
    • getSimulator

      public final org.opentrafficsim.core.dsol.OtsSimulatorInterface getSimulator()
      Returns:
      simulator.
    • windowOpened

      public void windowOpened(WindowEvent e)
      Specified by:
      windowOpened in interface WindowListener
    • windowClosing

      public final void windowClosing(WindowEvent e)
      Specified by:
      windowClosing in interface WindowListener
    • windowClosed

      public final void windowClosed(WindowEvent e)
      Specified by:
      windowClosed in interface WindowListener
    • windowIconified

      public final void windowIconified(WindowEvent e)
      Specified by:
      windowIconified in interface WindowListener
    • windowDeiconified

      public final void windowDeiconified(WindowEvent e)
      Specified by:
      windowDeiconified in interface WindowListener
    • windowActivated

      public final void windowActivated(WindowEvent e)
      Specified by:
      windowActivated in interface WindowListener
    • windowDeactivated

      public final void windowDeactivated(WindowEvent e)
      Specified by:
      windowDeactivated in interface WindowListener
    • getTimeFont

      public final Font getTimeFont()
      Returns:
      timeFont.
    • notify

      public final void notify(org.djutils.event.Event event) throws RemoteException
      Specified by:
      notify in interface org.djutils.event.EventListener
      Throws:
      RemoteException
    • toString

      public final String toString()
      Overrides:
      toString in class Component