@UiHandler("polyBtn")
 public void onPolyBtnClicked(ClickEvent event) {
   if (container != null) {
     container.clear();
     List<CanvasShape> shapes = new ArrayList<CanvasShape>();
     double factor = Math.pow(count, -0.5);
     for (int i = 0; i < count; i++) {
       double x1 = (Random.nextDouble() - 0.5) * (TOTAL_SIZE - SHAPE_SIZE * factor);
       double y1 = (Random.nextDouble() - 0.5) * (TOTAL_SIZE - SHAPE_SIZE * factor);
       double x2 = x1 + (Random.nextDouble() - 0.5) * SHAPE_SIZE * factor;
       double y2 = y1 + (Random.nextDouble() - 0.5) * SHAPE_SIZE * factor;
       double x3 = x1 + (Random.nextDouble() - 0.5) * SHAPE_SIZE * factor;
       double y3 = y1 + (Random.nextDouble() - 0.5) * SHAPE_SIZE * factor;
       Coordinate[] coords =
           new Coordinate[] {
             new Coordinate(x1, y1),
             new Coordinate(x2, y2),
             new Coordinate(x3, y3),
             new Coordinate(x1, y1)
           };
       Geometry ring = new Geometry(Geometry.LINEAR_RING, 0, 5);
       ring.setCoordinates(coords);
       Geometry poly = new Geometry(Geometry.POLYGON, 0, 5);
       poly.setGeometries(new Geometry[] {ring});
       CanvasPath path = new CanvasPath(poly);
       path.setFillStyle(getRandomRGB(0.5));
       path.setStrokeStyle(getRandomRGB(1));
       shapes.add(path);
     }
     container.addAll(shapes);
     container.repaint();
   }
 }
 @UiHandler("rectBtn")
 public void onRectangleBtnClicked(ClickEvent event) {
   if (container != null) {
     container.clear();
     List<CanvasShape> shapes = new ArrayList<CanvasShape>();
     double factor = Math.pow(count, -0.5);
     for (int i = 0; i < count; i++) {
       double x = (Random.nextDouble() - 0.5) * (TOTAL_SIZE - SHAPE_SIZE * factor);
       double y = (Random.nextDouble() - 0.5) * (TOTAL_SIZE - SHAPE_SIZE * factor);
       double width = Random.nextDouble() * SHAPE_SIZE * factor;
       double height = Random.nextDouble() * SHAPE_SIZE * factor;
       CanvasRect rect = new CanvasRect(new Bbox(x - width / 2, y - height / 2, width, height));
       rect.setFillStyle(getRandomRGB(0.5));
       rect.setStrokeStyle(getRandomRGB(1));
       shapes.add(rect);
     }
     container.addAll(shapes);
     container.repaint();
   }
 }