예제 #1
0
 @Override // from interface IRectangle
 public Rectangle union(IRectangle r) {
   Rectangle rect = new Rectangle(this);
   rect.add(r);
   return rect;
 }
  public void getSmallBox(int x, int y, int w, int h) {
    // create 9 small boxes

    cross = new Rectangle(x, y, w, h);
    cross.setBackground(Color.blue);

    circle = new Oval(x, y, w, h);
    circle.setBackground(Color.red);

    smallBox0 = new Rectangle(x, y, w / 3, h / 3);
    smallBox0.setBackground(Color.white);
    container.add(smallBox0);
    smallBox0.add(cross);
    cross.setVisible(setVisibility());
    smallBox0.add(circle);
    circle.setVisible(setVisibility());

    smallBox1 = new Rectangle(x + (w / 3), y, w / 3, h / 3);
    smallBox1.setBackground(Color.white);
    container.add(smallBox1);
    smallBox1.add(cross);
    cross.setVisible(setVisibility());
    smallBox1.add(circle);
    circle.setVisible(setVisibility());

    smallBox2 = new Rectangle(x + (2 * w / 3), y, w / 3, h / 3);
    smallBox2.setBackground(Color.white);
    container.add(smallBox2);
    smallBox2.add(cross);
    cross.setVisible(setVisibility());
    smallBox2.add(circle);
    circle.setVisible(setVisibility());

    smallBox3 = new Rectangle(x, y + (h / 3), w / 3, h / 3);
    smallBox3.setBackground(Color.white);
    container.add(smallBox3);
    smallBox3.add(cross);
    cross.setVisible(setVisibility());
    smallBox3.add(circle);
    circle.setVisible(setVisibility());

    smallBox4 = new Rectangle(x + (w / 3), y + (h / 3), w / 3, h / 3);
    smallBox4.setBackground(Color.white);
    container.add(smallBox4);
    smallBox4.add(cross);
    cross.setVisible(setVisibility());
    smallBox4.add(circle);
    circle.setVisible(setVisibility());

    smallBox5 = new Rectangle(x + (2 * w / 3), y + (h / 3), w / 3, h / 3);
    smallBox5.setBackground(Color.white);
    container.add(smallBox5);
    smallBox5.add(cross);
    cross.setVisible(setVisibility());
    smallBox5.add(circle);
    circle.setVisible(setVisibility());

    smallBox6 = new Rectangle(x, y + (2 * h / 3), w / 3, h / 3);
    smallBox6.setBackground(Color.white);
    container.add(smallBox6);
    smallBox6.add(cross);
    cross.setVisible(setVisibility());
    smallBox6.add(circle);
    circle.setVisible(setVisibility());

    smallBox7 = new Rectangle(x + (w / 3), y + (2 * h / 3), w / 3, h / 3);
    smallBox7.setBackground(Color.white);
    container.add(smallBox7);
    smallBox7.add(cross);
    cross.setVisible(setVisibility());
    smallBox7.add(circle);
    circle.setVisible(setVisibility());

    smallBox8 = new Rectangle(x + (2 * w / 3), y + (2 * h / 3), w / 3, h / 3);
    smallBox8.setBackground(Color.white);
    container.add(smallBox8);
    smallBox8.add(cross);
    cross.setVisible(setVisibility());
    smallBox8.add(circle);
    circle.setVisible(setVisibility());
  }