com.droplets.apix
Class GameBoard

java.lang.Object
  |
  +--com.droplets.api.Component
        |
        +--com.droplets.api.CustomComponent
              |
              +--com.droplets.apix.GameBoard

public class GameBoard
extends CustomComponent

This component can be used to implement board games where the board is made up of M x N rectangular cells with movable pieces. The colors, images, pieces, sizes, and cursors are all customizable.

The GameBoard supports events for pieces being dragged, and for cells being clicked.


Inner Class Summary
static class GameBoard.Cell
          Contains all the attributes for a cell on a GameBoard
static class GameBoard.CellActionEvent
          Event used to notify the application of user-actions in the GameBoard component.
static interface GameBoard.CellActionListener
          Interface objects must implement to receive CellActionEvents
static class GameBoard.Piece
          A Piece on a GameBoard.
 
Fields inherited from class com.droplets.api.Component
ANCHOR_CENTER, ANCHOR_EAST, ANCHOR_NORTH, ANCHOR_NORTHEAST, ANCHOR_NORTHWEST, ANCHOR_SOUTH, ANCHOR_SOUTHEAST, ANCHOR_SOUTHWEST, ANCHOR_WEST, FILL_BOTH, FILL_HORIZONTAL, FILL_NONE, FILL_VERTICAL
 
Constructor Summary
GameBoard(LayoutPlacement lp, Window w)
          Constructs a new GameBoard component.
 
Method Summary
 void addCellActionListener(GameBoard.CellActionListener l)
          Adds a CellActionListener to this object's event listeners.
 Color getBoardBackgroundColor()
          Gets the background color of the board portion of this component.
 Color getBoardBorderColor()
          Gets the color of the border of the board portion of the component.
 int getBoardBorderWidth()
          Gets the width in pixels of the border of the board portion of the component.
 int getBoardHeight()
          Gets the height in cells of the board.
 int getBoardWidth()
          Gets the width in cells of the board.
 GameBoard.Cell getCellAttributes(int x, int y)
          Returns the attributes associated with a cell, null means all defaults
 Color getCellBorderColor()
          Gets the color of the cell border.
 int getCellBorderWidth()
          Gets the width in pixels of the border of the cells.
 java.lang.String getDefaultBackgroundImage()
          Gets the default background image used for cells.
 Color getDefaultCellColor()
          Gets the default Cell color.
 boolean getIsDefaultBgImageScaled()
          Gets whether the default background image is scaled to the cell or not.
 GameBoard.Piece getPiece(int x, int y)
          gets the piece in a given cell, returns null if there is no piece in the cell
 void movePiece(int x, int y, int newX, int newY)
          Moves a piece from one position on the board to another.
protected  void onCustomAction(java.lang.String action, java.lang.String args)
          Used internally to route messages from the client.
 void putPieceOnBoard(int x, int y, GameBoard.Piece piece)
          put a game piece on the board, null removes any piece that was there.
 void removeCellActionListener(GameBoard.CellActionListener l)
          Removes a CellActionListener from this object's event listeners.
 void setBoardBackgroundColor(Color c)
          Sets the background color of the board portion of this component
 void setBoardBackgroundColor(Color c, java.lang.String skinName)
          Sets the background color of the board portion of this component.
 void setBoardBorderColor(Color c)
          Sets the color of the border of the board portion of the component.
 void setBoardBorderColor(Color c, java.lang.String skinName)
          Sets the color of the border of the board portion of the component.
 void setBoardBorderWidth(int w)
          Sets the width in pixels of the border of the board portion of the component.
 void setBoardBorderWidth(int w, java.lang.String skinName)
          Sets the width in pixels of the border of the board portion of the component.
 void setBoardHeight(int h)
          Sets the height in cells of the board.
 void setBoardHeight(int h, java.lang.String skinName)
          Sets the height in cells of the board.
 void setBoardWidth(int w)
          Sets the width in cells of the board.
 void setBoardWidth(int w, java.lang.String skinName)
          Sets the width in cells of the board.
 void setCellAttributes(int x, int y, GameBoard.Cell c)
          Sets the attributes associated with a cell, null means all defaults
 void setCellAttributes(int x, int y, GameBoard.Cell c, java.lang.String skinName)
          Sets the attributes associated with a cell, null means all defaults
 void setCellBorderColor(Color c)
          Sets the color of the cell border.
 void setCellBorderColor(Color c, java.lang.String skinName)
          Sets the color of the cell border.
 void setCellBorderWidth(int w)
          Sets the width in pixels of the border of the cells.
 void setCellBorderWidth(int w, java.lang.String skinName)
          Sets the width in pixels of the border of the cells.
 void setDefaultBackgroundImage(java.lang.String imageName)
          Sets the default background image used for cells.
 void setDefaultBackgroundImage(java.lang.String imageName, java.lang.String skinName)
          Sets the default background image used for cells.
 void setDefaultCellColor(Color c)
          Sets the default Cell color.
 void setDefaultCellColor(Color c, java.lang.String skinName)
          Sets the default Cell color.
 void setIsDefaultBgImageScaled(boolean isScaled)
          Sets whether the default background image is scaled to the cell or not.
 void setIsDefaultBgImageScaled(boolean scaled, java.lang.String skinName)
          Sets whether the default background image is scaled to the cell or not.
 
