use of org.rstudio.studio.client.application.DesktopFrame in project rstudio by rstudio.
the class CopyPlotToClipboardDesktopDialog method copyAsBitmap.
protected void copyAsBitmap(final Operation onCompleted) {
final ExportPlotSizeEditor sizeEditor = getSizeEditor();
sizeEditor.prepareForExport(new Command() {
@Override
public void execute() {
if (BrowseCap.isCocoaDesktop()) {
clipboard_.copyPlotToCocoaPasteboard(sizeEditor.getImageWidth(), sizeEditor.getImageHeight(), new Command() {
@Override
public void execute() {
onCompleted.execute();
}
});
} else {
WindowEx win = sizeEditor.getPreviewIFrame().getContentWindow();
Document doc = win.getDocument();
NodeList<Element> images = doc.getElementsByTagName("img");
if (images.getLength() > 0) {
ElementEx img = images.getItem(0).cast();
DesktopFrame frame = Desktop.getFrame();
frame.copyImageToClipboard(img.getClientLeft(), img.getClientTop(), img.getClientWidth(), img.getClientHeight());
}
onCompleted.execute();
}
}
});
}
Aggregations