Package swingtree.api
Interface Styler<C extends JComponent>
- Type Parameters:
C- the type of theJComponentthat theComponentStyleDelegateis delegating to.
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A
Note that all of this is done in a functional manner, so the original
This design makes the underlying style engine of SwingTree very flexible and scalable because it allows for the composition of styles and reuse of style logic across many components (see
Styler is a function that takes a ComponentStyleDelegate and then
transforms and returns it with some new style properties (see UIForAnySwing.withStyle(Styler)). Note that all of this is done in a functional manner, so the original
ComponentStyleDelegate
as well as the delegated StyleConf object is not modified
because ComponentStyleDelegate is an immutable object. This design makes the underlying style engine of SwingTree very flexible and scalable because it allows for the composition of styles and reuse of style logic across many components (see
StyleSheet for more advanced usage).-
Method Summary
Modifier and TypeMethodDescriptionstatic <C extends JComponent>
Styler<C> none()AStylerthat does nothing, meaning it simply returns the givenComponentStyleDelegatewithout applying any style to it.style(ComponentStyleDelegate<C> delegate) Applies some style to the givenComponentStyleDelegateand returns a newComponentStyleDelegatethat has the style applied (if any).
-
Method Details
-
none
AStylerthat does nothing, meaning it simply returns the givenComponentStyleDelegatewithout applying any style to it.- Type Parameters:
C- The type of theJComponentthat theComponentStyleDelegateis delegating to.- Returns:
- A
Stylerthat does nothing.
-
style
Applies some style to the givenComponentStyleDelegateand returns a newComponentStyleDelegatethat has the style applied (if any).
Note that this method deliberately requires the handling of checked exceptions at its invocation sites because there may be any number of implementations hiding behind this interface and so it is unwise to assume that all of them will be able to execute gracefully without throwing exceptions.- Parameters:
delegate- TheComponentStyleDelegateto apply the style to.- Returns:
- A new
ComponentStyleDelegatethat has the style applied. - Throws:
Exception- if the style could not be applied by the client code.
-
andThen
Returns a newStylerthat applies the style of thisStylerand then applies the style of the givenStyler.
This method is conceptually equivalent to theFunction.andThen(java.util.function.Function).
-