Enum Class UI.Axis
- All Implemented Interfaces:
Serializable,Comparable<UI.Axis>,Constable,UIEnum<UI.Axis>
- Enclosing class:
UI
JSlider, JProgressBar, JSeparator,
JSplitPane or JToolBar runs along, and the axis a
BoxLayout stacks its children on.
Two of the four constants say which way a thing runs outright:
HORIZONTAL and VERTICAL. The other two say it by way of the
reading direction of the container: LINE is the way a line of text runs
and PAGE is the way lines follow each other down a page. A
BoxLayout is the only place in SwingTree where that detour changes the
outcome, so every other component asks resolve() and reads LINE
as HORIZONTAL and PAGE as VERTICAL. That way a view
model which models its axis as LINE can feed a slider and a box layout
from one property.
Create a box layout for your components by calling the
UIForAnySwing.withBoxLayout(swingtree.UI.Axis) method, or use the
Layout.box(swingtree.UI.Axis) factory method returning a Layout config
object which can be passed to the style API (see UIForAnySwing.withStyle(Styler)
and ComponentStyleDelegate.layout(Layout)).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionSpecifies that something runs from left to right.Specifies that something runs in the direction of a line of text, as determined by the target container'sComponentOrientation.Specifies that something runs in the direction that lines follow each other down a page, as determined by the target container'sComponentOrientation.Specifies that something runs from top to bottom. -
Method Summary
Modifier and TypeMethodDescriptionintConverts this axis into the constant aBoxLayoutexpects.booleanTells whether this axis runs from side to side rather than from top to bottom.Returns the axis at a right angle to this one, so that code holding one axis in a variable can name the other without spelling out both constants.resolve()Reduces this axis to the one ofHORIZONTALorVERTICALit selects, which is what aJSlideror aJSeparatorneeds, because neither of them has a reading direction to honour.static UI.AxisReturns the enum constant of this class with the specified name.static UI.Axis[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
HORIZONTAL
Specifies that something runs from left to right. -
VERTICAL
Specifies that something runs from top to bottom. -
LINE
Specifies that something runs in the direction of a line of text, as determined by the target container'sComponentOrientation. That direction is always the horizontal one:ComponentOrientationis a final class offering three constants,LEFT_TO_RIGHT,RIGHT_TO_LEFTandUNKNOWN, and all three reportComponentOrientation.isHorizontal()astrue. Soresolve()answersHORIZONTALhere, and aBoxLayoutis the one place which still tells the two apart: givenLINEit places the children from right to left when the container reads right to left. -
PAGE
Specifies that something runs in the direction that lines follow each other down a page, as determined by the target container'sComponentOrientation. Every one of the three orientations runs its lines of text horizontally, which leaves its pages running vertically, soresolve()answersVERTICALhere. ABoxLayoutis the one place which still tells the two apart: givenPAGEit mirrors the horizontal alignment of the stacked children when the container reads right to left.
-
-
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
-
resolve
Reduces this axis to the one ofHORIZONTALorVERTICALit selects, which is what aJSlideror aJSeparatorneeds, because neither of them has a reading direction to honour.No orientation has to be passed in to do this:
ComponentOrientationis a final class offering three constants, and all three run their lines of text horizontally, soLINEis a horizontal axis under every one of them.- Returns:
HORIZONTALforHORIZONTALandLINE,VERTICALforVERTICALandPAGE.
-
isHorizontal
public boolean isHorizontal()Tells whether this axis runs from side to side rather than from top to bottom.- Returns:
- True for
HORIZONTALandLINE, false forVERTICALandPAGE.
-
perpendicular
Returns the axis at a right angle to this one, so that code holding one axis in a variable can name the other without spelling out both constants. AJSplitPanelaid out alongHORIZONTALputs its two components side by side, which makes the divider between them a vertical bar.- Returns:
VERTICALforHORIZONTALandLINE,HORIZONTALforVERTICALandPAGE.
-
forBoxLayout
public int forBoxLayout()Converts this axis into the constant aBoxLayoutexpects. A box layout is the one place which still tellsLINEandPAGEapart fromHORIZONTALandVERTICAL, so this method keeps all four apart rather than resolving them the wayresolve()does.- Returns:
BoxLayout.X_AXISforHORIZONTAL,BoxLayout.Y_AXISforVERTICAL,BoxLayout.LINE_AXISforLINEandBoxLayout.PAGE_AXISforPAGE.
-