// CS 134 program to draw a warning sign
// Second attempt - named locations, but not constants
import objectdraw.*;
import java.awt.*;
public class NoClicking2 extends WindowController
{
int circleLeft, circleTop; // Coordinates and dimensions of
int circleSize; // circle.
int lineInset; // inset to ends of diagonal
int lineX1,lineY1, // Coordinates for diagonal
lineX2,lineY2;
int messX, messY; // Coordinates for "CLICKING"
int poleLeft,poleTop; // Coordinates for the pole
int signLeft, signTop; // coordinates of sign's corner
int signSize; // dimensions of sign
int circleInset; // space from circle to sign edge
int messWidth, messHeight; // Dimensions for "CLICKING"
int poleWidth, poleHt; // Dimensions for pole
public void begin()
{
// specifications that control sign's shape
signLeft = 200;
signTop = 70;
signSize = 100;
circleInset = 7;
messWidth = 40;
messHeight = 10;
poleWidth = 5;
poleHt = 150;
// Coordinates and dimensions derived from specifications
circleLeft = signLeft + circleInset;
circleTop = signTop + circleInset;
circleSize = signSize - 2*circleInset;
messX = signLeft + (signSize-messWidth)/2;
messY = signTop + signSize/2 - messHeight/2;
lineInset = signSize/2 - 5*(signSize/2 - circleInset)/7;
lineX1 = signLeft + lineInset;
lineY1 = signTop + lineInset;
lineX2 = signLeft + signSize - lineInset;
lineY2 = signTop + signSize - lineInset;
poleTop = signTop + signSize;
poleLeft = signLeft + signSize/2 - poleWidth/2;
// Instructions to construct the sign
new FramedRect( signLeft, signTop,
signSize, signSize, canvas);
new FramedOval( circleLeft, circleTop,
circleSize, circleSize, canvas);
new Text( "CLICKING", messX, messY, canvas);
new Line(lineX1, lineY1, lineX2, lineY2, canvas);
new FilledRect(poleLeft, poleTop, poleWidth, poleHt, canvas);
}
}