Package VASSAL.counters
Class Embellishment
java.lang.Object
VASSAL.counters.Decorator
VASSAL.counters.Embellishment
- All Implemented Interfaces:
PropertyNameSource
,PropertySource
,EditablePiece
,GamePiece
,PropertyExporter
,StateMergeable
,TranslatablePiece
,PersistentPropertyContainer
public class Embellishment extends Decorator implements TranslatablePiece
The "Layer" trait. Contains a list of images that the user may cycle through.
The current image is superimposed over the inner piece. The entire layer may
be activated or deactivated.
Changes to support NamedKeyStrokes:
- Random and reset command changed directly to Name Key Strokes.
- Disentangle alwaysActive flag from length of activateKey field. Make a
separate field and save in type
- Add a Version field to type to enable conversion of Activate/Increase/Decrease
commands. Note commands with more than 1 target keycode cannot be converted
- Simplify code. Removed Version 0 (3.1) code to a separate class Embellishment0. The BasicCommandEncoder
replaces this class with an Embellishment0 if Embellishment(type, inner) returns
a version 0 Embellishment trait.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
Embellishment.Ed
Return Property names exposed by this trait -
Field Summary
Fields inherited from interface VASSAL.counters.PropertyExporter
LOCALIZED_NAME
Fields inherited from interface VASSAL.i18n.TranslatablePiece
PREFIX
-
Constructor Summary
Constructors Constructor Description Embellishment()
Embellishment(String type, GamePiece d)
-
Method Summary
Modifier and Type Method Description Rectangle
boundingBox()
The area which this GamePiece occupies when drawn at the point (0,0)boolean
canBeActivated()
Can this Layer be Activated? Old-style depended on checking if any activation keys where specified.protected void
checkPropertyLevel()
protected void
doDecrease()
protected void
doIncrease()
void
draw(Graphics g, int x, int y, Component obs, double zoom)
Draw this GamePieceprotected String
getCommonName(boolean localized, int i)
Get the name of this level (alone)protected Image
getCurrentImage()
Deprecated, for removal: This API element is subject to removal in a future version.Rectangle
getCurrentImageBounds()
String
getDescription()
A plain-English description of this type of piecePieceEditor
getEditor()
Get the configurer for this traitHelpFile
getHelpFile()
PieceI18nData
getI18nData()
Return I18n data for this pieceString
getLayerName()
Return raw Embellishment namestatic Embellishment
getLayerWithMatchingActivateCommand(GamePiece piece, KeyStroke stroke, boolean active)
If the argument GamePiece contains a Layer whose "activate" command matches the given keystroke, and whose active status matches the boolean argument, return that Layerstatic Embellishment
getLayerWithMatchingActivateCommand(GamePiece piece, NamedKeyStroke stroke, boolean active)
protected String
getLocalizedCommonName(int i)
Get the localized name of this level (alone)String
getLocalizedName()
Return the translated name for this piece.Object
getLocalizedProperty(Object key)
String
getName()
The plain English name for this pieceString
getName(boolean localized)
Object
getProperty(Object key)
List<String>
getPropertyNames()
Default Property Name SourceShape
getShape()
Return the Shape of the counter by adding the shape of this layer to the shape of all inner traits.int
getValue()
int
getVersion()
boolean
isActive()
KeyCommand[]
myGetKeyCommands()
String
myGetState()
String
myGetType()
Command
myKeyEvent(KeyStroke stroke)
The response of this trait alone to the given KeyStrokevoid
mySetState(String s)
Set just the state of this traitvoid
mySetType(String s)
Set the type information for this piece.String
oldGetType()
Deprecated, for removal: This API element is subject to removal in a future version.No Replacementvoid
setActive(boolean act)
void
setValue(int val)
Set the current level - First level = 0 Does not change the active statusprotected String
strip(String s)
Methods inherited from class VASSAL.counters.Decorator
getCommandDescription, getDecorator, getI18nData, getI18nData, getId, getInner, getInnermost, getKeyCommands, getMap, getOuter, getOutermost, getParent, getPersistentProperty, getPosition, getProperties, getState, getTranslation, getType, isSelected, keyEvent, mergeState, putOldProperties, repack, reportDataError, reportDataError, reportDataError, setId, setInner, setMap, setOldProperties, setOldProperties, setParent, setPersistentProperty, setPosition, setProperty, setSelected, setState, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface VASSAL.counters.GamePiece
getId, getMap, getParent, getPosition, getState, getType, keyEvent, setId, setMap, setParent, setPosition, setProperty, setState
Methods inherited from interface VASSAL.counters.PropertyExporter
getProperties
-
Field Details
-
OLD_ID
- See Also:
- Constant Field Values
-
ID
- See Also:
- Constant Field Values
-
IMAGE
- See Also:
- Constant Field Values
-
NAME
- See Also:
- Constant Field Values
-
LEVEL
- See Also:
- Constant Field Values
-
ACTIVE
- See Also:
- Constant Field Values
-
activateKey
-
upKey
-
downKey
-
activateModifiers
protected int activateModifiers -
upModifiers
protected int upModifiers -
downModifiers
protected int downModifiers -
upCommand
-
downCommand
-
activateCommand
-
resetCommand
-
resetLevel
-
loopLevels
protected boolean loopLevels -
resetKey
-
followProperty
protected boolean followProperty -
propertyName
-
followPropertyExpression
-
firstLevelValue
protected int firstLevelValue -
rndKey
-
value
protected int value -
nValues
protected int nValues -
xOff
protected int xOff -
yOff
protected int yOff -
imageName
-
commonName
-
size
-
imagePainter
-
drawUnderneathWhenSelected
protected boolean drawUnderneathWhenSelected -
name
-
commands
-
up
-
down
-
lastBounds
-
lastShape
-
BASE_VERSION
public static final int BASE_VERSION- See Also:
- Constant Field Values
-
CURRENT_VERSION
public static final int CURRENT_VERSION- See Also:
- Constant Field Values
-
version
protected int version -
alwaysActive
protected boolean alwaysActive -
activateKeyStroke
-
increaseKeyStroke
-
decreaseKeyStroke
-
-
Constructor Details
-
Embellishment
public Embellishment() -
Embellishment
-
-
Method Details
-
isActive
public boolean isActive() -
setActive
public void setActive(boolean act) -
getValue
public int getValue() -
setValue
public void setValue(int val)Set the current level - First level = 0 Does not change the active status- Parameters:
val
- Value to set
-
mySetType
Description copied from interface:EditablePiece
Set the type information for this piece. SeeDecorator.myGetType()
- Specified by:
mySetType
in interfaceEditablePiece
-
canBeActivated
public boolean canBeActivated()Can this Layer be Activated? Old-style depended on checking if any activation keys where specified. New-stule maintains a separate alwaysActive variable- Returns:
- true if this layer trait has an activate command
-
getLocalizedName
Description copied from class:Decorator
Return the translated name for this piece. Most pieces do not have translatable elements, so just return the standard name- Specified by:
getLocalizedName
in interfaceGamePiece
- Overrides:
getLocalizedName
in classDecorator
-
getName
Description copied from interface:GamePiece
The plain English name for this piece -
getName
-
getLayerName
Return raw Embellishment name- Returns:
- Embellishment name
-
mySetState
Description copied from class:Decorator
Set just the state of this trait- Specified by:
mySetState
in classDecorator
- See Also:
Decorator.myGetState()
-
myGetType
- Specified by:
myGetType
in classDecorator
- Returns:
- the type of this trait alone
- See Also:
Decorator.getType()
-
oldGetType
Deprecated, for removal: This API element is subject to removal in a future version.No Replacement -
myGetState
- Specified by:
myGetState
in classDecorator
- Returns:
- the state of this trait alone
- See Also:
Decorator.getState()
-
draw
Description copied from interface:GamePiece
Draw this GamePiece -
checkPropertyLevel
protected void checkPropertyLevel() -
myGetKeyCommands
- Specified by:
myGetKeyCommands
in classDecorator
- Returns:
- the commands for this trait alone
- See Also:
Decorator.getKeyCommands()
-
myKeyEvent
Description copied from class:Decorator
The response of this trait alone to the given KeyStroke- Specified by:
myKeyEvent
in classDecorator
- Parameters:
stroke
- Stroke to apply- Returns:
- Generated Command or null if no effect
- See Also:
Decorator.keyEvent(javax.swing.KeyStroke)
-
doIncrease
protected void doIncrease() -
doDecrease
protected void doDecrease() -
getCurrentImage
Deprecated, for removal: This API element is subject to removal in a future version.UseImageOp.getImage()
instead. -
boundingBox
Description copied from interface:GamePiece
The area which this GamePiece occupies when drawn at the point (0,0)- Specified by:
boundingBox
in interfaceGamePiece
-
getCurrentImageBounds
-
getShape
Return the Shape of the counter by adding the shape of this layer to the shape of all inner traits. Minimize generation of new Area objects. -
getDescription
Description copied from interface:EditablePiece
A plain-English description of this type of piece- Specified by:
getDescription
in interfaceEditablePiece
-
getProperty
- Specified by:
getProperty
in interfaceGamePiece
- Specified by:
getProperty
in interfacePropertySource
- Overrides:
getProperty
in classDecorator
-
getLocalizedProperty
- Specified by:
getLocalizedProperty
in interfacePropertySource
- Overrides:
getLocalizedProperty
in classDecorator
-
strip
-
getCommonName
Get the name of this level (alone) -
getLocalizedCommonName
Get the localized name of this level (alone) -
getHelpFile
- Specified by:
getHelpFile
in interfaceEditablePiece
-
getEditor
Description copied from interface:EditablePiece
Get the configurer for this trait- Specified by:
getEditor
in interfaceEditablePiece
- Overrides:
getEditor
in classDecorator
-
getVersion
public int getVersion() -
getLayerWithMatchingActivateCommand
public static Embellishment getLayerWithMatchingActivateCommand(GamePiece piece, KeyStroke stroke, boolean active)If the argument GamePiece contains a Layer whose "activate" command matches the given keystroke, and whose active status matches the boolean argument, return that Layer -
getLayerWithMatchingActivateCommand
public static Embellishment getLayerWithMatchingActivateCommand(GamePiece piece, NamedKeyStroke stroke, boolean active) -
getPropertyNames
Description copied from class:Decorator
Default Property Name Source- Specified by:
getPropertyNames
in interfacePropertyNameSource
- Overrides:
getPropertyNames
in classDecorator
-
getI18nData
Description copied from class:Decorator
Return I18n data for this piece- Specified by:
getI18nData
in interfaceTranslatablePiece
- Overrides:
getI18nData
in classDecorator
- Returns:
- I18n data
-
ImageOp.getImage()
instead.