/**
  * Utility method to feed a {@link PathConsumer2D} object from a given {@link PathIterator}. This
  * method deals with the details of running the iterator and feeding the consumer a segment at a
  * time.
  */
 public static void feedConsumer(PathIterator pi, PathConsumer2D consumer) {
   float coords[] = new float[6];
   while (!pi.isDone()) {
     switch (pi.currentSegment(coords)) {
       case PathIterator.SEG_MOVETO:
         consumer.moveTo(coords[0], coords[1]);
         break;
       case PathIterator.SEG_LINETO:
         consumer.lineTo(coords[0], coords[1]);
         break;
       case PathIterator.SEG_QUADTO:
         consumer.quadTo(
             coords[0], coords[1],
             coords[2], coords[3]);
         break;
       case PathIterator.SEG_CUBICTO:
         consumer.curveTo(
             coords[0], coords[1],
             coords[2], coords[3],
             coords[4], coords[5]);
         break;
       case PathIterator.SEG_CLOSE:
         consumer.closePath();
         break;
     }
     pi.next();
   }
 }
Example #2
0
 private void emitSeg(float[] buf, int off, int type) {
   switch (type) {
     case 8:
       out.curveTo(
           buf[off + 0], buf[off + 1],
           buf[off + 2], buf[off + 3],
           buf[off + 4], buf[off + 5]);
       break;
     case 6:
       out.quadTo(
           buf[off + 0], buf[off + 1],
           buf[off + 2], buf[off + 3]);
       break;
     case 4:
       out.lineTo(buf[off], buf[off + 1]);
   }
 }