org.vizzini.ui.game.boardgame
Class GridBoard3DUISwing

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.vizzini.ui.game.AbstractEnvironmentUISwing
                      extended by org.vizzini.ui.game.boardgame.AbstractGridBoardUISwing
                          extended by org.vizzini.ui.game.boardgame.GridBoard3DUISwing
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, IScoreListener, IStateListener, IGridBoard3DUISwing, IGridBoardUI, IGridBoardUISwing, IEnvironmentUI, IListener
Direct Known Subclasses:
AbstractGridBoardUISwing, DefaultGridBoard3DUISwing, GridBoardUISwing

public abstract class GridBoard3DUISwing
extends AbstractGridBoardUISwing
implements IGridBoard3DUISwing

Provides functionality for Swing 3D grid board environment user interfaces in the game framework.

Since:
v0.2
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  Arrangement _arrangement
          The board arrangement.
protected  BoardShape[] _boards
          The 2D board levels.
protected  IViewerSwing _viewer
          Handle to the object viewer.
static int BOARD_SEPARATION
          Separation distance between board levels.
 
Fields inherited from class org.vizzini.ui.game.boardgame.AbstractGridBoardUISwing
LABEL_PAINTED_PROPERTY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface org.vizzini.ui.game.boardgame.IGridBoard3DUISwing
ARRANGEMENT_PROPERTY
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GridBoard3DUISwing()
          Construct this object.
 
Method Summary
 void add(HighlightData highlightData)
          Add the given highlight data.
 void cantActionPerformed(ActionEvent event)
          Callback for the cant action.
 void clearHighlights()
          Clear the highlighted positions.
 void configure(Properties properties)
          Configure this environment.
protected  void createAndPlaceTokenUI(IToken token, Class type, int file, int rank, int level)
          Create and place a new token user interface component.
 JMenu createArrangementUI()
          Create an arrangement user interface widget.
protected  void createBoards(Color boardColor, int realFileCount, int realRankCount, int levelCount, Arrangement arrangement)
          Create the boards.
 JCheckBoxMenuItem createLabelPaintedUI()
          Create a label painted user interface widget.
protected  ITokenUI createTokenUI(IToken token, Class type)
          Create a token user interface component for the given agent.
protected  void fillAdditionalViewMenuItems(JMenu viewMenu)
          Fill in additional view menu items.
protected  ITokenUI get(int file, int rank, int level)
          Return the token UI at the given position.
 Arrangement getArrangement()
          Return the board arrangement.
protected  BoardShape getBoardUI(IntegerPosition position)
          Return the board which contains the given position.
protected  BoardShape getBoardUI(int file, int rank, int level)
          Return the board which contains the given position.
 double getMagnify()
          Return the magnification.
 Markings getMarkings()
          Return the board markings.
 IViewerSwing getObjectViewer()
          Return the object viewer.
 IPosition getPositionForPoint(Point point)
          Map the screen coordinates to a board position.
protected abstract  Class getTokenUIClassFor(IToken token)
          Return the proper ITokenUI type for the given token.
protected  boolean isArrangement(Arrangement arrangement)
          Return true if the given arrangement matches the current setting.
 void labelPaintedActionPerformed(ActionEvent event)
          Callback for the label painted action.
protected  void reconcileBoard(IGridBoard board)
          Reconcile the token UIs with the real board environment.
 void remove(HighlightData highlightData)
          Remove the given highlight data.
protected  void remove(ITokenUI tokenUI, int file, int rank, int level)
          Remove the token at the given position.
 void reset()
          Reset.
 void setArrangement(Arrangement arrangement)
          Set the board arrangement.
 void setBoardColor(Color color)
          Set the board color.
 void setCurrentHighlightData(HighlightData highlightData)
          Set the current highlight data.
 void setEnvironment(IEnvironment environment)
          Set the environment this UI represents.
 void setLabelColor(Color color)
          Set the label color.
 void setLabelPainted(boolean isLabelPainted)
          Set the label painted flag.
 void setMagnify(double magnify)
          Set the magnification.
 void setMarkings(Markings markings, Color firstColor, Color secondColor)
          Set the board markings by adjusting their colors.
 void setViewerColor(Color color)
          Set the viewer background color.
 void skewActionPerformed(ActionEvent event)
          Callback for the skew action.
 void slantActionPerformed(ActionEvent event)
          Callback for the slant action.
 void uprightActionPerformed(ActionEvent event)
          Callback for the upright action.
 
Methods inherited from class org.vizzini.ui.game.boardgame.AbstractGridBoardUISwing
clearCurrentHighlight, clearLastMoveHighlight, clearSelectionHighlight, getBoardColor, getCurrentColor, getCurrentHighlightWidth, getFirstColor, getGridLineColor, getLabelColor, getLastMoveColor, getLastMoveHighlightWidth, getPlacementAudioClip, getSecondColor, getSelectionColor, getSelectionHighlightData, getSelectionHighlightWidth, highlightCurrentPosition, highlightLastMovePosition, highlightSelectedPosition, isLabelPainted, isPositionUsable, setCurrentColor, setCurrentHighlightWidth, setFirstColor, setGridLineColor, setLastMoveColor, setLastMoveHighlightWidth, setSecondColor, setSelectionColor, setSelectionHighlightData, setSelectionHighlightWidth, stateChange
 
