public class Main2 {
public static void main(String[] args) {
// (see also shapes.impl.composite.Main)
// define a complex group of shapes.impl.composite
Builder builder = new CompositeBuilder();
builder.startGroup();
builder.addCircle(20);
builder.addRectangle(100, 200);
builder.startGroup();
builder.addRectangle(50, 30);
builder.addRectangle(300, 60);
builder.setFilled(false);
builder.startPolygon();
builder.addPoint(50, 50);
builder.addPoint(60, 100);
builder.addPoint(100, 110);
builder.addPoint(120, 60);
builder.endPolygon();
builder.setStroke(Color.CYAN);
builder.addCircle(50);
builder.setFilled(false);
builder.setStroke(Color.ORANGE);
builder.setLocation(100, 200);
builder.endGroup();
builder.setFilled(true);
builder.setStroke(Color.RED);
builder.setLocation(150, 50);
builder.endGroup();
builder.setLocation(50, 100);
final Shape s = builder.getProduct();
System.out.println(s.accept(new Size()) + " basic shapes");
// calculate the bounding box
final Location b = s.accept(new BoundingBox());
final Rectangle r = (Rectangle) b.getChild();