Methods inherited from class com.droplets.api.CustomComponent
fireActionEvent, fireAttributeChangeEvent, getBoolCustomAttribute, getColorCustomAttribute, getDoubleCustomAttribute, getIntCustomAttribute, getStringCustomAttribute, getValue, isFocusTraversableDefault, onCustomAttributeChanged, sendCustomAction, setBoolCustomAttribute, setColorCustomAttribute, setDoubleCustomAttribute, setIntCustomAttribute, setStringAttribute, setStringCustomAttribute, setStringCustomAttribute, setValue, start
 
Methods inherited from class com.droplets.api.Component
action, addActionListener, addAttributeChangeListener, addValueChangeListener, attributeChanged, constructionFailed, equals, fireValueChangeEvent, getAnchor, getAttribute, getBgColor, getBoolAttribute, getBordersAttribute, getColorAttribute, getCursor, getCursorType, getDoubleAttribute, getEnabled, getFgColor, getFill, getFont, getGridHeight, getGridWidth, getGridX, getGridY, getInsets, getIntAttribute, getIPadX, getIPadY, getOpaque, getParent, getScriptingName, getSpecification, getStringAttribute, getToolTip, getVisible, getWeightX, getWeightY, getWindow, invalidate, isAddedToWindow, isContainer, isFocusTraversable, isValid, removeActionListener, removeAttributeChangeListener, removeValueChangeListener, requestFocus, reset, sendCommandAttribute, setAnchor, setAnchor, setArg, setAttribute, setBgColor, setBgColor, setBoolAttribute, setBordersAttribute, setColorAttribute, setCursor, setCursor, setCursorType, setDoubleAttribute, setEnabled, setEnabled, setEnterButton, setEnterButton, setEnterButton, setFgColor, setFgColor, setFill, setFill, setFocusTraversable, setFont, setFont, setGridHeight, setGridHeight, setGridWidth, setGridWidth, setGridX, setGridX, setGridY, setGridY, setInsets, setInsets, setIntAttribute, setIPadX, setIPadX, setIPadY, setIPadY, setItemListAttribute, setOpaque, setOpaque, setScriptingName, setToolTip, setValue, setVisible, setVisible, setWeightX, setWeightX, setWeightY, setWeightY, storeAttribute, valueChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GameBoard

public GameBoard(LayoutPlacement lp,
                 Window w)
Constructs a new GameBoard component.
Method Detail

getBoardBackgroundColor

public Color getBoardBackgroundColor()
Gets the background color of the board portion of this component.

setBoardBackgroundColor

public void setBoardBackgroundColor(Color c)
Sets the background color of the board portion of this component

setBoardBackgroundColor

public void setBoardBackgroundColor(Color c,
                                    java.lang.String skinName)
Sets the background color of the board portion of this component.

getBoardBorderColor

public Color getBoardBorderColor()
Gets the color of the border of the board portion of the component.

setBoardBorderColor

public void setBoardBorderColor(Color c)
Sets the color of the border of the board portion of the component.

setBoardBorderColor

public void setBoardBorderColor(Color c,
                                java.lang.String skinName)
Sets the color of the border of the board portion of the component.

getBoardBorderWidth

public int getBoardBorderWidth()
Gets the width in pixels of the border of the board portion of the component.

setBoardBorderWidth

public void setBoardBorderWidth(int w)
Sets the width in pixels of the border of the board portion of the component.

setBoardBorderWidth

public void setBoardBorderWidth(int w,
                                java.lang.String skinName)
Sets the width in pixels of the border of the board portion of the component.

getBoardHeight

public int getBoardHeight()
Gets the height in cells of the board.

setBoardHeight

public void setBoardHeight(int h)
Sets the height in cells of the board.

setBoardHeight

public void setBoardHeight(int h,
                           java.lang.String skinName)
Sets the height in cells of the board.

getBoardWidth

public int getBoardWidth()
Gets the width in cells of the board.

setBoardWidth

public void setBoardWidth(int w)
Sets the width in cells of the board.

setBoardWidth

public void setBoardWidth(int w,
                          java.lang.String skinName)
Sets the width in cells of the board.

getCellBorderColor

public Color getCellBorderColor()
Gets the color of the cell border.

setCellBorderColor

public void setCellBorderColor(Color c)
Sets the color of the cell border.

setCellBorderColor

public void setCellBorderColor(Color c,
                               java.lang.String skinName)
Sets the color of the cell border.

getCellBorderWidth

public int getCellBorderWidth()
Gets the width in pixels of the border of the cells.

setCellBorderWidth

public void setCellBorderWidth(int w)
Sets the width in pixels of the border of the cells.

setCellBorderWidth

public void setCellBorderWidth(int w,
                               java.lang.String skinName)
Sets the width in pixels of the border of the cells.

getDefaultBackgroundImage

public java.lang.String getDefaultBackgroundImage()
Gets the default background image used for cells.

setDefaultBackgroundImage

public void setDefaultBackgroundImage(java.lang.String imageName)
Sets the default background image used for cells.

setDefaultBackgroundImage

public void setDefaultBackgroundImage(java.lang.String imageName,
                                      java.lang.String skinName)
Sets the default background image used for cells.

getIsDefaultBgImageScaled

public boolean getIsDefaultBgImageScaled()
Gets whether the default background image is scaled to the cell or not.

setIsDefaultBgImageScaled

public void setIsDefaultBgImageScaled(boolean isScaled)
Sets whether the default background image is scaled to the cell or not.

setIsDefaultBgImageScaled

public void setIsDefaultBgImageScaled(boolean scaled,
                                      java.lang.String skinName)
Sets whether the default background image is scaled to the cell or not.

getDefaultCellColor

public Color getDefaultCellColor()
Gets the default Cell color.

setDefaultCellColor

public void setDefaultCellColor(Color c)
Sets the default Cell color.

setDefaultCellColor

public void setDefaultCellColor(Color c,
                                java.lang.String skinName)
Sets the default Cell color.

getCellAttributes

public GameBoard.Cell getCellAttributes(int x,
                                        int y)
Returns the attributes associated with a cell, null means all defaults

setCellAttributes

public void setCellAttributes(int x,
                              int y,
                              GameBoard.Cell c,
                              java.lang.String skinName)
Sets the attributes associated with a cell, null means all defaults

setCellAttributes

public void setCellAttributes(int x,
                              int y,
                              GameBoard.Cell c)
Sets the attributes associated with a cell, null means all defaults

putPieceOnBoard

public void putPieceOnBoard(int x,
                            int y,
                            GameBoard.Piece piece)
put a game piece on the board, null removes any piece that was there. Only one piece can be in each cell

getPiece

public GameBoard.Piece getPiece(int x,
                                int y)
gets the piece in a given cell, returns null if there is no piece in the cell

movePiece

public void movePiece(int x,
                      int y,
                      int newX,
                      int newY)
Moves a piece from one position on the board to another.
Parameters:
x - The current X position
y - The current Y position
newX - The new X position
newY - The new Y position

addCellActionListener

public void addCellActionListener(GameBoard.CellActionListener l)
Adds a CellActionListener to this object's event listeners.
Parameters:
l - The CellActionListener to be added.

removeCellActionListener

public void removeCellActionListener(GameBoard.CellActionListener l)
Removes a CellActionListener from this object's event listeners.
Parameters:
l - The CellActionListener to be removed.

onCustomAction

protected void onCustomAction(java.lang.String action,
                              java.lang.String args)
Used internally to route messages from the client.
Overrides:
onCustomAction in class CustomComponent
Following copied from class: com.droplets.api.CustomComponent
Parameters:
action - The name of the custom action
args - Any arguments from the custom action


Copyright © Droplets, 2001. All Rights Reserved.