Package swingtree

Enum Class UI.ComponentArea

java.lang.Object
java.lang.Enum<UI.ComponentArea>
swingtree.UI.ComponentArea
All Implemented Interfaces:
Serializable, Comparable<UI.ComponentArea>, Constable, UIEnum<UI.ComponentArea>
Enclosing class:
UI

@Immutable public static enum UI.ComponentArea extends Enum<UI.ComponentArea> implements UIEnum<UI.ComponentArea>
Names a region of a styled component. A style lays a component out as three nested rings: the margin holds the outermost ring, the border width the next one, and what the border leaves over is the innermost region. This enum names those three, and two more which are unions of them.

Pass one to ImageConf.clipTo(swingtree.UI.ComponentArea) to clip an image to a region, to ComponentStyleDelegate.painter(Layer, ComponentArea, Painter) to confine your own painting to it, or to UIForAnySwing.onMouseEnter(ComponentArea, Action) to be told when the cursor reaches it, all as part of the style API (see UIForAnySwing.withStyle(Styler)).
The following list describes what each enum instance represents:

  • EXTERIOR - The ring the margin leaves around everything else.
  • BORDER - The ring the border width fills, between the exterior and the interior.
  • INTERIOR - Everything the border leaves over, which is ALL - EXTERIOR - BORDER.
  • BODY - The border and the interior together, which is ALL - EXTERIOR.
  • ALL - The whole component, which is EXTERIOR + BORDER + INTERIOR.
contains(ComponentArea) spells those unions out, and outerBoundary() names the UI.ComponentBoundary an area starts at.
See Also:
  • Enum Constant Details

  • Method Details

    • values

      public static UI.ComponentArea[] 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.ComponentArea 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
    • outerBoundary

      public UI.ComponentBoundary outerBoundary()
      Returns the boundary line this area starts at, coming from the outside in. ALL and EXTERIOR both start at the outer edge of the component, BORDER and BODY both start where the margin ends, and INTERIOR starts where the border ends.

      Two areas can share one boundary, so this is not the inverse of UI.ComponentBoundary.wrappedArea(): UI.ComponentBoundary.OUTER_TO_EXTERIOR is the answer for both ALL and EXTERIOR, and going back from it answers ALL. Only ALL, BODY and INTERIOR survive the round trip.

      Returns:
      The UI.ComponentBoundary that tightly wraps this area.
    • contains

      public boolean contains(UI.ComponentArea other)
      Tells whether this area covers every pixel the given area covers, which spells out the set algebra the constants of this enum are defined by: ALL covers all of them, BODY covers BORDER and INTERIOR, and the three remaining areas cover only themselves, because they do not overlap.
      Parameters:
      other - The area to test for being covered by this one.
      Returns:
      True if every pixel of other also belongs to this area.