コード例 #1
0
ファイル: AboutDartDialog.java プロジェクト: swarupsahoo/dart
  protected Point getInitialLocation(Point initialSize) {
    Composite parent = getParent();

    Rectangle parentBounds = parent.getClientArea();
    Point centerPoint = Geometry.centerPoint(parent.getBounds());

    return new Point(
        centerPoint.x - (initialSize.x / 2),
        Math.max(
            parentBounds.y,
            Math.min(
                centerPoint.y - (initialSize.y * 2 / 3),
                parentBounds.y + parentBounds.height - initialSize.y)));
  }
コード例 #2
0
  public static Point getPoint(Rectangle bounds, int side) {
    Point centerPoint = Geometry.centerPoint(bounds);

    switch (side) {
      case SWT.TOP:
        return new Point(centerPoint.x, bounds.y + 1);
      case SWT.BOTTOM:
        return new Point(centerPoint.x, bounds.y + bounds.height - 1);
      case SWT.LEFT:
        return new Point(bounds.x + 1, centerPoint.y);
      case SWT.RIGHT:
        return new Point(bounds.x + bounds.width - 1, centerPoint.y);
    }

    return centerPoint;
  }