VASSAL.build.module.map
Class BoardPicker

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Dialog
                          |
                          +--javax.swing.JDialog
                                |
                                +--VASSAL.build.module.map.BoardPicker
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, Buildable, CommandEncoder, Configurable, java.util.EventListener, GameComponent, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class BoardPicker
extends javax.swing.JDialog
implements java.awt.event.ActionListener, GameComponent, Configurable, CommandEncoder

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

See Also:
Serialized Form

Nested Class Summary
static class BoardPicker.SetBoards
           
 
Field Summary
protected  boolean allowMultiple
           
protected  javax.swing.JButton cancelButton
           
protected  javax.swing.JToolBar controls
           
protected  java.util.Vector currentBoards
           
protected  java.lang.String defaultSetup
           
static java.lang.String ID
           
protected  Map map
           
protected  java.util.Vector multipleButtons
           
protected  int nx
           
protected  int ny
           
protected  java.util.Vector possibleBoards
           
 java.lang.String SCALE
           
 java.lang.String SETUP
           
 java.lang.String SLOT_HEIGHT
           
 java.lang.String SLOT_WIDTH
           
protected  javax.swing.JPanel slotPanel
           
protected  javax.swing.JTextField status
           
protected  java.lang.String title
           
protected  java.lang.String version
           
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
BoardPicker()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void add(Buildable b)
          Add a board to the list of those available for the user to choose from
protected  javax.swing.JButton addButton(java.lang.String s)
           
protected  javax.swing.JButton addButton(java.lang.String s, int index)
           
protected  void addColumn()
           
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a PropertyChangeListener.
protected  void addRow()
           
 void addTo(Buildable b)
          Adds this component to its parent.
 void build(org.w3c.dom.Element e)
          Build the object
 Command decode(java.lang.String command)
          Translate a String into a Command
 java.lang.String encode(Command c)
          Translate a Command into a String
 java.lang.String[] getAllowableBoardNames()
           
 java.lang.Class[] getAllowableConfigureComponents()
          Return a list of valid sub-component Classes.
 Board getBoard(java.lang.String boardName)
           
 java.lang.String getBoardDelimiter()
           
 org.w3c.dom.Element getBuildElement(org.w3c.dom.Document doc)
           
 int getColumnCount()
           
 Configurable[] getConfigureComponents()
           
 java.lang.String getConfigureName()
          The name of this Configurable Object
 Configurer getConfigurer()
          Return a Configurer object which can be used to set the attributes of this object
static java.lang.String getConfigureTypeName()
           
 java.util.Enumeration getCurrentBoards()
           
 java.awt.Dimension getDefaultSlotSize()
           
 HelpFile getHelpFile()
           
 BoardSlot getNeighbor(BoardSlot slot, int dx, int dy)
           
 Command getRestoreCommand()
          The restore command of a BoardPicker, when executed, sets the boards of its Map to getCurrentBoards()
 int getRowCount()
           
 BoardSlot getSlot(int i)
           
 double getSlotScale()
           
protected  void initComponents()
           
 boolean isAllowMultiple()
           
 void pack()
           
 java.util.Vector pickBoards()
           
 void remove(Buildable b)
          Remove a board from the list of those available for the user to choose from
protected  void removeAllBoards()
           
 void removeFrom(Buildable parent)
          Remove this component from its parent
 void repaintAll()
           
 void reset()
           
