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

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

Introduction

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

Prototype

public static Point divide(Point toDivide, int scalar) 

Source Link

Document

Divides both coordinates of the given point by the given scalar.

Usage

From source file:org.eclipse.ui.internal.DetachedWindow.java

License:Open Source License

public void create() {
    windowShell = ((WorkbenchWindow) page.getWorkbenchWindow()).getDetachedWindowPool()
            .allocateShell(shellListener);
    windowShell.setData(this);
    windowShell.setText(""); //$NON-NLS-1$
    DragUtil.addDragTarget(windowShell, this);
    hideViewsOnClose = true;/*from  www.jav a  2 s . c  o  m*/
    if (bounds.isEmpty()) {
        Point center = Geometry.centerPoint(page.getWorkbenchWindow().getShell().getBounds());
        Point size = new Point(300, 200);
        Point upperLeft = Geometry.subtract(center, Geometry.divide(size, 2));

        bounds = Geometry.createRectangle(upperLeft, size);
    }

    // Force the rect into the current display
    Rectangle dispBounds = getShell().getDisplay().getBounds();
    if (bounds.width > dispBounds.width)
        bounds.width = dispBounds.width;
    if (bounds.height > dispBounds.height)
        bounds.height = dispBounds.height;
    if (bounds.x + bounds.width > dispBounds.width)
        bounds.x = dispBounds.width - bounds.width;
    if (bounds.y + bounds.height > dispBounds.height)
        bounds.y = dispBounds.height - bounds.height;

    getShell().setBounds(bounds);

    configureShell(windowShell);

    createContents(windowShell);
    windowShell.layout(true);
    folder.setBounds(windowShell.getClientArea());
}