fr.lip6.sma.simulacion.app.map
Class MapMultiCellPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by fr.lip6.sma.simulacion.app.map.MapPanel
                      extended by fr.lip6.sma.simulacion.app.map.MapMultiCellPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible

public abstract class MapMultiCellPanel
extends MapPanel
implements PropertyChangeListener

Classe de base pour décomposer une carte de jeu en zones appelée "cell"s. Motivations: découpler la gestion des agents de celle des interactions, fournir un moyen de localisation de haut niveau, gestion locale des agents.

Version:
$Revision: 5 $
Author:
Paul Guyot , Eric Platon
See Also:
"Nothing special", Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private  Map mAgentsCells
          Map of the cell of agents.
private  MapCell[][] mCells
          The cell map.
private  MapMultiCellController mController
          Controller of the map and its cells
private  MapMultiCellModel mModel
          Model to the map data.
private  int mNumCellX
          Number of cells on the map, X axis.
private  int mNumCellY
          Number of cells on the map, Y axis.
private  MapShapesModel mShapesModel
          Model to the shapes of the agents.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MapMultiCellPanel(MapMultiCellModel inModel, MapMultiCellGameController inGameController, MapPanelListener inMapListener, String inLocalAgentName, MapShapesModel inShapesModel)
          Constructor from models, a controller, a map listener and the name of the local agent.
 
Method Summary
 void addNotify()
          Method called when the map is shown.
protected abstract  MapCell createMapCell(int inXCoord, int inYCoord)
          Création d'une cellule pour la carte.
private  void doUpdateAgentPosition(String inAgentName, Point inOldPosition, Point inNewPosition)
          Update the position of an agent.
 MapCell getCell(Point inPosition)
          Retrieve a cell from a position.
 Point getLocationFromString(String inLocationProperty)
          Détermine la position à partir d'une chaîne.
protected  void initCells()
          Initialize the cells.
 void propertyChange(PropertyChangeEvent inEvent)
          Inherited from the PropertyChangeListener class.
 void removeNotify()
          Method called when the map is removed.
private  void updateAgentPosition(String inAgentName, Point inOldPosition, Point inNewPosition)
          Update the position of an agent.
protected  void updateSelection(Set inSelectedAgents)
          Méthode appelée lorsque la sélection a changé.
 
Methods inherited from class fr.lip6.sma.simulacion.app.map.MapPanel
getAllowMultipleSelection, getLocalAgentName, getMapListener, getSelectedAgents, getSelectedAgentsSet, isAgentOnMap, selectAgent, selectAgents, setAllowMultipleSelection
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mController

private final MapMultiCellController mController
Controller of the map and its cells


mModel

private final MapMultiCellModel mModel
Model to the map data.


mShapesModel

private final MapShapesModel mShapesModel
Model to the shapes of the agents.


mCells

private final MapCell[][] mCells
The cell map.


mAgentsCells

private final Map mAgentsCells
Map of the cell of agents. Keys: agent names, values: cells.


mNumCellX

private final int mNumCellX
Number of cells on the map, X axis.


mNumCellY

private final int mNumCellY
Number of cells on the map, Y axis.

Constructor Detail

MapMultiCellPanel

public MapMultiCellPanel(MapMultiCellModel inModel,
                         MapMultiCellGameController inGameController,
                         MapPanelListener inMapListener,
                         String inLocalAgentName,
                         MapShapesModel inShapesModel)
Constructor from models, a controller, a map listener and the name of the local agent.

Parameters:
inModel - model for the map.
inGameController - controller for the map.
inMapListener - référence sur le gestionnaire.
inLocalAgentName - nom de l'agent local.
inShapesModel - model avec les formes des agents.
Method Detail

initCells

protected void initCells()
Initialize the cells. This method must be called from the subclasses constructors when the subclasses are ready to build the cells.


addNotify

public void addNotify()
Method called when the map is shown. Display all known agents.

Overrides:
addNotify in class JComponent

removeNotify

public void removeNotify()
Method called when the map is removed.

Overrides:
removeNotify in class JComponent

getLocationFromString

public Point getLocationFromString(String inLocationProperty)
Détermine la position à partir d'une chaîne.

Parameters:
inLocationProperty - chaîne pour la position (dans le fichier XML)
Returns:
la position sous forme de point.

updateSelection

protected final void updateSelection(Set inSelectedAgents)
Méthode appelée lorsque la sélection a changé.

Specified by:
updateSelection in class MapPanel
Parameters:
inSelectedAgents - la liste des noms des agents sélectionnés. (le processus léger courant possde le moniteur dessus).

getCell

public MapCell getCell(Point inPosition)
Retrieve a cell from a position.

Parameters:
inPosition - position of the cell to retrieve.
Returns:
cell at this position.

updateAgentPosition

private void updateAgentPosition(String inAgentName,
                                 Point inOldPosition,
                                 Point inNewPosition)
Update the position of an agent.

Parameters:
inAgentName - name of the agent.
inOldPosition - old position of the agent.
inNewPosition - new position of the agent.

doUpdateAgentPosition

private void doUpdateAgentPosition(String inAgentName,
                                   Point inOldPosition,
                                   Point inNewPosition)
Update the position of an agent.

Parameters:
inAgentName - name of the agent.
inOldPosition - old position of the agent, null if the agent appeared.
inNewPosition - new position of the agent, null if the agent disappeared.

propertyChange

public void propertyChange(PropertyChangeEvent inEvent)
Inherited from the PropertyChangeListener class.

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
inEvent - The event to process.

createMapCell

protected abstract MapCell createMapCell(int inXCoord,
                                         int inYCoord)
Création d'une cellule pour la carte.

Parameters:
inXCoord - coordonnée X de la cellule.
inYCoord - coordonnée Y de la cellule.
Returns:
une nouvelle cellule.