Class TurnTracker
java.lang.Object
VASSAL.search.AbstractImageFinder
VASSAL.build.AbstractBuildable
VASSAL.build.AbstractConfigurable
VASSAL.build.module.turn.TurnComponent
VASSAL.build.module.turn.TurnTracker
- All Implemented Interfaces:
ActionListener
,EventListener
,AutoConfigurable
,Buildable
,Configurable
,GameComponent
,PropertyNameSource
,CommandEncoder
,ComponentDescription
,ValidityChecker
,Translatable
,Auditable
,ImageSearchTarget
,SearchTarget
,RecursionLimiter.Loopable
,UniqueIdManager.Identifyable
public class TurnTracker
extends TurnComponent
implements CommandEncoder, GameComponent, ActionListener, UniqueIdManager.Identifyable, RecursionLimiter.Loopable, ComponentDescription
Generic Turn Counter
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
protected class
static class
static class
protected class
protected class
Nested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
protected static final String
protected int
protected static final String
protected static final String
protected static final String
protected static String
protected static final String
protected static final String
protected static final String
static final String
protected boolean
static final String
static final String
protected String
protected static final UniqueIdManager
protected MutableProperty.Impl
protected MutableProperty.Impl
protected LaunchButton
protected JPanel
static final String
protected static final String
protected static final String
static final String
protected static final String
protected String
protected static final String
static final String
protected static final String
protected static final String
static final String
protected NamedKeyStrokeListener
protected static final String
Variable name for reporting formatstatic final String
protected int
protected JPopupMenu
protected static final String
static final String
protected NamedKeyStrokeListener
protected static final String
protected static final String
static final String
protected FormattedString
protected String
protected String
protected String
protected static final String
protected static String
protected TurnTracker.SetDialog
protected String
static final String
static final String
protected static final String
static final String
protected int
protected FormattedString
protected TurnTracker.TurnWidget
protected TurnTracker.TurnWindow
protected static String
protected int
Fields inherited from class VASSAL.build.module.turn.TurnComponent
description, DESCRIPTION, levels
Fields inherited from class VASSAL.build.AbstractConfigurable
changeSupport, config, localizedName, myI18nData, name
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validator
Fields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
void
Classes extending AbstractImageFinder should override this method in order to add the names of any image files they use to the collection.void
Adds this component to its parent.protected void
protected void
protected void
protected void
Translate a String into aCommand
protected void
Translate aCommand
into a StringA list of all active TurnLevels within the TurnTrackerClass<?>[]
String[]
Return an array of Strings describing the attributes of this object.String[]
Lists all the buildFile (XML) attribute names for this component.Class<?>[]
Return the Class for the attributes of this object.Called by theBuildable.getBuildElement(org.w3c.dom.Document)
method to write the attributes into an XML elementgetAttributeVisibility
(String name) By default, all attributes are visibleReturn the name of the trait or Component an Auditable isReturn a description of the Type of trait or Component an Auditable isstatic String
protected Font
protected int
protected int
getId()
protected int
protected String
Calculate the maximum sized turn string that can be generated by any turn combination.protected int
Calculate the maximum width for the turnWidget to display any item.When saving a game, each GameComponent should return aCommand
that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return nullgetState()
protected String
Build the turn string to be displayed from the currently active Child TurnLevel'sprotected boolean
isDocked()
protected void
next()
protected void
prev()
void
Remove this component from its parentvoid
replace
(StringBuilder s, String from, String to) protected void
reset()
protected void
save()
protected void
saveSet()
protected void
set()
void
setAttribute
(String key, Object value) Sets a buildFile (XML) attribute value for this component.protected void
protected void
setDocked
(boolean dock) protected void
void
protected void
void
void
setup
(boolean gameStarting) Notify the GameComponent that a game has started/endedprotected void
updateString
(String str, String[] from, String[] to) protected void
updateTurnDisplay
(String command) void
Methods inherited from class VASSAL.build.module.turn.TurnComponent
addLevel, getDescription, getTurnLevel, getTurnLevelCount, getTurnLevels, removeLevel
Methods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, getExpressionList, getI18nData, getI18nPrefix, getLocalizedConfigureName, getPropertyList, getTypeName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureName
Methods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, build, buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getNonFolderAncestor, getPropertyNames, setAncestor, validate
Methods inherited from class VASSAL.search.AbstractImageFinder
getAllImageNames, getLocalImageNames
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface VASSAL.build.Buildable
build, getBuildElement, isMandatory, isMovable, isUnique
Methods inherited from interface VASSAL.configure.ComponentDescription
getDescription
Methods inherited from interface VASSAL.tools.UniqueIdManager.Identifyable
getConfigureName
-
Field Details
-
idMgr
-
COMMAND_PREFIX
- See Also:
-
DEFAULT_FONT_SIZE_PROPERTY
- See Also:
-
DEFAULT_FONT_BOLD_PROPERTY
- See Also:
-
DEFAULT_DOCKED_PROPERTY
- See Also:
-
NAME
- See Also:
-
HOT_KEY
- See Also:
-
NEXT_HOT_KEY
- See Also:
-
PREV_HOT_KEY
- See Also:
-
ICON
- See Also:
-
BUTTON_TEXT
- See Also:
-
BUTTON_TOOLTIP
- See Also:
-
TURN_FORMAT
- See Also:
-
REPORT_FORMAT
- See Also:
-
TOOLTIP
- See Also:
-
LENGTH
- See Also:
-
LENGTH_STYLE
- See Also:
-
PLUS_BUTTON_WIDTH
- See Also:
-
TURN_BUTTON_HEIGHT
- See Also:
-
FWD_ONLY
- See Also:
-
FONT_SIZE
- See Also:
-
FONT_BOLD
- See Also:
-
DOCKED
- See Also:
-
OLD_TURN
-
NEW_TURN
- See Also:
-
LEVEL
- See Also:
-
TURN_FONT
- See Also:
-
SET_COMMAND
-
DOCK_COMMAND
-
UNDOCK_COMMAND
-
NEXT
- See Also:
-
PREV
- See Also:
-
SET
- See Also:
-
PROP_VALUE
- See Also:
-
PROP_COMMAND
- See Also:
-
LENGTH_VARIABLE
- See Also:
-
LENGTH_MAXIMUM
- See Also:
-
LENGTH_FIXED
- See Also:
-
turnFormat
-
reportFormat
-
turnWindow
-
turnWidget
-
launchWidget
-
setDialog
-
launch
-
nextListener
-
prevListener
-
toolTip
-
savedState
-
savedSetState
-
savedTurn
-
popup
-
currentLevel
protected int currentLevel -
id
-
width
protected int width -
lengthStyle
-
plusButtonWidth
protected int plusButtonWidth -
turnButtonHeight
protected int turnButtonHeight -
fwdOnly
protected boolean fwdOnly -
lastCommand
-
lastTurn
-
-
Constructor Details
-
TurnTracker
public TurnTracker()
-
-
Method Details
-
getState
-
setState
-
setLaunchToolTip
protected void setLaunchToolTip() -
getAttributeNames
Description copied from class:AbstractBuildable
Lists all the buildFile (XML) attribute names for this component. If this component is ALSO anAbstractConfigurable
, then this list of attributes determines the appropriate attribute order forAbstractConfigurable.getAttributeDescriptions()
andAbstractConfigurable.getAttributeTypes()
.- Specified by:
getAttributeNames
in interfaceAutoConfigurable
- Overrides:
getAttributeNames
in classTurnComponent
- Returns:
- a list of all buildFile (XML) attribute names for this component
-
setAttribute
Description copied from class:AbstractBuildable
Sets a buildFile (XML) attribute value for this component. Thekey
parameter will be one of those listed inAbstractBuildable.getAttributeNames()
. If thevalue
parameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)
for the samekey
. If the implementing class extendsAbstractConfigurable
, thenvalue
will be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
- Specified by:
setAttribute
in interfaceAutoConfigurable
- Specified by:
setAttribute
in interfaceTranslatable
- Overrides:
setAttribute
in classTurnComponent
- Parameters:
key
- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()
value
- If thevalue
parameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)
for the samekey
. If the implementing class extendsAbstractConfigurable
, thenvalue
can also be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
-
setWidgetWidth
protected void setWidgetWidth() -
getMaximumWidth
protected int getMaximumWidth()Calculate the maximum width for the turnWidget to display any item. First calculate the maximum string that can be displayed, then convert this to a width based on the display font.- Returns:
- Maximum Width
-
setDisplayFont
protected void setDisplayFont() -
getDisplayFont
-
setFontSize
protected void setFontSize() -
getFontSize
protected int getFontSize() -
getFontStyle
protected int getFontStyle() -
isDocked
protected boolean isDocked() -
setDocked
protected void setDocked(boolean dock) -
getAttributeValueString
Description copied from interface:AutoConfigurable
Called by theBuildable.getBuildElement(org.w3c.dom.Document)
method to write the attributes into an XML element- Specified by:
getAttributeValueString
in interfaceAutoConfigurable
- Specified by:
getAttributeValueString
in interfaceTranslatable
- Overrides:
getAttributeValueString
in classTurnComponent
- Parameters:
key
- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()
- Returns:
- a String representation of the XML buildFile attribute with the given name. When initializing a module,
this String value will loaded from the XML and passed to
AbstractBuildable.setAttribute(java.lang.String, java.lang.Object)
. It is also frequently used for checking the current value of an attribute.
-
getAttributeDescriptions
Description copied from interface:AutoConfigurable
Return an array of Strings describing the attributes of this object. These strings are used as prompts in the Properties window for this object.- Specified by:
getAttributeDescriptions
in interfaceAutoConfigurable
- Overrides:
getAttributeDescriptions
in classTurnComponent
- Returns:
- an array of Strings describing the buildFile (XML) attributes of this component. These strings are used as prompts in the
Properties window for this object, when the component is configured in the Editor. The order of descriptions should
be the same as the order of names in
AbstractBuildable.getAttributeNames()
-
getAttributeTypes
Description copied from interface:AutoConfigurable
Return the Class for the attributes of this object. Valid classes are: String, Integer, Double, Boolean, Image, File, Color, and KeyStroke- Specified by:
getAttributeTypes
in interfaceAutoConfigurable
- Overrides:
getAttributeTypes
in classTurnComponent
- Returns:
- the Class for the buildFile (XML) attributes of this component. Valid classes include: String, Integer, Double, Boolean, Image,
Color, and KeyStroke, along with any class for which a Configurer exists in VASSAL.configure. The class determines, among other things,
which type of
AutoConfigurer
will be used to configure the attribute when the object is configured in the Editor. The order of classes should be the same as the order of names inAbstractBuildable.getAttributeNames()
-
getAttributeVisibility
Description copied from class:AbstractConfigurable
By default, all attributes are visible- Specified by:
getAttributeVisibility
in interfaceAutoConfigurable
- Overrides:
getAttributeVisibility
in classAbstractConfigurable
- Parameters:
name
- Name (key) of one of this component's attributes- Returns:
- a
VisibilityCondition
for this attribute, or null if attribute should always be visible.
-
getAllowableConfigureComponents
- Specified by:
getAllowableConfigureComponents
in interfaceConfigurable
- Overrides:
getAllowableConfigureComponents
in classTurnComponent
- Returns:
- a list of valid sub-component Classes. If a Class
appears in this list, then instances of that class may be added
to this component from the Editor's
ConfigureTree
window by right-clicking on the component and selecting the appropriate "Add" option.
-
getConfigureTypeName
-
addTo
Description copied from interface:Buildable
Adds this component to its parent. In order to make Buildable objects extensible, the child is responsible for adding itself to the parent. That way, Buildable subcomponents can be defined in an extension package without needing to modify the containing class.- Specified by:
addTo
in interfaceBuildable
- Overrides:
addTo
in classTurnComponent
- Parameters:
b
- parent Buildable to add this component to as a subcomponent.
-
removeFrom
Description copied from interface:Configurable
Remove this component from its parent- Specified by:
removeFrom
in interfaceConfigurable
- Overrides:
removeFrom
in classTurnComponent
-
getHelpFile
- Specified by:
getHelpFile
in interfaceConfigurable
- Overrides:
getHelpFile
in classTurnComponent
- Returns:
- a HelpFile describing how to use and configure * this component
-
setId
- Specified by:
setId
in interfaceUniqueIdManager.Identifyable
-
getId
- Specified by:
getId
in interfaceUniqueIdManager.Identifyable
-
captureState
protected void captureState() -
save
protected void save() -
getMaximumTurnString
Calculate the maximum sized turn string that can be generated by any turn combination.- Returns:
- maximum turn string
-
getTurnString
Build the turn string to be displayed from the currently active Child TurnLevel's- Returns:
- Turn String
-
getActiveChildLevels
-
getLevelCount
protected int getLevelCount() -
next
protected void next() -
prev
protected void prev() -
doGlobalkeys
protected void doGlobalkeys() -
getComponentTypeName
Description copied from interface:Auditable
Return a description of the Type of trait or Component an Auditable is- Specified by:
getComponentTypeName
in interfaceAuditable
- Returns:
- Component Type
-
getComponentName
Description copied from interface:Auditable
Return the name of the trait or Component an Auditable is- Specified by:
getComponentName
in interfaceAuditable
- Returns:
- Component name
-
actionPerformed
- Specified by:
actionPerformed
in interfaceActionListener
-
set
protected void set() -
updateTurnDisplay
-
updateWidget
public void updateWidget() -
clearGlobalProperties
protected void clearGlobalProperties() -
decode
Description copied from interface:CommandEncoder
Translate a String into aCommand
- Specified by:
decode
in interfaceCommandEncoder
-
encode
Description copied from interface:CommandEncoder
Translate aCommand
into a String- Specified by:
encode
in interfaceCommandEncoder
-
setup
public void setup(boolean gameStarting) Description copied from interface:GameComponent
Notify the GameComponent that a game has started/ended- Specified by:
setup
in interfaceGameComponent
- Parameters:
gameStarting
- if true, a game is starting. If false, then a game is ending
-
reset
protected void reset() -
updateString
-
replace
-
getRestoreCommand
Description copied from interface:GameComponent
When saving a game, each GameComponent should return aCommand
that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null- Specified by:
getRestoreCommand
in interfaceGameComponent
-
buildPopup
protected void buildPopup() -
addItem
-
cancelSet
protected void cancelSet() -
saveSet
protected void saveSet() -
getFormattedStringList
- Specified by:
getFormattedStringList
in interfaceSearchTarget
- Overrides:
getFormattedStringList
in classAbstractConfigurable
- Returns:
- a list of any Message Format strings referenced in the Configurable, if any (for search)
-
getMenuTextList
- Specified by:
getMenuTextList
in interfaceSearchTarget
- Overrides:
getMenuTextList
in classAbstractConfigurable
- Returns:
- a list of any Menu/Button/Tooltip Text strings referenced in the Configurable, if any (for search)
-
getNamedKeyStrokeList
- Specified by:
getNamedKeyStrokeList
in interfaceSearchTarget
- Overrides:
getNamedKeyStrokeList
in classAbstractConfigurable
- Returns:
- a list of any Named KeyStrokes referenced in the Configurable, if any (for search)
-
addLocalImageNames
Description copied from class:AbstractImageFinder
Classes extending AbstractImageFinder should override this method in order to add the names of any image files they use to the collection.- Specified by:
addLocalImageNames
in interfaceImageSearchTarget
- Overrides:
addLocalImageNames
in classAbstractImageFinder
- Parameters:
s
- Collection to add image names to
-