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 StringBASIC_NAMEstatic StringCLICKED_Xstatic StringCLICKED_Ystatic StringCURRENT_BOARDstatic StringCURRENT_MAPstatic StringCURRENT_Xstatic StringCURRENT_Ystatic StringCURRENT_ZONEstatic StringDECK_NAMEstatic StringDECK_POSITIONstatic StringIDprotected ImageimageDeprecated.Replaced byprotected RectangleimageBoundsprotected StringimageNameprotected ScaledImagePainterimagePainterstatic StringLOCATION_NAMEReturn 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 StringOLD_BOARDstatic StringOLD_LOCATION_NAMEstatic StringOLD_MAPstatic StringOLD_Xstatic StringOLD_Ystatic StringOLD_ZONEstatic StringPIECE_NAMEprotected JPopupMenupopupstatic FontPOPUP_MENU_FONTFields inherited from interface VASSAL.counters.PropertyExporter
LOCALIZED_NAMEFields inherited from interface VASSAL.i18n.TranslatablePiece
PREFIX -
Constructor Summary
Constructors Constructor Description BasicPiece()BasicPiece(String type) -
Method Summary
Modifier and Type Method Description RectangleboundingBox()The area which this GamePiece occupies when drawn at the point (0,0)voiddraw(Graphics g, int x, int y, Component obs, double zoom)Draw this GamePiecebooleanequals(GamePiece c)StringgetDescription()A plain-English description of this type of piecePieceEditorgetEditor()Get the configurer for this traitStringgetGpId()HelpFilegetHelpFile()static HighlightergetHighlighter()Get the Highlighter instance for drawing selected pieces.PieceI18nDatagetI18nData()Return a PieceI18nData object returning the I18n data about this GamePiece.StringgetId()Each GamePiece must have a unique String identifierprotected KeyCommand[]getKeyCommands()StringgetLocalizedName()And the translated name for this pieceObjectgetLocalizedProperty(Object key)ObjectgetLocalizedPublicProperty(Object key)MapgetMap()StringgetName()The plain English name for this pieceStackgetParent()ObjectgetPersistentProperty(Object key)PointgetPosition()ObjectgetProperty(Object key)List<String>getPropertyNames()Return Property names exposed by this traitObjectgetPublicProperty(Object key)ShapegetShape()The shape of the piece from the user's viewpoint.StringgetState()The state information is information that can change during the course of a game.StringgetType()The type information is information that does not change during the course of a game.CommandkeyEvent(KeyStroke stroke)Keyboard events are forward to this method when a piece is selected The GamePiece can respond in any way it likesvoidmergeState(String newState, String oldState)Compute the difference betweennewStateandoldStateand appy that difference to the current statevoidmySetType(String type)Set the type information for this piece.protected ObjectprefsValue(String s)voidsetGpId(String id)static voidsetHighlighter(Highlighter h)Set the Highlighter for all piecesvoidsetId(String id)voidsetMap(Map map)Each GamePiece belongs to a singleMapvoidsetParent(Stack s)CommandsetPersistentProperty(Object key, Object newValue)voidsetPosition(Point p)voidsetProperty(Object key, Object val)Other properties, possibly game-specific, can be associated with a piece.voidsetState(String s)StringtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:EditablePieceSet the type information for this piece. SeeDecorator.myGetType()- Specified by:
mySetTypein interfaceEditablePiece
-
getType
Description copied from interface:GamePieceThe 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:
getTypein interfaceGamePiece- See Also:
BasicCommandEncoder
-
setMap
Description copied from interface:GamePieceEach GamePiece belongs to a singleMap -
getMap
-
getProperty
- Specified by:
getPropertyin interfaceGamePiece- Specified by:
getPropertyin interfacePropertySource
-
getPublicProperty
-
getLocalizedProperty
- Specified by:
getLocalizedPropertyin interfacePropertySource
-
getLocalizedPublicProperty
-
setProperty
Description copied from interface:GamePieceOther 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:
setPropertyin interfaceGamePiece
-
setPersistentProperty
- Specified by:
setPersistentPropertyin interfacePersistentPropertyContainer
-
getPersistentProperty
- Specified by:
getPersistentPropertyin interfacePersistentPropertyContainer
-
prefsValue
-
draw
Description copied from interface:GamePieceDraw this GamePiece -
getKeyCommands
-
getPosition
- Specified by:
getPositionin interfaceGamePiece- Returns:
- the location of this piece on its owning
Map
-
setPosition
- Specified by:
setPositionin interfaceGamePiece
-
getParent
-
setParent
-
boundingBox
Description copied from interface:GamePieceThe area which this GamePiece occupies when drawn at the point (0,0)- Specified by:
boundingBoxin interfaceGamePiece
-
getShape
Description copied from interface:GamePieceThe 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:GamePieceThe plain English name for this piece -
getLocalizedName
Description copied from interface:GamePieceAnd the translated name for this piece- Specified by:
getLocalizedNamein interfaceGamePiece
-
keyEvent
Description copied from interface:GamePieceKeyboard events are forward to this method when a piece is selected The GamePiece can respond in any way it likes- Specified by:
keyEventin interfaceGamePiece- Returns:
- a
Commandthat, when executed, will invoke the same response. Usually aChangePiececommand. - See Also:
ForwardToKeyBuffer
-
getState
Description copied from interface:GamePieceThe 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:StateMergeableCompute the difference betweennewStateandoldStateand appy that difference to the current state- Specified by:
mergeStatein interfaceStateMergeable
-
getId
Description copied from interface:GamePieceEach GamePiece must have a unique String identifier- Specified by:
getIdin 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:EditablePieceA plain-English description of this type of piece- Specified by:
getDescriptionin interfaceEditablePiece
-
getGpId
-
setGpId
-
getHelpFile
- Specified by:
getHelpFilein interfaceEditablePiece
-
getEditor
Description copied from interface:EditablePieceGet the configurer for this trait- Specified by:
getEditorin interfaceEditablePiece
-
toString
-
getI18nData
Description copied from interface:TranslatablePieceReturn a PieceI18nData object returning the I18n data about this GamePiece.- Specified by:
getI18nDatain interfaceTranslatablePiece
-
getPropertyNames
Return Property names exposed by this trait- Specified by:
getPropertyNamesin interfacePropertyNameSource
-