Package swingtree.api

Interface AnimatedItemStyler<T,C extends JComponent>

Type Parameters:
T - the type of the item of the bound property, supplied to this function as the first argument.
C - the type of the JComponent that the ComponentStyleDelegate is 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.

@FunctionalInterface public interface AnimatedItemStyler<T,C extends JComponent>
An AnimatedItemStyler is conceptually a union of the ItemStyler and AnimatedStyler functions, which is to say that it takes the current item of a bound Val property, an AnimationStatus and a ComponentStyleDelegate to produce a new ComponentStyleDelegate with some style properties applied to it (usually based on both the item and the animation progress).
All parameters are immutable value oriented objects, so the function is pure and does not modify any of them.

This interface is used by UIForAnySwing.withStyle(sprouts.Val, swingtree.animation.LifeTime, AnimatedItemStyler), where every change of the bound property item restarts a transition animation whose AnimationStatus.progress() runs from 0 to 1 over the given LifeTime. This allows a style to not only follow the application state, but to animate towards it.
Like the ItemStyler, this function receives the property item as an explicit argument, captured from the property change event on the property's owning thread, which is what makes it safe to evaluate on the UI thread in the decoupled threading mode (see EventProcessor.DECOUPLED). Never read the property itself inside this function!

When a single AnimatedItemStyler should follow several properties at once, merge them into one record with the composite view builder Viewable.of(Object, java.util.function.Function) (requires Sprouts 2.7.0 or above) and bind that one merged property, so that any of its inputs changing restarts the transition towards the newly merged item.

See Also: