Search in sources :

Example 1 with ExportPlotSizeEditor

use of org.rstudio.studio.client.workbench.exportplot.ExportPlotSizeEditor 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)

Example 2 with ExportPlotSizeEditor

use of org.rstudio.studio.client.workbench.exportplot.ExportPlotSizeEditor in project rstudio by rstudio.

the class CopyPlotToClipboardDesktopMetafileDialog method copyAsMetafile.

private void copyAsMetafile(final Operation onCompleted) {
    ExportPlotSizeEditor sizeEditor = getSizeEditor();
    clipboard_.copyPlotToClipboardMetafile(sizeEditor.getImageWidth(), sizeEditor.getImageHeight(), new Command() {

        @Override
        public void execute() {
            onCompleted.execute();
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) ExportPlotSizeEditor(org.rstudio.studio.client.workbench.exportplot.ExportPlotSizeEditor)

Aggregations

Command (com.google.gwt.user.client.Command)2 ExportPlotSizeEditor (org.rstudio.studio.client.workbench.exportplot.ExportPlotSizeEditor)2 Document (com.google.gwt.dom.client.Document)1 NodeList (com.google.gwt.dom.client.NodeList)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