List of usage examples for org.eclipse.jface.util Geometry centerPoint
public static Point centerPoint(Rectangle rect)
From source file:au.gov.ga.earthsci.eclipse.extras.ide.ChooseWorkspaceDialog.java
License:Open Source License
protected Point getInitialLocation(Point initialSize) { Composite parent = getShell().getParent(); if (!centerOnMonitor || parent == null) { return super.getInitialLocation(initialSize); }//from ww w. j a v a2s. com Monitor monitor = parent.getMonitor(); Rectangle monitorBounds = monitor.getClientArea(); Point centerPoint = Geometry.centerPoint(monitorBounds); return new Point(centerPoint.x - (initialSize.x / 2), Math.max(monitorBounds.y, Math.min(centerPoint.y - (initialSize.y * 2 / 3), monitorBounds.y + monitorBounds.height - initialSize.y))); }
From source file:au.gov.ga.earthsci.jface.extras.information.AbstractInformationControlManager.java
License:Open Source License
/** * Gets the closest monitor given an anchor and the subject area. * * @param area the subject area//from www. j a va 2s.c o m * @param anchor the anchor * @return the monitor closest to the edge of <code>area</code> defined by * <code>anchor</code> * @since 3.3 */ private Monitor getClosestMonitor(Rectangle area, Anchor anchor) { Point center; if (ANCHOR_GLOBAL == anchor) center = Geometry.centerPoint(area); else center = Geometry.centerPoint(Geometry.getExtrudedEdge(area, 0, anchor.getSWTFlag())); return getClosestMonitor(fSubjectControl.getDisplay(), Geometry.createRectangle(center, new Point(0, 0))); }
From source file:au.gov.ga.earthsci.jface.extras.information.AbstractInformationControlManager.java
License:Open Source License
/** * Copied from org.eclipse.jface.window.Window. Returns the monitor whose client area contains * the given point. If no monitor contains the point, returns the monitor that is closest to the * point. If this is ever made public, it should be moved into a separate utility class. * * @param display the display to search for monitors * @param rectangle the rectangle to find the closest monitor for (display coordinates) * @return the monitor closest to the given point * @since 3.3/*from w w w.j a v a2 s .co m*/ */ private Monitor getClosestMonitor(Display display, Rectangle rectangle) { int closest = Integer.MAX_VALUE; Point toFind = Geometry.centerPoint(rectangle); Monitor[] monitors = display.getMonitors(); Monitor result = monitors[0]; for (int idx = 0; idx < monitors.length; idx++) { Monitor current = monitors[idx]; Rectangle clientArea = current.getClientArea(); if (clientArea.contains(toFind)) { return current; } int distance = Geometry.distanceSquared(Geometry.centerPoint(clientArea), toFind); if (distance < closest) { closest = distance; result = current; } } return result; }
From source file:com.aptana.ide.snippets.SnippetDialog.java
License:Open Source License
/** * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite) *//* www. ja v a 2 s. co m*/ @Override protected Control createContents(Composite parent) { // save reference to snippet variables this._variables = snippet.getVariables(); // create window Shell shell = getShell(); int width = 230; int height = 240; shell.setText(snippet.getName()); Point centerPoint = null; Rectangle bounds = parent.getBounds(); Monitor monitor = parent.getMonitor(); Rectangle monitorBounds = monitor.getClientArea(); centerPoint = Geometry.centerPoint(bounds); centerPoint = new Point(centerPoint.x - (width / 2), Math.max(monitorBounds.y, Math.min(centerPoint.y - (height * 2 / 3), monitorBounds.y + monitorBounds.height - height))); shell.setBounds(centerPoint.x, centerPoint.y, width, height); shell.setMinimumSize(width, height); // create window's layout GridLayout windowLayout = new GridLayout(); windowLayout.numColumns = 1; windowLayout.marginHeight = 5; windowLayout.marginWidth = 5; shell.setLayout(windowLayout); // create contents this.createContents(shell); shell.pack(true); return super.createContents(parent); }
From source file:com.arc.intro.NewWorkspaceDialog.java
License:Open Source License
@Override protected Point getInitialLocation(Point initialSize) { Composite parent = getShell().getParent(); if (!centerOnMonitor || parent == null) return super.getInitialLocation(initialSize); Monitor monitor = parent.getMonitor(); Rectangle monitorBounds = monitor.getClientArea(); Point centerPoint = Geometry.centerPoint(monitorBounds); return new Point(centerPoint.x - (initialSize.x / 2), Math.max(monitorBounds.y, Math.min(centerPoint.y - (initialSize.y * 2 / 3), monitorBounds.y + monitorBounds.height - initialSize.y))); }
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 a va2 s .co 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:com.buglabs.bug.dragonfly.uitests.DndUtil.java
License:Open Source License
/** * Calculates a position which can be used to drop something <em>onto</em> * the given widget by a DND operation. For tree structures, this will most * likely result in another child node being added. But how this is handled * in detail ultimately depends on the "drop action"'s implementation. * /* w ww . j a va 2 s . c o m*/ * @param targetItem * On which to drop * @param <T> * . * @return The {@code targetItem}'s center * @see #dragAndDrop(Point) * @see DND#FEEDBACK_SELECT */ public static <T extends Widget> Point on(final AbstractSWTBot<T> targetItem) { return Geometry.centerPoint(absoluteLocation(targetItem)); }
From source file:com.buglabs.bug.dragonfly.uitests.DndUtil.java
License:Open Source License
private static Point pointOnLowerBorder(Rectangle rect) { return new Point(Geometry.centerPoint(rect).x, rect.y + rect.height - 1); }
From source file:com.buglabs.bug.dragonfly.uitests.DndUtil.java
License:Open Source License
private static Point pointOnUpperBorder(Rectangle rect) { return new Point(Geometry.centerPoint(rect).x, rect.y + 1); }
From source file:com.ebmwebsourcing.petals.tests.common.DndUtil.java
License:Open Source License
public void dragAndDrop(final AbstractSWTBot<? extends Widget> toDrag, SWTBotGefEditPart rootEditPart) { dragAndDrop(toDrag, Geometry.centerPoint(absoluteLocation(rootEditPart))); }