fr.lifl.jedi.gui.display.colorGrid
Class ColorGridGUIController

java.lang.Object
  extended by java.util.Observable
      extended by fr.lifl.jedi.controllersCore.AbstractGUIController<ColorGridGUI>
          extended by fr.lifl.jedi.gui.display.colorGrid.ColorGridGUIController
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseWheelListener, java.util.EventListener, java.util.Observer, javax.swing.event.ChangeListener

public class ColorGridGUIController
extends AbstractGUIController<ColorGridGUI>
implements javax.swing.event.ChangeListener, java.awt.event.MouseListener, java.awt.event.MouseWheelListener

This controller handles the messages exchanged between the running simulation and the GUI that displays it in a ColorGridGUI.

Version:
JEDI V 2.2
Created the 7th avr. 2009
Modified the 5th may 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
 
Fields inherited from class fr.lifl.jedi.controllersCore.AbstractGUIController
core, view
 
Constructor Summary
ColorGridGUIController(ColorGridGUI view)
          Constructor of the Controller that rules the behavior of a ColorGridGUI
 
Method Summary
protected  void computeNewSimulationStepImage()
          Gets informations from the environment, in order to update the double buffer that displays simulations data.
protected  void handleViewMessage(ISimulationEvent event)
          Defines how the controller reacts when it receives an event coming from the view.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
           
protected  void reactToCloseRequest()
          This method is called when the program is about to exit.
 void stateChanged(javax.swing.event.ChangeEvent e)
           
protected  void updateViewAfterInitialization()
          This method is called whenever the simulation core finished the environment's initialization.
protected  void updateViewAfterTimeStep()
          This method is called whenever a simulation step ends.
protected  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  void updateViewAtSimulationsEnd()
          This method is called when the simulation ended normaly -- i.e.
protected  void updateViewDuringTimeStep()
          This method is called whenever a simulation step starts.
protected  void updateViewWhenPaused()
          This method is called whenever the simulation is paused.
protected  void updateViewWhileInitializing()
          This method is called when the simulation core begins to (and has not finished to) initialize the simulation.
 void zoomDecrement()
          This method is called whenever the zoom is decremented with the mouse wheel.
 void zoomIncrement()
          This method is called whenever the zoom is incremented with the mouse wheel.
 
Methods inherited from class fr.lifl.jedi.controllersCore.AbstractGUIController
getView, setSimulationCore, update
 
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
 

Constructor Detail

ColorGridGUIController

public ColorGridGUIController(ColorGridGUI view)
Constructor of the Controller that rules the behavior of a ColorGridGUI

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

handleViewMessage

protected void handleViewMessage(ISimulationEvent event)
Description copied from class: AbstractGUIController
Defines how the controller reacts when it receives an event coming from the view.

Specified by:
handleViewMessage in class AbstractGUIController<ColorGridGUI>
Parameters:
event - The event that came from the view.
See Also:
AbstractGUIController.handleViewMessage(fr.lifl.jedi.gui.ISimulationEvent)

computeNewSimulationStepImage

protected void computeNewSimulationStepImage()
Gets informations from the environment, in order to update the double buffer that displays simulations data.


stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
Specified by:
stateChanged in interface javax.swing.event.ChangeListener
See Also:
ChangeListener.stateChanged(javax.swing.event.ChangeEvent)

zoomIncrement

public void zoomIncrement()
This method is called whenever the zoom is incremented with the mouse wheel.


zoomDecrement

public void zoomDecrement()
This method is called whenever the zoom is decremented with the mouse wheel.


mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseClicked(java.awt.event.MouseEvent)

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseEntered(java.awt.event.MouseEvent)

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent)

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener
See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent)

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent e)
Specified by:
mouseWheelMoved in interface java.awt.event.MouseWheelListener
See Also:
MouseWheelListener.mouseWheelMoved(java.awt.event.MouseWheelEvent)

reactToCloseRequest

protected void reactToCloseRequest()
Description copied from class: AbstractGUIController
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 AbstractGUIController.reactToCloseRequest() method.

Specified by:
reactToCloseRequest in class AbstractGUIController<ColorGridGUI>
See Also:
AbstractGUIController.reactToCloseRequest()

updateViewAfterInitialization

protected void updateViewAfterInitialization()
Description copied from class: AbstractGUIController
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 AbstractGUIController.updateViewAfterInitialization() method.

Specified by:
updateViewAfterInitialization in class AbstractGUIController<ColorGridGUI>
See Also:
AbstractGUIController.updateViewAfterInitialization()

updateViewAfterTimeStep

protected void updateViewAfterTimeStep()
Description copied from class: AbstractGUIController
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 AbstractGUIController.updateViewAfterTimeStep() method.

Specified by:
updateViewAfterTimeStep in class AbstractGUIController<ColorGridGUI>
See Also:
AbstractGUIController.updateViewAfterTimeStep()

updateViewAtSimulationsAbortion

protected void updateViewAtSimulationsAbortion()
Description copied from class: AbstractGUIController
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 AbstractGUIController.updateViewAtSimulationsAbortion() method.

Specified by:
updateViewAtSimulationsAbortion in class AbstractGUIController<ColorGridGUI>
See Also:
AbstractGUIController.updateViewAtSimulationsAbortion()

updateViewAtSimulationsEnd

protected void updateViewAtSimulationsEnd()
Description copied from class: AbstractGUIController
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 AbstractGUIController.updateViewAtSimulationsEnd() method.

Specified by:
updateViewAtSimulationsEnd in class AbstractGUIController<ColorGridGUI>
See Also:
AbstractGUIController.updateViewAtSimulationsEnd()

updateViewDuringTimeStep

protected void updateViewDuringTimeStep()
Description copied from class: AbstractGUIController
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.

Specified by:
updateViewDuringTimeStep in class AbstractGUIController<ColorGridGUI>
See Also:
AbstractGUIController.updateViewDuringTimeStep()

updateViewWhenPaused

protected void updateViewWhenPaused()
Description copied from class: AbstractGUIController
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 AbstractGUIController.updateViewWhenPaused() method.

Specified by:
updateViewWhenPaused in class AbstractGUIController<ColorGridGUI>
See Also:
AbstractGUIController.updateViewWhenPaused()

updateViewWhileInitializing

protected void updateViewWhileInitializing()
Description copied from class: AbstractGUIController
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.

Specified by:
updateViewWhileInitializing in class AbstractGUIController<ColorGridGUI>
See Also:
AbstractGUIController.updateViewWhileInitializing()