Package VASSAL.build.module.map
Class BoardPicker
java.lang.Object
VASSAL.build.AbstractBuildable
VASSAL.build.module.map.BoardPicker
- All Implemented Interfaces:
ActionListener,EventListener,Buildable,Configurable,GameComponent,GameSetupStep,PropertyNameSource,CommandEncoder,ValidityChecker,Translatable
public class BoardPicker extends AbstractBuildable implements ActionListener, GameComponent, GameSetupStep, Configurable, CommandEncoder, ValidityChecker
This class is responsible for maintaining the
Boards on a Map. As a CommandEncoder, it
recognizes Commands that specify the set of boards to be used on a map. As a GameComponent it reacts
to the start of a game by prompting the player to select boards if none have been specified.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBoardPicker.SetBoards -
Field Summary
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validatorFields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY -
Constructor Summary
Constructors Constructor Description BoardPicker() -
Method Summary
Modifier and Type Method Description voidactionPerformed(ActionEvent e)voidadd(Buildable b)Add a board to the list of those available for the user to choose fromprotected JButtonaddButton(String s)protected JButtonaddButton(String s, int index)protected voidaddColumn()voidaddPropertyChangeListener(PropertyChangeListener l)Add a PropertyChangeListener.protected voidaddRow()voidaddTo(Buildable b)Adds this component to its parent.voidbuild(Element e)Build this component by getting all XML attributes of the XML element and callingAbstractBuildable.setAttribute(java.lang.String, java.lang.Object)with the String value of the attributeCommanddecode(String command)Translate a String into aCommandStringencode(Command c)Translate aCommandinto a Stringvoidfinish()Apply the information gathered via the component to the game in progressString[]getAllowableBoardNames()Class<?>[]getAllowableConfigureComponents()Return a list of valid sub-component Classes.String[]getAllowableLocalizedBoardNames()String[]getAttributeNames()Lists all the buildFile (XML) attribute names for this component.StringgetAttributeValueString(String attr)BoardgetBoard(String boardName)protected BoardgetBoard(String boardName, boolean localized)StringgetBoardDelimiter()List<Board>getBoardsFromControls()Return the list of boards as specified in the current controlsElementgetBuildElement(Document doc)intgetColumnCount()Configurable[]getConfigureComponents()StringgetConfigureName()The name of this Configurable ObjectConfigurergetConfigurer()Return aConfigurerobject which can be used to set the attributes of this objectstatic StringgetConfigureTypeName()ComponentgetControls()A GUI component that prompts the player for the needed information.Enumeration<Board>getCurrentBoards()Deprecated, for removal: This API element is subject to removal in a future version.DimensiongetDefaultSlotSize()HelpFilegetHelpFile()ComponentI18nDatagetI18nData()BoardgetLocalizedBoard(String localizedBoardName)BoardSlotgetNeighbor(BoardSlot slot, int dx, int dy)CommandgetRestoreCommand()The restore command of a BoardPicker, when executed, sets the boards of itsMaptogetSelectedBoards()intgetRowCount()List<String>getSelectedBoardNames()Collection<Board>getSelectedBoards()BoardSlotgetSlot(int i)doublegetSlotScale()StringgetStepTitle()A human-understandable description of this stepprotected voidinitComponents()booleanisAllowMultiple()booleanisFinished()voidpack()Deprecated, for removal: This API element is subject to removal in a future version.No replacementVector<Board>pickBoards()Deprecated, for removal: This API element is subject to removal in a future version.voidremove(Buildable b)Remove a board from the list of those available for the user to choose fromprotected voidremoveAllBoards()voidremoveFrom(Buildable parent)Remove this component from its parentvoidrepaint()voidrepaintAll()voidreset()protected voidselectBoards(Component c)voidsetAllowMultiple(boolean val)voidsetAttribute(String key, Object value)Sets a buildFile (XML) attribute value for this component.voidsetBoards(Collection<Board> c)voidsetBoards(Enumeration<Board> bdEnum)Deprecated, for removal: This API element is subject to removal in a future version.UsesetBoards(Collection)instead.voidsetup(boolean show)When starting a game, check to see if any boards have been specified (via an encodedCommand.voidvalidate(Buildable target, ValidationReport report)voidwarn(String s)Methods inherited from class VASSAL.build.AbstractBuildable
getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getComponents, getComponentsOf, getPropertyNames
-
Field Details
-
ID
- See Also:
- Constant Field Values
-
possibleBoards
-
currentBoards
-
psize
-
slotScale
protected double slotScale -
status
Deprecated, for removal: This API element is subject to removal in a future version. -
statusLabel
-
map
-
slotPanel
-
version
-
nx
protected int nx -
ny
protected int ny -
toolbar
-
controls
-
addRowButton
-
addColumnButton
-
allowMultiple
protected boolean allowMultiple -
maxColumns
protected int maxColumns -
title
-
addRowButtonText
-
addColumnButtonText
-
boardPrompt
-
defaultSetup
-
multipleButtons
-
SCALE
- See Also:
- Constant Field Values
-
SLOT_HEIGHT
- See Also:
- Constant Field Values
-
SLOT_WIDTH
- See Also:
- Constant Field Values
-
SETUP
- See Also:
- Constant Field Values
-
DIALOG_TITLE
- See Also:
- Constant Field Values
-
ADD_ROW_BUTTON_TEXT
- See Also:
- Constant Field Values
-
ADD_COLUMN_BUTTON_TEXT
- See Also:
- Constant Field Values
-
BOARD_PROMPT
- See Also:
- Constant Field Values
-
MAX_COLUMNS
- See Also:
- Constant Field Values
-
clearButton
-
okButton
-
myI18nData
-
slotScroll
-
-
Constructor Details
-
BoardPicker
public BoardPicker()
-
-
Method Details
-
initComponents
protected void initComponents() -
getDefaultSlotSize
-
getSlotScale
public double getSlotScale()- Returns:
- the zoom factory at which to display boards when selecting them
-
warn
-
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. -
build
Description copied from class:AbstractBuildableBuild this component by getting all XML attributes of the XML element and callingAbstractBuildable.setAttribute(java.lang.String, java.lang.Object)with the String value of the attribute- Specified by:
buildin interfaceBuildable- Overrides:
buildin classAbstractBuildable- Parameters:
e- the XML element containing the object data
-
validate
- Specified by:
validatein interfaceValidityChecker- Overrides:
validatein classAbstractBuildable
-
add
Add a board to the list of those available for the user to choose from- Specified by:
addin interfaceBuildable- Overrides:
addin classAbstractBuildable
-
remove
Remove a board from the list of those available for the user to choose from- Specified by:
removein interfaceConfigurable
-
removeFrom
Description copied from interface:ConfigurableRemove this component from its parent- Specified by:
removeFromin interfaceConfigurable
-
getConfigureTypeName
-
getConfigureName
Description copied from interface:ConfigurableThe name of this Configurable Object- Specified by:
getConfigureNamein interfaceConfigurable
-
getBoardDelimiter
-
getHelpFile
- Specified by:
getHelpFilein interfaceConfigurable- Returns:
- a HelpFilte describing how to use and configure this component
-
getConfigurer
Description copied from interface:ConfigurableReturn aConfigurerobject which can be used to set the attributes of this object- Specified by:
getConfigurerin interfaceConfigurable
-
getConfigureComponents
- Specified by:
getConfigureComponentsin interfaceConfigurable- Returns:
- an array of Configurer objects representing the Configurable children of this Configurable object
-
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
-
addPropertyChangeListener
Description copied from interface:ConfigurableAdd a PropertyChangeListener. A PropertyChangeEvent should be fired with property nameConfigurable.NAME_PROPERTYwhen the value returned fromConfigurable.getConfigureName()has changed- Specified by:
addPropertyChangeListenerin interfaceConfigurable
-
setBoards
-
setBoards
Deprecated, for removal: This API element is subject to removal in a future version.UsesetBoards(Collection)instead. -
selectBoards
-
getSelectedBoards
- Returns:
- a Collection of boards that have been selected either by the user via the dialog or from reading a savefile
-
getSelectedBoardNames
- Returns:
- a List of the names of all boards from which have been selected either by the user via the dialog or from reading a savefile
-
getCurrentBoards
Deprecated, for removal: This API element is subject to removal in a future version.UsegetSelectedBoards()instead.- Returns:
- an Enumeration of boards that have been selected either by the user via the dialog or from reading a savefile
-
getAllowableBoardNames
- Returns:
- an array of the names of all boards from which the user may choose
-
getAllowableLocalizedBoardNames
-
getBoard
- Returns:
- a Board with the given name.
-
getLocalizedBoard
-
getBoard
-
setup
public void setup(boolean show)When starting a game, check to see if any boards have been specified (via an encodedCommand. If not, show a dialog to prompt the user for boards. When ending a game, clear the selected boards- Specified by:
setupin interfaceGameComponent- Parameters:
show- if true, a game is starting. If false, then a game is ending
-
finish
public void finish()Description copied from interface:GameSetupStepApply the information gathered via the component to the game in progress- Specified by:
finishin interfaceGameSetupStep
-
getControls
Description copied from interface:GameSetupStepA GUI component that prompts the player for the needed information. If null, then no further information is needed- Specified by:
getControlsin interfaceGameSetupStep
-
getStepTitle
Description copied from interface:GameSetupStepA human-understandable description of this step- Specified by:
getStepTitlein interfaceGameSetupStep
-
isFinished
public boolean isFinished()- Specified by:
isFinishedin interfaceGameSetupStep- Returns:
- true if this step needs no further information, false if the player should be prompted for more information
-
getRestoreCommand
The restore command of a BoardPicker, when executed, sets the boards of itsMaptogetSelectedBoards()- Specified by:
getRestoreCommandin interfaceGameComponent
-
addButton
-
addButton
-
addRow
protected void addRow() -
addColumn
protected void addColumn() -
actionPerformed
- Specified by:
actionPerformedin interfaceActionListener
-
pickBoards
Deprecated, for removal: This API element is subject to removal in a future version. -
getBoardsFromControls
Return the list of boards as specified in the current controls- Returns:
- List of Boards
-
reset
public void reset() -
getRowCount
public int getRowCount() -
getColumnCount
public int getColumnCount() -
getNeighbor
-
getSlot
-
repaintAll
public void repaintAll() -
removeAllBoards
protected void removeAllBoards() -
isAllowMultiple
public boolean isAllowMultiple()- Returns:
- true if multiple boards per map window are allowed
-
setAllowMultiple
public void setAllowMultiple(boolean val) -
getBuildElement
- Specified by:
getBuildElementin interfaceBuildable- Overrides:
getBuildElementin classAbstractBuildable- Returns:
- an XML element from which this component can be built
-
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
-
getI18nData
- Specified by:
getI18nDatain interfaceTranslatable
-
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 interfaceTranslatable- Specified by:
setAttributein classAbstractBuildable- 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()
-
getAttributeValueString
- Specified by:
getAttributeValueStringin interfaceTranslatable- Specified by:
getAttributeValueStringin classAbstractBuildable- Parameters:
attr- 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).
-
repaint
public void repaint() -
pack
Deprecated, for removal: This API element is subject to removal in a future version.No replacement -
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 classAbstractBuildable- Returns:
- a list of all buildFile (XML) attribute names for this component
-
getSelectedBoards()instead.