Package swingtree
Enum Class 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
You may want to pass constants of this enum to
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionFit the image or icon to the height of a component by scaling the icon/image along the y-axis.Fit the image to the largest dimension of the component.Fit the image to the smallest dimension of the component, while preserving the aspect ratio of the image.Do not fit the image to the component, while preserving the aspect ratio of the image.How a particular image is supposed to fit a component is unknown and may be overridden by another policy or default behavior.Fit the image or icon to the width of a component by scaling the icon/image along the x-axis.Fit the image or icon to both fit the width and height of the component. -
Method Summary
Modifier and TypeMethodDescriptionstatic UI.FitComponentReturns the enum constant of this class with the specified name.static UI.FitComponent[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
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 toNO. -
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
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
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
Fit the image to the largest dimension of the component. -
MIN_DIM
Fit the image to the smallest dimension of the component, while preserving the aspect ratio of the image. -
NO
Do not fit the image to the component, while preserving the aspect ratio of the image.
-
-
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
-