1  import java.awt.*;
  2  import java.awt.geom.*;
  3  
  4  /**
  5     A scene shape that is composed of multiple geometric shapes.
  6  */
  7  public abstract class CompoundShape extends SelectableShape
  8  {
  9     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(int dx, int dy)
 25     {
 26        path.transform(
 27              AffineTransform.getTranslateInstance(dx, dy));
 28     }
 29  
 30     public void draw(Graphics2D g2)
 31     {
 32        g2.draw(path);
 33     }
 34     
 35     private GeneralPath path;
 36  }
 37  
 38  
 39  
 40  
 41  
 42  
 43