Example usage for org.eclipse.jface.util Geometry toDisplay

List of usage examples for org.eclipse.jface.util Geometry toDisplay

Introduction

In this page you can find the example usage for org.eclipse.jface.util Geometry toDisplay.

Prototype

public static Rectangle toDisplay(Control coordinateSystem, Rectangle toConvert) 

Source Link

Document

Converts the given rectangle from the local coordinate system of the given object into display coordinates.

Usage

From source file:au.gov.ga.earthsci.jface.extras.information.AbstractInformationControlManager.java

License:Open Source License

/**
 * Computes the location of the information control depending on the
 * subject area and the size of the information control. This method attempts
 * to find a location at which the information control lies completely in the display's
 * client area while honoring the manager's default anchor. If this isn't possible using the
 * default anchor, the fallback anchors are tried out.
 *
 * @param subjectArea the information area
 * @param controlSize the size of the information control
 * @return the computed location of the information control
 *//*from w w  w . ja v  a 2 s .c  o m*/
protected Point computeInformationControlLocation(Rectangle subjectArea, Point controlSize) {
    Rectangle subjectAreaDisplayRelative = Geometry.toDisplay(fSubjectControl, subjectArea);

    Point upperLeft;
    Anchor testAnchor = fAnchor;
    Rectangle bestBounds = null;
    int bestArea = Integer.MIN_VALUE;
    Anchor bestAnchor = null;
    do {

        upperLeft = computeLocation(subjectArea, controlSize, testAnchor);
        Monitor monitor = getClosestMonitor(subjectAreaDisplayRelative, testAnchor);
        if (updateLocation(upperLeft, controlSize, monitor.getClientArea(), testAnchor))
            return upperLeft;

        // compute available area for this anchor and update if better than best
        Rectangle available = computeAvailableArea(subjectAreaDisplayRelative, monitor.getClientArea(),
                testAnchor);
        Rectangle proposed = new Rectangle(upperLeft.x, upperLeft.y, controlSize.x, controlSize.y);
        available.intersect(proposed);
        int area = available.width * available.height;
        if (area > bestArea) {
            bestArea = area;
            bestBounds = available;
            bestAnchor = testAnchor;
        }

        testAnchor = getNextFallbackAnchor(testAnchor);

    } while (testAnchor != fAnchor && testAnchor != null);

    // no anchor is perfect - select the one with larges area and set the size to not overlap with the subjectArea
    if (bestAnchor != ANCHOR_GLOBAL)
        Geometry.set(controlSize, Geometry.getSize(bestBounds));
    return Geometry.getLocation(bestBounds);
}

From source file:com.aptana.ide.core.ui.RectangleAnimation.java

License:Open Source License

public void addStartRect(Control ctrl) {
    Rectangle ctrlBounds = ctrl.getBounds();
    Rectangle startRect = Geometry.toDisplay(ctrl.getParent(), ctrlBounds);
    addStartRect(startRect);
}

From source file:com.aptana.ide.core.ui.RectangleAnimation.java

License:Open Source License

public void addEndRect(Control ctrl) {
    Rectangle ctrlBounds = ctrl.getBounds();
    Rectangle endRect = Geometry.toDisplay(ctrl.getParent(), ctrlBounds);
    addEndRect(endRect);
}

From source file:com.aptana.ide.intro.browser.CoreURL.java

License:Open Source License

private boolean switchToLaunchBar() {
    IIntroPart intro = PlatformUI.getWorkbench().getIntroManager().getIntro();
    if (intro == null) {
        return false;
    }/*  w  w  w.  j a  v  a 2  s .c  o m*/

    CustomizableIntroPart cpart = (CustomizableIntroPart) intro;
    IntroModelRoot modelRoot = IntroPlugin.getDefault().getIntroModelRoot();
    String pageId = modelRoot.getCurrentPageId();
    IntroTheme theme = modelRoot.getTheme();
    Rectangle bounds = cpart.getControl().getBounds();
    Rectangle startBounds = Geometry.toDisplay(cpart.getControl().getParent(), bounds);

    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IntroLaunchBarElement launchBarElement = modelRoot.getPresentation().getLaunchBarElement();
    if (launchBarElement == null) {
        return true;
    }
    IntroLaunchBar launchBar = new IntroLaunchBar(launchBarElement.getOrientation(), pageId, launchBarElement,
            theme);
    launchBar.createInActiveWindow();
    Rectangle endBounds = Geometry.toDisplay(launchBar.getControl().getParent(),
            launchBar.getControl().getBounds());

    RectangleAnimation animation = new RectangleAnimation(window.getShell(), startBounds, endBounds);
    animation.schedule();
    return true;
}

From source file:com.cisco.yangide.ext.refactoring.ui.RenameInformationPopup.java

License:Open Source License

private void updateVisibility() {
    if (fPopup != null && !fPopup.isDisposed() && fDelayJobFinished) {
        boolean visible = false;
        // TODO: Check for visibility of linked position, not whether popup is outside of
        // editor?
        if (renameLinkedMode.isCaretInLinkedPosition()) {
            StyledText textWidget = editor.getViewer().getTextWidget();
            Rectangle eArea = Geometry.toDisplay(textWidget, textWidget.getClientArea());
            Rectangle pBounds = fPopup.getBounds();
            pBounds.x -= GAP;/*from w  ww . j  a va2s. c  om*/
            pBounds.y -= GAP;
            pBounds.width += 2 * GAP;
            pBounds.height += 2 * GAP;
            if (eArea.intersects(pBounds)) {
                visible = true;
            }
        }
        if (visible && !fPopup.isVisible()) {
            ISourceViewer viewer = editor.getViewer();
            if (viewer instanceof IWidgetTokenOwnerExtension) {
                IWidgetTokenOwnerExtension widgetTokenOwnerExtension = (IWidgetTokenOwnerExtension) viewer;
                widgetTokenOwnerExtension.requestWidgetToken(this, WIDGET_PRIORITY);
            }
        } else if (!visible && fPopup.isVisible()) {
            releaseWidgetToken();
        }
        fPopup.setVisible(visible);
    }
}

