com.tivoli.twg.guilibs
Class AnimationPanel

java.lang.Object
  extended byTWGDialogPanel
      extended bycom.tivoli.twg.guilibs.AnimationPanel
All Implemented Interfaces:
java.lang.Runnable

public class AnimationPanel
extends TWGDialogPanel
implements java.lang.Runnable

This is the base class for the Director simple animation component. It creates an animation by displaying a series of images in sequence. You can specify the delay between frames in milliseconds. The animation can loop for a specific number of iterations or it can run forever. Note that the animation is not meant to be reentrant. You should not call startAnimation while the animation is in progress. The second call is ignored and the first call to stopAnimation will stop the animation. The start/stops are not reference counted. This makes sense since this class has class data that stores the information for animation.

See Also:
TWGTaskFrame, TWGStatusIndicator, Serialized Form

Nested Class Summary
protected  class AnimationPanel.AccessibleStatusIndicator
          This class implements accessibility support for the JPanel class.
 
Field Summary
protected  boolean animationRunning
          True animation is running, false otherwise.
protected  java.awt.Image backgroundImage
          The image to use when the animation images are not loaded.
protected  boolean clearFrame
          Clear frame between each image.
protected  java.awt.Image currentImage
          Image currently being shown.
protected  int defaultDelay
          Delay time between images, in milliseconds.
protected  java.util.Hashtable delays
          Duration of each image (Integers, in milliseconds).
protected  java.lang.Thread displayThread
          Thread which runs the animation.
protected  java.awt.Image extraLargeBackgroundImage
           
protected  java.util.Vector extraLargeImages
           
protected  boolean forever
          Run animation forever.
protected  java.util.Vector images
          Images to be displayed.
protected  java.awt.Image largeBackgroundImage
           
protected  java.util.Vector largeImages
           
protected  int maxHeight
          Dimension of largest image in sequence.
protected  int maxWidth
          Dimension of largest image in sequence.
protected  int numLoops
          Number of times to show the animation sequence.
protected  boolean previewMode
          Preview this component at design time.
protected  java.awt.Image smallbackgroundImage
           
protected  java.util.Vector smallimages
           
 
Constructor Summary
AnimationPanel()
          Constructs a default Animation Panel.
 
Method Summary
protected  void finalize()
          Make sure as part of the cleanup, the animation is stopped and the thread is destroyed.
 javax.accessibility.AccessibleContext getAccessibleContext()
          Gets the AccessibleContext associated with this JPanel.
 java.awt.Image getBackgroundImage()
          This function allows you to query the background image the animation panel displays when animation is not running.
 int getDefaultDelay()
          Returns the current delay between animation frames.
 int getFrameDelay(int frameNumber)
          You can use this function to query the amount of time a specific frame in an animation sequence is shown before displaying the next animation frame.
 java.awt.Dimension getMaximumSize()
          Returns the maximum dimensions to properly display this component.
 java.awt.Dimension getMinimumSize()
          Returns the minimum dimensions to properly display this component.
 int getNumLoops()
          Returns the current animation set loop count.
 java.awt.Dimension getPreferredSize()
          Returns the recommended dimensions to properly display this component.
 boolean isClearFrame()
          Gets the current clear frame setting.
 boolean isPreviewMode()
          Gets the preview mode flag.
 boolean isRepeatMode()
          Retrieve the current repeat mode setting.
 void paint(java.awt.Graphics g)
          Paints this component using the given graphics context.
 void resetFrameDelaysToDefault()
          This function allows you to reset all individual frame delays to the class's default delay.
 void run()
          Body of Animation Thread.
 void setBackgroundImage(java.awt.Image background)
          This function allows you to set a background image that is displayed in the animation panel when animation is not running.
 void setBackgroundImages(java.awt.Image smallbackground, java.awt.Image mediumbackground, java.awt.Image largebackground)
          This function allows you to set a background image that is displayed in the animation panel when animation is not running.
 void setClearFrame(boolean newClearFrame)
          Sets whether or not the animation frame area is cleared between each frame.
 void setDefaultDelay(int newDefaultDelay)
          Sets the delay between animation frames.
 void setFrameDelay(int frameNumber, int newDelay)
          This function allows you to set the amount of time an specific animation frame will be displayed.
 void setImageList(java.util.Vector newImageList)
          This function allows you to set a vector of images the animation panel will display as its animation sequence.
 void setImageLists(java.util.Vector smallImageList, java.util.Vector mediumImageList, java.util.Vector largeImageList)
          This function allows you to set a vector of images the animation panel will display as its animation sequence.
 void setNumLoops(int newNumLoops)
          Sets the number of loops to perform when displaying the animation set.
 void setPreviewMode(boolean newPreviewMode)
          Deprecated. - this method will be removed in framework4.
 void setRepeatMode(boolean newRepeatMode)
          Sets the repeat mode setting.
 void startAnimation()
          Starts the animation.
 void stopAnimation()
          Stops the animation.
 void updateUI()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultDelay

