import EDU.Washington.grad.gjb.cassowary.*; import java.awt.Graphics; import java.awt.Color; public class Square { private ClPoint center; private int sx, sy; // Screen x, y of center private int rad; // radius of square (squares with radius, that's new...) private int num; // rectangle number // create a new one public Square(double x, double y, int radius, int number) { center = new ClPoint(x, y); rad = radius; num = number; cvt(); } // Helper function to convert center to screen coords void cvt() { sx = (int) center.X().value(); sy = (int) center.Y().value(); } // Draw the rectangle. Not pretty, but it works. public void draw(Graphics g) { cvt(); g.setColor(Color.blue); g.drawRect(sx - rad, sy - rad, rad*2, rad*2); g.drawString("" + num, sx-4, sy+4); } public double CenterX() { return center.Xvalue(); } public double CenterY() { return center.Yvalue(); } public double Radius() { return rad; } public ClVariable X() { return center.X(); } public ClVariable Y() { return center.Y(); } public ClPoint CenterPt() { return center; } }