String file = XJFileChooser.shared().getSelectedFilePath();
if(file == null)
return;
try {
GEnginePS engine = new GEnginePS();
GContext context = graph.getContext();
GEngine oldEngine = context.engine;
context.setEngine(engine);
graph.draw();
context.setEngine(oldEngine);
XJUtils.writeStringToFile(engine.getPSText(), file);
} catch (Exception e) {
window.consoleTab.println(e);
XJAlert.display(window.getJavaContainer(), "Error", "Cannot export to EPS file: "+file+"\nError: "+e);
}
}