Package VASSAL.counters
Class Labeler
java.lang.Object
VASSAL.counters.Decorator
VASSAL.counters.Labeler
- All Implemented Interfaces:
PropertyNameSource
,PropertySource
,EditablePiece
,GamePiece
,PropertyExporter
,StateMergeable
,TranslatablePiece
,PersistentPropertyContainer
,RecursionLimiter.Loopable
public class Labeler extends Decorator implements TranslatablePiece, RecursionLimiter.Loopable
Displays a text label, with content specified by the user at runtime.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
Labeler.HTMLLabelOp
protected static class
Labeler.LabelOp
-
Field Summary
Fields Modifier and Type Field Description static int
BOTTOM
Deprecated, for removal: This API element is subject to removal in a future version.static int
CENTER
Deprecated, for removal: This API element is subject to removal in a future version.protected String
description
static int
HORIZONTAL_ALIGNMENT
Deprecated, for removal: This API element is subject to removal in a future version.static String
ID
protected ScaledImagePainter
imagePainter
Deprecated.protected Rectangle
lastRect
protected Area
lastShape
static int
LEFT
Deprecated, for removal: This API element is subject to removal in a future version.protected KeyCommand
menuKeyCommand
protected String
propertyName
static int
RIGHT
Deprecated, for removal: This API element is subject to removal in a future version.protected int
rotateDegrees
protected Color
textBg
protected Color
textFg
static int
TOP
Deprecated, for removal: This API element is subject to removal in a future version.static int
VERTICAL_ALIGNMENT
Deprecated, for removal: This API element is subject to removal in a future version.Fields inherited from interface VASSAL.counters.PropertyExporter
LOCALIZED_NAME
Fields inherited from interface VASSAL.i18n.TranslatablePiece
PREFIX
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description Rectangle
boundingBox()
The area which this GamePiece occupies when drawn at the point (0,0)protected String
clean(String s)
void
draw(Graphics g, int x, int y, Component obs, double zoom)
Draw this GamePiecestatic void
drawLabel(Graphics g, String text, int x, int y, int hAlign, int vAlign, Color fgColor, Color bgColor)
Deprecated, for removal: This API element is subject to removal in a future version.static void
drawLabel(Graphics g, String text, int x, int y, Font f, int hAlign, int vAlign, Color fgColor, Color bgColor, Color borderColor)
Deprecated, for removal: This API element is subject to removal in a future version.String
getComponentName()
String
getComponentTypeName()
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
getLabel()
String
getLocalizedLabel()
String
getLocalizedName()
Return the translated name for this piece.Object
getLocalizedProperty(Object key)
String
getName()
The plain English name for this pieceObject
getProperty(Object key)
List<String>
getPropertyNames()
Return Property names exposed by this traitShape
getShape()
Return the Shape of the counter by adding the shape of this label to the shape of all inner traits.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 type)
Set the type information for this piece.void
setBackground(Color textBg)
void
setForeground(Color textFg)
void
setLabel(String s)
protected void
updateCachedImage()
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
-
ID
- See Also:
- Constant Field Values
-
textBg
-
textFg
-
CENTER
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
- Constant Field Values
-
RIGHT
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
- Constant Field Values
-
LEFT
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
- Constant Field Values
-
TOP
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
- Constant Field Values
-
BOTTOM
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
- Constant Field Values
-
HORIZONTAL_ALIGNMENT
Deprecated, for removal: This API element is subject to removal in a future version. -
VERTICAL_ALIGNMENT
Deprecated, for removal: This API element is subject to removal in a future version. -
imagePainter
Deprecated. -
rotateDegrees
protected int rotateDegrees -
propertyName
-
description
-
lastRect
-
lastShape
-
-
Constructor Details
-
Labeler
public Labeler() -
Labeler
-
-
Method Details
-
mySetType
Description copied from interface:EditablePiece
Set the type information for this piece. SeeDecorator.myGetType()
- Specified by:
mySetType
in interfaceEditablePiece
-
clean
-
getLocalizedProperty
- Specified by:
getLocalizedProperty
in interfacePropertySource
- Overrides:
getLocalizedProperty
in classDecorator
-
getProperty
- Specified by:
getProperty
in interfaceGamePiece
- Specified by:
getProperty
in interfacePropertySource
- Overrides:
getProperty
in classDecorator
-
myGetType
- Specified by:
myGetType
in classDecorator
- Returns:
- the type of this trait alone
- See Also:
Decorator.getType()
-
myGetState
- Specified by:
myGetState
in classDecorator
- Returns:
- the state of this trait alone
- See Also:
Decorator.getState()
-
mySetState
Description copied from class:Decorator
Set just the state of this trait- Specified by:
mySetState
in classDecorator
- See Also:
Decorator.myGetState()
-
getName
Description copied from interface:GamePiece
The plain English name for this piece -
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
-
draw
Description copied from interface:GamePiece
Draw this GamePiece -
updateCachedImage
protected void updateCachedImage() -
setLabel
-
setBackground
-
setForeground
-
getLabel
-
getLocalizedLabel
-
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
Return the Shape of the counter by adding the shape of this label to the shape of all inner traits. Minimize generation of new Area objects. -
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)
-
getDescription
Description copied from interface:EditablePiece
A plain-English description of this type of piece- Specified by:
getDescription
in interfaceEditablePiece
-
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
-
getPropertyNames
Return Property names exposed by this trait- 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
-
getComponentTypeName
- Specified by:
getComponentTypeName
in interfaceRecursionLimiter.Loopable
-
getComponentName
- Specified by:
getComponentName
in interfaceRecursionLimiter.Loopable
-
drawLabel
@Deprecated(since="2020-08-27", forRemoval=true) public static void drawLabel(Graphics g, String text, int x, int y, int hAlign, int vAlign, Color fgColor, Color bgColor)Deprecated, for removal: This API element is subject to removal in a future version. -
drawLabel
@Deprecated(since="2020-08-27", forRemoval=true) public static void drawLabel(Graphics g, String text, int x, int y, Font f, int hAlign, int vAlign, Color fgColor, Color bgColor, Color borderColor)Deprecated, for removal: This API element is subject to removal in a future version.
-
LabelUtils.drawLabel(Graphics, String, int, int, int, int, Color, Color)
instead.