Package swingtree

Enum Class UI.Span

All Implemented Interfaces:
Serializable, Comparable<UI.Span>, Constable, UIEnum<UI.Span>
Enclosing class:
UI

@Immutable public static enum UI.Span extends Enum<UI.Span> implements UIEnum<UI.Span>
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:
  • Enum Constant Details

    • TOP_LEFT_TO_BOTTOM_RIGHT

      public static final UI.Span TOP_LEFT_TO_BOTTOM_RIGHT
      Diagonally from the top left corner down to the bottom right corner.
    • BOTTOM_LEFT_TO_TOP_RIGHT

      public static final UI.Span BOTTOM_LEFT_TO_TOP_RIGHT
      Diagonally from the bottom left corner up to the top right corner.
    • TOP_RIGHT_TO_BOTTOM_LEFT

      public static final UI.Span TOP_RIGHT_TO_BOTTOM_LEFT
      Diagonally from the top right corner down to the bottom left corner.
    • BOTTOM_RIGHT_TO_TOP_LEFT

      public static final UI.Span BOTTOM_RIGHT_TO_TOP_LEFT
      Diagonally from the bottom right corner up to the top left corner.
    • TOP_TO_BOTTOM

      public static final UI.Span TOP_TO_BOTTOM
      Straight down, from the middle of the top edge to the middle of the bottom edge.
    • LEFT_TO_RIGHT

      public static final UI.Span LEFT_TO_RIGHT
      Straight across, from the middle of the left edge to the middle of the right edge.
    • BOTTOM_TO_TOP

      public static final UI.Span BOTTOM_TO_TOP
      Straight up, from the middle of the bottom edge to the middle of the top edge.
    • RIGHT_TO_LEFT

      public static final UI.Span RIGHT_TO_LEFT
      Straight across, from the middle of the right edge to the middle of the left edge.
  • Method Details

    • values

      public static UI.Span[] 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

      public static UI.Span valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • from

      public UI.Placement from()
      Returns the point of the component this span starts at, which is where the first color handed to GradientConf.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

      public UI.Placement to()
      Returns the point of the component this span ends at, which is where the last color handed to GradientConf.colors(java.awt.Color...) sits.
      Returns:
      The ending point, which is always UI.Placement.opposite() of what from() returns.
    • reversed

      public UI.Span 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 handing GradientConf.colors(java.awt.Color...) its colors in the reverse order.
      Returns:
      The span whose from() is this span's to().
    • axis

      public Optional<UI.Axis> 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 empty Optional rather than picking one of the two.
      Returns:
      UI.Axis.HORIZONTAL for LEFT_TO_RIGHT and RIGHT_TO_LEFT, UI.Axis.VERTICAL for TOP_TO_BOTTOM and BOTTOM_TO_TOP, and an empty Optional for 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:
      true for the four corner to corner spans, false for the four side to side ones.