Class SpiroAnim

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----SpiroAnim

public class SpiroAnim
extends Canvas
implements Runnable, WindowListener
SpiroAnim - a class that produces an animated spirograph. SpiroAnim is an ideal component for entertaining users waiting for downloading applications. You can add it to any Container and an animation of a spirograph starts. It's thread has minimum priority. You can configure the component to stop and start or to reset when clicked.

If you like this class, feel free to use it. I'd like to hear how you like it, so don't hesitate to inform me if you use it.

Version:
1.00
Author:
Jos van den Oever

Constructor Index

 o SpiroAnim()
Constructs a SpiroAnim with 100 lines per frame.
 o SpiroAnim(boolean)
Constructs a SpiroAnim with 100 lines per frame.
 o SpiroAnim(int)
Constructs a SpiroAnim with the specified number of lines per frame.
 o SpiroAnim(int, boolean)
Constructs a SpiroAnim with the specified number of lines per frame.

Method Index

 o addNotify()
Notifies the component it has been added to a Container.
 o invalidate()
Invalidate the component.
 o paint(Graphics)
The paint method draws the spirograph using double buffering.
 o processComponentEvent(ComponentEvent)
Processes ComponentEvents concerning this component.
 o processMouseEvent(MouseEvent)
Processes MouseEvents concerning this component.
 o removeNotify()
Notifies the component is has been removed from a component.
 o reset()
Resets the animation.
 o run()
Called when the animation is started.
 o start()
Starts the animation.
 o stop()
Stops the animation.
 o update(Graphics)
Update method, calls paint().
 o validate()
Validate the component.
 o windowActivated(WindowEvent)
Unused WindowListener interface function.
 o windowClosed(WindowEvent)
Unused WindowListener interface function.
 o windowClosing(WindowEvent)
Unused WindowListener interface function.
 o windowDeactivated(WindowEvent)
Unused WindowListener interface function.
 o windowDeiconified(WindowEvent)
Function handles deiconification of parent window to start animation.
 o windowIconified(WindowEvent)
Function handles iconification of parent window to stop animation.
 o windowOpened(WindowEvent)
Unused WindowListener interface function.

Constructors

 o SpiroAnim
 public SpiroAnim()
Constructs a SpiroAnim with 100 lines per frame.
 o SpiroAnim
 public SpiroAnim(boolean mouseUpStopsAnimation)
Constructs a SpiroAnim with 100 lines per frame.
Parameters:
mouseUpStopsAnimation - if true the animation stops when clicked else resets when clicked
 o SpiroAnim
 public SpiroAnim(int I)
Constructs a SpiroAnim with the specified number of lines per frame.
Parameters:
I - the number of lines per frame
 o SpiroAnim
 public SpiroAnim(int I,
                  boolean mouseUpStopsAnimation)
Constructs a SpiroAnim with the specified number of lines per frame.
Parameters:
I - the number of lines per frame
mouseUpStopsAnimation - if true the animation stops when clicked else resets when clicked

Methods

 o start
 public void start()
Starts the animation.
 o stop
 public void stop()
Stops the animation.
 o run
 public void run()
Called when the animation is started. Shouldn't be called by user.
 o update
 public void update(Graphics g)
Update method, calls paint().
Parameters:
g - the graphics object on which is to be drawn
Overrides:
update in class Component
 o paint
 public void paint(Graphics g)
The paint method draws the spirograph using double buffering.
Parameters:
g - the graphics object on which is to be drawn
Overrides:
paint in class Canvas
 o reset
 public void reset()
Resets the animation.
 o invalidate
 public void invalidate()
Invalidate the component. Shouldn't be called by user.
Overrides:
invalidate in class Component
 o validate
 public void validate()
Validate the component. Is called by the system before the component is painted, if it has been invalidated. Shouldn't be called by user.
Overrides:
validate in class Component
 o addNotify
 public void addNotify()
Notifies the component it has been added to a Container. Shouldn't be called by user.
Overrides:
addNotify in class Canvas
 o removeNotify
 public void removeNotify()
Notifies the component is has been removed from a component. Shouldn't be called by user.
Overrides:
removeNotify in class Component
 o processComponentEvent
 protected void processComponentEvent(ComponentEvent e)
Processes ComponentEvents concerning this component. Deals with showing and hiding this component. The SpiroAnim doesn't animate when hidden to save cpu time.
Parameters:
e - The ComponentEvent to be handled.
Overrides:
processComponentEvent in class Component
 o processMouseEvent
 protected void processMouseEvent(MouseEvent e)
Processes MouseEvents concerning this component. Deals with mouse clicking on this component. The animation starts/stops or resets on mouse click according to configuration.
Parameters:
e - The MouseEvent to be handled.
Overrides:
processMouseEvent in class Component
 o windowOpened
 public void windowOpened(WindowEvent e)
Unused WindowListener interface function.
Parameters:
e - The WindowEvent to be handled.
 o windowClosing
 public void windowClosing(WindowEvent e)
Unused WindowListener interface function.
Parameters:
e - The WindowEvent to be handled.
 o windowClosed
 public void windowClosed(WindowEvent e)
Unused WindowListener interface function.
Parameters:
e - The WindowEvent to be handled.
 o windowIconified
 public void windowIconified(WindowEvent e)
Function handles iconification of parent window to stop animation. This save cpu time.
Parameters:
e - The WindowEvent to be handled.
 o windowDeiconified
 public void windowDeiconified(WindowEvent e)
Function handles deiconification of parent window to start animation.
Parameters:
e - The WindowEvent to be handled.
 o windowActivated
 public void windowActivated(WindowEvent e)
Unused WindowListener interface function.
Parameters:
e - The WindowEvent to be handled.
 o windowDeactivated
 public void windowDeactivated(WindowEvent e)
Unused WindowListener interface function.
Parameters:
e - The WindowEvent to be handled.