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

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

Introduction

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

Prototype

public static Point add(Point point1, Point point2) 

Source Link

Document

Adds two points as 2d vectors.

Usage

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

License:Open Source License

/**
 * Opens the information control with the given information and the specified
 * subject area. It also activates the information control closer.
 *
 * @param subjectArea the information area
 * @param information the information//w  ww .j  a  va 2s  . co m
 */
public void showInformationControl(Rectangle subjectArea, Object information) {
    IInformationControl informationControl = getInformationControl();

    Rectangle controlBounds = fContentBounds;
    if (informationControl instanceof IInformationControlExtension3) {
        IInformationControlExtension3 iControl3 = (IInformationControlExtension3) informationControl;
        Rectangle trim = iControl3.computeTrim();
        controlBounds = Geometry.add(controlBounds, trim);

        /*
         * Ensure minimal size. Interacting with a tiny information control
         * (resizing, selecting text) would be a pain.
         */
        controlBounds.width = Math.max(controlBounds.width, MIN_WIDTH);
        controlBounds.height = Math.max(controlBounds.height, MIN_HEIGHT);

        getInternalAccessor().cropToClosestMonitor(controlBounds);
    }

    Point location = Geometry.getLocation(controlBounds);
    Point size = Geometry.getSize(controlBounds);

    // Caveat: some IInformationControls fail unless setSizeConstraints(..) is called with concrete values
    informationControl.setSizeConstraints(size.x, size.y);

    if (informationControl instanceof IInformationControlExtension2)
        ((IInformationControlExtension2) informationControl).setInput(information);
    else
        informationControl.setInformation(information.toString());

    informationControl.setLocation(location);
    informationControl.setSize(size.x, size.y);

    showInformationControl(subjectArea);
}

From source file:com.buglabs.bug.dragonfly.uitests.DndUtil.java

License:Open Source License

/**
 * Performs a DND operation to an arbitrary location. The drag start
 * location will be chosen depending on this widget's default
 * implementation.//  w  w w  . j av  a  2  s .c o  m
 * 
 * @param source
 *            the source widget to drag
 * @param target
 *            The target locations where the DND shall finish.
 * @see #before(AbstractSWTBot)
 * @see #on(AbstractSWTBot)
 * @see #after(AbstractSWTBot)
 */
public void dragAndDrop(final AbstractSWTBot<? extends Widget> source, final Point target) {
    final Rectangle sourceLocation = absoluteLocation(source);
    final Point slightOffset = Geometry.add(Geometry.getLocation(sourceLocation),
            new Point(DRAG_THRESHOLD, DRAG_THRESHOLD));
    doDragAndDrop(Geometry.min(Geometry.centerPoint(sourceLocation), slightOffset), target);
}

From source file:mbtarranger.editors.GenericInformationControl.java

License:Open Source License

public Rectangle computeTrim() {
    return Geometry.add(super.computeTrim()
    //, fText.computeTrim(0, 0, 0, 0));
            , fBrowser.computeTrim(0, 0, 0, 0));
}

From source file:net.openchrom.xxd.processor.supplier.rscripting.ui.editor.RDefaultInformationControl.java

License:Open Source License

public Rectangle computeTrim() {

    return Geometry.add(super.computeTrim(), fText.computeTrim(0, 0, 0, 0));
}

From source file:net.sf.eclipsensis.editor.codeassist.NSISInformationControl.java

License:Open Source License

public Rectangle computeTrim() {
    Rectangle trim = mShell.computeTrim(0, 0, 0, 0);

    if (mStatusComposite != null)
        trim.height += mStatusComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;

    return Geometry.add(trim, mText.computeTrim(0, 0, 0, 0));
}

From source file:org.eclipse.sirius.tests.swtbot.support.utils.dnd.DndUtil.java

License:Open Source License

/**
 * Performs a DND operation to an arbitrary location. The drag start
 * location will be chosen depending on this widget's default
 * implementation./*from  w  ww.  j a va 2s  .  c o m*/
 * 
 * @param source
 *            the source widget to drag
 * @param target
 *            The target locations where the DND shall finish.
 * @see #before(AbstractSWTBot)
 * @see #on(AbstractSWTBot)
 * @see #after(AbstractSWTBot)
 */
public void dragAndDrop(final AbstractSWTBot<? extends Widget> source, final Point target) {
    final Rectangle sourceLocation = DndUtil.absoluteLocation(source);
    final Point slightOffset = Geometry.add(Geometry.getLocation(sourceLocation),
            new Point(DndUtil.DRAG_THRESHOLD, DndUtil.DRAG_THRESHOLD));
    doDragAndDrop(Geometry.min(Geometry.centerPoint(sourceLocation), slightOffset), target);
}

From source file:org.eclipse.virgo.ide.ui.editors.text.JFaceDefaultInformationControl.java

License:Open Source License

@Override
public Rectangle computeTrim() {
    return Geometry.add(super.computeTrim(), this.fText.computeTrim(0, 0, 0, 0));
}

From source file:org.jboss.tools.ui.bot.ext.helper.DragAndDropHelper.java

License:Open Source License

public static void dnd(final TreeItem ti, final TreeItem ti2) {
    Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {

        public Rectangle run() {
            return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
        }//from  w w w  .j a v a  2  s.c  om
    });
    final Point slightOffset = Geometry.add(Geometry.getLocation(r1), new Point(10, 10));

    Rectangle r2 = UIThreadRunnable.syncExec(new Result<Rectangle>() {

        public Rectangle run() {
            return ti2.getDisplay().map(ti2.getParent(), null, ti2.getBounds());
        }
    });

    doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset), Geometry.centerPoint(r2));
}

From source file:org.jboss.tools.ui.bot.ext.helper.DragAndDropHelper.java

License:Open Source License

public static void dnd(final TreeItem ti, final FigureCanvas fc) {
    Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {

        public Rectangle run() {
            return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
        }/*from  w w  w  . j  a va2 s  .c o  m*/
    });
    final Point slightOffset = Geometry.add(Geometry.getLocation(r1), new Point(10, 10));

    Rectangle r2 = UIThreadRunnable.syncExec(new Result<Rectangle>() {

        public Rectangle run() {
            return fc.getDisplay().map(fc.getParent(), null, fc.getBounds());
        }
    });

    doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset), Geometry.centerPoint(r2));
}

From source file:org.jboss.tools.ui.bot.ext.helper.DragAndDropHelper.java

License:Open Source License

public static void dnd(final TreeItem ti, final Control fc, final int x, final int y) {
    Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {

        public Rectangle run() {
            return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
        }//from  w  w  w. j  ava 2  s . co  m
    });
    final Point slightOffset = Geometry.add(Geometry.getLocation(r1), new Point(10, 10));

    Point r2 = UIThreadRunnable.syncExec(new Result<Point>() {

        public Point run() {
            log.info("xxx: " + fc.getLocation().x + ":" + fc.getLocation().y);
            return fc.getDisplay().map(fc, null, x, y);
        }
    });

    doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset), r2);
}