    01: import java.awt.*;
    02: import java.awt.geom.*;
    03:
    04: /**
    05:    A scene shape that is composed of multiple geometric shapes.
    06: */
    07: public abstract class CompoundShape extends SelectableShape
    08: {
    09:    public CompoundShape()
    10:    {
    11:       path = new GeneralPath();
    12:    }
    13:
    14:    protected void add(Shape s)
    15:    {
    16:       path.append(s, false);
    17:    }
    18:
    19:    public boolean contains(Point2D aPoint)
    20:    {
    21:       return path.contains(aPoint);
    22:    }
    23:
    24:    public void translate(double dx, double dy)
    25:    {
    26:       AffineTransform t
    27:          = AffineTransform.getTranslateInstance(dx, dy);
    28:       path.transform(t);
    29:    }
    30:
    31:    public void draw(Graphics2D g2)
    32:    {
    33:       g2.draw(path);
    34:    }
    35:
    36:    private GeneralPath path;
    37: }
    38:
    39:
    40:
    41:
    42:
    43:
    44: