VASSAL.counters
Interface GamePiece

All Known Subinterfaces:
EditablePiece
All Known Implementing Classes:
BasicPiece, Decorator, Embellishment, FreeRotator, Hideable, Immobilized, Labeler, Marker, MovementMarkable, Obscurable, PlaceMarker, ReportState, Restricted, ReturnToDeck, Stack, TableInfo

public interface GamePiece

Basic class for representing a physical component of the game


Method Summary
 java.awt.Rectangle boundingBox()
          The area which this GamePiece occupies when drawn at the point given by getPosition().
 void draw(java.awt.Graphics g, int x, int y, java.awt.Component obs, double zoom)
           
 java.lang.String getId()
          Each GamePiece must have a unique String identifier
 Map getMap()
           
 java.lang.String getName()
          The plain English name for this piece
 Stack getParent()
           
 java.awt.Point getPosition()
           
 java.lang.Object getProperty(java.lang.Object key)
           
 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.
 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
 java.awt.Rectangle selectionBounds()
          The area which is considered part of this GamePiece for purposes of selecting it with the mouse
 void setId(java.lang.String id)
           
 void setMap(Map map)
           
 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)
           
 

Method Detail

setMap

public void setMap(Map map)

getMap

public Map getMap()

draw

public void draw(java.awt.Graphics g,
                 int x,
                 int y,
                 java.awt.Component obs,
                 double zoom)

getPosition

public java.awt.Point getPosition()

setPosition

public void setPosition(java.awt.Point p)

boundingBox

public java.awt.Rectangle boundingBox()
The area which this GamePiece occupies when drawn at the point given by getPosition().


selectionBounds

public java.awt.Rectangle selectionBounds()
The area which is considered part of this GamePiece for purposes of selecting it with the mouse


getParent

public Stack getParent()

setParent

public void setParent(Stack s)

keyEvent

public 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

Returns:
a Command that, when executed, will invoke the same response. Usually a ChangePiece command.
See Also:
ForwardToKeyBuffer

getName

public java.lang.String getName()
The plain English name for this piece


getId

public java.lang.String getId()
Each GamePiece must have a unique String identifier

See Also:
GameState.getNewPieceId()

setId

public void setId(java.lang.String id)

getType

public java.lang.String getType()
The type information is information that does not change during the course of a game. Image file names, popup menu command names, etc., all should be reflected in the type.

See Also:
BasicCommandEncoder

getState

public java.lang.String getState()
The state information is information that can change during the course of a game. State information is saved when the game is saved and is transferred between players on the server. For example, the relative order of pieces in a stack is state information, but whether the stack is expanded is not


setState

public void setState(java.lang.String newState)

setProperty

public 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.


getProperty

public java.lang.Object getProperty(java.lang.Object key)