public class BoardDrawing<LOCATION> extends StandardDrawing implements BoardGameObserver<LOCATION>
Modifier and Type | Field and Description |
---|---|
protected PositioningStrategy<LOCATION> |
adjuster |
protected FigureFactory<LOCATION> |
factory |
protected java.util.Map<LOCATION,java.util.List<BoardFigure>> |
figureMap
"Map of list" collection, mapping each location to the set of images
positioned on it.
|
protected PropAppearanceStrategy |
propChanger |
protected java.util.Map<java.lang.String,BoardFigure> |
propMap
Map collection, mapping graphical (x,y) positions to the props of the game.
|
listenerHandler, selectionHandler
fFigures
Constructor and Description |
---|
BoardDrawing(FigureFactory<LOCATION> factory,
PositioningStrategy<LOCATION> adjuster,
PropAppearanceStrategy propChanger)
Construct a Drawing specifically for handling figures associated with Board
games.
|
Modifier and Type | Method and Description |
---|---|
protected void |
adjustFigurePosition(BoardFigure figure,
LOCATION location,
int index) |
protected void |
buildPieceMap() |
protected void |
buildPropMap() |
void |
pieceMovedEvent(LOCATION from,
LOCATION to)
the update method for pieces moved from location 'from' to location 'to'.
|
void |
propChangeEvent(java.lang.String key)
the update method for props changed.
|
addDrawingChangeListener, addToSelection, clearSelection, displayBox, figureChanged, figureInvalidated, lock, removeDrawingChangeListener, removeFromSelection, requestUpdate, selection, toggleSelection, unlock
add, basicMoveBy, draw, figureRemoved, figureRequestRemove, figureRequestUpdate, findFigure, iterator, remove
addFigureChangeListener, changed, invalidate, moveBy, removeFigureChangeListener, willChange
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
add, findFigure, iterator, remove
figureRemoved, figureRequestRemove, figureRequestUpdate
protected java.util.Map<LOCATION,java.util.List<BoardFigure>> figureMap
protected java.util.Map<java.lang.String,BoardFigure> propMap
protected FigureFactory<LOCATION> factory
protected PositioningStrategy<LOCATION> adjuster
protected PropAppearanceStrategy propChanger
public BoardDrawing(FigureFactory<LOCATION> factory, PositioningStrategy<LOCATION> adjuster, PropAppearanceStrategy propChanger)
factory
- abstract factory to return the initial set of piece images and
propsadjuster
- the strategy for calculating proper positions of piece images on
locations. Must be non-null.propChanger
- the strategy for changing the appearance of props. This reference
may be null if no props are used and the domain code ensures that
no propChangeEvents are ever sent.protected void adjustFigurePosition(BoardFigure figure, LOCATION location, int index)
protected void buildPieceMap()
protected void buildPropMap()
public void pieceMovedEvent(LOCATION from, LOCATION to)
BoardGameObserver
pieceMovedEvent
in interface BoardGameObserver<LOCATION>
from
- the LOCATION that a piece has moved fromto
- the LOCATION that a piece has moved topublic void propChangeEvent(java.lang.String key)
BoardGameObserver
propChangeEvent
in interface BoardGameObserver<LOCATION>
key
- a string key identifying the game domain object that has changed.
This key must be identical to that assigned in the FigureFactory'sFrom the book: Flexible, Reliable Software, © CRC Press 2010. Author: Henrik B. Christensen, Aarhus University, Denmark