Package VASSAL.build.module.turn
Class TurnTracker
java.lang.Object
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
,ValidityChecker
,Translatable
,UniqueIdManager.Identifyable
public class TurnTracker extends TurnComponent implements CommandEncoder, GameComponent, ActionListener, UniqueIdManager.Identifyable
Generic Turn Counter
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TurnTracker.IconConfig
static class
TurnTracker.LengthStyleConfig
static class
TurnTracker.ReportFormatConfig
protected class
TurnTracker.SetDialog
static class
TurnTracker.SetTurn
static class
TurnTracker.TurnFormatConfig
protected class
TurnTracker.TurnWidget
protected class
TurnTracker.TurnWindow
Nested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
-
Field Summary
Fields inherited from class VASSAL.build.module.turn.TurnComponent
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
Constructors Constructor Description TurnTracker()
-
Method Summary
Modifier and Type Method Description void
actionPerformed(ActionEvent e)
protected void
addItem(JMenu menu, String command)
void
addTo(Buildable b)
Adds this component to its parent.protected void
buildPopup()
protected void
cancelSet()
protected void
captureState()
protected void
clearGlobalProperties()
Command
decode(String command)
Translate a String into aCommand
protected void
doGlobalkeys()
String
encode(Command c)
Translate aCommand
into a Stringprotected List<TurnLevel>
getActiveChildLevels()
A list of all active TurnLevels within the TurnTrackerClass<?>[]
getAllowableConfigureComponents()
Return a list of valid sub-component Classes.String[]
getAttributeDescriptions()
Return an array of Strings describing the attributes of this object.String[]
getAttributeNames()
Lists all the buildFile (XML) attribute names for this component.Class<?>[]
getAttributeTypes()
Return the Class for the buildFile (XML) attributes of this component.String
getAttributeValueString(String key)
Called by theBuildable.getBuildElement(org.w3c.dom.Document)
method to write the attributes into an XML elementVisibilityCondition
getAttributeVisibility(String name)
By default, all attributes are visiblestatic String
getConfigureTypeName()
protected Font
getDisplayFont()
protected int
getFontSize()
protected int
getFontStyle()
HelpFile
getHelpFile()
String
getId()
protected int
getLevelCount()
protected String
getMaximumTurnString()
Calculate the maximum sized turn string that can be generated by any turn combination.protected int
getMaximumWidth()
Calculate the maximum width for the turnWidget to display any item.Command
getRestoreCommand()
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 nullString
getState()
protected String
getTurnString()
Build the turn string to be displayed from the currently active Child TurnLevel'sprotected boolean
isDocked()
protected void
next()
protected void
prev()
void
removeFrom(Buildable b)
Remove this component from its parentvoid
replace(StringBuffer s, String from, String to)
Deprecated, for removal: This API element is subject to removal in a future version.void
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
setDisplayFont()
protected void
setDocked(boolean dock)
protected void
setFontSize()
void
setId(String id)
protected void
setLaunchToolTip()
void
setState(String newState)
void
setup(boolean gameStarting)
Notify the GameComponent that a game has started/endedprotected void
setWidgetWidth()
String
updateString(String str, String[] from, String[] to)
protected void
updateTurnDisplay(String command)
Methods inherited from class VASSAL.build.module.turn.TurnComponent
addLevel, getTurnLevel, getTurnLevelCount, getTurnLevels, removeLevel
Methods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, getI18nData, getI18nPrefix, getLocalizedConfigureName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureName
Methods inherited from class VASSAL.build.AbstractBuildable
build, getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getPropertyNames, validate
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
Methods inherited from interface VASSAL.tools.UniqueIdManager.Identifyable
getConfigureName
-
Field Details
-
idMgr
-
COMMAND_PREFIX
- See Also:
- Constant Field Values
-
NAME
- See Also:
- Constant Field Values
-
HOT_KEY
- See Also:
- Constant Field Values
-
NEXT_HOT_KEY
- See Also:
- Constant Field Values
-
PREV_HOT_KEY
- See Also:
- Constant Field Values
-
ICON
- See Also:
- Constant Field Values
-
BUTTON_TEXT
- See Also:
- Constant Field Values
-
BUTTON_TOOLTIP
- See Also:
- Constant Field Values
-
TURN_FORMAT
- See Also:
- Constant Field Values
-
REPORT_FORMAT
- See Also:
- Constant Field Values
-
TOOLTIP
- See Also:
- Constant Field Values
-
LENGTH
- See Also:
- Constant Field Values
-
LENGTH_STYLE
- See Also:
- Constant Field Values
-
FONT_SIZE
- See Also:
- Constant Field Values
-
FONT_BOLD
- See Also:
- Constant Field Values
-
DOCKED
- See Also:
- Constant Field Values
-
OLD_TURN
Variable name for reporting format- See Also:
- Constant Field Values
-
NEW_TURN
- See Also:
- Constant Field Values
-
LEVEL
- See Also:
- Constant Field Values
-
TURN_FONT
- See Also:
- Constant Field Values
-
SET_COMMAND
-
DOCK_COMMAND
-
UNDOCK_COMMAND
-
NEXT
- See Also:
- Constant Field Values
-
PREV
- See Also:
- Constant Field Values
-
SET
- See Also:
- Constant Field Values
-
PROP_VALUE
- See Also:
- Constant Field Values
-
PROP_COMMAND
- See Also:
- Constant Field Values
-
LENGTH_VARIABLE
- See Also:
- Constant Field Values
-
LENGTH_MAXIMUM
- See Also:
- Constant Field Values
-
LENGTH_FIXED
- See Also:
- Constant Field Values
-
turnFormat
-
reportFormat
-
turnWindow
-
turnWidget
-
launchWidget
-
setDialog
-
launch
-
nextListener
-
prevListener
-
savedState
-
savedSetState
-
savedTurn
-
popup
-
currentLevel
protected int currentLevel -
id
-
width
protected int width -
lengthStyle
-
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 attribute with the given name. When initializing a module, this String value will be passed to
AbstractBuildable.setAttribute(java.lang.String, java.lang.Object)
.
-
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 class:AbstractConfigurable
Return 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 ofAutoConfigurer
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()
- Specified by:
getAttributeTypes
in interfaceAutoConfigurable
- Overrides:
getAttributeTypes
in classTurnComponent
-
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
Description copied from interface:Configurable
Return 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 Configuration Window.- Specified by:
getAllowableConfigureComponents
in interfaceConfigurable
- Overrides:
getAllowableConfigureComponents
in classTurnComponent
-
getConfigureTypeName
-
addTo
Description copied from interface:Buildable
Adds this component to its parent. In order to make Buildable objects extensible, the child is reponsible 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
-
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 HelpFilte 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
A list of all active TurnLevels within the TurnTracker- Returns:
- List of Turn levels
-
getLevelCount
protected int getLevelCount() -
next
protected void next() -
prev
protected void prev() -
doGlobalkeys
protected void doGlobalkeys() -
actionPerformed
- Specified by:
actionPerformed
in interfaceActionListener
-
set
protected void set() -
updateTurnDisplay
-
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
-
replace
@Deprecated(since="2020-08-06", forRemoval=true) public void replace(StringBuffer s, String from, String to)Deprecated, for removal: This API element is subject to removal in a future version.Usereplace(StringBuilder,String,String)
instead. -
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()
-
replace(StringBuilder,String,String)
instead.