+ segments.add(l);
+
+ break;
+ case PathIterator.SEG_QUADTO:
+ // TODO: implement gaps
+ path2.quadTo(c[0], c[1], c[2], c[3]);
+ break;
+ case PathIterator.SEG_CUBICTO:
+ // TODO: implement gaps
+ path2.curveTo(c[0], c[1], c[2], c[3], c[4], c[5]);
+ break;
+ case PathIterator.SEG_CLOSE:
+ // TODO: implement gaps
+ path2.closePath();
+ break;
+ default:
+ throw new RuntimeException("Unexpected segment type " + i);
+ }
+ iter.next();
+ }
+ } else {
+ while (!iter.isDone()) {
+
+ double c[] = new double[6];
+ int i = iter.currentSegment(c);
+ switch (i) {
+ case PathIterator.SEG_MOVETO:
+ path2.moveTo(c[0], c[1]);
+ break;
+ case PathIterator.SEG_LINETO:
+ Segment l = new Segment(path2.getCurrentPoint().getX(), path2.getCurrentPoint().getY(), c[0], c[1]);
+
+ List<Double> gaps = new ArrayList<>();
+ for (Segment old : segments) {
+ Double t = lineLineIntersection(old, l);
+ if (t != null) {
+ gaps.add(t);
+ }
+ }
+
+ if (gaps.isEmpty()) {
+ path2.lineTo(c[0], c[1]);