Class SimulationView

All Implemented Interfaces:
IFeedbackProvider, ISimulationHost, SimulationListener, IFileDropHandler, ComponentListener, FocusListener, MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants
Direct Known Subclasses:
ImageEvolutionDemoView, NetworkDeclutterDemoView, TspDemoView

public class SimulationView extends BaseView implements ISimulationHost, SimulationListener
Base class for an MDI BaseView that hosts a SimulationEngine.

This class is the "MDI bridge" for the MDI-agnostic simulation framework: the simulation engine knows nothing about views/containers, while this view knows how to repaint an IContainer on refresh and optionally hosts UI components (control panel, diagnostics).

Layout

BaseView already installs the container component in BorderLayout.CENTER (or inside a split pane), and may add a toolbar in BorderLayout.NORTH. This class adds:

  • Optional control panel in BorderLayout.SOUTH
  • Optional diagnostics component on the right, installed by wrapping the current CENTER component in a JSplitPane

Threading

All SimulationListener callbacks arrive on the Swing EDT (as guaranteed by SimulationEngine). Therefore, onRefresh(SimulationContext) safely repaints the container component.

See Also:
  • Field Details

    • engine

      protected volatile SimulationEngine engine
      Hosted engine (never null).
    • controlPanel

      protected final JComponent controlPanel
      Optional control panel component (may be null).
    • diagnostics

      protected final JComponent diagnostics
      Optional diagnostics component (may be null).
    • diagnosticsSplitPane

      protected final JSplitPane diagnosticsSplitPane
      If diagnostics is installed, this is the split pane (else null).
  • Constructor Details

    • SimulationView

      public SimulationView(Simulation simulation, Object... keyVals)
      Construct a simulation view using default engine configuration and including the default control panel.
      Parameters:
      simulation - the simulation to run (non-null)
      keyVals - standard BaseView key-value arguments
    • SimulationView

      public SimulationView(Simulation simulation, SimulationEngineConfig config, boolean includeControlPanel, Object... keyVals)
      Construct a simulation view with optional inclusion of the default control panel.
      Parameters:
      simulation - the simulation to run (non-null)
      config - engine configuration (non-null)
      includeControlPanel - if true, creates and adds the default control panel at SOUTH
      keyVals - standard BaseView key-value arguments
    • SimulationView

      public SimulationView(Simulation simulation, SimulationEngineConfig config, boolean includeControlPanel, SimulationView.ControlPanelFactory factory, Object... keyVals)
      Construct a simulation view with a caller-provided control panel factory.
      Parameters:
      simulation - the simulation to run (non-null)
      config - engine configuration (non-null)
      includeControlPanel - if true, creates and adds a control panel at SOUTH
      factory - factory used to create the control panel component
      keyVals - standard BaseView key-value arguments
    • SimulationView

      public SimulationView(Simulation simulation, SimulationEngineConfig config, boolean includeControlPanel, SimulationView.ControlPanelFactory controlPanelFactory, boolean includeDiagnostics, SimulationView.DiagnosticFactory diagnosticFactory, double initialSplitFraction, Object... keyVals)
      Construct a simulation view with optional control panel and optional diagnostics panel.
      Parameters:
      simulation - the simulation to run (non-null)
      config - engine configuration (non-null)
      includeControlPanel - if true, creates and adds a control panel at SOUTH
      controlPanelFactory - factory used to create the control panel component (may be null if includeControlPanel is false)
      includeDiagnostics - if true, installs a right-side diagnostics component via a split pane
      diagnosticFactory - factory used to create the diagnostics component (required if includeDiagnostics is true)
      initialSplitFraction - fraction of width given to the main (left) component on startup (0..1)
      keyVals - standard BaseView key-value arguments
  • Method Details