private void paint(SeaGlassPainter p,SynthContext ctx,Graphics g,int x,int y,int w,int h,AffineTransform transform){
  if (p != null) {
    if (g instanceof Graphics2D) {
      Graphics2D gfx=(Graphics2D)g;
      if (transform != null) {
        gfx.transform(transform);
      }
      gfx.translate(x,y);
      p.paint(gfx,ctx.getComponent(),w,h);
      gfx.translate(-x,-y);
      if (transform != null) {
        try {
          gfx.transform(transform.createInverse());
        }
 catch (        NoninvertibleTransformException e) {
          e.printStackTrace();
        }
      }
    }
 else {
      BufferedImage img=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
      Graphics2D gfx=img.createGraphics();
      if (transform != null) {
        gfx.transform(transform);
      }
      p.paint(gfx,ctx.getComponent(),w,h);
      gfx.dispose();
      g.drawImage(img,x,y,null);
      img=null;
    }
  }
}

private void paint ( SeaGlassPainter p , SynthContext ctx , Graphics g , int x , int y , int w , int h , AffineTransform transform ) { if ( p != null ) { if ( g instanceof Graphics2D ) { Graphics2D gfx = ( Graphics2D ) g ; if ( transform != null ) { gfx . transform ( transform ) ; } gfx . translate ( x , y ) ; p . paint ( gfx , ctx . getComponent ( ) , w , h ) ; gfx . translate ( - x , - y ) ; if ( transform != null ) { try { gfx . transform ( transform . createInverse ( ) ) ; } catch ( NoninvertibleTransformException e ) { e . printStackTrace ( ) ; } } } else { BufferedImage img = new BufferedImage ( w , h , BufferedImage . TYPE_INT_ARGB ) ; Graphics2D gfx = img . createGraphics ( ) ; if ( transform != null ) { gfx . transform ( transform ) ; } p . paint ( gfx , ctx . getComponent ( ) , w , h ) ; gfx . dispose ( ) ; g . drawImage ( img , x , y , null ) ; img = null ; } } }
paint the provided painter using the provided transform at the specified position and size . handles if g is a non 2d graphics by painting via a bufferedimage .
