code: public static Shape copyOf(Shape shape) {
         Args.nullNotPermitted(shape, "shape");
         if (shape instanceof Line2D) {
             Line2D l = (Line2D) shape;
             return new Line2D.Double(l.getX1(), l.getY1(), l.getX2(), l.getY2());
         }
         if (shape instanceof Rectangle2D) {
             Rectangle2D r = (Rectangle2D) shape;
             return new Rectangle2D.Double(r.getX(), r.getY(), r.getWidth(), 
                     r.getHeight());
         }
         if (shape instanceof RoundRectangle2D) {
             RoundRectangle2D rr = (RoundRectangle2D) shape;
             return new RoundRectangle2D.Double(rr.getX(), rr.getY(), 
                     rr.getWidth(), rr.getHeight(), rr.getArcWidth(), 
                     rr.getArcHeight());
         }
         if (shape instanceof Arc2D) {
             Arc2D arc = (Arc2D) shape;
             return new Arc2D.Double(arc.getX(), arc.getY(), arc.getWidth(),
                     arc.getHeight(), arc.getAngleStart(), arc.getAngleExtent(),
                     arc.getArcType());
         }
         if (shape instanceof Ellipse2D) {
             Ellipse2D ell = (Ellipse2D) shape;
             return new Ellipse2D.Double(ell.getX(), ell.getY(), ell.getWidth(),
                     ell.getHeight());
         }
         if (shape instanceof Polygon) {
             Polygon p = (Polygon) shape;
             return new Polygon(p.xpoints, p.ypoints, p.npoints);
         }
         return new Path2D.Double(shape);
      }
docs: Returns a shape that is (more or less) equivalent to the supplied shape.
  For some known shape implementations ({@code Line2D},
  {@code Rectangle2D}, {@code RoundRectangle2D}, {@code Arc2D},
  {@code Ellipse2D}, and {@code Polygon}) the copy will be an instance of
  that class.  For other shapes, a {@code Path2D} containing the outline
  of the shape is returned.
  
  @param shape  the shape ({@code null} not permitted).
  
  @return A copy of the shape or shape outline (never {@code null}).