public void run() { double outerCircleDiameter = 2 * OUTER_CIRCLE_RADIUS; double middleCircleDiameter = 2 * MIDDLE_CIRCLE_RADIUS; double innerCircleDiameter = 2 * INNER_CIRCLE_RADIUS; double xOuterCircle = (getWidth() - outerCircleDiameter) / 2; double xMiddleCircle = (getWidth() - middleCircleDiameter) / 2; double xInnerCircle = (getWidth() - innerCircleDiameter) / 2; double yOuterCircle = (getHeight() - outerCircleDiameter) / 2; double yMiddleCircle = (getHeight() - middleCircleDiameter) / 2; double yInnerCircle = (getHeight() - innerCircleDiameter) / 2; GOval outCircle = new GOval(xOuterCircle, yOuterCircle, outerCircleDiameter, outerCircleDiameter); GOval middleCircle = new GOval(xMiddleCircle, yMiddleCircle, middleCircleDiameter, middleCircleDiameter); GOval centreCircle = new GOval(xInnerCircle, yInnerCircle, innerCircleDiameter, innerCircleDiameter); outCircle.setColor(Color.RED); middleCircle.setColor(Color.WHITE); centreCircle.setColor(Color.RED); outCircle.setFilled(true); middleCircle.setFilled(true); centreCircle.setFilled(true); outCircle.setFillColor(Color.RED); middleCircle.setFillColor(Color.WHITE); centreCircle.setFillColor(Color.RED); add(outCircle); add(middleCircle); add(centreCircle); }
private void drawOval(int x, int y, int size) { // create circle and set whether it will be red or white GOval circle = new GOval(x, y, size, size); if ((size % 2) == 0) { // if the size of the circle divides evenly (remainder of zero) // color the circle RED circle.setFillColor(Color.RED); } else { // color the circle white circle.setFillColor(Color.WHITE); } circle.setFilled(true); // add color add(circle); // create circle }
private void buildEye(double x, double y) { GOval Eye = new GOval(x, y, eye_radius * 2, eye_radius * 2); Eye.setColor(Color.YELLOW); Eye.setFilled(true); Eye.setFillColor(Color.YELLOW); add(Eye); }
/** The method takes parameters and returns, oval shape figure */ private GOval oval(int x, int y, int width, int height, Color colorSetFill, Color colorSet) { GOval oval = new GOval(x, y, width, height); oval.setFilled(true); oval.setFillColor(colorSetFill); oval.setColor(colorSet); add(oval); return oval; }
public void drawInnerOval() { double x = getWidth() / 2.0 - INNER_CIRCLE_WIDTH / 2.0; double y = getHeight() / 2.0 - INNER_CIRCLE_WIDTH / 2.0; GOval oval = new GOval(x, y, INNER_CIRCLE_WIDTH, INNER_CIRCLE_WIDTH); add(oval); oval.setFilled(true); oval.setFillColor(Color.RED); oval.setColor(Color.WHITE); }
public void drawWhiteOval() { double x = getWidth() / 2.0 - WHITE_CIRCLE_WIDTH / 2.0; double y = getHeight() / 2.0 - WHITE_CIRCLE_WIDTH / 2.0; GOval oval = new GOval(x, y, WHITE_CIRCLE_WIDTH, WHITE_CIRCLE_WIDTH); add(oval); oval.setFilled(true); oval.setFillColor(Color.WHITE); oval.setColor(Color.WHITE); }