public Shape inverseShape(Shape shape){
  PathIterator pi=shape.getPathIterator(null);
  double[] coords=new double[6];
  Point2D world=new Point2D.Double();
  Point2D world2=new Point2D.Double();
  Point2D world3=new Point2D.Double();
  Point2D screen=new Point2D.Double();
  Point2D screen2=new Point2D.Double();
  Point2D screen3=new Point2D.Double();
  GeneralPath path=new GeneralPath(GeneralPath.WIND_EVEN_ODD);
  while (!pi.isDone()) {
    int type=pi.currentSegment(coords);
    screen.setLocation(coords[0],coords[1]);
    inverse(screen,world);
    if (type == PathIterator.SEG_MOVETO) {
      path.moveTo(world.getX(),world.getY());
    }
 else     if (type == PathIterator.SEG_LINETO) {
      path.lineTo(world.getX(),world.getY());
    }
 else     if (type == PathIterator.SEG_CLOSE) {
      path.closePath();
    }
 else {
      screen2.setLocation(coords[2],coords[3]);
      inverse(screen2,world2);
      if (type == PathIterator.SEG_QUADTO) {
        path.quadTo(world.getX(),world.getY(),world2.getX(),world2.getY());
      }
 else       if (type == PathIterator.SEG_CUBICTO) {
        screen3.setLocation(coords[4],coords[5]);
        inverse(screen3,world3);
        path.curveTo(world.getX(),world.getY(),world2.getX(),world2.getY(),world3.getX(),world3.getY());
      }
    }
    pi.next();
  }
  return path;
}

public Shape inverseShape ( Shape shape ) { PathIterator pi = shape . getPathIterator ( null ) ; double [ ] coords = new double [ 6 ] ; Point2D world = new Point2D . Double ( ) ; Point2D world2 = new Point2D . Double ( ) ; Point2D world3 = new Point2D . Double ( ) ; Point2D screen = new Point2D . Double ( ) ; Point2D screen2 = new Point2D . Double ( ) ; Point2D screen3 = new Point2D . Double ( ) ; GeneralPath path = new GeneralPath ( GeneralPath . WIND_EVEN_ODD ) ; while ( ! pi . isDone ( ) ) { int type = pi . currentSegment ( coords ) ; screen . setLocation ( coords [ 0 ] , coords [ 1 ] ) ; inverse ( screen , world ) ; if ( type == PathIterator . SEG_MOVETO ) { path . moveTo ( world . getX ( ) , world . getY ( ) ) ; } else if ( type == PathIterator . SEG_LINETO ) { path . lineTo ( world . getX ( ) , world . getY ( ) ) ; } else if ( type == PathIterator . SEG_CLOSE ) { path . closePath ( ) ; } else { screen2 . setLocation ( coords [ 2 ] , coords [ 3 ] ) ; inverse ( screen2 , world2 ) ; if ( type == PathIterator . SEG_QUADTO ) { path . quadTo ( world . getX ( ) , world . getY ( ) , world2 . getX ( ) , world2 . getY ( ) ) ; } else if ( type == PathIterator . SEG_CUBICTO ) { screen3 . setLocation ( coords [ 4 ] , coords [ 5 ] ) ; inverse ( screen3 , world3 ) ; path . curveTo ( world . getX ( ) , world . getY ( ) , world2 . getX ( ) , world2 . getY ( ) , world3 . getX ( ) , world3 . getY ( ) ) ; } } pi . next ( ) ; } return path ; }
simple shape inverse projection , converts the x , y values in the shape to the x , y values of the projection .
