Package VASSAL.counters
Class BasicPiece
java.lang.Object
VASSAL.counters.BasicPiece
- All Implemented Interfaces:
PropertyNameSource
,PropertySource
,EditablePiece
,GamePiece
,PropertyExporter
,StateMergeable
,TranslatablePiece
,PersistentPropertyContainer
public class BasicPiece extends Object implements TranslatablePiece, StateMergeable, PropertyNameSource, PersistentPropertyContainer, PropertyExporter
Basic class for representing a physical component of the game Can be a counter, a card, or an overlay
-
Field Summary
Fields Modifier and Type Field Description static String
BASIC_NAME
static String
CLICKED_X
static String
CLICKED_Y
static String
CURRENT_BOARD
static String
CURRENT_MAP
static String
CURRENT_X
static String
CURRENT_Y
static String
CURRENT_ZONE
static String
DECK_NAME
static String
DECK_POSITION
static String
ID
protected Image
image
Deprecated.Replaced byprotected Rectangle
imageBounds
protected String
imageName
protected ScaledImagePainter
imagePainter
static String
LOCATION_NAME
Return information about the current location of the piece through getProperty(): LocationName - Current Location Name of piece as displayed in Chat Window CurrentX - Current X position CurrentY - Current Y position CurrentMap - Current Map name or "" if not on a map CurrentBoard - Current Board name or "" if not on a map CurrentZone - If the current map has a multi-zoned grid, then return the name of the Zone the piece is in, or "" if the piece is not in any zone, or not on a mapstatic String
OLD_BOARD
static String
OLD_LOCATION_NAME
static String
OLD_MAP
static String
OLD_X
static String
OLD_Y
static String
OLD_ZONE
static String
PIECE_NAME
protected JPopupMenu
popup
static Font
POPUP_MENU_FONT
Fields inherited from interface VASSAL.counters.PropertyExporter
LOCALIZED_NAME
Fields inherited from interface VASSAL.i18n.TranslatablePiece
PREFIX
-
Constructor Summary
Constructors Constructor Description BasicPiece()
BasicPiece(String type)
-
Method Summary
Modifier and Type Method Description Rectangle
boundingBox()
The area which this GamePiece occupies when drawn at the point (0,0)void
draw(Graphics g, int x, int y, Component obs, double zoom)
Draw this GamePieceboolean
equals(GamePiece c)
String
getDescription()
A plain-English description of this type of piecePieceEditor
getEditor()
Get the configurer for this traitString
getGpId()
HelpFile
getHelpFile()
static Highlighter
getHighlighter()
Get the Highlighter instance for drawing selected pieces.PieceI18nData
getI18nData()
Return a PieceI18nData object returning the I18n data about this GamePiece.String
getId()
Each GamePiece must have a unique String identifierprotected KeyCommand[]
getKeyCommands()
String
getLocalizedName()
And the translated name for this pieceObject
getLocalizedProperty(Object key)
Object
getLocalizedPublicProperty(Object key)
Map
getMap()
String
getName()
The plain English name for this pieceStack
getParent()
Object
getPersistentProperty(Object key)
Point
getPosition()
Object
getProperty(Object key)
List<String>
getPropertyNames()
Return Property names exposed by this traitObject
getPublicProperty(Object key)
Shape
getShape()
The shape of the piece from the user's viewpoint.String
getState()
The state information is information that can change during the course of a game.String
getType()
The type information is information that does not change during the course of a game.Command
keyEvent(KeyStroke stroke)
Keyboard events are forward to this method when a piece is selected The GamePiece can respond in any way it likesvoid
mergeState(String newState, String oldState)
Compute the difference betweennewState
andoldState
and appy that difference to the current statevoid
mySetType(String type)
Set the type information for this piece.protected Object
prefsValue(String s)
void
setGpId(String id)
static void
setHighlighter(Highlighter h)
Set the Highlighter for all piecesvoid
setId(String id)
void
setMap(Map map)
Each GamePiece belongs to a singleMap
void
setParent(Stack s)
Command
setPersistentProperty(Object key, Object newValue)
void
setPosition(Point p)
void
setProperty(Object key, Object val)
Other properties, possibly game-specific, can be associated with a piece.void
setState(String s)
String
toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface VASSAL.counters.PropertyExporter
getProperties, getProperties
-
Field Details
-
ID
- See Also:
- Constant Field Values
-
LOCATION_NAME
Return information about the current location of the piece through getProperty(): LocationName - Current Location Name of piece as displayed in Chat Window CurrentX - Current X position CurrentY - Current Y position CurrentMap - Current Map name or "" if not on a map CurrentBoard - Current Board name or "" if not on a map CurrentZone - If the current map has a multi-zoned grid, then return the name of the Zone the piece is in, or "" if the piece is not in any zone, or not on a map- See Also:
- Constant Field Values
-
CURRENT_MAP
- See Also:
- Constant Field Values
-
CURRENT_BOARD
- See Also:
- Constant Field Values
-
CURRENT_ZONE
- See Also:
- Constant Field Values
-
CURRENT_X
- See Also:
- Constant Field Values
-
CURRENT_Y
- See Also:
- Constant Field Values
-
OLD_LOCATION_NAME
- See Also:
- Constant Field Values
-
OLD_MAP
- See Also:
- Constant Field Values
-
OLD_BOARD
- See Also:
- Constant Field Values
-
OLD_ZONE
- See Also:
- Constant Field Values
-
OLD_X
- See Also:
- Constant Field Values
-
OLD_Y
- See Also:
- Constant Field Values
-
BASIC_NAME
- See Also:
- Constant Field Values
-
PIECE_NAME
- See Also:
- Constant Field Values
-
DECK_NAME
- See Also:
- Constant Field Values
-
DECK_POSITION
- See Also:
- Constant Field Values
-
CLICKED_X
- See Also:
- Constant Field Values
-
CLICKED_Y
- See Also:
- Constant Field Values
-
POPUP_MENU_FONT
-
popup
-
imageBounds
-
imagePainter
-
image
Deprecated.Replaced by -
imageName
-
-
Constructor Details
-
BasicPiece
public BasicPiece() -
BasicPiece
-
-
Method Details
-
mySetType
Description copied from interface:EditablePiece
Set the type information for this piece. SeeDecorator.myGetType()
- Specified by:
mySetType
in interfaceEditablePiece
-
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 interfaceGamePiece
- See Also:
BasicCommandEncoder
-
setMap
Description copied from interface:GamePiece
Each GamePiece belongs to a singleMap
-
getMap
-
getProperty
- Specified by:
getProperty
in interfaceGamePiece
- Specified by:
getProperty
in interfacePropertySource
-
getPublicProperty
-
getLocalizedProperty
- Specified by:
getLocalizedProperty
in interfacePropertySource
-
getLocalizedPublicProperty
-
setProperty
Description copied from interface:GamePiece
Other properties, possibly game-specific, can be associated with a piece. The properties may or may not need to be encoded in the piece'sGamePiece.getState()
method.- Specified by:
setProperty
in interfaceGamePiece
-
setPersistentProperty
- Specified by:
setPersistentProperty
in interfacePersistentPropertyContainer
-
getPersistentProperty
- Specified by:
getPersistentProperty
in interfacePersistentPropertyContainer
-
prefsValue
-
draw
Description copied from interface:GamePiece
Draw this GamePiece -
getKeyCommands
-
getPosition
- Specified by:
getPosition
in interfaceGamePiece
- Returns:
- the location of this piece on its owning
Map
-
setPosition
- Specified by:
setPosition
in interfaceGamePiece
-
getParent
-
setParent
-
boundingBox
Description copied from interface:GamePiece
The area which this GamePiece occupies when drawn at the point (0,0)- Specified by:
boundingBox
in interfaceGamePiece
-
getShape
Description copied from interface:GamePiece
The shape of the piece from the user's viewpoint. This defines the area in which the user must click to select or move the piece, for example. LikeGamePiece.boundingBox()
, it assumes the position is (0,0) and must be translated to the actual location where the piece is being drawn. -
equals
-
getName
Description copied from interface:GamePiece
The plain English name for this piece -
getLocalizedName
Description copied from interface:GamePiece
And the translated name for this piece- Specified by:
getLocalizedName
in interfaceGamePiece
-
keyEvent
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 interfaceGamePiece
- Returns:
- a
Command
that, when executed, will invoke the same response. Usually aChangePiece
command. - See Also:
ForwardToKeyBuffer
-
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 -
setState
-
mergeState
Description copied from interface:StateMergeable
Compute the difference betweennewState
andoldState
and appy that difference to the current state- Specified by:
mergeState
in interfaceStateMergeable
-
getId
Description copied from interface:GamePiece
Each GamePiece must have a unique String identifier- Specified by:
getId
in interfaceGamePiece
- See Also:
GameState.getNewPieceId()
-
setId
-
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
Set the Highlighter for all pieces -
getDescription
Description copied from interface:EditablePiece
A plain-English description of this type of piece- Specified by:
getDescription
in interfaceEditablePiece
-
getGpId
-
setGpId
-
getHelpFile
- Specified by:
getHelpFile
in interfaceEditablePiece
-
getEditor
Description copied from interface:EditablePiece
Get the configurer for this trait- Specified by:
getEditor
in interfaceEditablePiece
-
toString
-
getI18nData
Description copied from interface:TranslatablePiece
Return a PieceI18nData object returning the I18n data about this GamePiece.- Specified by:
getI18nData
in interfaceTranslatablePiece
-
getPropertyNames
Return Property names exposed by this trait- Specified by:
getPropertyNames
in interfacePropertyNameSource
-