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 classTurnTracker.IconConfigstatic classTurnTracker.LengthStyleConfigstatic classTurnTracker.ReportFormatConfigprotected classTurnTracker.SetDialogstatic classTurnTracker.SetTurnstatic classTurnTracker.TurnFormatConfigprotected classTurnTracker.TurnWidgetprotected classTurnTracker.TurnWindowNested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util -
Field Summary
Fields inherited from class VASSAL.build.module.turn.TurnComponent
levelsFields inherited from class VASSAL.build.AbstractConfigurable
changeSupport, config, localizedName, myI18nData, nameFields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validatorFields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY -
Constructor Summary
Constructors Constructor Description TurnTracker() -
Method Summary
Modifier and Type Method Description voidactionPerformed(ActionEvent e)protected voidaddItem(JMenu menu, String command)voidaddTo(Buildable b)Adds this component to its parent.protected voidbuildPopup()protected voidcancelSet()protected voidcaptureState()protected voidclearGlobalProperties()Commanddecode(String command)Translate a String into aCommandprotected voiddoGlobalkeys()Stringencode(Command c)Translate aCommandinto 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.StringgetAttributeValueString(String key)Called by theBuildable.getBuildElement(org.w3c.dom.Document)method to write the attributes into an XML elementVisibilityConditiongetAttributeVisibility(String name)By default, all attributes are visiblestatic StringgetConfigureTypeName()protected FontgetDisplayFont()protected intgetFontSize()protected intgetFontStyle()HelpFilegetHelpFile()StringgetId()protected intgetLevelCount()protected StringgetMaximumTurnString()Calculate the maximum sized turn string that can be generated by any turn combination.protected intgetMaximumWidth()Calculate the maximum width for the turnWidget to display any item.CommandgetRestoreCommand()When saving a game, each GameComponent should return aCommandthat, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return nullStringgetState()protected StringgetTurnString()Build the turn string to be displayed from the currently active Child TurnLevel'sprotected booleanisDocked()protected voidnext()protected voidprev()voidremoveFrom(Buildable b)Remove this component from its parentvoidreplace(StringBuffer s, String from, String to)Deprecated, for removal: This API element is subject to removal in a future version.voidreplace(StringBuilder s, String from, String to)protected voidreset()protected voidsave()protected voidsaveSet()protected voidset()voidsetAttribute(String key, Object value)Sets a buildFile (XML) attribute value for this component.protected voidsetDisplayFont()protected voidsetDocked(boolean dock)protected voidsetFontSize()voidsetId(String id)protected voidsetLaunchToolTip()voidsetState(String newState)voidsetup(boolean gameStarting)Notify the GameComponent that a game has started/endedprotected voidsetWidgetWidth()StringupdateString(String str, String[] from, String[] to)protected voidupdateTurnDisplay(String command)Methods inherited from class VASSAL.build.module.turn.TurnComponent
addLevel, getTurnLevel, getTurnLevelCount, getTurnLevels, removeLevelMethods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, getI18nData, getI18nPrefix, getLocalizedConfigureName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureNameMethods inherited from class VASSAL.build.AbstractBuildable
build, getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getPropertyNames, validateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface VASSAL.build.Buildable
build, getBuildElementMethods 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:AbstractBuildableLists 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:
getAttributeNamesin interfaceAutoConfigurable- Overrides:
getAttributeNamesin classTurnComponent- Returns:
- a list of all buildFile (XML) attribute names for this component
-
setAttribute
Description copied from class:AbstractBuildableSets a buildFile (XML) attribute value for this component. Thekeyparameter will be one of those listed inAbstractBuildable.getAttributeNames(). If thevalueparameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluewill be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()- Specified by:
setAttributein interfaceAutoConfigurable- Specified by:
setAttributein interfaceTranslatable- Overrides:
setAttributein classTurnComponent- Parameters:
key- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()value- If thevalueparameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluecan 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:AutoConfigurableCalled by theBuildable.getBuildElement(org.w3c.dom.Document)method to write the attributes into an XML element- Specified by:
getAttributeValueStringin interfaceAutoConfigurable- Specified by:
getAttributeValueStringin interfaceTranslatable- Overrides:
getAttributeValueStringin 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:AutoConfigurableReturn 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:
getAttributeDescriptionsin interfaceAutoConfigurable- Overrides:
getAttributeDescriptionsin 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:AbstractConfigurableReturn 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 ofAutoConfigurerwill 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:
getAttributeTypesin interfaceAutoConfigurable- Overrides:
getAttributeTypesin classTurnComponent
-
getAttributeVisibility
Description copied from class:AbstractConfigurableBy default, all attributes are visible- Specified by:
getAttributeVisibilityin interfaceAutoConfigurable- Overrides:
getAttributeVisibilityin classAbstractConfigurable- Parameters:
name- Name (key) of one of this component's attributes- Returns:
- a
VisibilityConditionfor this attribute, or null if attribute should always be visible.
-
getAllowableConfigureComponents
Description copied from interface:ConfigurableReturn 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:
getAllowableConfigureComponentsin interfaceConfigurable- Overrides:
getAllowableConfigureComponentsin classTurnComponent
-
getConfigureTypeName
-
addTo
Description copied from interface:BuildableAdds 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:
addToin interfaceBuildable- Overrides:
addToin classTurnComponent
-
removeFrom
Description copied from interface:ConfigurableRemove this component from its parent- Specified by:
removeFromin interfaceConfigurable- Overrides:
removeFromin classTurnComponent
-
getHelpFile
- Specified by:
getHelpFilein interfaceConfigurable- Overrides:
getHelpFilein classTurnComponent- Returns:
- a HelpFilte describing how to use and configure this component
-
setId
- Specified by:
setIdin interfaceUniqueIdManager.Identifyable
-
getId
- Specified by:
getIdin 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:
actionPerformedin interfaceActionListener
-
set
protected void set() -
updateTurnDisplay
-
clearGlobalProperties
protected void clearGlobalProperties() -
decode
Description copied from interface:CommandEncoderTranslate a String into aCommand- Specified by:
decodein interfaceCommandEncoder
-
encode
Description copied from interface:CommandEncoderTranslate aCommandinto a String- Specified by:
encodein interfaceCommandEncoder
-
setup
public void setup(boolean gameStarting)Description copied from interface:GameComponentNotify the GameComponent that a game has started/ended- Specified by:
setupin 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:GameComponentWhen saving a game, each GameComponent should return aCommandthat, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null- Specified by:
getRestoreCommandin interfaceGameComponent
-
buildPopup
protected void buildPopup() -
addItem
-
cancelSet
protected void cancelSet() -
saveSet
protected void saveSet()
-
replace(StringBuilder,String,String)instead.