public class Alignment extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BOTTOM
Constant for positioning on the bottom.
|
static int |
HCENTER
Constant for centering horizontally.
|
static int |
LEFT
Constant for positioning on the left.
|
static int |
RIGHT
Constant for positioning on the right.
|
static int |
TOP
Constant for positioning on the top.
|
static int |
VCENTER
Constant for centering vertically.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
checkHorizontalAlignment(int horizontalAlignment)
Checks whether the given value represents a valid horizontal alignment.
|
static boolean |
checkVerticalAlignment(int verticalAlignment)
Checks whether the given value represents a valid vertical alignment.
|
static int |
computeLeftX(int width,
int anchorX,
int horizontalAlignment)
Computes the x coordinate of the left edge of an object aligned on an anchor point.
|
static int |
computeLeftX(int width,
int areaX,
int areaWidth,
int horizontalAlignment)
Computes the x coordinate of the left edge of an object aligned in an area.
|
static int |
computeTopY(int height,
int anchorY,
int verticalAlignment)
Computes the y coordinate of the top edge of an object aligned on an anchor point.
|
static int |
computeTopY(int height,
int areaY,
int areaHeight,
int verticalAlignment)
Computes the y coordinate of the top edge of an object aligned in an area.
|
static void |
validateHorizontalAlignment(int horizontalAlignment)
Validates that the given value represents a valid horizontal alignment.
|
static void |
validateVerticalAlignment(int verticalAlignment)
Validates that the given value represents a valid vertical alignment.
|
public static final int BOTTOM
public static final int HCENTER
public static final int LEFT
public static final int RIGHT
public static final int TOP
public static final int VCENTER
public static boolean checkHorizontalAlignment(int horizontalAlignment)
A value represents a valid horizontal alignment if it is equal to either LEFT
, HCENTER
or
RIGHT
.
horizontalAlignment
- the horizontal alignment to check.true
if the given horizontal alignment is valid, false
otherwise.public static boolean checkVerticalAlignment(int verticalAlignment)
A value represents a valid vertical alignment if it is equal to either TOP
, VCENTER
or
BOTTOM
.
verticalAlignment
- the vertical alignment to check.true
if the given vertical alignment is valid, false
otherwise.public static int computeLeftX(int width, int anchorX, int horizontalAlignment)
If the horizontal alignment is invalid, the object is aligned on the left.
width
- the object width.anchorX
- the anchor x coordinate.horizontalAlignment
- the horizontal alignment.public static int computeLeftX(int width, int areaX, int areaWidth, int horizontalAlignment)
If the horizontal alignment is invalid or not set, the object is aligned on the left.
width
- the object width.areaX
- the area x coordinate.areaWidth
- the area width.horizontalAlignment
- the horizontal alignment.checkHorizontalAlignment(int)
public static int computeTopY(int height, int anchorY, int verticalAlignment)
If the vertical alignment is invalid, the object is aligned on the top.
height
- the object height.anchorY
- the anchor y coordinate.verticalAlignment
- the vertical alignment.public static int computeTopY(int height, int areaY, int areaHeight, int verticalAlignment)
If the vertical alignment is invalid or not set, the object is aligned on the top.
height
- the object height.areaY
- the area y coordinate.areaHeight
- the area height.verticalAlignment
- the vertical alignment.checkVerticalAlignment(int)
public static void validateHorizontalAlignment(int horizontalAlignment)
This method is equivalent to checkHorizontalAlignment(int)
except that it throws an exception rather
than return a boolean.
horizontalAlignment
- the horizontal alignment to check.IllegalArgumentException
- if the given horizontal alignment is not valid.public static void validateVerticalAlignment(int verticalAlignment)
This method is equivalent to checkVerticalAlignment(int)
except that it throws an exception rather than
return a boolean.
verticalAlignment
- the vertical alignment to check.IllegalArgumentException
- if the given vertical alignment is not valid.