classes/BoardCell.java
import SimpleBoard;
import awt.Graphics;
import awt.Color;
/**
塗りつぶす領域を表す BoardCell クラス
*/
class BoardCell {
public SimpleBoard parent; // 親のオブジェクト
public int i,j; // セルのインデックス
public int width, height; // セルのサイズ
public Color color; // セルの色
public boolean isPainted; // セルが塗りつぶされているか
public boolean toBePainted; // セルをこれから塗り直すべきか
/**
コンストラクタ(クラスの新しいデータの生成を行う)
*/
BoardCell( SimpleBoard parent, int i, int j,
int width, int height ) {
this.parent=parent;
this.i=i; this.j=j;
this.width=width; this.height=height;
this.color=parent.bgColor;
this.isPainted=false;
}
/**
セルに色の設定・変更を行う関数
*/
public void setColor( Color color ){
this.color = color;
}
/**
セルを塗りつぶす関数
*/
public void paint( Graphics g ){
g.setForeground( color );
g.paint3DRect( i*width, j*height, width, height,
true, true );
this.isPainted = true;
}
/**
セルをクリアする関数
*/
public void clear( Graphics g ){
g.clearRect( i*width, j*height, width, height );
this.isPainted = false;
}
}