Class BasicTextAnimation
- java.lang.Object
-
- com.jgoodies.animation.AbstractAnimation
-
- com.jgoodies.animation.swing.animations.BasicTextAnimation
-
- All Implemented Interfaces:
Animation
public final class BasicTextAnimation extends AbstractAnimation
A basic text animation that fades in a text, changes the x and y scaling, the position, and the space between glyphs.- Version:
- $Revision: 1.7 $
- See Also:
Animation
,BasicTextLabel
,AnimationFunction
,AnimationFunctions
-
-
Field Summary
Fields Modifier and Type Field Description private AnimationFunction<java.awt.Color>
colorFunction
private BasicTextLabel
label
private boolean
offsetEnabled
private AnimationFunction<java.lang.Integer>
offsetFunction
private AnimationFunction<java.lang.Float>
scaleXFunction
private AnimationFunction<java.lang.Float>
scaleYFunction
private AnimationFunction<java.lang.Float>
spaceFunction
private java.lang.String
text
-
Constructor Summary
Constructors Constructor Description BasicTextAnimation(BasicTextLabel label, long duration, java.lang.String text, AnimationFunction<java.awt.Color> colorFunction, AnimationFunction<java.lang.Float> scaleXFunction, AnimationFunction<java.lang.Float> scaleYFunction, AnimationFunction<java.lang.Float> spaceFunction)
Constructs a text animation that fades in a text, scales it and fades it out.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
applyEffect(long time)
Applies the effect: sets color, spacing, scaling and offset, the latter only if enabled.static AnimationFunction<java.awt.Color>
cinemaFadeColorFunction(long duration, java.awt.Color baseColor)
Creates and returns the color animation function for the default fade.static BasicTextAnimation
defaultFade(BasicTextLabel label, long duration, java.lang.String text, java.awt.Color baseColor)
Creates and returns an animation for a text fade-in and -out.static AnimationFunction<java.awt.Color>
defaultFadeColorFunction(long duration, java.awt.Color baseColor)
Creates and returns the color animation function for the default fade.static AnimationFunction<java.lang.Integer>
defaultOffsetFunction()
Returns the animation function for the default random position offset.static BasicTextAnimation
defaultScale(BasicTextLabel label, long duration, java.lang.String text, java.awt.Color baseColor)
Creates and answers an animation, that provides a text fade-in and -out and scales the text while fading out.static AnimationFunction<java.awt.Color>
defaultScaleColorFunction(long duration, java.awt.Color baseColor)
Creates and returns the animation function for the default scaling.static AnimationFunction<java.lang.Float>
defaultScaleFunction(long duration)
Creates and returns the default scaling animation function.static BasicTextAnimation
defaultSpace(BasicTextLabel label, long duration, java.lang.String text, java.awt.Color baseColor)
Creates and answers an animation, that provides a text fade-in and -out and increases the glyph spacing.static AnimationFunction<java.awt.Color>
defaultSpaceColorFunction(long duration, java.awt.Color baseColor)
Creates and answers the color animation function for the default spacing animation.static AnimationFunction<java.lang.Float>
defaultSpaceFunction(long duration)
Creates and returns the default spacing animation function.boolean
isOffsetEnabled()
Answers whether the random position offset is enabled.void
setOffsetEnabled(boolean b)
Enables or disables the random position offset.-
Methods inherited from class com.jgoodies.animation.AbstractAnimation
addAnimationListener, animate, duration, fireAnimationStarted, fireAnimationStopped, isFreezed, removeAnimationListener, toString
-
-
-
-
Field Detail
-
label
private final BasicTextLabel label
-
text
private final java.lang.String text
-
colorFunction
private final AnimationFunction<java.awt.Color> colorFunction
-
offsetFunction
private final AnimationFunction<java.lang.Integer> offsetFunction
-
scaleXFunction
private final AnimationFunction<java.lang.Float> scaleXFunction
-
scaleYFunction
private final AnimationFunction<java.lang.Float> scaleYFunction
-
spaceFunction
private final AnimationFunction<java.lang.Float> spaceFunction
-
offsetEnabled
private boolean offsetEnabled
-
-
Constructor Detail
-
BasicTextAnimation
public BasicTextAnimation(BasicTextLabel label, long duration, java.lang.String text, AnimationFunction<java.awt.Color> colorFunction, AnimationFunction<java.lang.Float> scaleXFunction, AnimationFunction<java.lang.Float> scaleYFunction, AnimationFunction<java.lang.Float> spaceFunction)
Constructs a text animation that fades in a text, scales it and fades it out. Uses the given color and scaling functions.- Parameters:
label
- the animation target componentduration
- the animation durationtext
- the text to fade incolorFunction
- the animation function for the colorscaleXFunction
- the animation function for the horizontal scalescaleYFunction
- the animation function for the vertical scalespaceFunction
- the animation function for the glyph space
-
-
Method Detail
-
defaultFade
public static BasicTextAnimation defaultFade(BasicTextLabel label, long duration, java.lang.String text, java.awt.Color baseColor)
Creates and returns an animation for a text fade-in and -out.- Parameters:
label
- the animation target componentduration
- the animation durationtext
- the text to fade inbaseColor
- the base color for the fade effect- Returns:
- an animation with a default text fade
-
defaultScale
public static BasicTextAnimation defaultScale(BasicTextLabel label, long duration, java.lang.String text, java.awt.Color baseColor)
Creates and answers an animation, that provides a text fade-in and -out and scales the text while fading out.- Parameters:
label
- the animation target componentduration
- the animation durationtext
- the text to fade inbaseColor
- the base color for the fade effect- Returns:
- an animation with a default scaling text effect
-
defaultSpace
public static BasicTextAnimation defaultSpace(BasicTextLabel label, long duration, java.lang.String text, java.awt.Color baseColor)
Creates and answers an animation, that provides a text fade-in and -out and increases the glyph spacing.- Parameters:
label
- the animation target componentduration
- the animation durationtext
- the text to fade inbaseColor
- the base color for the fade effect- Returns:
- an animation with a default glyph spacing effect
-
defaultFadeColorFunction
public static AnimationFunction<java.awt.Color> defaultFadeColorFunction(long duration, java.awt.Color baseColor)
Creates and returns the color animation function for the default fade.- Parameters:
duration
- the animation durationbaseColor
- the base color for the fade effect- Returns:
- a Color-valued animation function for the default fade
-
cinemaFadeColorFunction
public static AnimationFunction<java.awt.Color> cinemaFadeColorFunction(long duration, java.awt.Color baseColor)
Creates and returns the color animation function for the default fade.- Parameters:
duration
- the animation durationbaseColor
- the base color for the fade effect- Returns:
- a Color-valued animation function for the default fade
-
defaultScaleColorFunction
public static AnimationFunction<java.awt.Color> defaultScaleColorFunction(long duration, java.awt.Color baseColor)
Creates and returns the animation function for the default scaling.- Parameters:
duration
- the animation durationbaseColor
- the base color for the fade effect- Returns:
- a Color-valued animation function for the default scaling
-
defaultSpaceColorFunction
public static AnimationFunction<java.awt.Color> defaultSpaceColorFunction(long duration, java.awt.Color baseColor)
Creates and answers the color animation function for the default spacing animation.- Parameters:
duration
- the animation durationbaseColor
- the base color for the fade effect- Returns:
- a Color-valued animation function for the default spacing
-
defaultOffsetFunction
public static AnimationFunction<java.lang.Integer> defaultOffsetFunction()
Returns the animation function for the default random position offset.- Returns:
- an animation function for a default random offset
-
defaultScaleFunction
public static AnimationFunction<java.lang.Float> defaultScaleFunction(long duration)
Creates and returns the default scaling animation function.- Parameters:
duration
- the animation duration- Returns:
- an animation function for the default scaling effect
-
defaultSpaceFunction
public static AnimationFunction<java.lang.Float> defaultSpaceFunction(long duration)
Creates and returns the default spacing animation function.- Parameters:
duration
- the animation duration- Returns:
- an animation function for the default spacing effect
-
applyEffect
protected void applyEffect(long time)
Applies the effect: sets color, spacing, scaling and offset, the latter only if enabled.- Specified by:
applyEffect
in classAbstractAnimation
- Parameters:
time
- the render time
-
isOffsetEnabled
public boolean isOffsetEnabled()
Answers whether the random position offset is enabled.- Returns:
- true indicates offset enabled, false disabled
-
setOffsetEnabled
public void setOffsetEnabled(boolean b)
Enables or disables the random position offset.- Parameters:
b
- the new enablement
-
-