private int getPoints(GeneralPath path, float[] mypoints) {
        int count = 0;
        float x = 0;
        float y = 0;
        float startx = 0;
        float starty = 0;
        float[] coords = new float[6];

        PathIterator pi = path.getPathIterator(new AffineTransform());
        while (!pi.isDone()) {
            if (count >= mypoints.length) {
                mypoints = null;
                break;
            }

            int pathtype = pi.currentSegment(coords);
            switch (pathtype) {
                case PathIterator.SEG_MOVETO:
                    startx = x = coords[0];
                    starty = y = coords[1];
                    break;
                case PathIterator.SEG_LINETO:
                    mypoints[count++] = x;
                    mypoints[count++] = y;
                    x = mypoints[count++] = coords[0];
                    y = mypoints[count++] = coords[1];
                    break;
                case PathIterator.SEG_QUADTO:
                    x = coords[2];
                    y = coords[3];
                    break;
                case PathIterator.SEG_CUBICTO:
                    x = mypoints[4];
                    y = mypoints[5];
                    break;
                case PathIterator.SEG_CLOSE:
                    mypoints[count++] = x;
                    mypoints[count++] = y;
                    x = mypoints[count++] = startx;
                    y = mypoints[count++] = starty;
                    break;
            }

            pi.next();
        }

        return count;
    }