use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.
the class AceEditor method toScreenCoordinates.
public Rectangle toScreenCoordinates(Range range) {
Renderer renderer = widget_.getEditor().getRenderer();
ScreenCoordinates start = renderer.textToScreenCoordinates(range.getStart().getRow(), range.getStart().getColumn());
ScreenCoordinates end = renderer.textToScreenCoordinates(range.getEnd().getRow(), range.getEnd().getColumn());
return new Rectangle(start.getPageX(), start.getPageY(), end.getPageX() - start.getPageX(), renderer.getLineHeight());
}
use of org.rstudio.core.client.Rectangle 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();
}
});
}
});
}
use of org.rstudio.core.client.Rectangle in project rstudio by rstudio.
the class SpellingDialog method setEditorSelectionBounds.
@Override
public void setEditorSelectionBounds(Rectangle selectionBounds) {
// Inflate the bounds by 10 pixels to add a little air
boundsToAvoid_ = selectionBounds.inflate(10);
if (isShowing()) {
Rectangle screen = new Rectangle(0, 0, Window.getClientWidth(), Window.getClientHeight());
Rectangle bounds = new Rectangle(getPopupLeft(), getPopupTop(), getOffsetWidth(), getOffsetHeight());
// In case user moved the dialog off the screen
bounds = bounds.attemptToMoveInto(screen, FailureMode.NO_CHANGE);
// Now avoid the selected word
move(bounds.avoidBounds(boundsToAvoid_, screen), true);
}
}
Aggregations