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
Board
s on a Map
. As a CommandEncoder
, it
recognizes Command
s 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 class
BoardPicker.SetBoards
-
Field Summary
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validator
Fields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY
-
Constructor Summary
Constructors Constructor Description BoardPicker()
-
Method Summary
Modifier and Type Method Description void
actionPerformed(ActionEvent e)
void
add(Buildable b)
Add a board to the list of those available for the user to choose fromprotected JButton
addButton(String s)
protected JButton
addButton(String s, int index)
protected void
addColumn()
void
addPropertyChangeListener(PropertyChangeListener l)
Add a PropertyChangeListener.protected void
addRow()
void
addTo(Buildable b)
Adds this component to its parent.void
build(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 attributeCommand
decode(String command)
Translate a String into aCommand
String
encode(Command c)
Translate aCommand
into a Stringvoid
finish()
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.String
getAttributeValueString(String attr)
Board
getBoard(String boardName)
protected Board
getBoard(String boardName, boolean localized)
String
getBoardDelimiter()
List<Board>
getBoardsFromControls()
Return the list of boards as specified in the current controlsElement
getBuildElement(Document doc)
int
getColumnCount()
Configurable[]
getConfigureComponents()
String
getConfigureName()
The name of this Configurable ObjectConfigurer
getConfigurer()
Return aConfigurer
object which can be used to set the attributes of this objectstatic String
getConfigureTypeName()
Component
getControls()
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.Dimension
getDefaultSlotSize()
HelpFile
getHelpFile()
ComponentI18nData
getI18nData()
Board
getLocalizedBoard(String localizedBoardName)
BoardSlot
getNeighbor(BoardSlot slot, int dx, int dy)
Command
getRestoreCommand()
The restore command of a BoardPicker, when executed, sets the boards of itsMap
togetSelectedBoards()
int
getRowCount()
List<String>
getSelectedBoardNames()
Collection<Board>
getSelectedBoards()
BoardSlot
getSlot(int i)
double
getSlotScale()
String
getStepTitle()
A human-understandable description of this stepprotected void
initComponents()
boolean
isAllowMultiple()
boolean
isFinished()
void
pack()
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.void
remove(Buildable b)
Remove a board from the list of those available for the user to choose fromprotected void
removeAllBoards()
void
removeFrom(Buildable parent)
Remove this component from its parentvoid
repaint()
void
repaintAll()
void
reset()
protected void
selectBoards(Component c)
void
setAllowMultiple(boolean val)
void
setAttribute(String key, Object value)
Sets a buildFile (XML) attribute value for this component.void
setBoards(Collection<Board> c)
void
setBoards(Enumeration<Board> bdEnum)
Deprecated, for removal: This API element is subject to removal in a future version.UsesetBoards(Collection)
instead.void
setup(boolean show)
When starting a game, check to see if any boards have been specified (via an encodedCommand
.void
validate(Buildable target, ValidationReport report)
void
warn(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: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. -
build
Description copied from class:AbstractBuildable
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 attribute- Specified by:
build
in interfaceBuildable
- Overrides:
build
in classAbstractBuildable
- Parameters:
e
- the XML element containing the object data
-
validate
- Specified by:
validate
in interfaceValidityChecker
- Overrides:
validate
in classAbstractBuildable
-
add
Add a board to the list of those available for the user to choose from- Specified by:
add
in interfaceBuildable
- Overrides:
add
in classAbstractBuildable
-
remove
Remove a board from the list of those available for the user to choose from- Specified by:
remove
in interfaceConfigurable
-
removeFrom
Description copied from interface:Configurable
Remove this component from its parent- Specified by:
removeFrom
in interfaceConfigurable
-
getConfigureTypeName
-
getConfigureName
Description copied from interface:Configurable
The name of this Configurable Object- Specified by:
getConfigureName
in interfaceConfigurable
-
getBoardDelimiter
-
getHelpFile
- Specified by:
getHelpFile
in interfaceConfigurable
- Returns:
- a HelpFilte describing how to use and configure this component
-
getConfigurer
Description copied from interface:Configurable
Return aConfigurer
object which can be used to set the attributes of this object- Specified by:
getConfigurer
in interfaceConfigurable
-
getConfigureComponents
- Specified by:
getConfigureComponents
in interfaceConfigurable
- Returns:
- an array of Configurer objects representing the Configurable children of this Configurable object
-
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
-
addPropertyChangeListener
Description copied from interface:Configurable
Add a PropertyChangeListener. A PropertyChangeEvent should be fired with property nameConfigurable.NAME_PROPERTY
when the value returned fromConfigurable.getConfigureName()
has changed- Specified by:
addPropertyChangeListener
in 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:
setup
in interfaceGameComponent
- Parameters:
show
- if true, a game is starting. If false, then a game is ending
-
finish
public void finish()Description copied from interface:GameSetupStep
Apply the information gathered via the component to the game in progress- Specified by:
finish
in interfaceGameSetupStep
-
getControls
Description copied from interface:GameSetupStep
A GUI component that prompts the player for the needed information. If null, then no further information is needed- Specified by:
getControls
in interfaceGameSetupStep
-
getStepTitle
Description copied from interface:GameSetupStep
A human-understandable description of this step- Specified by:
getStepTitle
in interfaceGameSetupStep
-
isFinished
public boolean isFinished()- Specified by:
isFinished
in 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 itsMap
togetSelectedBoards()
- Specified by:
getRestoreCommand
in interfaceGameComponent
-
addButton
-
addButton
-
addRow
protected void addRow() -
addColumn
protected void addColumn() -
actionPerformed
- Specified by:
actionPerformed
in 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:
getBuildElement
in interfaceBuildable
- Overrides:
getBuildElement
in classAbstractBuildable
- Returns:
- an XML element from which this component can be built
-
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
-
getI18nData
- Specified by:
getI18nData
in interfaceTranslatable
-
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 interfaceTranslatable
- Specified by:
setAttribute
in classAbstractBuildable
- 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()
-
getAttributeValueString
- Specified by:
getAttributeValueString
in interfaceTranslatable
- Specified by:
getAttributeValueString
in 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: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 classAbstractBuildable
- Returns:
- a list of all buildFile (XML) attribute names for this component
-
getSelectedBoards()
instead.