List of usage examples for org.eclipse.jface.util Geometry getSize
public static Point getSize(Rectangle rectangle)
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 ww . ja v a2 s . com 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:au.gov.ga.earthsci.jface.extras.information.AbstractInformationControlManager.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//from w w w . j a v a 2 s .c o m */ private void internalShowInformationControl(Rectangle subjectArea, Object information) { if (this instanceof InformationControlReplacer) { ((InformationControlReplacer) this).showInformationControl(subjectArea, information); return; } IInformationControl informationControl = getInformationControl(); if (informationControl != null) { Point sizeConstraints = computeSizeConstraints(fSubjectControl, fSubjectArea, informationControl); if (informationControl instanceof IInformationControlExtension3) { IInformationControlExtension3 iControl3 = (IInformationControlExtension3) informationControl; Rectangle trim = iControl3.computeTrim(); sizeConstraints.x += trim.width; sizeConstraints.y += trim.height; } informationControl.setSizeConstraints(sizeConstraints.x, sizeConstraints.y); if (informationControl instanceof IInformationControlExtension2) ((IInformationControlExtension2) informationControl).setInput(information); else informationControl.setInformation(information.toString()); if (informationControl instanceof IInformationControlExtension) { IInformationControlExtension extension = (IInformationControlExtension) informationControl; if (!extension.hasContents()) return; } Point size = null; Point location = null; Rectangle bounds = restoreInformationControlBounds(); if (bounds != null) { if (bounds.x > -1 && bounds.y > -1) location = Geometry.getLocation(bounds); if (bounds.width > -1 && bounds.height > -1) size = Geometry.getSize(bounds); } if (size == null) size = informationControl.computeSizeHint(); if (fEnforceAsMinimalSize) size = Geometry.max(size, sizeConstraints); if (fEnforceAsMaximalSize) size = Geometry.min(size, sizeConstraints); if (location == null) location = computeInformationControlLocation(subjectArea, size); Rectangle controlBounds = Geometry.createRectangle(location, size); cropToClosestMonitor(controlBounds); location = Geometry.getLocation(controlBounds); size = Geometry.getSize(controlBounds); informationControl.setLocation(location); informationControl.setSize(size.x, size.y); showInformationControl(subjectArea); } }
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 w w. ja v a2 s. c o 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.microsoft.tfs.client.common.ui.framework.validation.ErrorLabel.java
License:Open Source License
@Override public Point computeSize(final int wHint, final int hHint, final boolean changed) { if (computedSize == null) { final Rectangle r = errorImage.getBounds().union(warningImage.getBounds()); computedSize = Geometry.getSize(r); }/* www .j ava 2 s .c o m*/ return computedSize; }
From source file:org.eclipse.ui.internal.presentations.NativeStackPresentation.java
License:Open Source License
public Point computeMinimumSize() { return Geometry.getSize(tabFolder.computeTrim(0, 0, 0, 0)); }
From source file:org.eclipse.ui.internal.presentations.PaneFolder.java
License:Open Source License
public Point computeMinimumSize() { Point result = Geometry.getSize(tabFolder.computeTrim(0, 0, 0, 0)); // Add some space for the minimize and maximize buttons plus a tab. // Right now this isn't exposed from SWT as API, so we just add 50 // pixels.//from w w w.ja v a 2s . c o m result.x += 100; return result; }
From source file:org.eclipse.ui.internal.presentations.R21BasicStackPresentation.java
License:Open Source License
public Point computeMinimumSize() { Point result = Geometry.getSize(paneFolder.computeTrim(0, 0, 0, 0)); result.x += 100; return result; }
From source file:org.eclipse.ui.tests.performance.layout.TestWidgetFactory.java
License:Open Source License
public Point getMaxSize() throws CoreException, WorkbenchException { Composite control = getControl(); Composite parent = control.getParent(); if (parent == null) { return new Point(800, 600); }/*from w w w.j av a2 s. c om*/ return Geometry.getSize(parent.getClientArea()); }
From source file:org.jboss.tools.common.text.ext.hyperlink.xpl.InformationPresenter.java
License:Open Source License
private IInformationControl showInformation_internal(boolean test) { IInformationControl iControl = getInformationControl(); Point sizeConstraints = computeSizeConstraints(viwer.getTextWidget(), null, iControl); iControl.setSizeConstraints(sizeConstraints.x, sizeConstraints.y); Point size = null;//from w w w . j a v a 2s . c om Rectangle bounds = restoreInformationControlBounds(); if (bounds != null) { if (bounds.width > -1 && bounds.height > -1) size = Geometry.getSize(bounds); } if (size == null) size = iControl.computeSizeHint(); size = Geometry.max(size, sizeConstraints); iControl.setSize(size.x, size.y); if (test) { ((HierarchyInformationControl) iControl).setBlockOnOpen(false); } iControl.setVisible(true); return iControl; }
From source file:org.pentaho.di.ui.core.gui.WindowProperty.java
License:Apache License
/** * @param constrainee/*from w w w . j a va 2s.c om*/ * @param container */ private void constrainRectangleToContainer(Rectangle constrainee, Rectangle container) { Point originalSize = Geometry.getSize(constrainee); Point containerSize = Geometry.getSize(container); Point oversize = Geometry.subtract(originalSize, containerSize); if (oversize.x > 0) { constrainee.width = originalSize.x - oversize.x; } if (oversize.y > 0) { constrainee.height = originalSize.y - oversize.y; } // Detect if the dialog was positioned outside the container Geometry.moveInside(constrainee, container); }