fileChooser.addChoosableFileFilter(EPSfilter);
int r = fileChooser.showSaveDialog((Component) parent);
if (r == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
if (fileChooser.getFileFilter().equals(EPSfilter)) {
PAPlot plot = parent.getPlot();
try {
FileOutputStream fileStream = new FileOutputStream(file);
plot.export(fileStream);
fileStream.close();
} catch (FileNotFoundException fnf) {
JOptionPane.showMessageDialog(fileChooser, "File not found", "JMT - Error", JOptionPane.ERROR_MESSAGE);
} catch (IOException ioe) {
JOptionPane.showMessageDialog(fileChooser, "I/O exception", "JMT - Error", JOptionPane.ERROR_MESSAGE);
}
} else {
PAPlot plot = parent.getPlot();
BufferedImage image = plot.exportImage();
try {
int targetType = BufferedImage.TYPE_INT_RGB;
BufferedImage originalImage = convertType(image, targetType);
ImageIO.write(originalImage, "png", file);
ImageIO.createImageOutputStream(file).close();