protected int defaultDelay
Delay time between images, in milliseconds.


delays

protected java.util.Hashtable delays
Duration of each image (Integers, in milliseconds).


numLoops

protected int numLoops
Number of times to show the animation sequence.


forever

protected boolean forever
Run animation forever. If false, use numLoops.


images

protected java.util.Vector images
Images to be displayed.


smallimages

protected java.util.Vector smallimages

largeImages

protected java.util.Vector largeImages

extraLargeImages

protected java.util.Vector extraLargeImages

backgroundImage

protected java.awt.Image backgroundImage
The image to use when the animation images are not loaded.


smallbackgroundImage

protected java.awt.Image smallbackgroundImage

largeBackgroundImage

protected java.awt.Image largeBackgroundImage

extraLargeBackgroundImage

protected java.awt.Image extraLargeBackgroundImage

currentImage

protected transient java.awt.Image currentImage
Image currently being shown.


displayThread

protected transient java.lang.Thread displayThread
Thread which runs the animation.


maxWidth

protected int maxWidth
Dimension of largest image in sequence.


maxHeight

protected int maxHeight
Dimension of largest image in sequence.


clearFrame

protected boolean clearFrame
Clear frame between each image.


previewMode

protected boolean previewMode
Preview this component at design time.


animationRunning

protected boolean animationRunning
True animation is running, false otherwise.

Constructor Detail

AnimationPanel

public AnimationPanel()
Constructs a default Animation Panel. The animator defaults to a 100 millisecond delay, and loops forever.

Method Detail

updateUI

public void updateUI()

finalize

protected void finalize()
                 throws java.lang.Throwable
Make sure as part of the cleanup, the animation is stopped and the thread is destroyed.

Throws:
java.lang.Throwable

setDefaultDelay

public void setDefaultDelay(int newDefaultDelay)
Sets the delay between animation frames.

Parameters:
newDefaultDelay - the animation delay, in milliseconds
See Also:
getDefaultDelay()

getDefaultDelay

public int getDefaultDelay()
Returns the current delay between animation frames.

Returns:
current animation delay, in milliseconds
See Also:
setDefaultDelay(int)

setFrameDelay

public void setFrameDelay(int frameNumber,
                          int newDelay)
This function allows you to set the amount of time an specific animation frame will be displayed.

Parameters:
frameNumber - The frame you want the specific delay for. The number is a zero based index into the animation frames.
newDelay - The delay, in milliseconds, to use for that frame.
See Also:
getFrameDelay(int)

getFrameDelay

public int getFrameDelay(int frameNumber)
You can use this function to query the amount of time a specific frame in an animation sequence is shown before displaying the next animation frame.

Parameters:
frameNumber - The frame you want the specific delay for. The number is a zero based index into the animation frames.
Returns:
The delay, in milliseconds, that will be used for that frame.
See Also:
setFrameDelay(int, int)

resetFrameDelaysToDefault

public void resetFrameDelaysToDefault()
This function allows you to reset all individual frame delays to the class's default delay.

See Also:
setFrameDelay(int, int)

setNumLoops

public void setNumLoops(int newNumLoops)
Sets the number of loops to perform when displaying the animation set. This value is ignored if the repeat mode is set to true (i.e. loop forever).

Parameters:
newNumLoops - the new loop count to use when iterating through the animation frame set.

getNumLoops

public int getNumLoops()
Returns the current animation set loop count. This is the number of times the animation will repeat before it stops. This count is ignored if the repeat mode is set to true (i.e. loop forever). The default loop count is 1.

Returns:
The number of loops (iterations) the animator will make through the animation set before the animation stops.
See Also:
setNumLoops(int)

setRepeatMode

public void setRepeatMode(boolean newRepeatMode)
Sets the repeat mode setting.

Parameters:
newRepeatMode - If true, then the animation panel will loop through the animation set forever (or until stopped). If false, the animation panel will loop through the animation set for the number times specified by the loop count.
See Also:
setNumLoops(int)

