code: public static GeneralPath shapeOf(Shape shape, Color color) {
          List<PathElement> elements = new ArrayList<PathElement>();
          PathIterator pathIt = shape.getPathIterator(new AffineTransform());
          double[] data = new double[6];
          while (!pathIt.isDone()) {
              switch (pathIt.currentSegment(data)) {
                  case PathIterator.SEG_MOVETO:
                      elements.add(new MoveTo(data));
                      break;
                  case PathIterator.SEG_LINETO:
                      elements.add(new LineTo(data));
                      break;
                  case PathIterator.SEG_CLOSE:
                      elements.add(new Close());
                      break;
                  case PathIterator.SEG_QUADTO:
                      elements.add(new QuadTo(data));
                      break;
                  case PathIterator.SEG_CUBICTO:
                      elements.add(new CubicTo(data));
                      break;
              }
              pathIt.next();
          }
          return new GeneralPath(elements, color, pathIt.getWindingRule(), 0d, true);
      }
docs: Create a filled path of the specified Java 2D Shape and color.
  
  @param shape Java 2D shape
  @param color the color to fill the shape with
  @return a new general path