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.
  • Field Details

    • OLD_ID

      public static final String OLD_ID
      See Also:
      Constant Field Values
    • ID

      public static final String ID
      See Also:
      Constant Field Values
    • IMAGE

      public static final String IMAGE
      See Also:
      Constant Field Values
    • NAME

      public static final String NAME
      See Also:
      Constant Field Values
    • LEVEL

      public static final String LEVEL
      See Also:
      Constant Field Values
    • ACTIVE

      public static final String ACTIVE
      See Also:
      Constant Field Values
    • activateKey

      protected String activateKey
    • upKey

      protected String upKey
    • downKey

      protected String downKey
    • activateModifiers

      protected int activateModifiers
    • upModifiers

      protected int upModifiers
    • downModifiers

      protected int downModifiers
    • upCommand

      protected String upCommand
    • downCommand

      protected String downCommand
    • activateCommand

      protected String activateCommand
    • resetCommand

      protected String resetCommand
    • resetLevel

      protected FormattedString resetLevel
    • loopLevels

      protected boolean loopLevels
    • resetKey

      protected NamedKeyStroke resetKey
    • followProperty

      protected boolean followProperty
    • propertyName

      protected String propertyName
    • followPropertyExpression

      protected Expression followPropertyExpression
    • firstLevelValue

      protected int firstLevelValue
    • rndKey

      protected NamedKeyStroke rndKey
    • value

      protected int value
    • nValues

      protected int nValues
    • xOff

      protected int xOff
    • yOff

      protected int yOff
    • imageName

      protected String[] imageName
    • commonName

      protected String[] commonName
    • size

      protected Rectangle[] size
    • imagePainter

      protected ScaledImagePainter[] imagePainter
    • drawUnderneathWhenSelected

      protected boolean drawUnderneathWhenSelected
    • name

      protected String name
    • commands

      protected KeyCommand[] commands
    • up

      protected KeyCommand up
    • down

      protected KeyCommand down
    • lastBounds

      protected Rectangle lastBounds
    • lastShape

      protected Area 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

      protected NamedKeyStroke activateKeyStroke
    • increaseKeyStroke

      protected NamedKeyStroke increaseKeyStroke
    • decreaseKeyStroke

      protected NamedKeyStroke decreaseKeyStroke
  • Constructor Details

    • Embellishment

      public Embellishment()
    • Embellishment

      public Embellishment​(String type, GamePiece d)
  • 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

      public void mySetType​(String s)
      Description copied from interface: EditablePiece
      Set the type information for this piece. See Decorator.myGetType()
      Specified by:
      mySetType in interface EditablePiece
    • 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

      public String 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 interface GamePiece
      Overrides:
      getLocalizedName in class Decorator
    • getName

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

      public String getName​(boolean localized)
    • getLayerName

      public String getLayerName()
      Return raw Embellishment name
      Returns:
      Embellishment name
    • mySetState

      public void mySetState​(String s)
      Description copied from class: Decorator
      Set just the state of this trait
      Specified by:
      mySetState in class Decorator
      See Also:
      Decorator.myGetState()
    • myGetType

      public String myGetType()
      Specified by:
      myGetType in class Decorator
      Returns:
      the type of this trait alone
      See Also:
      Decorator.getType()
    • oldGetType

      @Deprecated(since="2020-08-06", forRemoval=true) public String oldGetType()
      Deprecated, for removal: This API element is subject to removal in a future version.
      No Replacement
    • myGetState

      public String myGetState()
      Specified by:
      myGetState in class Decorator
      Returns:
      the state of this trait alone
      See Also:
      Decorator.getState()
    • draw

      public void draw​(Graphics g, int x, int y, Component obs, double zoom)
      Description copied from interface: GamePiece
      Draw this GamePiece
      Specified by:
      draw in interface GamePiece
      x - x-location of the center of the piece
      y - y-location of the center of the piece
      obs - the Component on which this piece is being drawn
      zoom - the scaling factor.
    • checkPropertyLevel

      protected void checkPropertyLevel()
    • myGetKeyCommands

      public KeyCommand[] myGetKeyCommands()
      Specified by:
      myGetKeyCommands in class Decorator
      Returns:
      the commands for this trait alone
      See Also:
      Decorator.getKeyCommands()
    • myKeyEvent

      public Command myKeyEvent​(KeyStroke stroke)
      Description copied from class: Decorator
      The response of this trait alone to the given KeyStroke
      Specified by:
      myKeyEvent in class Decorator
      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(since="2020-08-06", forRemoval=true) protected Image getCurrentImage()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use ImageOp.getImage() instead.
    • boundingBox

      public Rectangle boundingBox()
      Description copied from interface: GamePiece
      The area which this GamePiece occupies when drawn at the point (0,0)
      Specified by:
      boundingBox in interface GamePiece
    • getCurrentImageBounds

      public Rectangle getCurrentImageBounds()
    • getShape

      public Shape 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.
      Specified by:
      getShape in interface GamePiece
    • getDescription

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

      public Object getProperty​(Object key)
      Specified by:
      getProperty in interface GamePiece
      Specified by:
      getProperty in interface PropertySource
      Overrides:
      getProperty in class Decorator
    • getLocalizedProperty

      public Object getLocalizedProperty​(Object key)
      Specified by:
      getLocalizedProperty in interface PropertySource
      Overrides:
      getLocalizedProperty in class Decorator
    • strip

      protected String strip​(String s)
    • getCommonName

      protected String getCommonName​(boolean localized, int i)
      Get the name of this level (alone)
    • getLocalizedCommonName

      protected String getLocalizedCommonName​(int i)
      Get the localized name of this level (alone)
    • 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
      Overrides:
      getEditor in class Decorator
    • 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

      public List<String> getPropertyNames()
      Description copied from class: Decorator
      Default Property Name Source
      Specified by:
      getPropertyNames in interface PropertyNameSource
      Overrides:
      getPropertyNames in class Decorator
    • getI18nData

      public PieceI18nData getI18nData()
      Description copied from class: Decorator
      Return I18n data for this piece
      Specified by:
      getI18nData in interface TranslatablePiece
      Overrides:
      getI18nData in class Decorator
      Returns:
      I18n data