Methods inherited from class org.vizzini.ui.game.AbstractEnvironmentUISwing
assignAgentListener, assignAgentListeners, getEnvironment, getSupport, init, isAudioOn, removeAgentListener, removeAgentListeners, scoreChange, setAudioOn
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.vizzini.ui.game.boardgame.IGridBoardUISwing
clearCurrentHighlight, clearLastMoveHighlight, clearSelectionHighlight, getBoardColor, getCurrentColor, getCurrentHighlightWidth, getFirstColor, getGridLineColor, getLabelColor, getLastMoveColor, getLastMoveHighlightWidth, getSecondColor, getSelectionColor, getSelectionHighlightWidth, highlightCurrentPosition, highlightLastMovePosition, highlightSelectedPosition, isLabelPainted, setCurrentColor, setCurrentHighlightWidth, setFirstColor, setGridLineColor, setLastMoveColor, setLastMoveHighlightWidth, setSecondColor, setSelectionColor, setSelectionHighlightWidth
 
Methods inherited from interface org.vizzini.ui.game.IEnvironmentUI
assignAgentListeners, getEnvironment, isAudioOn, removeAgentListeners, setAudioOn
 
Methods inherited from interface org.vizzini.game.event.IStateListener
stateChange
 
Methods inherited from interface org.vizzini.game.event.IScoreListener
scoreChange
 

Field Detail

BOARD_SEPARATION

public static final int BOARD_SEPARATION
Separation distance between board levels.

See Also:
Constant Field Values

_arrangement

protected Arrangement _arrangement
The board arrangement.


_boards

protected BoardShape[] _boards
The 2D board levels.


_viewer

protected IViewerSwing _viewer
Handle to the object viewer.

Constructor Detail

GridBoard3DUISwing

public GridBoard3DUISwing()
Construct this object.

Since:
v0.2
Method Detail

add

public void add(HighlightData highlightData)
Add the given highlight data.

Specified by:
add in interface IGridBoardUISwing
Since:
v0.2

cantActionPerformed

public void cantActionPerformed(ActionEvent event)
Callback for the cant action.

Parameters:
event - Action event.
Since:
v0.3

clearHighlights

public void clearHighlights()
Clear the highlighted positions.

Specified by:
clearHighlights in interface IGridBoardUISwing
Since:
v0.2

configure

public void configure(Properties properties)
               throws InstantiationException,
                      IllegalAccessException
Configure this environment. Extends the super method to configure the object viewer.

Specified by:
configure in interface IEnvironmentUI
Overrides:
configure in class AbstractGridBoardUISwing
Parameters:
properties - Source of configuration information.
Throws:
InstantiationException
IllegalAccessException
Since:
v0.2

createArrangementUI

public JMenu createArrangementUI()
Description copied from interface: IGridBoard3DUISwing
Create an arrangement user interface widget.

Specified by:
createArrangementUI in interface IGridBoard3DUISwing

createLabelPaintedUI

public JCheckBoxMenuItem createLabelPaintedUI()
Create a label painted user interface widget.

Since:
v0.2

getArrangement

public Arrangement getArrangement()
Description copied from interface: IGridBoard3DUISwing
Return the board arrangement.

Specified by:
getArrangement in interface IGridBoard3DUISwing
Returns:
UPRIGHT, CANT, SLANT, or SKEW.

getMagnify

public double getMagnify()
Description copied from interface: IGridBoard3DUISwing
Return the magnification.

Specified by:
getMagnify in interface IGridBoard3DUISwing

getMarkings

public Markings getMarkings()
Description copied from interface: IGridBoard3DUISwing
Return the board markings.

Specified by:
getMarkings in interface IGridBoard3DUISwing
Returns:
VARYING or CONSTANT.

getObjectViewer

public IViewerSwing getObjectViewer()
Return the object viewer.

Since:
v0.2

getPositionForPoint

public IPosition getPositionForPoint(Point point)
Map the screen coordinates to a board position.

Specified by:
getPositionForPoint in interface IGridBoardUISwing
Parameters:
point - A mouse click point.
Since:
v0.2

labelPaintedActionPerformed

public void labelPaintedActionPerformed(ActionEvent event)
Callback for the label painted action.

Since:
v0.2

remove

public void remove(HighlightData highlightData)
Remove the given highlight data.

Specified by:
remove in interface IGridBoardUISwing
Since:
v0.3

reset

public void reset()
Reset. Extend the super method to clear highlights.

Specified by:
reset in interface IEnvironmentUI
Overrides:
reset in class AbstractEnvironmentUISwing
Since:
v0.2

setArrangement

public void setArrangement(Arrangement arrangement)
Description copied from interface: IGridBoard3DUISwing
Set the board arrangement.