isRepeatMode

public boolean isRepeatMode()
Retrieve the current repeat mode setting. The default repeat mode is true.

Returns:
the current repeat mode setting. If true, then the animation panel will loop through the animation set forever (or until stopped). If false, the animation panel will loop through the animation set for the number times specified by the loop count.
See Also:
setRepeatMode(boolean)

setBackgroundImages

public void setBackgroundImages(java.awt.Image smallbackground,
                                java.awt.Image mediumbackground,
                                java.awt.Image largebackground)
This function allows you to set a background image that is displayed in the animation panel when animation is not running.


setBackgroundImage

public void setBackgroundImage(java.awt.Image background)
This function allows you to set a background image that is displayed in the animation panel when animation is not running.

Parameters:
background - The Image to display as the background.

getBackgroundImage

public java.awt.Image getBackgroundImage()
This function allows you to query the background image the animation panel displays when animation is not running.


setImageList

public void setImageList(java.util.Vector newImageList)
This function allows you to set a vector of images the animation panel will display as its animation sequence.

Parameters:
newImageList - The Vector containing the Images that will be used as the animation set.

setImageLists

public void setImageLists(java.util.Vector smallImageList,
                          java.util.Vector mediumImageList,
                          java.util.Vector largeImageList)
This function allows you to set a vector of images the animation panel will display as its animation sequence.


setClearFrame

public void setClearFrame(boolean newClearFrame)
Sets whether or not the animation frame area is cleared between each frame.

Parameters:
newClearFrame - If true, the frame area is cleared between each animation frame; if false, the frame area is not cleared.
See Also:
#getClearFrame

isClearFrame

public boolean isClearFrame()
Gets the current clear frame setting. The default is false.

Returns:
boolean - if true, the frame area is cleared between each animation frame; if false, the frame area is not cleared.
See Also:
setClearFrame(boolean)

setPreviewMode

public void setPreviewMode(boolean newPreviewMode)
Deprecated. - this method will be removed in framework4.

Sets the preview mode flag. This flag is used by Visual Cafe to determine if this component should be run during design time.

Parameters:
newPreviewMode - new preview mode
See Also:
#getPreviewMode

isPreviewMode

public boolean isPreviewMode()
Gets the preview mode flag. This flag is used by Visual Cafe to determine if this component should be run during design time.

See Also:
setPreviewMode(boolean)

startAnimation

public void startAnimation()
Starts the animation. The animation panel will sequence through the images specified in the animation set based on the parameters set (i.e. loop forever, loop for a specific count, etc)

See Also:
stopAnimation()

stopAnimation

public void stopAnimation()
Stops the animation. The animation will stop sequencing through the images and any default background set will be redisplayed. We have had problems with thread.stop so this method sets forceStop to force the run method to end.

See Also:
startAnimation()

run

public void run()
Body of Animation Thread. This method is called by the Java Virtual Machine in response to a call to the start method of this object.

Specified by:
run in interface java.lang.Runnable

paint

public void paint(java.awt.Graphics g)
Paints this component using the given graphics context. This is a standard Java AWT method which typically gets called by the AWT to handle painting this component. It paints this component using the given graphics context. The graphics context clipping region is set to the bounding rectangle of this component and its <0,0> coordinate is this component's top-left corner.

Parameters:
g - the graphics context used for painting
See Also:
Component.repaint()

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the recommended dimensions to properly display this component. This is a standard Java AWT method which gets called to determine the recommended size of this component.

Returns:
If no images have been loaded, a dimension of 10 by 10 is returned. If one or more images have been loaded, the largest height and the largest width of any image is returned.
See Also:
getMinimumSize()

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum dimensions to properly display this component. This is a standard Java AWT method which gets called to determine the minimum size of this component.

Returns:
If no images have been loaded, a dimension of 10 by 10 is returned. If one or more images have been loaded, the largest height and the largest width of any image is returned.
See Also:
getPreferredSize()

getMaximumSize

public java.awt.Dimension getMaximumSize()
Returns the maximum dimensions to properly display this component. This is a standard Java AWT method which gets called to determine the maximum size of this component.

Returns:
The preferred size is returned.
See Also:
getPreferredSize()

getAccessibleContext

public javax.accessibility.AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JPanel. For JPanels, the AccessibleContext takes the form of an AccessibleJPanel. A new AccessibleJPanel instance is created if necessary.

Returns:
an AccessibleJPanel that serves as the AccessibleContext of this JPanel