/* * A Java program that demonstrates a simple general-purpose drawing architecture * * Ben Bederson, April 18, 2002 */ import java.awt.*; public class RectGlyph extends Glyph { Rectangle rect; public RectGlyph(Scene scene, int x, int y, int width, int height) { super(scene); color = Color.black; setRect(x, y, width, height); } public void setRect(int x, int y, int width, int height) { rect = new Rectangle(x, y, width, height); computeBounds(); repaint(); } public void computeBounds() { bounds = new Rectangle(rect); } public void paintGlyph(Graphics2D g) { if (color != null) { g.setColor(color); g.fillRect(rect.x, rect.y, rect.width, rect.height); } } }