|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--VASSAL.counters.Stack
A collection of GamePieces which can be moved as a single unit
| Field Summary | |
protected GamePiece[] |
contents
|
protected static int |
INCR
|
protected Map |
map
|
protected int |
pieceCount
|
protected java.awt.Point |
pos
|
static java.lang.String |
TYPE
|
| Constructor Summary | |
Stack()
|
|
Stack(GamePiece p)
|
|
| Method Summary | |
void |
add(GamePiece c)
Adds a piece to the stack. |
GamePiece |
bottomPiece()
|
java.awt.Rectangle |
boundingBox()
The area which this GamePiece occupies when drawn at the point (0,0) |
void |
draw(java.awt.Graphics g,
int x,
int y,
java.awt.Component obs,
double zoom)
If the obs parameter is a Map, delegate
drawing of this Stack to the StackMetrics of that Map. |
StackMetrics |
getDefaultMetrics()
|
java.lang.String |
getId()
Each GamePiece must have a unique String identifier |
Map |
getMap()
|
java.lang.String |
getName()
Return a comma-separated list of the names of the pieces in this Stack |
Stack |
getParent()
|
GamePiece |
getPieceAt(int index)
|
int |
getPieceCount()
|
java.util.Enumeration |
getPieces()
|
java.util.Enumeration |
getPiecesInReverseOrder()
|
java.util.Enumeration |
getPiecesInVisibleOrder()
Returns pieces in the order in which they are visible to the player -- topmost first In other words, selected pieces first, then unselected pieces from the top to the bottom |
java.awt.Point |
getPosition()
|
java.lang.Object |
getProperty(java.lang.Object key)
|
java.awt.Shape |
getShape()
The shape of the piece from the user's viewpoint. |
java.lang.String |
getState()
The state information is information that can change during the course of a game. |
java.lang.String |
getType()
The type information is information that does not change during the course of a game. |
int |
indexOf(GamePiece p)
|
void |
insert(GamePiece p,
int pos)
Inserts a child GamePiece at a given index. |
void |
insertChild(GamePiece child,
int index)
Adds a GamePiece to this Stack. |
protected void |
insertPieceAt(GamePiece p,
int index)
|
boolean |
isExpanded()
|
Command |
keyEvent(javax.swing.KeyStroke stroke)
Keyboard events are forward to this method when a piece is selected The GamePiece can respond in any way it likes |
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 int |
nVisible()
|
void |
remove(GamePiece p)
|
void |
removeAll()
|
void |
selectNext(GamePiece c)
|
static void |
setDefaultMetrics(StackMetrics s)
|
void |
setExpanded(boolean b)
|
void |
setId(java.lang.String id)
|
void |
setMap(Map map)
Each GamePiece belongs to a single Map |
void |
setParent(Stack s)
|
void |
setPosition(java.awt.Point p)
|
void |
setProperty(java.lang.Object key,
java.lang.Object val)
Other properties, possibly game-specific, can be associated with a piece. |
void |
setState(java.lang.String s)
|
GamePiece |
topPiece()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String TYPE
protected static final int INCR
protected GamePiece[] contents
protected int pieceCount
protected java.awt.Point pos
protected Map map
| Constructor Detail |
public Stack()
public Stack(GamePiece p)
| Method Detail |
public java.util.Enumeration getPieces()
public java.util.Enumeration getPiecesInReverseOrder()
public java.util.Enumeration getPiecesInVisibleOrder()
public void remove(GamePiece p)
protected void insertPieceAt(GamePiece p,
int index)
public void removeAll()
public int indexOf(GamePiece p)
public GamePiece getPieceAt(int index)
public void add(GamePiece c)
c -
public void insertChild(GamePiece child,
int index)
insert(VASSAL.counters.GamePiece, int) because
it assumes the piece does not already belong to this Stack.child - index - public int getPieceCount()
public void insert(GamePiece p,
int pos)
p - pos -
public void draw(java.awt.Graphics g,
int x,
int y,
java.awt.Component obs,
double zoom)
obs parameter is a Map, delegate
drawing of this Stack to the StackMetrics of that Map.
If obs is not a Map, use the default StackMetricsdraw in interface GamePieceStackMetrics.draw(VASSAL.counters.Stack, java.awt.Graphics, int, int, java.awt.Component, double),
getDefaultMetrics()public java.lang.String getName()
getName in interface GamePiecepublic java.awt.Rectangle boundingBox()
GamePieceboundingBox in interface GamePiecepublic java.awt.Shape getShape()
GamePieceGamePiece.boundingBox(), it assumes the position is (0,0) and must be translated
to the actual location where the piece is being drawn.getShape in interface GamePiecepublic void selectNext(GamePiece c)
public GamePiece topPiece()
public GamePiece bottomPiece()
protected int nVisible()
public Command keyEvent(javax.swing.KeyStroke stroke)
GamePiecekeyEvent in interface GamePieceVASSAL.counters.GamePieceCommand that, when executed, will invoke
the same response. Usually a ChangePiece command.ForwardToKeyBufferpublic boolean isExpanded()
public void setExpanded(boolean b)
public java.lang.String getState()
GamePiecegetState in interface GamePiecepublic void setState(java.lang.String s)
setState in interface GamePiece
public void mergeState(java.lang.String newState,
java.lang.String oldState)
newState and oldState
and appy that difference to the current statenewState - oldState - public java.lang.String getType()
GamePiecegetType in interface GamePieceVASSAL.counters.GamePieceBasicCommandEncoder
public void setProperty(java.lang.Object key,
java.lang.Object val)
GamePieceGamePiece.getState() method.setProperty in interface GamePiecepublic java.lang.Object getProperty(java.lang.Object key)
getProperty in interface GamePiecepublic void setMap(Map map)
GamePieceMapsetMap in interface GamePiecepublic Map getMap()
getMap in interface GamePiecepublic java.awt.Point getPosition()
getPosition in interface GamePieceVASSAL.counters.GamePieceMappublic void setPosition(java.awt.Point p)
setPosition in interface GamePiecepublic Stack getParent()
getParent in interface GamePieceVASSAL.counters.GamePieceStack to which this piece belongs, or null if it doesn't belong to a stack.public void setParent(Stack s)
setParent in interface GamePiecepublic java.lang.String getId()
GamePiecegetId in interface GamePieceVASSAL.counters.GamePieceGameState.getNewPieceId()public void setId(java.lang.String id)
setId in interface GamePiecepublic static void setDefaultMetrics(StackMetrics s)
public StackMetrics getDefaultMetrics()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||