public void deco (int x, int y, int width, int height, int depth) {
    if (width < min_size || height < min_size
      || random.nextInt (max_depth) > depth) { // stop recursion
    
      gc.set_foreground (random_color ());
      window.rectangle (gc, x, y, width, height, true);

      // draw border to look nice
      window.rectangle (display.default_gc, x, y, width, height, false);

    } else if (random.nextBoolean ()) {
      /* A rounding bug in original implementation.
       *
       * Note rounding error in width/2 + widht/2 != width!!!
       * Use <code>width-width/2</code> to get ceiling.
       */

      // left-right split
      deco (x, y, width/2, height, depth-1);
      deco (x+width/2, y, width-width/2, height, depth-1);

    } else {
      // top-bottom split
      deco (x, y, width, height/2, depth-1);
      deco (x, y+height/2, width, height-height/2, depth-1);
    }
  }