use of org.rstudio.core.client.dom.ElementEx in project rstudio by rstudio.
the class PlotsPanePreviewer method getPreviewClientRect.
public Rectangle getPreviewClientRect() {
WindowEx win = imageFrame_.getElement().<IFrameElementEx>cast().getContentWindow();
Document doc = win.getDocument();
NodeList<Element> images = doc.getElementsByTagName("img");
if (images.getLength() > 0) {
ElementEx img = images.getItem(0).cast();
return new Rectangle(img.getClientLeft(), img.getClientTop(), img.getClientWidth(), img.getClientHeight());
} else {
return new Rectangle(0, 0, 0, 0);
}
}
use of org.rstudio.core.client.dom.ElementEx in project rstudio by rstudio.
the class DesktopExport method export.
public static void export(final ExportPlotSizeEditor sizeEditor, final OperationWithInput<Rectangle> exporter, final Operation onCompleted) {
sizeEditor.prepareForExport(new Command() {
@Override
public void execute() {
// hide gripper
sizeEditor.setGripperVisible(false);
// get zoom level
double zoomLevel = BrowseCap.isMacintoshDesktop() ? getSafariZoomFactor() : Desktop.getFrame().getZoomLevel();
// get the preview iframe rect
ElementEx iframe = sizeEditor.getPreviewIFrame().<ElementEx>cast();
final Rectangle viewerRect = new Rectangle((int) Math.ceil(zoomLevel * iframe.getClientLeft()), (int) Math.ceil(zoomLevel * iframe.getClientTop()), (int) Math.ceil(zoomLevel * iframe.getClientWidth()), (int) Math.ceil(zoomLevel * iframe.getClientHeight())).inflate(-1);
// perform the export
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
exporter.execute(viewerRect);
// show gripper
sizeEditor.setGripperVisible(true);
// call onCompleted
if (onCompleted != null)
onCompleted.execute();
}
});
}
});
}
Aggregations