painter = (Painter)cl.newInstance();
}catch(Exception e){
exit(1);
}
// Begin encoding to PNG image file
ImageTranscoder transcoder
= (ImageTranscoder)getTranscoder();
Dimension size = painter.getSize();
BufferedImage buf = transcoder.createImage(size.width, size.height);
Graphics2D g = buf.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
Shape clip = new Rectangle(0, 0, 300, 400);
clip = new GeneralPath(clip);
g.setClip(clip);
painter.paint(g);
g.dispose();
try{
transcoder.writeImage(buf, new FileOutputStream(testImageName));
}
catch(Exception e){
}
}