Enum Class Align
- All Implemented Interfaces:
Serializable,Comparable<Align>,Constable
The enum
Align defines a range of horizontal alignments.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionCenter alignment with a portion value of 0.5.Center-left alignment with a portion value of 0.25.Center-right alignment with a portion value of 0.75.Left alignment with a portion value of 0.0.Right alignment with a portion value of 1.0. -
Method Summary
Modifier and TypeMethodDescriptionstatic AlignGets the align enumeration value for the specified string.doublegetLocation(double width, double objectWidth) Gets the location for the specified object width to be horizontally aligned relatively to the bounds of the specified width.
Suitable for entity alignment.doublegetLocation(double width, double objectWidth, boolean preventOverflow) Gets the location for the specified object width to be horizontally aligned relatively to the bounds of the specified width.floatGets the portion value of the alignment.doublegetValue(double width) Gets the proportional value of this instance.floatgetValue(float width) Gets the proportional value of this instance.intgetValue(int width) Gets the proportional value of this instance.static AlignReturns the enum constant of this class with the specified name.static Align[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
CENTER
Center alignment with a portion value of 0.5. -
LEFT
Left alignment with a portion value of 0.0. -
RIGHT
Right alignment with a portion value of 1.0. -
CENTER_LEFT
Center-left alignment with a portion value of 0.25. -
CENTER_RIGHT
Center-right alignment with a portion value of 0.75.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
get
-
getValue
public float getValue(float width) Gets the proportional value of this instance.- Parameters:
width- The width to calculate the relative value from.- Returns:
- The proportional value for the specified height.
-
getValue
public double getValue(double width) Gets the proportional value of this instance.- Parameters:
width- The width to calculate the relative value from.- Returns:
- The proportional value for the specified height.
-
getValue
public int getValue(int width) Gets the proportional value of this instance.- Parameters:
width- The width to calculate the relative value from.- Returns:
- The proportional value for the specified height.
-
getLocation
public double getLocation(double width, double objectWidth) Gets the location for the specified object width to be horizontally aligned relatively to the bounds of the specified width.
Suitable for entity alignment. The return value might be negative or exceed the right boundary which iswidth-objectWidth.
For text alignmentgetLocation(double, double, boolean)should be used withpreventOverflowset totrue.- Parameters:
width- The width, limiting the horizontal alignment.objectWidth- The width of the object for which to calculate the horizontally aligned location.- Returns:
- The x-coordinate for the location of the object with the specified width.
-
getLocation
public double getLocation(double width, double objectWidth, boolean preventOverflow) Gets the location for the specified object width to be horizontally aligned relatively to the bounds of the specified width. An overflow behavior (wheneverobjectWidth>width) can be controlled usingpreventOverflowparameter:- false: the return value might be negative or exceed the right boundary which is
width-objectWidth(good for entity alignment). - true: the return value will always be clamped within the bounds (good for text alignment).
- Parameters:
width- The width, limiting the horizontal alignment.objectWidth- The width of the object for which to calculate the horizontally aligned location.preventOverflow- A flag indicating whether the return value should be clamped to keep it within the bounds (prevent values that are negative or beyond the right boundary).- Returns:
- The x-coordinate for the location of the object with the specified width.
- false: the return value might be negative or exceed the right boundary which is
-
getPortion
public float getPortion()Gets the portion value of the alignment.- Returns:
- The portion value of the alignment.
-