code: static List<Point2D> pointsOf(final Shape shape) {
          final List<Point2D> points = new ArrayList<Point2D>();
          final double[] coordinates = new double[6];
          for (PathIterator i = shape.getPathIterator(null); !i.isDone(); i.next()) {
              switch (i.currentSegment(coordinates)) {
                  case PathIterator.SEG_CLOSE:
                      break;
                  case PathIterator.SEG_MOVETO:
                  case PathIterator.SEG_LINETO:
                      points.add(new Point2D.Double(coordinates[0], coordinates[1]));
                      break;
                  case PathIterator.SEG_QUADTO:
                      points.add(new Point2D.Double(coordinates[0], coordinates[1]));
                      points.add(new Point2D.Double(coordinates[2], coordinates[3]));
                      break;
                  case PathIterator.SEG_CUBICTO:
                      points.add(new Point2D.Double(coordinates[0], coordinates[1]));
                      points.add(new Point2D.Double(coordinates[2], coordinates[3]));
                      points.add(new Point2D.Double(coordinates[4], coordinates[5]));
                      break;
              }
          }
  
          if (!points.isEmpty() && points.get(points.size() - 1).equals(points.get(0))) {
              points.remove(points.size() - 1);
          }
          return points;
      }
docs: Convert a Java 2D shape to a list of points.
  
  @param shape a shape
  @return list of point