public Shape transform(Shape shape){
  GeneralPath newPath=new GeneralPath();
  float[] coords=new float[6];
  for (PathIterator iterator=shape.getPathIterator(null); iterator.isDone() == false; iterator.next()) {
    int type=iterator.currentSegment(coords);
switch (type) {
case PathIterator.SEG_MOVETO:
      Point2D p=transform(new Point2D.Float(coords[0],coords[1]));
    newPath.moveTo((float)p.getX(),(float)p.getY());
  break;
case PathIterator.SEG_LINETO:
p=transform(new Point2D.Float(coords[0],coords[1]));
newPath.lineTo((float)p.getX(),(float)p.getY());
break;
case PathIterator.SEG_QUADTO:
p=transform(new Point2D.Float(coords[0],coords[1]));
Point2D q=transform(new Point2D.Float(coords[2],coords[3]));
newPath.quadTo((float)p.getX(),(float)p.getY(),(float)q.getX(),(float)q.getY());
break;
case PathIterator.SEG_CUBICTO:
p=transform(new Point2D.Float(coords[0],coords[1]));
q=transform(new Point2D.Float(coords[2],coords[3]));
Point2D r=transform(new Point2D.Float(coords[4],coords[5]));
newPath.curveTo((float)p.getX(),(float)p.getY(),(float)q.getX(),(float)q.getY(),(float)r.getX(),(float)r.getY());
break;
case PathIterator.SEG_CLOSE:
newPath.closePath();
break;
}
}
return newPath;
}

public Shape transform ( Shape shape ) { GeneralPath newPath = new GeneralPath ( ) ; float [ ] coords = new float [ 6 ] ; for ( PathIterator iterator = shape . getPathIterator ( null ) ; iterator . isDone ( ) == false ; iterator . next ( ) ) { int type = iterator . currentSegment ( coords ) ; switch ( type ) { case PathIterator . SEG_MOVETO : Point2D p = transform ( new Point2D . Float ( coords [ 0 ] , coords [ 1 ] ) ) ; newPath . moveTo ( ( float ) p . getX ( ) , ( float ) p . getY ( ) ) ; break ; case PathIterator . SEG_LINETO : p = transform ( new Point2D . Float ( coords [ 0 ] , coords [ 1 ] ) ) ; newPath . lineTo ( ( float ) p . getX ( ) , ( float ) p . getY ( ) ) ; break ; case PathIterator . SEG_QUADTO : p = transform ( new Point2D . Float ( coords [ 0 ] , coords [ 1 ] ) ) ; Point2D q = transform ( new Point2D . Float ( coords [ 2 ] , coords [ 3 ] ) ) ; newPath . quadTo ( ( float ) p . getX ( ) , ( float ) p . getY ( ) , ( float ) q . getX ( ) , ( float ) q . getY ( ) ) ; break ; case PathIterator . SEG_CUBICTO : p = transform ( new Point2D . Float ( coords [ 0 ] , coords [ 1 ] ) ) ; q = transform ( new Point2D . Float ( coords [ 2 ] , coords [ 3 ] ) ) ; Point2D r = transform ( new Point2D . Float ( coords [ 4 ] , coords [ 5 ] ) ) ; newPath . curveTo ( ( float ) p . getX ( ) , ( float ) p . getY ( ) , ( float ) q . getX ( ) , ( float ) q . getY ( ) , ( float ) r . getX ( ) , ( float ) r . getY ( ) ) ; break ; case PathIterator . SEG_CLOSE : newPath . closePath ( ) ; break ; } } return newPath ; }
transform the supplied shape from graph ( layout ) to screen ( view ) coordinates .
