Package VASSAL.build.module.map
Class BoardPicker
java.lang.Object
VASSAL.search.AbstractImageFinder
VASSAL.build.AbstractBuildable
VASSAL.build.module.map.BoardPicker
- All Implemented Interfaces:
ActionListener
,EventListener
,Buildable
,Configurable
,GameComponent
,GameSetupStep
,PropertyNameSource
,CommandEncoder
,ValidityChecker
,Translatable
,Auditable
,ImageSearchTarget
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
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
protected JButton
protected String
protected JButton
protected String
protected boolean
static final String
protected String
protected JButton
protected JPanel
protected String
static final String
static final String
protected Map
static final String
protected int
protected ComponentI18nData
protected int
protected int
protected JButton
protected Dimension
static final String
static final String
static final String
static final String
protected JPanel
protected double
protected JScrollPane
protected JLabel
protected String
protected JToolBar
protected String
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validator
Fields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
Add a board to the list of those available for the user to choose fromprotected JButton
protected JButton
protected void
void
Add a PropertyChangeListener.protected void
addRow()
void
Adds this component to its parent.void
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 attributeTranslate a String into aCommand
Translate aCommand
into a Stringvoid
finish()
Apply the information gathered via the component to the game in progressString[]
Class<?>[]
String[]
String[]
Lists all the buildFile (XML) attribute names for this component.protected Board
Return the list of boards as specified in the current controlsgetBuildElement
(Document doc) int
The name of this Configurable Objectstatic String
A GUI component that prompts the player for the needed information.getLocalizedBoard
(String localizedBoardName) getNeighbor
(BoardSlot slot, int dx, int dy) The restore command of a BoardPicker, when executed, sets the boards of itsMap
togetSelectedBoards()
int
getSlot
(int i) double
A human-understandable description of this stepprotected void
boolean
boolean
boolean
Is this component a reqired component within its parent?boolean
isUnique()
Does this component need to be unique within it's parent?void
Remove a board from the list of those available for the user to choose fromprotected void
void
removeFrom
(Buildable parent) Remove this component from its parentvoid
repaint()
void
void
reset()
protected void
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
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
Methods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getComponents, getComponentsOf, getNonFolderAncestor, getPropertyNames, setAncestor
Methods inherited from class VASSAL.search.AbstractImageFinder
addLocalImageNames, getAllImageNames, getLocalImageNames
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface VASSAL.script.expression.Auditable
getComponentName, getComponentTypeName
Methods inherited from interface VASSAL.build.module.GameSetupStep
setController
-
Field Details
-
ID
- See Also:
-
possibleBoards
-
currentBoards
-
psize
-
slotScale
protected double slotScale -
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:
-
SLOT_HEIGHT
- See Also:
-
SLOT_WIDTH
- See Also:
-
SETUP
- See Also:
-
DIALOG_TITLE
- See Also:
-
ADD_ROW_BUTTON_TEXT
- See Also:
-
ADD_COLUMN_BUTTON_TEXT
- See Also:
-
BOARD_PROMPT
- See Also:
-
MAX_COLUMNS
- See Also:
-
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 responsible 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
- Parameters:
b
- Child to attach to this buildable as a subcomponent
-
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 HelpFile describing how to use and configure * this component
-
getConfigurer
- Specified by:
getConfigurer
in interfaceConfigurable
- Returns:
- a
Configurer
object which can be used to set the attributes of this object
-
getConfigureComponents
- Specified by:
getConfigureComponents
in interfaceConfigurable
- Returns:
- an array of Configurer objects representing the Configurable children of this Configurable object
-
getAllowableConfigureComponents
- Specified by:
getAllowableConfigureComponents
in interfaceConfigurable
- Returns:
- 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 Editor's
ConfigureTree
window by right-clicking on the component and selecting the appropriate "Add" option.
-
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
-
selectBoards
-
getSelectedBoards
- Returns:
- a Collection of boards that have been selected either by the user via the dialog or from reading a savefile
-
getSelectedBoardNames
-
getAllowableBoardNames
- Returns:
- an array of the names of all boards from which the user may choose
-
getAllowableLocalizedBoardNames
-
getBoard
-
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
-
getBoardsFromControls
-
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
- Parameters:
doc
- XML file- 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 XML buildFile attribute with the given name. When initializing a module,
this String value will loaded from the XML and passed to
AbstractBuildable.setAttribute(java.lang.String, java.lang.Object)
. It is also frequently used for checking the current value of an attribute.
-
repaint
public void repaint() -
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
-
isMandatory
public boolean isMandatory()Description copied from interface:Buildable
Is this component a reqired component within its parent?- Specified by:
isMandatory
in interfaceBuildable
- Returns:
- true if component is mandatory
-
isUnique
-