VASSAL.counters
Class BasicPiece

java.lang.Object
  |
  +--VASSAL.counters.BasicPiece
All Implemented Interfaces:
EditablePiece, GamePiece

public class BasicPiece
extends java.lang.Object
implements EditablePiece

Basic class for representing a physical component of the game Can be a counter, a card, or an overlay


Field Summary
static java.lang.String ID
           
protected  java.lang.String imageName
           
protected  java.awt.Dimension imageSize
           
protected  javax.swing.JPopupMenu popup
           
static java.awt.Font POPUP_MENU_FONT
           
 
Constructor Summary
BasicPiece()
           
BasicPiece(java.lang.String type)
           
 
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)
           
 boolean equals(GamePiece c)
           
 java.lang.String getDescription()
          A plain-English description of this type of piece
 PieceEditor getEditor()
          Get the configurer for this trait
 HelpFile getHelpFile()
           
static Highlighter getHighlighter()
          Get the Highlighter instance for drawing selected pieces.
 java.lang.String getId()
          Each GamePiece must have a unique String identifier
protected  KeyCommand[] getKeyCommands()
           
 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
protected  java.awt.Image myImage()
           
 void mySetType(java.lang.String type)
          Set the type information for this piece.
protected  java.lang.Object prefsValue(java.lang.String s)
           
 java.awt.Rectangle selectionBounds()
          The area which is considered part of this GamePiece for purposes of selecting it with the mouse
static void setHighlighter(Highlighter h)
          Set the Highlighter for all pieces
 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 s)
           
 void showPopup(java.awt.event.MouseEvent e)
           
static void verifySize(java.awt.Dimension d, java.awt.Image i, java.awt.Component obs)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final java.lang.String ID

POPUP_MENU_FONT

public static java.awt.Font POPUP_MENU_FONT

imageSize

protected java.awt.Dimension imageSize

popup

protected javax.swing.JPopupMenu popup

imageName

protected java.lang.String imageName
Constructor Detail

BasicPiece

public BasicPiece()

BasicPiece

public BasicPiece(java.lang.String type)
Method Detail

mySetType

public void mySetType(java.lang.String type)
Description copied from interface: EditablePiece
Set the type information for this piece. See Decorator.myGetType()
Specified by:
mySetType in interface EditablePiece

getType

public java.lang.String getType()
Description copied from interface: GamePiece
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.
Specified by:
getType in interface GamePiece
Following copied from interface: VASSAL.counters.GamePiece
See Also:
BasicCommandEncoder

setMap

public void setMap(Map map)
Specified by:
setMap in interface GamePiece

getMap

public Map getMap()
Specified by:
getMap in interface GamePiece

getProperty

public java.lang.Object getProperty(java.lang.Object key)
Specified by:
getProperty in interface GamePiece

setProperty

public void setProperty(java.lang.Object key,
                        java.lang.Object val)
Description copied from interface: GamePiece
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 GamePiece.getState() method.
Specified by:
setProperty in interface GamePiece

prefsValue

protected java.lang.Object prefsValue(java.lang.String s)

myImage

protected java.awt.Image myImage()

verifySize

public static void verifySize(java.awt.Dimension d,
                              java.awt.Image i,
                              java.awt.Component obs)

draw

public void draw(java.awt.Graphics g,
                 int x,
                 int y,
                 java.awt.Component obs,
                 double zoom)
Specified by:
draw in interface GamePiece

getKeyCommands

protected KeyCommand[] getKeyCommands()

getPosition

public java.awt.Point getPosition()
Specified by:
getPosition in interface GamePiece

setPosition

public void setPosition(java.awt.Point p)
Specified by:
setPosition in interface GamePiece

getParent

public Stack getParent()
Specified by:
getParent in interface GamePiece

setParent

public void setParent(Stack s)
Specified by:
setParent in interface GamePiece

boundingBox

public java.awt.Rectangle boundingBox()
Description copied from interface: GamePiece
The area which this GamePiece occupies when drawn at the point given by getPosition().
Specified by:
boundingBox in interface GamePiece

selectionBounds

public java.awt.Rectangle selectionBounds()
Description copied from interface: GamePiece
The area which is considered part of this GamePiece for purposes of selecting it with the mouse
Specified by:
selectionBounds in interface GamePiece

equals

public boolean equals(GamePiece c)

getName

public java.lang.String getName()
Description copied from interface: GamePiece
The plain English name for this piece
Specified by:
getName in interface GamePiece

keyEvent

public Command keyEvent(javax.swing.KeyStroke stroke)
Description copied from interface: GamePiece
Keyboard events are forward to this method when a piece is selected The GamePiece can respond in any way it likes
Specified by:
keyEvent in interface GamePiece
Following copied from interface: VASSAL.counters.GamePiece
Returns:
a Command that, when executed, will invoke the same response. Usually a ChangePiece command.
See Also:
ForwardToKeyBuffer

showPopup

public void showPopup(java.awt.event.MouseEvent e)

getState

public java.lang.String getState()
Description copied from interface: GamePiece
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
Specified by:
getState in interface GamePiece

setState

public void setState(java.lang.String s)
Specified by:
setState in interface GamePiece

getId

public java.lang.String getId()
Description copied from interface: GamePiece
Each GamePiece must have a unique String identifier
Specified by:
getId in interface GamePiece
Following copied from interface: VASSAL.counters.GamePiece
See Also:
GameState.getNewPieceId()

setId

public void setId(java.lang.String id)
Specified by:
setId in interface GamePiece

getHighlighter

public static Highlighter getHighlighter()
Get the Highlighter instance for drawing selected pieces. Note that since this is a static method, all pieces in a module will always use the same Highlighter

setHighlighter

public static void setHighlighter(Highlighter h)
Set the Highlighter for all pieces

getDescription

public java.lang.String getDescription()
Description copied from interface: EditablePiece
A plain-English description of this type of piece
Specified by:
getDescription in interface EditablePiece

getHelpFile

public HelpFile getHelpFile()
Specified by:
getHelpFile in interface EditablePiece

getEditor

public PieceEditor getEditor()
Description copied from interface: EditablePiece
Get the configurer for this trait
Specified by:
getEditor in interface EditablePiece