org.formaria.swing
Class CreditsText

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.CreditsText
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.print.Printable, java.io.Serializable, TextHolder

public class CreditsText
extends AnimationSurface

A component that displays text that animates/scrolls up the screen like movie credits

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 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.animation.AnimationSurface
animationContext, animator, antiAlias, ascent, autoStart, bimg, composite, currentProject, finished, imageType, increment, label, loopTime, oH, oldH, oldW, oW, oX, oY, 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 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
CreditsText()
          Create a new credits text animation
 
Method Summary
 void drawObjects(int w, int h, java.awt.Graphics2D g2)
          All classes that extend JAnimationSurface must implement this routine...
 int getFade()
          Return the current amount of fading as a percentage of the component width.
 void reset(AnimationThread at, int w, int h)
          Adjust the settings for the next step.
 void setFade(int percentage)
          Set the percentage of the width over which to fade the ends in and out.
 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.
protected  double wrapString(java.awt.Graphics2D g2, java.lang.String localCopy, double y, boolean doPaint)
          Render a text that wraps within the client area
 
Methods inherited from class org.formaria.swing.animation.AnimationSurface
autoStart, begin, createBufferedImage, createGraphics2D, end, getAnimator, getAntiAlias, getAutoStart, getComposite, getImageType, getIncrement, getLoopTime, getRendering, getSleepTime, getText, init, isAnimated, isFinished, isStarted, paintComponent, print, quoteReplacement, render, repeat, replace, reset, setAnimator, setAntiAlias, setAutoStart, setComposite, setImageType, setIncrement, setLoopTime, setRendering, setSleepTime, setText, 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

CreditsText

public CreditsText()
Create a new credits text animation

Method Detail

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

reset

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

Parameters:
w - the width
h - the height
at - the animation thread on which this object is running

step

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

Parameters:
w - the width
h - the height

drawObjects

public void drawObjects(int w,
                        int h,
                        java.awt.Graphics2D g2)
All classes that extend JAnimationSurface must implement this routine...

Specified by:
drawObjects in class AnimationSurface
Parameters:
w - the width
h - the height
g2 - the graphics context

wrapString

protected double wrapString(java.awt.Graphics2D g2,
                            java.lang.String localCopy,
                            double y,
                            boolean doPaint)
Render a text that wraps within the client area

Parameters:
g2 - the graphics context
localCopy - the string to render
y - the y offset into the client area
doPaint - true to paint, false to just calculate
Returns:
the latest y position

setFade

public void setFade(int percentage)
Set the percentage of the width over which to fade the ends in and out. The fading usies the background colour to give a smooth transition by placing a gradient fading from full opacity at the extreme left and right to full transparency at the percentage of the width specified by the fade parameter. By default the fade is set to zero for no fade. The value is bound within the range 0-50.

Parameters:
percentage - the new fade percentage

getFade

public int getFade()
Return the current amount of fading as a percentage of the component width.