Creating an image from SGT in java
JPlotLayout jpl;
// initialize and add plots to jpl ... ommitted here.
// Get graphic
int width = jpl.getWidth();
int height = jpl.getHeight();
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = img.getGraphics();
jpl.paint(g);
// Save to a file
try {
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("some.jpg"));
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncoderParam param = encoder.getDefaultJPEGEncoderParam(img);
int quality = 100;
quality = Math.max(0, Math.min(quality, 100));
param.setQuality((float) quality/100F, false);
encoder.setJPEGEncoderParam(param);
encoder.encode(img);
out.close();
}
catch (IOException e) {
// Log or deai with exception
}