Package swingtree.api
Interface AnimatedStyler<C extends JComponent>
- Type Parameters:
C
- the type of theJComponent
that theComponentStyleDelegate
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.
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 AnimationState
and a
ComponentStyleDelegate
to produce a new ComponentStyleDelegate
with some style properties applied to it (usually based on the AnimationState
). Note that both paramters are immutable value oriented objects, so the function is pure and does not modify the original
ComponentStyleDelegate
or AnimationState
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 newAnimatedStyler
that applies the style of thisAnimatedStyler
and then applies the style of the givenAnimatedStyler
.static <C extends JComponent>
AnimatedStyler<C>none()
AAnimatedStyler
that does nothing, meaning it simply returns the givenComponentStyleDelegate
without applying any style to it.style
(AnimationState state, ComponentStyleDelegate<C> delegate) Applies some style to the givenComponentStyleDelegate
and returns a newComponentStyleDelegate
that has the style applied (if any).
-
Method Details
-
none
AAnimatedStyler
that does nothing, meaning it simply returns the givenComponentStyleDelegate
without applying any style to it. Conceptually speaking, this returns the null object of theAnimatedStyler
type.- Type Parameters:
C
- The type of theJComponent
that theComponentStyleDelegate
is delegating to.- Returns:
- A
AnimatedStyler
that does nothing.
-
style
Applies some style to the givenComponentStyleDelegate
and returns a newComponentStyleDelegate
that has the style applied (if any).- Parameters:
state
- TheAnimationState
which is used to configure the style (usually based on theAnimationState.progress
).delegate
- TheComponentStyleDelegate
to apply the style to.- Returns:
- A new
ComponentStyleDelegate
that has the style applied.
-
andThen
Returns a newAnimatedStyler
that applies the style of thisAnimatedStyler
and then applies the style of the givenAnimatedStyler
.
This method is conceptually equivalent to theFunction.andThen(java.util.function.Function)
.- Parameters:
other
- theAnimatedStyler
to apply after thisAnimatedStyler
.- Returns:
- a new
AnimatedStyler
that applies the style of thisAnimatedStyler
and then applies the style of the givenAnimatedStyler
.
-