Class RandomTextButton
- All Implemented Interfaces:
PropertyChangeListener, EventListener, AutoConfigurable, Buildable, Configurable, GameComponent, PropertyNameSource, ValidityChecker, Translatable, Auditable, ImageSearchTarget, SearchTarget
- Author:
- Michael Blumoehr This component places a button into the controls window toolbar. Pressing the button generates random numbers or strings and displays the result in the Chatter
-
Nested Class Summary
Nested classes/interfaces inherited from class DiceButton
DiceButton.IconConfig, DiceButton.KeepConfig, DiceButton.ReportFormatConfigModifier and TypeClassDescriptionstatic classDeprecated, for removal: This API element is subject to removal in a future version.static classstatic classNested classes/interfaces inherited from class AbstractToolbarItem
AbstractToolbarItem.FormattedStringConfigNested classes/interfaces inherited from interface AutoConfigurable
AutoConfigurable.Util -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected booleanprotected String[]static final StringFields inherited from class DiceButton
ADD_TO_TOTAL, addToTotal, BUTTON_TEXT, counts, DEPRECATED_NAME, HOTKEY, ICON, KEEP_COUNT, KEEP_DICE, KEEP_EQUAL, KEEP_GREATER, KEEP_LARGEST, KEEP_LESS, KEEP_OPTION, KEEP_SMALLEST, keepCount, keepDice, keepingDice, keepOption, keepProp, keepValue, launch, LOCK_ADD, LOCK_DICE, LOCK_PLUS, LOCK_SIDES, lockAdd, lockDice, lockPlus, lockSides, N_DICE, N_SIDES, NAME, nDice, nSides, NUMERIC_TOTAL, numericTotal, plus, PLUS, PROMPT_ALWAYS, promptAlways, property, ran, rawCounts, rawRolls, REPORT_FORMAT, REPORT_NAME, REPORT_TOTAL, reportFormat, reportTotal, RESULT, RESULT_N, SORT_DICE_RESULTS, sortDice, SUMMARY, summaryProp, tooltip, TOOLTIP, totalPropModifier and TypeFieldDescriptionstatic final Stringprotected intstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.protected int[]Counts of each modified face of kept dicestatic final Stringstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.static final StringDeprecated, for removal: This API element is subject to removal in a future version.static final Stringstatic final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringstatic final Stringprotected static final StringKeep Optionsprotected intNumber of dice kept from those rolledprotected int[]A list of individual rolls keptprotected booleanAre we keeping only specific rolls?protected StringWhat rule are we using to keep rolls?protected final MutableProperty.Implprotected intHow many rolls, or what size rolls are we keeping?protected LaunchButtonDeprecated, for removal: This API element is subject to removal in a future version.use launch from the superclassstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected booleanprotected booleanprotected booleanprotected booleanLocking of options for roll promptsstatic final Stringstatic final Stringstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.protected intprotected intstatic final Stringprotected intTotal of all dice kept, including per-die and per-roll adjustmentsprotected intstatic final Stringstatic final Stringprotected booleanprotected final MutableProperty.Implprotected Randomprotected int[]Counts of each face prior to keepingprotected int[]The Raw rolls before keepingstatic final Stringstatic final Stringstatic final Stringprotected final FormattedStringprotected booleanstatic final Stringstatic final Stringstatic final Stringprotected booleanstatic final StringVariable name for reporting formatprotected final MutableProperty.Implprotected Stringstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.protected final MutableProperty.ImplFields inherited from class AbstractToolbarItem
CAN_DISABLE, canDisable, DISABLED_ICON, disabledIconConfig, HIDE_WHEN_DISABLED, hideWhenDisabled, PROPERTY_GATE, propertyGate, showDisabledOptionsFields inherited from class AbstractConfigurable
changeSupport, config, localizedName, myI18nData, nameModifier and TypeFieldDescriptionprotected PropertyChangeSupportprotected Configurerprotected Stringprotected ComponentI18nDataprotected StringFields inherited from class AbstractBuildable
buildComponents, validatorFields inherited from interface Configurable
NAME_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidIn case reports use HTML and refer to any image filesprotected voidDR()Forwards the result of the roll to theChatter.send(String)method of theChatterof theGameModule.String[]This getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.String[]This getAttributeNames() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.Class<?>[]This getAttributeTypes() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.getAttributeVisibility(String name) By default, all attributes are visiblestatic StringvoidsetAttribute(String key, Object value) Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.Methods inherited from class DiceButton
addTo, formatResult, formatResult, getAllowableConfigureComponents, getPropertyNames, initLaunchButtonModifier and TypeMethodDescriptionvoidExpects to be added to a GameModule.protected StringformatResult(String result) Deprecated.protected StringformatResult(String result, String summary) Use the configured FormattedString to format the result of a rollClass<?>[]Implement PropertyNameSource - Expose roll result propertyprotected voidMethods inherited from class AbstractToolbarItem
addPropertyGateListener, addPropertyGateListener, checkDisabled, disableIfTrue, getComponent, getLaunchButton, getMenuTextList, getNamedKeyStrokeList, getNameKey, getPropertyList, getRestoreCommand, isShowDisabledOptions, makeLaunchButton, propertyChange, removeFrom, removePropertyGateListener, setButtonTextKey, setHotKeyKey, setIconKey, setLaunchButton, setNameKey, setNamePrompt, setShowDisabledOptions, setTooltipKey, setupModifier and TypeMethodDescriptionprotected voidprotected voidaddPropertyGateListener(boolean dontCheck) If we have a disable-this-button property, set a listener on itvoidCheck our disable-this-button property and enable/disable our button as appropriate based on its valuevoiddisableIfTrue(boolean disable) protected ComponentThe component to be added to the control window toolbarprotected StringWhen 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 nullbooleanprotected LaunchButtonmakeLaunchButton(String tooltip, String button_text, String iconFile, ActionListener action) Create a standard toolbar launcher button for this itemvoidListens to our disable-this-button property; enables/disables our button as appropriate when it changesvoidremoveFrom(Buildable parent) Remove from our parentprotected voidRemove any existing disable-this-button propertyprotected voidsetButtonTextKey(String buttonTextKey) protected voidsetHotKeyKey(String hotKeyKey) protected voidsetIconKey(String iconKey) protected voidsetLaunchButton(LaunchButton launch) Sets launch button for this toolbar itemprotected voidsetNameKey(String nameKey) protected voidsetNamePrompt(String namePrompt) protected voidsetShowDisabledOptions(boolean show) protected voidsetTooltipKey(String tooltipKey) voidsetup(boolean gameStarting) Notify the GameComponent that a game has started/endedMethods inherited from class AbstractConfigurable
add, addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, getExpressionList, getI18nData, getI18nPrefix, getLocalizedConfigureName, getTypeName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureNameModifier and TypeMethodDescriptionvoidSet the owning translatable of this componentvoidAdd a PropertyChangeListener.ConfigureName is used, in particular, by the Editor to track the names of components, and is preferred byUniqueIdManager.protected StringReturns the name of the configurable type for display purposes.voidRemove a Buildable object from this objectvoidprotected voidSets all attributes untranslatable.protected voidsetAttributeTranslatable(String attr, boolean b) Over-ride the default attribute translatability.voidSets the name and fires a PropertyChangeEventMethods inherited from class AbstractBuildable
addImageNamesRecursively, build, buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getNonFolderAncestor, setAncestor, validateModifier and TypeMethodDescriptionvoidAdds all images used by this component AND any subcomponents to the collectionvoidBuild this component by getting all XML attributes of the XML element and callingAbstractBuildable.setAttribute(String, Object)with the String value of the attribute<T> List<T> getAllDescendantComponentsOf(Class<T> target) Recursively descend the build tree and return aListof all components that are instances of the given classDeprecated, for removal: This API element is subject to removal in a future version.UseAbstractBuildable.getBuildables()instead.getBuildElement(Document doc) <T> Enumeration<T> getComponents(Class<T> target) Deprecated, for removal: This API element is subject to removal in a future version.UseAbstractBuildable.getComponentsOf(Class)instead.<T> List<T> getComponentsOf(Class<T> target) voidsetAncestor(Buildable ancestor) voidvalidate(Buildable target, ValidationReport report) Methods inherited from class AbstractImageFinder
getAllImageNames, getLocalImageNamesModifier and TypeMethodDescriptionMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Auditable
getComponentName, getComponentTypeNameMethods inherited from interface Buildable
isMandatory, isMovable, isUniqueModifier and TypeMethodDescriptiondefault booleanIs this component a reqired component within its parent?default booleanIs this component allowed to be moved around the Configure Tree?default booleanisUnique()Does this component need to be unique within it's parent?
-
Field Details
-
m_faces
-
isNumeric
protected boolean isNumeric -
FACES
- See Also:
-
NUMERIC
- See Also:
-
-
Constructor Details
-
RandomTextButton
public RandomTextButton()
-
-
Method Details
-
getConfigureTypeName
-
DR
protected void DR()Forwards the result of the roll to theChatter.send(String)method of theChatterof theGameModule. Format is prefix+[comma-separated roll list]+suffix- Overrides:
DRin classDiceButton
-
getAttributeVisibility
Description copied from class:AbstractConfigurableBy default, all attributes are visible- Specified by:
getAttributeVisibilityin interfaceAutoConfigurable- Overrides:
getAttributeVisibilityin classDiceButton- Parameters:
name- Name (key) of one of this component's attributes- Returns:
- a
VisibilityConditionfor this attribute, or null if attribute should always be visible.
-
getAttributeNames
Description copied from class:AbstractToolbarItemThis getAttributeNames() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeNames(), key1, ..., keyN), or supply their own order from scratch.Lists all the buildFile (XML) attribute names for this component. If this component is ALSO an
AbstractConfigurable, then this list of attributes determines the appropriate attribute order forAbstractConfigurable.getAttributeDescriptions()andAbstractConfigurable.getAttributeTypes().- Specified by:
getAttributeNamesin interfaceAutoConfigurable- Overrides:
getAttributeNamesin classDiceButton- Returns:
- an array of all buildFile (XML) attribute names for this component
-
getAttributeDescriptions
Description copied from class:AbstractToolbarItemThis getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeDescriptions(), key1, ..., keyN), or supply their own order from scratch.- Specified by:
getAttributeDescriptionsin interfaceAutoConfigurable- Overrides:
getAttributeDescriptionsin classDiceButton- 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:AbstractToolbarItemThis getAttributeTypes() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeTypes(), key1, ..., keyN), or supply their own order from scratch.- Specified by:
getAttributeTypesin interfaceAutoConfigurable- Overrides:
getAttributeTypesin classDiceButton- 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
AutoConfigurerwill 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 in
AbstractBuildable.getAttributeNames()
-
setAttribute
Description copied from class:AbstractToolbarItemClasses extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.Sets a buildFile (XML) attribute value for this component. The
keyparameter will be one of those listed inAbstractToolbarItem.getAttributeNames(). If thevalueparameter is a String, it will be the value returned byAbstractToolbarItem.getAttributeValueString(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 classDiceButton- Parameters:
key- the name of the attribute. Will be one of those listed inAbstractToolbarItem.getAttributeNames()value- If thevalueparameter is a String, it will be the value returned byAbstractToolbarItem.getAttributeValueString(String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluecan also be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
-
getAttributeValueString
Description copied from class:AbstractToolbarItemClasses extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.- Specified by:
getAttributeValueStringin interfaceAutoConfigurable- Specified by:
getAttributeValueStringin interfaceTranslatable- Overrides:
getAttributeValueStringin classDiceButton- Parameters:
key- the name of the attribute. Will be one of those listed inAbstractToolbarItem.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
AbstractToolbarItem.setAttribute(String, Object). It is also frequently used for checking the current value of an attribute.
-
getHelpFile
- Specified by:
getHelpFilein interfaceConfigurable- Overrides:
getHelpFilein classDiceButton- Returns:
- a HelpFile describing how to use and configure * this component
-
getFormattedStringList
- Specified by:
getFormattedStringListin interfaceSearchTarget- Overrides:
getFormattedStringListin classAbstractConfigurable- Returns:
- a list of any Message Format strings referenced in the Configurable, if any (for search)
-
addLocalImageNames
In case reports use HTML and refer to any image files- Specified by:
addLocalImageNamesin interfaceImageSearchTarget- Overrides:
addLocalImageNamesin classDiceButton- Parameters:
s- Collection to add image names to
-
AbstractToolbarItem.IconConfiginstead.