dsto.dfc.swt.util
Class Geometry

java.lang.Object
  extended by dsto.dfc.swt.util.Geometry

public final class Geometry
extends Object

Basic geometrical utilities for SWT.

Author:
mpp

Field Summary
static int BOTTOM
           
static int BOTTOM_LEFT
           
static int BOTTOM_RIGHT
           
static int CENTER
           
static int LEFT
           
static int MID_BOTTOM
           
static int MID_LEFT
           
static int MID_RIGHT
           
static int MID_TOP
           
static int RIGHT
           
static int TOP
           
static int TOP_LEFT
           
static int TOP_RIGHT
           
 
Method Summary
static org.eclipse.swt.graphics.Point bumpRectangle(org.eclipse.swt.graphics.Rectangle windowRect)
          Return a rectangle's position, adjusting so it does not go outside the screen.
static void bumpRectangle(org.eclipse.swt.graphics.Rectangle parentRect, org.eclipse.swt.graphics.Rectangle childRect)
          Ensure that childRect is in parentRect, and move it into it if not.
static boolean contains(org.eclipse.swt.graphics.Rectangle r1, org.eclipse.swt.graphics.Rectangle r2)
          Test if one rectangle fully contains another.
static int offsetForAlignment(int parentLength, int childLength, int alignment)
          Calculate offset from a parent length necessary to align a child length.
static org.eclipse.swt.graphics.Point offsetForAlignment(org.eclipse.swt.graphics.Point parentSize, org.eclipse.swt.graphics.Point childSize, int alignment)
          Calculate offset of a child region from a parent region necessary to align child region.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CENTER

public static final int CENTER
See Also:
Constant Field Values

LEFT

public static final int LEFT
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

TOP

public static final int TOP
See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
See Also:
Constant Field Values

TOP_LEFT

public static final int TOP_LEFT
See Also:
Constant Field Values

MID_TOP

public static final int MID_TOP
See Also:
Constant Field Values

TOP_RIGHT

public static final int TOP_RIGHT
See Also:
Constant Field Values

MID_RIGHT

public static final int MID_RIGHT
See Also:
Constant Field Values

BOTTOM_RIGHT

public static final int BOTTOM_RIGHT
See Also:
Constant Field Values

MID_BOTTOM

public static final int MID_BOTTOM
See Also:
Constant Field Values

BOTTOM_LEFT

public static final int BOTTOM_LEFT
See Also:
Constant Field Values

MID_LEFT

public static final int MID_LEFT
See Also:
Constant Field Values
Method Detail

offsetForAlignment

public static org.eclipse.swt.graphics.Point offsetForAlignment(org.eclipse.swt.graphics.Point parentSize,
                                                                org.eclipse.swt.graphics.Point childSize,
                                                                int alignment)
Calculate offset of a child region from a parent region necessary to align child region.

Parameters:
parentSize - Size of parent region.
childSize - Size of child region;
alignment - Alignment of child relative to parent.

offsetForAlignment

public static int offsetForAlignment(int parentLength,
                                     int childLength,
                                     int alignment)
Calculate offset from a parent length necessary to align a child length.

Parameters:
parentLength - Size of parent region.
childLength - Size of child region;
alignment - Alignment of child relative to parent. One of LEFT/TOP, CENTER or RIGHT/BOTTOM.

bumpRectangle

public static org.eclipse.swt.graphics.Point bumpRectangle(org.eclipse.swt.graphics.Rectangle windowRect)
Return a rectangle's position, adjusting so it does not go outside the screen.

Returns:
The new location.

bumpRectangle

public static void bumpRectangle(org.eclipse.swt.graphics.Rectangle parentRect,
                                 org.eclipse.swt.graphics.Rectangle childRect)
Ensure that childRect is in parentRect, and move it into it if not.


contains

public static boolean contains(org.eclipse.swt.graphics.Rectangle r1,
                               org.eclipse.swt.graphics.Rectangle r2)
Test if one rectangle fully contains another.

Returns:
True if r1 fully contains r2.


Copyright © 2008 Commonwealth of Australia