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
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 -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringprotected JButtonprotected Stringprotected JButtonprotected Stringprotected booleanstatic final Stringprotected Stringprotected JButtonprotected JPanelprotected Stringstatic final Stringstatic final Stringprotected Mapstatic final Stringprotected intprotected ComponentI18nDataprotected intprotected intprotected JButtonprotected Dimensionstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected JPanelprotected doubleprotected JScrollPaneprotected JLabelprotected Stringprotected JToolBarprotected StringFields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validatorFields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidAdd a board to the list of those available for the user to choose fromprotected JButtonprotected JButtonprotected voidvoidAdd a PropertyChangeListener.protected voidaddRow()voidAdds this component to its parent.voidBuild 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 aCommandTranslate aCommandinto a Stringvoidfinish()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 BoardReturn the list of boards as specified in the current controlsgetBuildElement(Document doc) intThe name of this Configurable Objectstatic StringA 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 itsMaptogetSelectedBoards()intgetSlot(int i) doubleA human-understandable description of this stepprotected voidbooleanbooleanbooleanIs this component a reqired component within its parent?booleanisUnique()Does this component need to be unique within it's parent?voidRemove a board from the list of those available for the user to choose fromprotected voidvoidremoveFrom(Buildable parent) Remove this component from its parentvoidrepaint()voidvoidreset()protected voidvoidsetAllowMultiple(boolean val) voidsetAttribute(String key, Object value) Sets a buildFile (XML) attribute value for this component.voidsetBoards(Collection<Board> c) voidsetup(boolean show) When starting a game, check to see if any boards have been specified (via an encodedCommand.voidvalidate(Buildable target, ValidationReport report) voidMethods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getComponents, getComponentsOf, getNonFolderAncestor, getPropertyNames, setAncestorMethods inherited from class VASSAL.search.AbstractImageFinder
addLocalImageNames, getAllImageNames, getLocalImageNamesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface VASSAL.script.expression.Auditable
getComponentName, getComponentTypeNameMethods 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:BuildableAdds 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: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- 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:
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 HelpFile describing how to use and configure * this component
-
getConfigurer
- Specified by:
getConfigurerin interfaceConfigurable- Returns:
- a
Configurerobject which can be used to set the attributes of this object
-
getConfigureComponents
- Specified by:
getConfigureComponentsin interfaceConfigurable- Returns:
- an array of Configurer objects representing the Configurable children of this Configurable object
-
getAllowableConfigureComponents
- Specified by:
getAllowableConfigureComponentsin 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
ConfigureTreewindow by right-clicking on the component and selecting the appropriate "Add" option.
-
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
-
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
-
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
-
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- Parameters:
doc- XML file- 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 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: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
-
isMandatory
public boolean isMandatory()Description copied from interface:BuildableIs this component a reqired component within its parent?- Specified by:
isMandatoryin interfaceBuildable- Returns:
- true if component is mandatory
-
isUnique
public boolean isUnique()Description copied from interface:BuildableDoes this component need to be unique within it's parent?
-