public enum AnchorPosition extends java.lang.Enum<AnchorPosition>
Enum Constant and Description |
---|
CENTER |
CENTER_BOTTOM |
CENTER_TOP |
LEFT_BOTTOM |
LEFT_CENTER |
LEFT_TOP |
RIGHT_BOTTOM |
RIGHT_CENTER |
RIGHT_TOP |
Modifier and Type | Method and Description |
---|---|
static AnchorPosition |
combine(AnchorPosition horizontal,
AnchorPosition vertical)
Produces a new anchor position which takes the horizontal position from
horizontal and the vertical position from vertical . |
static float |
deltaX(float startX,
AnchorPosition startAnchor,
float newX,
AnchorPosition newAnchor,
float width)
Determines how much the coordinates move horizontally from a starting point to the ending point.
|
static float |
deltaY(float startY,
AnchorPosition startAnchor,
float newY,
AnchorPosition newAnchor,
float height)
Determines how much the coordinates move vertically from a starting point to the ending point.
|
float |
getBottom(float y,
float height)
Return the bottom-most point of a region with the given height where y is a point inside that region determined by this anchor.
|
float |
getLeft(float x,
float width)
Return the left-most point of a region with the given width where x is a point inside that region determined by this anchor.
|
float |
getXFromLeft(float left,
float width)
Computes an x value adjusted by this anchor, given a leftmost point and the width of the area.
|
float |
getXFromRight(float right,
float width)
Similar to
getXFromLeft(float, float) , except the range is inside [right - width, right] . |
float |
getYFromBottom(float bottom,
float height)
Computes a y value adjusted by this anchor, given a bottom point and the height of the area.
|
float |
getYFromTop(float top,
float height)
Similar to
getYFromBottom(float, float) , except the range is inside [top - height, top] . |
boolean |
isBottom()
Returns true if the anchor is vertically bottom.
|
boolean |
isCenterX()
Returns true if the anchor is horizontally centered.
|
boolean |
isCenterY()
Returns true if the anchor is vertically centered.
|
boolean |
isLeft()
Returns true if the anchor is horizontally left.
|
boolean |
isRight()
Returns true if the anchor is horizontally right.
|
boolean |
isTop()
Returns true if the anchor is vertically top.
|
AnchorPosition |
next()
DEBUG.
|
static AnchorPosition |
randomAnchor()
DEBUG.
|
static AnchorPosition |
randomAnchor(AnchorPosition previous)
DEBUG.
|
static AnchorPosition |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static AnchorPosition[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final AnchorPosition LEFT_TOP
public static final AnchorPosition CENTER_TOP
public static final AnchorPosition RIGHT_TOP
public static final AnchorPosition LEFT_CENTER
public static final AnchorPosition CENTER
public static final AnchorPosition RIGHT_CENTER
public static final AnchorPosition LEFT_BOTTOM
public static final AnchorPosition CENTER_BOTTOM
public static final AnchorPosition RIGHT_BOTTOM
public static AnchorPosition[] values()
for (AnchorPosition c : AnchorPosition.values()) System.out.println(c);
public static AnchorPosition valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic boolean isLeft()
LEFT_TOP
, LEFT_CENTER
, or LEFT_BOTTOM
public boolean isRight()
RIGHT_TOP
, RIGHT_CENTER
, or RIGHT_BOTTOM
public boolean isBottom()
LEFT_BOTTOM
, CENTER_BOTTOM
, or RIGHT_BOTTOM
public boolean isTop()
LEFT_TOP
, CENTER_TOP
, or RIGHT_TOP
public boolean isCenterX()
CENTER_TOP
, CENTER
, or CENTER_BOTTOM
public boolean isCenterY()
LEFT_CENTER
, CENTER
, or RIGHT_CENTER
public float getXFromLeft(float left, float width)
left
- leftmost point of the region to anchor intowidth
- width of the region to anchor into[left, left + width]
with the horizontal position determined by this anchorpublic float getXFromRight(float right, float width)
getXFromLeft(float, float)
, except the range is inside [right - width, right]
.right
- rightmost point of the region to anchor intowidth
- width of the region to anchor into[right - width, right]
with the horizontal position determined by this anchorgetXFromLeft(float, float)
public float getYFromBottom(float bottom, float height)
bottom
- lowest point of the region to anchor intoheight
- height of the region to anchor into[bottom, bottom + height]
with the vertical position determined by this anchorpublic float getYFromTop(float top, float height)
getYFromBottom(float, float)
, except the range is inside [top - height, top]
.top
- highest point of the region to anchor intoheight
- height of the region to anchor into[top - height, top]
with the vertical position determined by this anchorgetYFromBottom(float, float)
public float getLeft(float x, float width)
x
- a point placed inside the region according to this anchorwidth
- the width of the regionpublic float getBottom(float y, float height)
y
- a point placed inside the region according to this anchorheight
- the height of the regionpublic static float deltaX(float startX, AnchorPosition startAnchor, float newX, AnchorPosition newAnchor, float width)
newX - startX
). This lets you quickly find the horizontal delta between ALL points in the region, given any anchored point in the original position compared to any anchored point in the new position. This assumes the width of the region stays constant, and the move is a strict translation.startX
- a point placed inside the starting region with its local position determined by startAnchorstartAnchor
- the position of startX inside the starting region (is it on the left side of the region, the center, or the right)newX
- a point placed inside the ending region with its local position determined by newAnchornewAnchor
- the position of newX inside the ending region (is it on the left side of the region, the center, or the right)width
- the width of the region being translated (assumed constant)deltaY(float, AnchorPosition, float, AnchorPosition, float)
public static float deltaY(float startY, AnchorPosition startAnchor, float newY, AnchorPosition newAnchor, float height)
newY - startY
). This lets you quickly find the vertical delta between ALL points in the region, given any anchored point in the original position compared to any anchored point in the new position. This assumes the height of the region stays constant, and the move is a strict translation.startY
- a point placed inside the starting region with its local position determined by startAnchorstartAnchor
- the position of startY inside the starting region (is it on the bottom of the region, the center, or the top)newY
- a point placed inside the ending region with its local position determined by newAnchornewAnchor
- the position of newY inside the ending region (is it on the bottom of the region, the center, or the top)height
- the height of the region being translated (assumed constant)deltaX(float, AnchorPosition, float, AnchorPosition, float)
public static AnchorPosition combine(AnchorPosition horizontal, AnchorPosition vertical)
horizontal
and the vertical position from vertical
.horizontal
- determines if the output anchor is LEFT_
, CENTER_
, or RIGHT_
.vertical
- determines if the output anchor is _BOTTOM
, _CENTER
, or _TOP
.public static AnchorPosition randomAnchor()
randomAnchor(AnchorPosition)
public static AnchorPosition randomAnchor(AnchorPosition previous)
next()
instead, which will cycle through the enum and not have to loop.previous
- the anchor position to skip (can't be in the output)previous
next()
,
randomAnchor()
public AnchorPosition next()