Esempio n. 1
0
 /**
  * Convert an AWT Shape to an SWT Path.
  *
  * @param shape
  * @return the SWT Path or <code>null</code> if <code>shape == null</code>
  */
 private Path convertToPath(Shape shape) {
   if (shape == null) {
     return null;
   }
   Path path = new Path(_gc.getDevice());
   PathIterator iter = shape.getPathIterator(null);
   float[] coords = new float[6];
   while (!iter.isDone()) {
     int op = iter.currentSegment(coords);
     switch (op) {
       case PathIterator.SEG_MOVETO:
         path.moveTo(coords[0], coords[1]);
         break;
       case PathIterator.SEG_LINETO:
         path.lineTo(coords[0], coords[1]);
         break;
       case PathIterator.SEG_QUADTO:
         path.quadTo(coords[0], coords[1], coords[2], coords[3]);
         break;
       case PathIterator.SEG_CUBICTO:
         path.cubicTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
         break;
       case PathIterator.SEG_CLOSE:
         path.close();
         break;
     }
     iter.next();
   }
   return path;
 }