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 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 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
(AnimationStatus status, 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
ComponentStyleDelegate<C> style(AnimationStatus status, ComponentStyleDelegate<C> delegate) throws Exception Applies some style to the givenComponentStyleDelegate
and returns a newComponentStyleDelegate
that 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
- TheAnimationStatus
which is used to configure the style (usually based on theAnimationStatus.progress()
).delegate
- TheComponentStyleDelegate
to apply the style to.- Returns:
- A new
ComponentStyleDelegate
that has the style applied. - Throws:
Exception
-
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
.
-