fr.lifl.jedi.controllersCore
Class AbstractGUIController<GUIView extends ISimulationGUI>

java.lang.Object
  extended by java.util.Observable
      extended by fr.lifl.jedi.controllersCore.AbstractGUIController<GUIView>
All Implemented Interfaces:
java.util.Observer
Direct Known Subclasses:
AbstractControlGUIController, AbstractSimulationDataExportationController, AgentNumberDisplayFrameController, ColorGridGUIController, PerformedInteractionsDisplayerController

public abstract class AbstractGUIController<GUIView extends ISimulationGUI>
extends java.util.Observable
implements java.util.Observer

Controller associated with all GUI that display simulations data.

Such controllers have to be registered to the simulation core. Whenever the state of the simulations core changes, one of these methods are called :

Version:
JEDI V 2.3
Created the 2nd april 2009
Modified the 5th june 2009
Author:
Yoann Kubera
SMAC Team (Systèmes Multi-Agents et Comportement)
LIFL (Laboratoire d'Informatique Fondamentale de Lille)
University of Lille, France

Field Summary
protected  SimulationCore core
          The simulation core to which the controller is registered.
protected  GUIView view
          The view associated with this controller.
 
Constructor Summary
AbstractGUIController(GUIView view)
          Constructor of the controller associated with the control gui that manages the initialization, pause, run or abortion of the simulation.
 
Method Summary
 GUIView getView()
          Gets the view associated with this controller.
protected abstract  void handleViewMessage(ISimulationEvent event)
          Defines how the controller reacts when it receives an event coming from the view.
protected abstract  void reactToCloseRequest()
          This method is called when the program is about to exit.
 void setSimulationCore(SimulationCore core)
          This method is automatically called whenever a controller is added to the simulation core.
 void update(java.util.Observable o, java.lang.Object arg)
           
protected abstract  void updateViewAfterInitialization()
          This method is called whenever the simulation core finished the environment's initialization.
protected abstract  void updateViewAfterTimeStep()
          This method is called whenever a simulation step ends.
protected abstract  void updateViewAtSimulationsAbortion()
          This method is called when the simulation ended because of an abortion (because of a ToSimulationCoreControlEvents.TO_CORE_ABORT_SIMULATION event sent by the controller of a simulation control GUI).
protected abstract  void updateViewAtSimulationsEnd()
          This method is called when the simulation ended normaly -- i.e.
protected abstract  void updateViewDuringTimeStep()
          This method is called whenever a simulation step starts.
protected abstract  void updateViewWhenPaused()
          This method is called whenever the simulation is paused.
protected abstract  void updateViewWhileInitializing()
          This method is called when the simulation core begins to (and has not finished to) initialize the simulation.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

view

protected GUIView extends ISimulationGUI view
The view associated with this controller.


core

protected SimulationCore core
The simulation core to which the controller is registered.

Constructor Detail

AbstractGUIController

public AbstractGUIController(GUIView view)
Constructor of the controller associated with the control gui that manages the initialization, pause, run or abortion of the simulation.

Parameters:
view - The view associated with this controller.
Method Detail

setSimulationCore

public void setSimulationCore(SimulationCore core)
This method is automatically called whenever a controller is added to the simulation core.

Parameters:
core - The simulation core to which the controller registers.

getView

public GUIView getView()
Gets the view associated with this controller.

Returns:
The view associated with this controller.

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer
See Also:
Observer.update(java.util.Observable, java.lang.Object)

handleViewMessage

protected abstract void handleViewMessage(ISimulationEvent event)
Defines how the controller reacts when it receives an event coming from the view.

Parameters:
event - The event that came from the view.

updateViewWhileInitializing

protected abstract void updateViewWhileInitializing()
This method is called when the simulation core begins to (and has not finished to) initialize the simulation. Please do not access to the environment in this method. Otherwise, a concurrent access exception might be thrown.


updateViewAfterInitialization

protected abstract void updateViewAfterInitialization()
This method is called whenever the simulation core finished the environment's initialization. The simulation can be started (i.e. the first simulation step can be performed) only when all controllers registered to the simulation core finished their call to the updateViewAfterInitialization() method.


updateViewDuringTimeStep

protected abstract void updateViewDuringTimeStep()
This method is called whenever a simulation step starts. Please do not access to the environment in this method. Otherwise, a concurrent access exception might be thrown.


updateViewAfterTimeStep

protected abstract void updateViewAfterTimeStep()
This method is called whenever a simulation step ends. The simulation will resume (i.e. the next simulation step will be performed) only when all controllers registered to the simulation core finished their call to the updateViewAfterTimeStep() method.


updateViewWhenPaused

protected abstract void updateViewWhenPaused()
This method is called whenever the simulation is paused. The simulation can resume only when all controllers registered to the simulation core finished their call to the updateViewWhenPaused() method.


updateViewAtSimulationsEnd

protected abstract void updateViewAtSimulationsEnd()
This method is called when the simulation ended normaly -- i.e. if the simulation met its ending criterion (see SimulationCore.hasToStop()). The simulation can be initialized again only when all controllers registered to the simulation core finished their call to the updateViewAtSimulationsEnd() method.


updateViewAtSimulationsAbortion

protected abstract void updateViewAtSimulationsAbortion()
This method is called when the simulation ended because of an abortion (because of a ToSimulationCoreControlEvents.TO_CORE_ABORT_SIMULATION event sent by the controller of a simulation control GUI). The simulation can be initialized again only when all controllers registered to the simulation core finished their call to the updateViewAtSimulationsAbortion() method.


reactToCloseRequest

protected abstract void reactToCloseRequest()
This method is called when the program is about to exit. The program exits only when all controllers registered to the simulation core finished their call to the reactToCloseRequest() method.