Cell.java
import java.awt.Graphics;
import java.awt.Color;
/** 色付きの升目の領域Cellクラス */
public class Cell {
/** セルの色 */
protected Color color;
/** セルのサイズ */
protected int width, height;
/** コンストラクタ(クラスの新しいデータの生成を行う)*/
Cell( int width, int height ) {
this.width = width;
this.height = height;
this.color = Color.black;
}
Cell( int width, int height, Color color ) {
this.width = width;
this.height = height;
this.color = color;
}
/** セル内部に描画を行うメソッド */
public void paint( Graphics g ){
g.setColor( color );
g.fill3DRect( 1, 1, width-2, height-2, true );
}
/** セル内部をクリアするメソッド */
public void clear( Graphics g ){
g.clearRect( 0, 0, width, height );
}
/** セルに色を再設定するメソッド */
public void setColor( Color color ){
this.color = color;
}
/** セルの色を調べるメソッド */
public Color getColor(){
return color;
}
/** セルのサイズを調べるメソッド */
public int getWidth(){
return width;
}
/** セルのサイズを調べるメソッド */
public int getHeight(){
return height;
}
}