From source file:com.google.dart.tools.ui.internal.refactoring.reorg.RenameInformationPopup.java

License:Open Source License

private void updateVisibility() {
    if (fPopup != null && !fPopup.isDisposed() && fDelayJobFinished) {
        boolean visible = false;
        //TODO: Check for visibility of linked position, not whether popup is outside of editor?
        if (fRenameLinkedMode.isCaretInLinkedPosition()) {
            StyledText textWidget = fEditor.getViewer().getTextWidget();
            Rectangle eArea = Geometry.toDisplay(textWidget, textWidget.getClientArea());
            Rectangle pBounds = fPopup.getBounds();
            pBounds.x -= GAP;/*w ww . j a  v a2 s.co m*/
            pBounds.y -= GAP;
            pBounds.width += 2 * GAP;
            pBounds.height += 2 * GAP;
            if (eArea.intersects(pBounds)) {
                visible = true;
            }
        }
        if (visible && !fPopup.isVisible()) {
            ISourceViewer viewer = fEditor.getViewer();
            if (viewer instanceof IWidgetTokenOwnerExtension) {
                IWidgetTokenOwnerExtension widgetTokenOwnerExtension = (IWidgetTokenOwnerExtension) viewer;
                widgetTokenOwnerExtension.requestWidgetToken(this, WIDGET_PRIORITY);
            }
        } else if (!visible && fPopup.isVisible()) {
            releaseWidgetToken();
        }
        fPopup.setVisible(visible);
    }
}

From source file:com.redhat.ceylon.eclipse.code.refactor.RefactorInformationPopup.java

License:Open Source License

private void updateVisibility() {
    if (fPopup != null && !fPopup.isDisposed() && fDelayJobFinished) {
        boolean visible = false;
        //TODO: Check for visibility of linked position, not whether popup is outside of editor?
        if (fLinkedMode.isCaretInLinkedPosition()) {
            StyledText textWidget = fEditor.getCeylonSourceViewer().getTextWidget();
            Rectangle eArea = Geometry.toDisplay(textWidget, textWidget.getClientArea());
            Rectangle pBounds = fPopup.getBounds();
            pBounds.x -= GAP;//from w  ww  . j a  v a 2s  . c  o  m
            pBounds.y -= GAP;
            pBounds.width += 2 * GAP;
            pBounds.height += 2 * GAP;
            if (eArea.intersects(pBounds)) {
                visible = true;
            }
        }
        if (visible && !fPopup.isVisible()) {
            /*ISourceViewer viewer= fEditor.getCeylonSourceViewer();
            if (viewer instanceof IWidgetTokenOwnerExtension) {
            IWidgetTokenOwnerExtension widgetTokenOwnerExtension= (IWidgetTokenOwnerExtension) viewer;
            visible= widgetTokenOwnerExtension.requestWidgetToken(this, WIDGET_PRIORITY);
            }*/
            visible = true;
        } else if (!visible && fPopup.isVisible()) {
            releaseWidgetToken();
        }
        fPopup.setVisible(visible);
    }
}

From source file:eu.jucy.gui.representation.ProxyControl.java

License:Open Source License

/**
 * Moves the target control on top of the dummy control.
 *//*from  w  w  w .j  a  va 2  s.  c o m*/
public void layout() {
    if (getTargetControl() == null) {
        return;
    }

    // Compute the unclipped bounds of the target in display coordinates
    Rectangle displayBounds = Geometry.toDisplay(control.getParent(), control.getBounds());

    // Clip the bounds of the target so that it doesn't go outside the dummy control's parent
    Rectangle clippingRegion = DragUtil.getDisplayBounds(control.getParent());
    displayBounds = displayBounds.intersection(clippingRegion);

    // Compute the bounds of the target, in the local coordinate system of its parent
    Rectangle targetBounds = Geometry.toControl(getTargetControl().getParent(), displayBounds);

    // Move the target
    getTargetControl().setBounds(targetBounds);
}

From source file:org.dafoe.application.presentations.MyDefaultTabFolder.java

License:Open Source License

public Rectangle getTabArea() {
    return Geometry.toDisplay(paneFolder.getControl(), paneFolder.getTitleArea());
}

From source file:org.eclipse.e4.ui.workbench.addons.dndaddon.DragAndDropUtil.java

License:Open Source License

/**
 * Shorthand method. Returns the bounding rectangle for the given control,
 * in display coordinates./*  ww w.  ja  va  2 s  . com*/
 *
 * @param boundsControl
 *            the control whose bounds are to be computed
 * @return the bounds of the given control in display coordinates
 */
public static Rectangle getDisplayBounds(Control boundsControl) {
    Control parent = boundsControl.getParent();
    if (parent == null || boundsControl instanceof Shell) {
        return boundsControl.getBounds();
    }

    return Geometry.toDisplay(parent, boundsControl.getBounds());
}