|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectGrid
Class representing the grid where caterpillar is moving and where barriers are placed.
Field Summary | |
static int |
cellSize
Width and height (cells are squares) of interior of a cell. |
Constructor Summary | |
Grid(int width,
int height)
Creates a new instance of grid |
Method Summary | |
static java.awt.Point |
countCellPosition(int cellX,
int cellY,
int positionX,
int positionY)
Counts the upper-left corner point of a interior of a specific cell. |
int |
GetHeight()
Gets the height of a grid (number of cells). |
int |
GetHeightPixels()
Gets the height of a grid in pixels. |
int |
GetWidth()
Gets the width of a grid (number of cells). |
int |
GetWidthPixels()
Gets the width of a grid in pixels. |
void |
Paint(java.awt.Color backgroundColor,
java.awt.Graphics g,
int left,
int top)
Call this method to repaint the grid. |
void |
SetHeight(int height)
Sets the height of a grid. |
void |
SetWidth(int width)
Sets the width of a grid. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static int cellSize
Constructor Detail |
public Grid(int width, int height)
width
- Width of a grid (number of cells).height
- Height of a grid (number of cells).Method Detail |
public void Paint(java.awt.Color backgroundColor, java.awt.Graphics g, int left, int top)
backgroundColor
- Background color of a grid. Is used to clear grid if it is reduced.g
- Graphics object used to painting.left
- x-coordinate of upper-left corner of a grid (in pixels).top
- y-coordinate of upper-left corner of a grid (in pixels).public int GetWidthPixels()
public int GetHeightPixels()
public void SetWidth(int width) throws java.lang.IllegalArgumentException
width
- Width of a grid (number of cells).
java.lang.IllegalArgumentException
- Throws if width is less than 1 or greater than 50.public void SetHeight(int height) throws java.lang.IllegalArgumentException
height
- Height of a grid (number of cells).
java.lang.IllegalArgumentException
- Throws if height is less than 1 or greater than 50.public int GetWidth()
public int GetHeight()
public static java.awt.Point countCellPosition(int cellX, int cellY, int positionX, int positionY)
cellX
- Column number. Zero-based.cellY
- Row number. Zero-based.positionX
- X-coordinate (in pixels) of upper-left corner of a grid.positionY
- Y-coordinate (in pixels) of upper-left corner of a grid.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |