com.jgoodies.animation.components
Class AnimatedLabel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.jgoodies.animation.components.AnimatedLabel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

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
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
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
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
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.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROPERTYNAME_ANIMATED

public static final String PROPERTYNAME_ANIMATED
See Also:
Constant Field Values

PROPERTYNAME_DURATION

public static final String PROPERTYNAME_DURATION
See Also:
Constant Field Values

PROPERTYNAME_FOREGROUND

public static final String PROPERTYNAME_FOREGROUND
See Also:
Constant Field Values

PROPERTYNAME_TEXT

public static final String PROPERTYNAME_TEXT
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

CENTER

public static final int CENTER
See Also:
Constant Field Values

LEFT

public static final int LEFT
See Also:
Constant Field Values

DEFAULT_BASE_COLOR

public static final Color DEFAULT_BASE_COLOR

DEFAULT_FONT_EXTRA_SIZE

public static final int DEFAULT_FONT_EXTRA_SIZE
See Also:
Constant Field Values
Constructor Detail

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 Detail

isAnimated

public boolean isAnimated()
Answers whether the animation is currently enabled.

Returns:
true if the animation is enabled, false if disabled

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.

Overrides:
getForeground in class Component
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

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.

Overrides:
setForeground in class JComponent
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.