file.deleteOnExit();
CanvasDocument doc = context.getDocument();
if(doc instanceof SketchDocument) {
SketchDocument sdoc = (SketchDocument) doc;
SavePNGAction save = new SavePNGAction(null);
VectorDocContext vdc = (VectorDocContext) context;
save.includeBackground = true;
if(includeStamp.isSelected()) {
save.includeStamp = true;
}
if(tg.getSelectedButton() == page) {
save.includeDocumentBounds = true;
}
if(tg.getSelectedButton() == selected) {
SavePNGAction.exportFragment(file, (Iterable<SNode>) vdc.getSelection().items());
} else {
save.export(file, sdoc);
}
}
if(doc instanceof PixelDocument) {
SavePNGAction save = new SavePNGAction(null);
save.exportStatic(file, (PixelDocument) doc);
}
requestMessage(file);
}
});