org.formaria.swing
Class AnimatedText

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.formaria.swing.animation.AnimationSurface
                  extended by org.formaria.swing.FlowedTextComponent
                      extended by org.formaria.swing.AnimatedText
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, javax.swing.SwingConstants, TextHolder

public class AnimatedText
extends FlowedTextComponent
implements javax.swing.SwingConstants

A fade in animation of text. The text is faded in from the background color to the foreground color.

Copyright (c) Formaria Ltd., 2008, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from Formaria.

$Revision: 1.17 $

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.formaria.swing.FlowedTextComponent
FlowedTextComponent.Attrib
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class org.formaria.swing.FlowedTextComponent
ascent, attributedStrings, clip, cols, colSpacing, currentColumn, deltaX, deltaY, flowArea, oH, oW, oX, oY
 
Fields inherited from class org.formaria.swing.animation.AnimationSurface
animationContext, animator, antiAlias, autoStart, bimg, composite, currentProject, finished, imageType, increment, label, loopTime, oldH, oldW, position, rendering, sleepTime, startTime, texture, timingFraction
 
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 javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AnimatedText()
          Create a new AnimatedText instance
 
Method Summary
 void applyState(java.awt.Graphics2D g2)
          Apply the current state to the graphics rendering context
 int getAlignment()
          Get the text alignment
 java.lang.String getContent()
          Get the text content
 int getIncrement()
          Get the update increment
 void init()
          Initialize the animation surface and prepare the starting point/setup
 boolean isAnimated(Animator at)
          Should the object be animated in this step?
 boolean isFinished(Animator at)
          Are there more steps to come?
 void reset(int w, int h)
          Adjust the settings for the next step.
 void setAlignment(int align)
          Sets the text alignment.
 void setContent(java.lang.String content)
          Set the text content for the component.
 void setIncrement(int incr)
          Sets the update increment.
 void step(int w, int h)
          Adjust the settings for the next step.
 void timingEvent(float fraction)
          This method will receive all of the timing events from an Animator during an animation.
 void useStyle(int newStyle)
          Specifies a new style for the control.
 
Methods inherited from class org.formaria.swing.FlowedTextComponent
drawObjects, getAttributedString, getClip, getColSpacing, getNumColumns, getText, setClip, setCols, setColSpacing, setNumColumns, setText, wrapString
 
Methods inherited from class org.formaria.swing.animation.AnimationSurface
autoStart, begin, createBufferedImage, createGraphics2D, end, getAnimator, getAntiAlias, getAutoStart, getComposite, getImageType, getLoopTime, getRendering, getSleepTime, isStarted, paintComponent, print, quoteReplacement, render, repeat, replace, reset, setAnimator, setAntiAlias, setAutoStart, setComposite, setImageType, setLoopTime, setRendering, setSleepTime, setTexture, start, stop
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
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, transferFocusBackward, 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, getForeground, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AnimatedText

public AnimatedText()
Create a new AnimatedText instance

Method Detail

init

public void init()
Initialize the animation surface and prepare the starting point/setup

Overrides:
init in class FlowedTextComponent

useStyle

public void useStyle(int newStyle)
Specifies a new style for the control.

Parameters:
newStyle - the new style name

timingEvent

public void timingEvent(float fraction)
This method will receive all of the timing events from an Animator during an animation. The fraction is the percent elapsed (0 to 1) of the current animation cycle.

Overrides:
timingEvent in class AnimationSurface
Parameters:
fraction - the fraction of completion between the start and end of the current cycle. Note that on reversing cycles (Animator.Direction#BACKWARD) the fraction decreases from 1.0 to 0 on backwards-running cycles. Note also that animations with a duration of INFINITE will call timingEvent with an undefined value for fraction, since there is no fraction that makes sense if the animation has no defined length.
See Also:
Animator.Direction

applyState

public void applyState(java.awt.Graphics2D g2)
Apply the current state to the graphics rendering context

Overrides:
applyState in class FlowedTextComponent
Parameters:
g2 - the graphics context

reset

public void reset(int w,
                  int h)
Adjust the settings for the next step.

Overrides:
reset in class FlowedTextComponent
Parameters:
w - the width
h - the height

step

public void step(int w,
                 int h)
Adjust the settings for the next step.

Overrides:
step in class FlowedTextComponent
Parameters:
w - the width
h - the height

isFinished

public boolean isFinished(Animator at)
Are there more steps to come?

Overrides:
isFinished in class AnimationSurface
Parameters:
at - the animation thread
Returns:
true if the animation has completed, false otherwise

isAnimated

public boolean isAnimated(Animator at)
Should the object be animated in this step?

Overrides:
isAnimated in class AnimationSurface
Parameters:
at - the animation thread
Returns:
true is the animation is running

setIncrement

public void setIncrement(int incr)
Sets the update increment.

Overrides:
setIncrement in class AnimationSurface
Parameters:
incr - the time in milliseconds between animation steps

getIncrement

public int getIncrement()
Get the update increment

Overrides:
getIncrement in class AnimationSurface
Returns:
the time between animation steps in milliseconds

setAlignment

public void setAlignment(int align)
Sets the text alignment.

Parameters:
align - the alignment

getAlignment

public int getAlignment()
Get the text alignment

Returns:
the alignment value

setContent

public void setContent(java.lang.String content)
Set the text content for the component.

Parameters:
set - the text value

getContent

public java.lang.String getContent()
Get the text content

Returns:
the text value