Let's clone that helper from DropBoard & let it help.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@983 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Dave Hoover
2010-10-15 20:15:41 +00:00
parent 6b1d055f10
commit 596e38abe8
@@ -137,7 +137,7 @@ public abstract class DropBoardView extends PuzzleBoardView
*/
public void createPiece (int piece, int sx, int sy)
{
if (sx < 0 || sy < 0 || sx >= _bwid || sy >= _bhei) {
if (!inBounds(sx, sy)) {
log.warning("Requested to create piece in invalid location", "sx", sx, "sy", sy,
new Exception());
return;
@@ -164,7 +164,7 @@ public abstract class DropBoardView extends PuzzleBoardView
*/
public void updatePiece (int piece, int sx, int sy)
{
if (sx < 0 || sy < 0 || sx >= _bwid || sy >= _bhei) {
if (!inBounds(sx, sy)) {
log.warning("Requested to update piece in invalid location",
"sx", sx, "sy", sy, new Exception());
return;
@@ -182,7 +182,7 @@ public abstract class DropBoardView extends PuzzleBoardView
*/
public void createPiece (int piece, int sx, int sy, int tx, int ty, long duration)
{
if (tx < 0 || ty < 0 || tx >= _bwid || ty >= _bhei) {
if (!inBounds(tx, ty)) {
log.warning("Requested to create and move piece to invalid location",
"tx", tx, "ty", ty, new Exception());
return;
@@ -512,6 +512,15 @@ public abstract class DropBoardView extends PuzzleBoardView
return new Dimension(wid, hei);
}
/**
* Returns true if the specified coordinate is within the bounds of the board, false if it is
* not.
*/
public boolean inBounds (int col, int row)
{
return (col >= 0 && row >= 0 && col < getWidth() && row < getHeight());
}
/**
* Renders the row of rising pieces to the given graphics context. Sub-classes that make use
* of board rising functionality should override this method to draw the rising piece row.