|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--VASSAL.counters.Decorator
The abstract class describing a generic 'trait' of a GamePiece. Follows the Decorator design pattern of wrapping around another instance of GamePiece (the 'inner' piece) and delegating some of the GamePiece methods to it
| Constructor Summary | |
Decorator()
|
|
| Method Summary | |
static GamePiece |
getDecorator(GamePiece p,
java.lang.Class type)
|
PieceEditor |
getEditor()
|
java.lang.String |
getId()
Each GamePiece must have a unique String identifier |
GamePiece |
getInner()
|
static GamePiece |
getInnermost(GamePiece p)
|
protected KeyCommand[] |
getKeyCommands()
The set of key commands that will populate the piece's right-click menu. |
Map |
getMap()
|
static GamePiece |
getOutermost(GamePiece p)
|
Stack |
getParent()
|
java.awt.Point |
getPosition()
|
java.lang.Object |
getProperty(java.lang.Object key)
|
java.lang.String |
getState()
The state of a Decorator is a composition of myGetState() and the inner piece's state |
java.lang.String |
getType()
The type of a Decorator is a composition of myGetType() and the type of its inner piece |
Command |
keyEvent(javax.swing.KeyStroke stroke)
Append the command returned by myKeyEvent(javax.swing.KeyStroke) with the command returned
by the inner piece's GamePiece.keyEvent(javax.swing.KeyStroke) method. |
void |
mergeState(java.lang.String newState,
java.lang.String oldState)
Compute the difference between newState and oldState
and appy that difference to the current state |
protected abstract KeyCommand[] |
myGetKeyCommands()
|
abstract java.lang.String |
myGetState()
|
abstract java.lang.String |
myGetType()
|
abstract Command |
myKeyEvent(javax.swing.KeyStroke stroke)
The response of this trait alone to the given KeyStroke |
abstract void |
mySetState(java.lang.String newState)
Set just the state of this trait |
void |
setId(java.lang.String id)
|
void |
setInner(GamePiece p)
Set the inner GamePiece |
void |
setMap(Map m)
|
void |
setParent(Stack s)
|
void |
setPosition(java.awt.Point p)
|
void |
setProperty(java.lang.Object key,
java.lang.Object val)
The GamePiece should store properties for retrieval (e.g in a Hashtable) It is not necessary that properties stored with this method be retained in the piece's getState() method. |
void |
setState(java.lang.String newState)
Extract the string describing this trait's state and forward the remaining string to the inner piece |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface VASSAL.counters.GamePiece |
boundingBox, draw, getName, selectionBounds |
| Constructor Detail |
public Decorator()
| Method Detail |
public void setInner(GamePiece p)
public GamePiece getInner()
public void setMap(Map m)
setMap in interface GamePiecepublic Map getMap()
getMap in interface GamePiecepublic void setParent(Stack s)
setParent in interface GamePiecepublic Stack getParent()
getParent in interface GamePiecepublic java.lang.Object getProperty(java.lang.Object key)
getProperty in interface GamePiece
public void setProperty(java.lang.Object key,
java.lang.Object val)
GamePieceGamePiece.getState() method.setProperty in interface GamePiecepublic void setPosition(java.awt.Point p)
setPosition in interface GamePiecepublic java.awt.Point getPosition()
getPosition in interface GamePiecepublic abstract void mySetState(java.lang.String newState)
myGetState()public void setState(java.lang.String newState)
setState in interface GamePiecenewState - the new state of this trait and all inner pieces
public void mergeState(java.lang.String newState,
java.lang.String oldState)
newState and oldState
and appy that difference to the current statenewState - oldState - public abstract java.lang.String myGetState()
getState()public java.lang.String getState()
myGetState() and the inner piece's stategetState in interface GamePiecepublic abstract java.lang.String myGetType()
getType()public java.lang.String getType()
myGetType() and the type of its inner piecegetType in interface GamePieceprotected abstract KeyCommand[] myGetKeyCommands()
getKeyCommands()protected KeyCommand[] getKeyCommands()
Properties.KEY_COMMANDS property.
The commands for a Decorator are a composite of myGetKeyCommands() and the
commands of its inner piece.public abstract Command myKeyEvent(javax.swing.KeyStroke stroke)
stroke - keyEvent(javax.swing.KeyStroke)public Command keyEvent(javax.swing.KeyStroke stroke)
myKeyEvent(javax.swing.KeyStroke) with the command returned
by the inner piece's GamePiece.keyEvent(javax.swing.KeyStroke) method.keyEvent in interface GamePiecestroke - public java.lang.String getId()
GamePiecegetId in interface GamePieceVASSAL.counters.GamePieceGameState.getNewPieceId()public void setId(java.lang.String id)
setId in interface GamePiecepublic static GamePiece getOutermost(GamePiece p)
p - public static GamePiece getInnermost(GamePiece p)
p - BasicPiece
public static GamePiece getDecorator(GamePiece p,
java.lang.Class type)
public PieceEditor getEditor()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||