classes/SimpleBoard.java
import browser.Applet;
import awt.Graphics;
import awt.Image;
import awt.Color;
/**
看板の土台になる SimpleBoard クラスの定義
*/
class SimpleBoard extends Applet {
protected Color bgColor; // 背景色
protected Image bgImage; // 背景イメージ
/**
初期設定の関数。
*/
protected void init() {
bgImage = getBGImage();
bgColor = getBGColor();
resize( width, height );
}
/**
アプレットの表示を行う関数。初期設定の画像。
*/
public void paint( Graphics g ) {
if( bgImage == null ) {
g.setForeground( bgColor );
g.paint3DRect( 0, 0, width, height, true, true );
}
else {
for( int i=0; i*bgImage.width<width; i++ )
for( int j=0; j*bgImage.height<height; j++ )
g.drawImage( bgImage, i*bgImage.width, j*bgImage.height );
g.paint3DRect( 0, 0, width, height, false, true );
}
}
/**
背景のイメージを得るための関数
*/
protected Image getBGImage() {
String imageSource = getAttribute("bgimage");
if( imageSource == null )
return null;
else
return getImage( imageSource );
}
/**
背景の色を得るための関数
*/
protected Color getBGColor() {
String colorName = getAttribute("bgcolor");
if( colorName == null )
return Color.lightGray;
else if( colorName.equals("red") )
return Color.red;
else if( colorName.equals("yellow") )
return Color.yellow;
else if( colorName.equals("green") )
return Color.green;
else if( colorName.equals("blue") )
return Color.blue;
else if( colorName.equals("white") )
return Color.white;
else
return Color.lightGray;
}
}