Search in sources :

Example 1 with DesktopFrame

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();
            }
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) ElementEx(org.rstudio.core.client.dom.ElementEx) NodeList(com.google.gwt.dom.client.NodeList) WindowEx(org.rstudio.core.client.dom.WindowEx) Document(com.google.gwt.dom.client.Document) DesktopFrame(org.rstudio.studio.client.application.DesktopFrame) ExportPlotSizeEditor(org.rstudio.studio.client.workbench.exportplot.ExportPlotSizeEditor)

Aggregations

Document (com.google.gwt.dom.client.Document)1 NodeList (com.google.gwt.dom.client.NodeList)1 Command (com.google.gwt.user.client.Command)1 ElementEx (org.rstudio.core.client.dom.ElementEx)1 WindowEx (org.rstudio.core.client.dom.WindowEx)1 DesktopFrame (org.rstudio.studio.client.application.DesktopFrame)1 ExportPlotSizeEditor (org.rstudio.studio.client.workbench.exportplot.ExportPlotSizeEditor)1