Interface ISimulationHost

All Known Implementing Classes:
ImageEvolutionDemoView, NetworkDeclutterDemoView, SimulationView, TspDemoView

public interface ISimulationHost
Convenience interface for any object that *hosts* a SimulationEngine.

This interface is intentionally minimal and MDI-agnostic. It provides:

  • a single accessor for the underlying SimulationEngine
  • default lifecycle control methods (start, run, pause, resume, stop, cancel)

Typical Usage

 
 public class IsingModelView extends BaseView
         implements ISimulationHost, SimulationListener {

     private final SimulationEngine engine;

     public IsingModelView(...) {
         engine = new SimulationEngine(new IsingSimulation(), SimulationEngineConfig.defaults());
         engine.addListener(this);
     }

     @Override
     public SimulationEngine getSimulationEngine() {
         return engine;
     }

     @Override
     public void onRefresh(SimulationContext ctx) {
         getContainer().repaint();
     }
 }
 
 

By implementing this interface, UI code (toolbars, menus, control panels) can manipulate simulations in a uniform way without knowing implementation details.

  • Method Details

    • getSimulationEngine

      SimulationEngine getSimulationEngine()
      Return the SimulationEngine hosted by this object.
      Returns:
      the simulation engine (never null)
    • startSimulation

      default void startSimulation()
      Start the simulation engine.

      This is safe to call multiple times; only the first call has an effect.

    • runSimulation

      default void runSimulation()
      Request the simulation to begin or continue running.

      If the engine is paused, this resumes execution. If the engine is READY and autoRun == false, this begins execution.

    • pauseSimulation

      default void pauseSimulation()
      Request that the simulation pause.

      The engine will transition to SimulationState.PAUSED at the next safe point.

    • resumeSimulation

      default void resumeSimulation()
      Resume a paused simulation.

      This is equivalent to runSimulation().

    • stopSimulation

      default void stopSimulation()
      Request a normal stop.

      The simulation will terminate and invoke Simulation.shutdown(SimulationContext) on the simulation thread.

    • cancelSimulation

      default void cancelSimulation()
      Request cancellation.

      Cancellation is cooperative. The simulation should observe SimulationContext.isCancelRequested() and exit promptly.

    • getSimulationState

      default SimulationState getSimulationState()
      Convenience method to query the current simulation state.
      Returns:
      current SimulationState
    • getSimulationContext

      default SimulationContext getSimulationContext()
      Convenience method to query the simulation context.
      Returns:
      simulation context