Package swingtree.api
Interface AnimatedStyler<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.
An
Note that both paramters are immutable value oriented objects, so the function is pure and does not modify 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
AnimatedStyler is conceptually a union of the Animation
and Styler functions, which is to say that it takes both an AnimationStatus and a
ComponentStyleDelegate to produce a new ComponentStyleDelegate
with some style properties applied to it (usually based on the AnimationStatus). Note that both paramters are immutable value oriented objects, so the function is pure and does not modify the original
ComponentStyleDelegate or AnimationStatus objects. 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).
This interface is typically used in AbstractDelegate.animateStyleFor(LifeTime, AnimatedStyler)
and AbstractDelegate.animateStyleFor(double, TimeUnit, AnimatedStyler).
-
Method Summary
Modifier and TypeMethodDescriptiondefault AnimatedStyler<C> andThen(AnimatedStyler<C> other) Returns a newAnimatedStylerthat applies the style of thisAnimatedStylerand then applies the style of the givenAnimatedStyler.static <C extends JComponent>
AnimatedStyler<C> none()AAnimatedStylerthat does nothing, meaning it simply returns the givenComponentStyleDelegatewithout applying any style to it.style(AnimationStatus status, ComponentStyleDelegate<C> delegate) Applies some style to the givenComponentStyleDelegateand returns a newComponentStyleDelegatethat has the style applied (if any).
-
Method Details
-
none
AAnimatedStylerthat does nothing, meaning it simply returns the givenComponentStyleDelegatewithout applying any style to it. Conceptually speaking, this returns the null object of theAnimatedStylertype.- Type Parameters:
C- The type of theJComponentthat theComponentStyleDelegateis delegating to.- Returns:
- A
AnimatedStylerthat does nothing.
-
style
ComponentStyleDelegate<C> style(AnimationStatus status, ComponentStyleDelegate<C> delegate) throws Exception 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:
status- TheAnimationStatuswhich is used to configure the style (usually based on theAnimationStatus.progress()).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 newAnimatedStylerthat applies the style of thisAnimatedStylerand then applies the style of the givenAnimatedStyler.
This method is conceptually equivalent to theFunction.andThen(java.util.function.Function).- Parameters:
other- theAnimatedStylerto apply after thisAnimatedStyler.- Returns:
- a new
AnimatedStylerthat applies the style of thisAnimatedStylerand then applies the style of the givenAnimatedStyler.
-