Package swingtree

Enum Class UI.FitComponent

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

@Immutable public static enum UI.FitComponent extends Enum<UI.FitComponent> implements UIEnum<UI.FitComponent>
This enum is used to specify how an image or icon (usually a SvgIcon) should be scaled to fit the dimensions of the component that it is being rendered into, like for example through the SvgIcon.paintIcon(java.awt.Component, Graphics, int, int) method.
You may want to pass constants of this enum to ImageConf.fitMode(FitComponent) as part of using the style API:

  UI.button("Click Me!")
  .withStyle( conf -> conf
      .image( img -> img
          .image(SvgIcon.at("my/path/to.svg"))
          .fitMode(UI.FitComponent.MIN_DIM)
      )
      .border(12, UI.Color.LIGHTSTEELBLUE)
      .borderRadius(8)
  )
  
See Also:
  • Enum Constant Details

    • UNDEFINED

      public static final UI.FitComponent UNDEFINED
      How a particular image is supposed to fit a component is unknown and may be overridden by another policy or default behavior. Typically, this is equivalent to NO.
    • WIDTH

      public static final UI.FitComponent WIDTH
      Fit the image or icon to the width of a component by scaling the icon/image along the x-axis. This implies that you only want to scale the width of an image/icon, but not its height, so this constant may change the inherent aspect ratio of a targeted image/icon!
    • HEIGHT

      public static final UI.FitComponent HEIGHT
      Fit the image or icon to the height of a component by scaling the icon/image along the y-axis. This implies that you only want to scale the height of an image/icon, but not its width, so this constant may change the inherent aspect ratio of a targeted image/icon!
    • WIDTH_AND_HEIGHT

      public static final UI.FitComponent WIDTH_AND_HEIGHT
      Fit the image or icon to both fit the width and height of the component. Note that this may change the inherent aspect ratio of the image in favor of the components aspect ratio...
    • MAX_DIM

      public static final UI.FitComponent MAX_DIM
      Fit the image to the largest dimension of the component.
    • MIN_DIM

      public static final UI.FitComponent MIN_DIM
      Fit the image to the smallest dimension of the component, while preserving the aspect ratio of the image.
    • NO

      public static final UI.FitComponent NO
      Do not fit the image to the component, while preserving the aspect ratio of the image.
  • Method Details

    • values

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