You can create the plot with a toolbar. The toolbar has export button. The sample code is in:
http://git.eclipse.org/c/nebula/org.eclipse.nebula.git/plain/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/visualization/SimpleToolbarArmedXYGraphExample.java
The relatived code in org.eclipse.nebula.visualization.xygraph.figures.XYGraphToolbar.java is:
private void addSnapshotButton() {
Button snapShotButton = new Button(XYGraphMediaFactory.getInstance().getImage("images/camera.png"));
snapShotButton.setToolTip(new Label("Save Snapshot to PNG file"));
addButton(snapShotButton);
snapShotButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
// Have valid name, so get image
ImageLoader loader = new ImageLoader();
Image image = xyGraph.getImage();
loader.data = "" ImageData[] { image.getImageData() };
image.dispose();
// Prompt for file name
String path = SingleSourceHelper2.getImageSavePath();
if (path == null || path.length() <= 0)
return;
// Assert *.png at end of file name
if (!path.toLowerCase().endsWith(".png"))
path = path + ".png";
// Save
loader.save(path, SWT.IMAGE_PNG);
}
});
}