com.jgoodies.animation.components

Class AnimatedLabel


public final class AnimatedLabel
extends JPanel

An anti-aliased text label that can animate text changes using a blend over effect.

Note: This is preview code that is not supported. It is more raw than other classes that you have downloaded from JGoodies.com in the past and contains known bugs.

Version:
$Revision: 1.1 $
Author:
Karsten Lentzsch

Field Summary

static int
CENTER
static Color
DEFAULT_BASE_COLOR
static int
DEFAULT_FONT_EXTRA_SIZE
static int
LEFT
static String
PROPERTYNAME_ANIMATED
static String
PROPERTYNAME_DURATION
static String
PROPERTYNAME_FOREGROUND
static String
PROPERTYNAME_TEXT
static int
RIGHT

Constructor Summary

AnimatedLabel()
Constructs an AnimatedLabel with default base color, default font extra size, and an empty text.
AnimatedLabel(Color baseColor, int fontExtraSize, String text)
Constructs an AnimatedLabel with the given initial text using a left oriented label.
AnimatedLabel(Color baseColor, int fontExtraSize, String text, int orientation)
Constructs an AnimatedLabel with the given initial text and orientation.
AnimatedLabel(Color baseColor, int fontExtraSize, String text, int orientation, int duration, int frames_per_second)
Constructs an AnimatedLabel with the given properties.

Method Summary

long
getDuration()
Returns the duration of the blend over animation.
Color
getForeground()
Returns the label's foreground base color.
String
getText()
Returns the text of the foreground label.
boolean
isAnimated()
Answers whether the animation is currently enabled.
void
setAnimated(boolean animated)
Enables or disables the blend over effect.
void
setDuration(long newDuration)
Sets the animation's duration and invalidates the animation cache.
void
setForeground(Color newForeground)
Sets a new foreground base color.
void
setText(String newText)
Sets a new text.
void
setTextImmediately(String newText)
Sets a new text without using the blend over animation.

Field Details

CENTER

public static final int CENTER

DEFAULT_BASE_COLOR

public static final Color DEFAULT_BASE_COLOR

DEFAULT_FONT_EXTRA_SIZE

public static final int DEFAULT_FONT_EXTRA_SIZE
Field Value:
8

LEFT

public static final int LEFT

PROPERTYNAME_ANIMATED

public static final String PROPERTYNAME_ANIMATED

PROPERTYNAME_DURATION

public static final String PROPERTYNAME_DURATION

PROPERTYNAME_FOREGROUND

public static final String PROPERTYNAME_FOREGROUND

PROPERTYNAME_TEXT

public static final String PROPERTYNAME_TEXT

RIGHT

public static final int RIGHT

Constructor Details

AnimatedLabel

public AnimatedLabel()
Constructs an AnimatedLabel with default base color, default font extra size, and an empty text.

AnimatedLabel

public AnimatedLabel(Color baseColor,
                     int fontExtraSize,
                     String text)
Constructs an AnimatedLabel with the given initial text using a left oriented label.
Parameters:
baseColor - the color used as a basis for the text color
fontExtraSize - pixels that are added to the dialog font size
text - the initial text to be displayed

AnimatedLabel

public AnimatedLabel(Color baseColor,
                     int fontExtraSize,
                     String text,
                     int orientation)
Constructs an AnimatedLabel with the given initial text and orientation.
Parameters:
baseColor - the color used as a basis for the text color
fontExtraSize - pixels that are added to the dialog font size
text - the initial text to be displayed
orientation - the label's orientation

AnimatedLabel

public AnimatedLabel(Color baseColor,
                     int fontExtraSize,
                     String text,
                     int orientation,
                     int duration,
                     int frames_per_second)
Constructs an AnimatedLabel with the given properties.
Parameters:
baseColor - the color used as a basis for the text color
fontExtraSize - pixels that are added to the dialog font size
text - the initial text to be displayed
orientation - the label's orientation
duration - the duration of the blend over animation
frames_per_second - the blend over animation's frame rate

Method Details

getDuration

public long getDuration()
Returns the duration of the blend over animation.
Returns:
the duration of the blend over animaton

getForeground

public Color getForeground()
Returns the label's foreground base color.
Returns:
this label's foreground base color

getText

public String getText()
Returns the text of the foreground label.
Returns:
the text of the foreground label

isAnimated

public boolean isAnimated()
Answers whether the animation is currently enabled.
Returns:
true if the animation is enabled, false if disabled

setAnimated

public void setAnimated(boolean animated)
Enables or disables the blend over effect. This can be useful in environments with a poor rendering performance or if the user disables all kinds of animations. You can still use this class but enable and disable the animations.
Parameters:
animated - true to enable the blend over effect, false to disable it

setDuration

public void setDuration(long newDuration)
Sets the animation's duration and invalidates the animation cache.
Parameters:
newDuration - the duration to be set

setForeground

public void setForeground(Color newForeground)
Sets a new foreground base color.
Parameters:
newForeground - the color to be set as new foreground base color

setText

public void setText(String newText)
Sets a new text. If the animation is disabled the text will be set immediately otherwise a blend over animation is used.
Parameters:
newText - the new text to be displayed

setTextImmediately

public void setTextImmediately(String newText)
Sets a new text without using the blend over animation.
Parameters:
newText - the text to be set

Copyright © 2001-2006 JGoodies Karsten Lentzsch. All Rights Reserved.