Exemple #1
0
 public DotPath manageRect(Rectangle2D start, Rectangle2D end) {
   final List<CubicCurve2D.Double> list = new ArrayList<CubicCurve2D.Double>(this.beziers);
   while (true) {
     if (BezierUtils.isCutting(list.get(0), start) == false) {
       throw new IllegalStateException();
     }
     if (BezierUtils.dist(list.get(0)) <= 1.0) {
       break;
     }
     final CubicCurve2D.Double left = new CubicCurve2D.Double();
     final CubicCurve2D.Double right = new CubicCurve2D.Double();
     list.get(0).subdivide(left, right);
     list.set(0, left);
     list.add(1, right);
     if (BezierUtils.isCutting(list.get(1), start)) {
       list.remove(0);
     }
   }
   return new DotPath(list);
 }
Exemple #2
0
 public Point2D getFrontierIntersection(Shape shape, Rectangle2D... notIn) {
   final List<CubicCurve2D.Double> all = new ArrayList<CubicCurve2D.Double>(beziers);
   for (int i = 0; i < 8; i++) {
     for (CubicCurve2D.Double immutable : all) {
       if (contains(immutable, notIn)) {
         continue;
       }
       final CubicCurve2D.Double bez = new CubicCurve2D.Double();
       bez.setCurve(immutable);
       if (BezierUtils.isCutting(bez, shape)) {
         while (BezierUtils.dist(bez) > 1.0) {
           BezierUtils.shorten(bez, shape);
         }
         final Point2D.Double result =
             new Point2D.Double((bez.x1 + bez.x2) / 2, (bez.y1 + bez.y2) / 2);
         if (contains(result, notIn) == false) {
           return result;
         }
       }
     }
     cutAllCubic(all);
   }
   throw new IllegalArgumentException("shape=" + shape);
 }