Package swingtree
Enum Class UI.Span
- All Implemented Interfaces:
Serializable,Comparable<UI.Span>,Constable,UIEnum<UI.Span>
- Enclosing class:
UI
Names the direction a gradient travels across a component. The four straight spans
run from the middle of one side to the middle of the facing side, and the four
diagonal ones run from one corner to the facing corner. The first color of the
gradient sits at
from() and the last one at to(), which are
points of the component named by UI.Placement.
Pass one to GradientConf.span(swingtree.UI.Span) while configuring a
gradient through ComponentStyleDelegate.gradient(Configurator) or
ComponentStyleDelegate.gradient(swingtree.UI.Layer, String, Configurator),
as part of the style API (see UIForAnySwing.withStyle(Styler)).
reversed() returns the span running the other way, isDiagonal()
tells the corner to corner spans from the side to side ones, and axis()
names the axis a side to side span travels along.
- 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 ConstantDescriptionDiagonally from the bottom left corner up to the top right corner.Diagonally from the bottom right corner up to the top left corner.Straight up, from the middle of the bottom edge to the middle of the top edge.Straight across, from the middle of the left edge to the middle of the right edge.Straight across, from the middle of the right edge to the middle of the left edge.Diagonally from the top left corner down to the bottom right corner.Diagonally from the top right corner down to the bottom left corner.Straight down, from the middle of the top edge to the middle of the bottom edge. -
Method Summary
Modifier and TypeMethodDescriptionaxis()Returns the axis this span travels along.from()Returns the point of the component this span starts at, which is where the first color handed toGradientConf.colors(java.awt.Color...)sits.booleanTells whether this span runs from a corner to a corner rather than from the middle of one side to the middle of another.reversed()Returns the span running the other way, so that a gradient held in a variable can be turned around without naming the constant it turns into.to()Returns the point of the component this span ends at, which is where the last color handed toGradientConf.colors(java.awt.Color...)sits.static UI.SpanReturns the enum constant of this class with the specified name.static UI.Span[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
TOP_LEFT_TO_BOTTOM_RIGHT
Diagonally from the top left corner down to the bottom right corner. -
BOTTOM_LEFT_TO_TOP_RIGHT
Diagonally from the bottom left corner up to the top right corner. -
TOP_RIGHT_TO_BOTTOM_LEFT
Diagonally from the top right corner down to the bottom left corner. -
BOTTOM_RIGHT_TO_TOP_LEFT
Diagonally from the bottom right corner up to the top left corner. -
TOP_TO_BOTTOM
Straight down, from the middle of the top edge to the middle of the bottom edge. -
LEFT_TO_RIGHT
Straight across, from the middle of the left edge to the middle of the right edge. -
BOTTOM_TO_TOP
Straight up, from the middle of the bottom edge to the middle of the top edge. -
RIGHT_TO_LEFT
Straight across, from the middle of the right edge to the middle of the left edge.
-
-
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
-
from
Returns the point of the component this span starts at, which is where the first color handed toGradientConf.colors(java.awt.Color...)sits.- Returns:
- The starting point: a corner for a diagonal span, and the middle of a side for a straight one.
-
to
Returns the point of the component this span ends at, which is where the last color handed toGradientConf.colors(java.awt.Color...)sits.- Returns:
- The ending point, which is always
UI.Placement.opposite()of whatfrom()returns.
-
reversed
Returns the span running the other way, so that a gradient held in a variable can be turned around without naming the constant it turns into. Reversing a span paints the same picture as keeping it and handingGradientConf.colors(java.awt.Color...)its colors in the reverse order. -
axis
Returns the axis this span travels along. A diagonal span travels along both axes at once, so it names neither, and answers with an emptyOptionalrather than picking one of the two.- Returns:
UI.Axis.HORIZONTALforLEFT_TO_RIGHTandRIGHT_TO_LEFT,UI.Axis.VERTICALforTOP_TO_BOTTOMandBOTTOM_TO_TOP, and an emptyOptionalfor the four corner to corner spans.
-
isDiagonal
public boolean isDiagonal()Tells whether this span runs from a corner to a corner rather than from the middle of one side to the middle of another.- Returns:
truefor the four corner to corner spans,falsefor the four side to side ones.
-