java.lang.ObjectColorGrid
public class ColorGrid
Represents a color grid, a two-dimensional array of colors. Allows clients to set and modify the colors of individual cells and rectangular areas.
| Constructor Summary | |
|---|---|
ColorGrid()
Constructs a 100x100 grid, with all cells set to Color.WHITE. |
|
ColorGrid(int rows,
int columns)
Constructs a rows x columns grid, with all cells set to Color.WHITE. |
|
ColorGrid(int rows,
int columns,
Color startingColor)
Constructs a rows x columns grid, with all cells set to startingColor. |
|
| Method Summary | |
|---|---|
void |
brighten(int row,
int column)
Brightens (makes brighter) the color at the indicated row and column of the grid. |
void |
brighten(int row1,
int column1,
int row2,
int column2)
Brightens the indicated rectangle of the grid. |
int |
columns()
Gets the number of columns. |
void |
darken(int row,
int column)
Darkens (makes darker) the color at the indicated row and column of the grid. |
void |
darken(int row1,
int column1,
int row2,
int column2)
Darkens the indicated rectangle of the grid. |
Color |
get(int row,
int column)
Gets the color at the indicated row and column of the grid. |
Color[][] |
grid()
Gets a copy of the color grid as a 2-dimensional array. |
int |
rows()
Gets the number of rows. |
void |
set(int row,
int column,
Color color)
Sets the color at the indicated row and column of the grid. |
void |
set(int row1,
int column1,
int row2,
int column2,
Color color)
Sets the color of the indicated rectangle of the grid. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ColorGrid()
public ColorGrid(int rows,
int columns)
rows - the number of rows.columns - the number of columns.
public ColorGrid(int rows,
int columns,
Color startingColor)
rows - the number of rows.columns - the number of columns.startingColor - the starting color for all cells in the grid.| Method Detail |
|---|
public int rows()
public int columns()
public Color[][] grid()
public Color get(int row,
int column)
row - the row of the grid cell to get - range 0 to rows-1 assumed.column - the column of the grid cell to get. - 0 to columns-1 assumed.
public void set(int row,
int column,
Color color)
row - the row of the grid cell to set - range 0 to rows-1 assumed.column - the column of the grid cell to set - 0 to columns-1 assumed.color - the color to which the grid cell is set.
public void set(int row1,
int column1,
int row2,
int column2,
Color color)
row1 - the first row of the rectangle - range 0 to rows-1 assumed.column1 - the first column of the rectangle - range 0 to -1 assumed.row2 - last row of the rectangle - range row1 to rows-1 assumed.column2 - last column of the rectangle - range column1 to columns-1 assumed.color - the color to which the grid cell is set.
public void darken(int row,
int column)
row - the row of the grid cell to darken - range 0 to rows-1 assumed.column - the column of the grid cell to darken - 0 to columns-1 assumed.
public void brighten(int row,
int column)
row - the row of the grid cell to brighten - range 0 to rows-1 assumed.column - the column of the grid cell to brighten - 0 to columns-1 assumed.
public void darken(int row1,
int column1,
int row2,
int column2)
row1 - the first row of the rectangle - range 0 to rows-1 assumed.column1 - the first column of the rectangle - range 0 to -1 assumed.row2 - last row of the rectangle - range row1 to rows-1 assumed.column2 - last column of the rectangle - range column1 to columns-1 assumed.
public void brighten(int row1,
int column1,
int row2,
int column2)
row1 - the first row of the rectangle - range 0 to rows-1 assumed.column1 - the first column of the rectangle - range 0 to -1 assumed.row2 - last row of the rectangle - range row1 to rows-1 assumed.column2 - last column of the rectangle - range column1 to columns-1 assumed.