|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.droplets.api.Component | +--com.droplets.api.CustomComponent | +--com.droplets.apix.GameBoard
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GameBoard(LayoutPlacement lp, Window w)
GameBoard
component.Method Detail |
public Color getBoardBackgroundColor()
public void setBoardBackgroundColor(Color c)
public void setBoardBackgroundColor(Color c, java.lang.String skinName)
public Color getBoardBorderColor()
public void setBoardBorderColor(Color c)
public void setBoardBorderColor(Color c, java.lang.String skinName)
public int getBoardBorderWidth()
public void setBoardBorderWidth(int w)
public void setBoardBorderWidth(int w, java.lang.String skinName)
public int getBoardHeight()
public void setBoardHeight(int h)
public void setBoardHeight(int h, java.lang.String skinName)
public int getBoardWidth()
public void setBoardWidth(int w)
public void setBoardWidth(int w, java.lang.String skinName)
public Color getCellBorderColor()
public void setCellBorderColor(Color c)
public void setCellBorderColor(Color c, java.lang.String skinName)
public int getCellBorderWidth()
public void setCellBorderWidth(int w)
public void setCellBorderWidth(int w, java.lang.String skinName)
public java.lang.String getDefaultBackgroundImage()
public void setDefaultBackgroundImage(java.lang.String imageName)
public void setDefaultBackgroundImage(java.lang.String imageName, java.lang.String skinName)
public boolean getIsDefaultBgImageScaled()
public void setIsDefaultBgImageScaled(boolean isScaled)
public void setIsDefaultBgImageScaled(boolean scaled, java.lang.String skinName)
public Color getDefaultCellColor()
public void setDefaultCellColor(Color c)
public void setDefaultCellColor(Color c, java.lang.String skinName)
public GameBoard.Cell getCellAttributes(int x, int y)
null
means all defaultspublic void setCellAttributes(int x, int y, GameBoard.Cell c, java.lang.String skinName)
null
means all defaultspublic void setCellAttributes(int x, int y, GameBoard.Cell c)
null
means all defaultspublic void putPieceOnBoard(int x, int y, GameBoard.Piece piece)
public GameBoard.Piece getPiece(int x, int y)
public void movePiece(int x, int y, int newX, int newY)
x
- The current X positiony
- The current Y positionnewX
- The new X positionnewY
- The new Y positionpublic void addCellActionListener(GameBoard.CellActionListener l)
CellActionListener
to this object's
event listeners.l
- The CellActionListener
to be added.public void removeCellActionListener(GameBoard.CellActionListener l)
CellActionListener
from this
object's event listeners.l
- The CellActionListener
to be removed.protected void onCustomAction(java.lang.String action, java.lang.String args)
onCustomAction
in class CustomComponent
com.droplets.api.CustomComponent
action
- The name of the custom actionargs
- Any arguments from the custom action
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |