Source of CompoundShape.java


  1: import java.awt.*;
  2: import java.awt.geom.*;

  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:    }

 14:    protected void add(Shape s)
 15:    {
 16:       path.append(s, false);
 17:    }

 19:    public boolean contains(Point2D aPoint)
 20:    {
 21:       return path.contains(aPoint);
 22:    }

 24:    public void translate(int dx, int dy)
 25:    {
 26:       path.transform(
 27:             AffineTransform.getTranslateInstance(dx, dy));
 28:    }

 30:    public void draw(Graphics2D g2)
 31:    {
 32:       g2.draw(path);
 33:    }
 34:    
 35:    private GeneralPath path;
 36: }