Specified by:
setArrangement in interface IGridBoard3DUISwing
Parameters:
arrangement - The board arrangement, UPRIGHT, CANT, SLANT, or SKEW.

setBoardColor

public void setBoardColor(Color color)
Set the board color. Extends the super method to pass the color along to the board shapes.

Specified by:
setBoardColor in interface IGridBoardUISwing
Overrides:
setBoardColor in class AbstractGridBoardUISwing
Since:
v0.2

setCurrentHighlightData

public void setCurrentHighlightData(HighlightData highlightData)
Set the current highlight data.

Overrides:
setCurrentHighlightData in class AbstractGridBoardUISwing
Parameters:
highlightData - The currentHighlightData to set.
Since:
v0.3

setEnvironment

public void setEnvironment(IEnvironment environment)
Set the environment this UI represents. Extends the super method to create the boards.

Specified by:
setEnvironment in interface IEnvironmentUI
Overrides:
setEnvironment in class AbstractEnvironmentUISwing
Parameters:
environment - Environment.
Since:
v0.2

setLabelColor

public void setLabelColor(Color color)
Set the label color. Extends the super method to pass the label color on to the board shapes.

Specified by:
setLabelColor in interface IGridBoardUISwing
Overrides:
setLabelColor in class AbstractGridBoardUISwing
Since:
v0.2

setLabelPainted

public void setLabelPainted(boolean isLabelPainted)
Set the label painted flag. Extends the super method to pass the flag on to the board shapes.

Specified by:
setLabelPainted in interface IGridBoardUISwing
Overrides:
setLabelPainted in class AbstractGridBoardUISwing
Since:
v0.2

setMagnify

public void setMagnify(double magnify)
Description copied from interface: IGridBoard3DUISwing
Set the magnification.

Specified by:
setMagnify in interface IGridBoard3DUISwing
Parameters:
magnify - The new magnification.

setMarkings

public void setMarkings(Markings markings,
                        Color firstColor,
                        Color secondColor)
Description copied from interface: IGridBoard3DUISwing
Set the board markings by adjusting their colors.

Specified by:
setMarkings in interface IGridBoard3DUISwing
Parameters:
markings - The board markings, VARYING or CONSTANT.
firstColor - The color at 0,0.
secondColor - The other color.

setViewerColor

public void setViewerColor(Color color)
Set the viewer background color.

Since:
v0.2

skewActionPerformed

public void skewActionPerformed(ActionEvent event)
Callback for the skew action.

Parameters:
event - Action event.
Since:
v0.3

slantActionPerformed

public void slantActionPerformed(ActionEvent event)
Callback for the slant action.

Parameters:
event - Action event.
Since:
v0.3

uprightActionPerformed

public void uprightActionPerformed(ActionEvent event)
Callback for the upright action.

Parameters:
event - Action event.
Since:
v0.3

getTokenUIClassFor

protected abstract Class getTokenUIClassFor(IToken token)
Return the proper ITokenUI type for the given token.

Since:
v0.2

createAndPlaceTokenUI

protected void createAndPlaceTokenUI(IToken token,
                                     Class type,
                                     int file,
                                     int rank,
                                     int level)
Create and place a new token user interface component.

Parameters:
token - Token.
type - Token class to create.
file - The file position.
rank - The rank position.
level - The level position.
Since:
v0.2

createBoards

protected void createBoards(Color boardColor,
                            int realFileCount,
                            int realRankCount,
                            int levelCount,
                            Arrangement arrangement)
Create the boards.

Since:
v0.2

createTokenUI

protected ITokenUI createTokenUI(IToken token,
                                 Class type)
Create a token user interface component for the given agent.

Parameters:
token - Token.
type - Token UI class.
Since:
v0.2

fillAdditionalViewMenuItems

protected void fillAdditionalViewMenuItems(JMenu viewMenu)
Fill in additional view menu items. These menu items are placed below the other menu items.

Overrides:
fillAdditionalViewMenuItems in class AbstractGridBoardUISwing
Parameters:
viewMenu - View menu.
Since:
v0.2

get

protected ITokenUI get(int file,
                       int rank,
                       int level)
Return the token UI at the given position.

Since:
v0.2

getBoardUI

protected BoardShape getBoardUI(IntegerPosition position)
Return the board which contains the given position.

Since:
v0.2

getBoardUI

protected BoardShape getBoardUI(int file,
                                int rank,
                                int level)
Return the board which contains the given position.

Since:
v0.2

isArrangement

protected boolean isArrangement(Arrangement arrangement)
Return true if the given arrangement matches the current setting.

Parameters:
arrangement - Arrangement in question.
Since:
v0.3

reconcileBoard

protected void reconcileBoard(IGridBoard board)
Reconcile the token UIs with the real board environment.

Specified by:
reconcileBoard in class AbstractGridBoardUISwing
Parameters:
board - The current board environment.
Since:
v0.2

remove

protected void remove(ITokenUI tokenUI,
                      int file,
                      int rank,
                      int level)
Remove the token at the given position.

Since:
v0.2


Copyright © 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02