protected  void selectBoards()
           
 void setAllowMultiple(boolean val)
           
 void setBoards(java.util.Enumeration bdEnum)
           
 void setup(boolean show)
          When starting a game, check to see if any boards have been specified (via an encoded Command.
 void warn(java.lang.String s)
           
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Dialog
addNotify, dispose, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ID

public static final java.lang.String ID
See Also:
Constant Field Values

possibleBoards

protected java.util.Vector possibleBoards

currentBoards

protected java.util.Vector currentBoards

status

protected javax.swing.JTextField status

cancelButton

protected javax.swing.JButton cancelButton

map

protected Map map

slotPanel

protected javax.swing.JPanel slotPanel

version

protected java.lang.String version

nx

protected int nx

ny

protected int ny

controls

protected javax.swing.JToolBar controls

allowMultiple

protected boolean allowMultiple

title

protected java.lang.String title

defaultSetup

protected java.lang.String defaultSetup

multipleButtons

protected java.util.Vector multipleButtons

SCALE

public final java.lang.String SCALE
See Also:
Constant Field Values

SLOT_HEIGHT

public final java.lang.String SLOT_HEIGHT
See Also:
Constant Field Values

SLOT_WIDTH

public final java.lang.String SLOT_WIDTH
See Also:
Constant Field Values

SETUP

public final java.lang.String SETUP
See Also:
Constant Field Values
Constructor Detail

BoardPicker

public BoardPicker()
Method Detail

initComponents

protected void initComponents()

getDefaultSlotSize

public java.awt.Dimension getDefaultSlotSize()

getSlotScale

public double getSlotScale()
Returns:
the zoom factory at which to display boards when selecting them

warn

public void warn(java.lang.String s)

addTo

public void addTo(Buildable b)
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.

Specified by:
addTo in interface Buildable

build

public void build(org.w3c.dom.Element e)
Description copied from interface: Buildable
Build the object

Specified by:
build in interface Buildable
Parameters:
e - the XML element containing the object data

add

public void add(Buildable b)
Add a board to the list of those available for the user to choose from

Specified by:
add in interface Buildable

remove

public void remove(Buildable b)
Remove a board from the list of those available for the user to choose from

Specified by:
remove in interface Configurable

removeFrom

public void removeFrom(Buildable parent)
Description copied from interface: Configurable
Remove this component from its parent

Specified by:
removeFrom in interface Configurable

getConfigureTypeName

public static java.lang.String getConfigureTypeName()

getConfigureName

public java.lang.String getConfigureName()
Description copied from interface: Configurable
The name of this Configurable Object

Specified by:
getConfigureName in interface Configurable

getBoardDelimiter

public java.lang.String getBoardDelimiter()

getHelpFile

public HelpFile getHelpFile()
Specified by:
getHelpFile in interface Configurable
Returns:
a HelpFilte describing how to use and configure this component

getConfigurer

public Configurer getConfigurer()
Description copied from interface: Configurable
Return a Configurer object which can be used to set the attributes of this object

Specified by:
getConfigurer in interface Configurable

getConfigureComponents

public Configurable[] getConfigureComponents()
Specified by:
getConfigureComponents in interface Configurable
Returns:
an array of Configurer objects representing the Configurable children of this Configurable object

getAllowableConfigureComponents

public java.lang.Class[] 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 interface Configurable

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Description copied from interface: Configurable
Add a PropertyChangeListener. A PropertyChangeEvent should be fired with property name Configurable.NAME_PROPERTY when the value returned from Configurable.getConfigureName() has changed

Specified by:
addPropertyChangeListener in interface Configurable
Overrides:
addPropertyChangeListener in class java.awt.Window

setBoards

public void setBoards(java.util.Enumeration bdEnum)

pack

public void pack()
Overrides:
pack in class java.awt.Window

selectBoards

protected void selectBoards()

getCurrentBoards

public java.util.Enumeration getCurrentBoards()
Returns:
an Enumeration of boards that have been selected either by the user via the dialog or from reading a savefile

getAllowableBoardNames

public java.lang.String[] getAllowableBoardNames()
Returns:
an array of the names of all boards from which the user may choose

getBoard

public Board getBoard(java.lang.String boardName)
Returns:
a Board with the given name. Duplicate boards with the same name are clones.

setup

public void setup(boolean show)
When starting a game, check to see if any boards have been specified (via an encoded Command. If not, show a dialog to prompt the user for boards. When ending a game, clear the selected boards

Specified by:
setup in interface GameComponent
Parameters:
show - if true, a game is starting. If false, then a game is ending

getRestoreCommand

public Command getRestoreCommand()
The restore command of a BoardPicker, when executed, sets the boards of its Map to getCurrentBoards()

Specified by:
getRestoreCommand in interface GameComponent

addButton

protected javax.swing.JButton addButton(java.lang.String s)

addButton

protected javax.swing.JButton addButton(java.lang.String s,
                                        int index)

addRow

protected void addRow()

addColumn

protected void addColumn()

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

pickBoards

public java.util.Vector pickBoards()

reset

public void reset()

getRowCount

public int getRowCount()

getColumnCount

public int getColumnCount()

getNeighbor

public BoardSlot getNeighbor(BoardSlot slot,
                             int dx,
                             int dy)

getSlot

public BoardSlot getSlot(int i)

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

public org.w3c.dom.Element getBuildElement(org.w3c.dom.Document doc)
Specified by:
getBuildElement in interface Buildable
Returns:
an XML element from which this component can be built

decode

public Command decode(java.lang.String command)
Description copied from interface: CommandEncoder
Translate a String into a Command

Specified by:
decode in interface CommandEncoder

encode

public java.lang.String encode(Command c)
Description copied from interface: CommandEncoder
Translate a Command into a String

Specified by:
encode in interface CommandEncoder