fcmodeler.animation
Class Animator

java.lang.Object
  |
  +--fcmodeler.animation.Animator
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener

public class Animator
extends java.lang.Object
implements java.awt.event.ActionListener

An animation controller. This class uses a list of sets of node mappings and a list of sets of edge mappings, and applies each set of mappings to all node and edge figures in the view one at a time to produce an animation of changing visual attributes. Each element in the lists represents one time step.

Since:
JDK1.3
Version:
$Revision: 1.2 $
Author:
Zach Cox

Constructor Summary
Animator(java.util.List nodeMappings, java.util.List edgeMappings, diva.graph.GraphView view)
          Creates a new Animator using the specified node and edge mappings.
Animator(java.io.Reader reader, diva.graph.GraphView view)
          Creates a new Animator using the node and edge mappings in the XML obtained from the specified reader.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent actionEvent)
          Invoked by the timer when the next frame of the animation should be shown.
 void addAnimationListener(AnimationListener listener)
          Registers the specified animation listener to receive animation events from this animator.
protected  void fireAnimationPaused()
          Notifies all animation listeners that the animation was paused.
protected  void fireAnimationStarted()
          Notifies all animation listeners that the animation was started.
protected  void fireAnimationStopped()
          Notifies all animation listeners that the animation was stopped.
protected  void fireFrameShown()
          Notifies all animation listeners that a new frame was shown.
 java.util.Iterator getAnimationListeners()
          Returns an iterator over the animation listeners registered with this animator.
 int getDelay()
          Returns the delay between animation steps.
 java.util.List getEdgeMappings()
          Returns the list of sets of edge mappings.
 int getFrame()
          Returns the current frame being shown by this animator.
 int getFrameCount()
          Returns the total number of frames to be shown by this animator.
 diva.graph.GraphView getGraphView()
          Returns the graph view used by this animator.
 java.util.List getNodeMappings()
          Returns the list of sets of node mappings.
 boolean isPaused()
          Returns true if the animation is paused.
 boolean isStopped()
          Returns true if the animation is stopped.
 boolean isValidFrame(int frame)
          Returns true if the specified frame number is valid.
 void next()
          Shows the next frame of the animation.
 void pause()
          Pauses the animation.
 void previous()
          Shows the previous frame of the animation.
 void removeAnimationListener(AnimationListener listener)
          Removes the specified animation listener from the list of listeners for this animator.
 void setDelay(int delay)
          Sets the delay between animation steps to the specified value.
 void showFrame(int frame)
          Shows the specified frame of the animation.
 void start()
          Starts the animation.
 void stop()
          Stops the animation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Animator

public Animator(java.io.Reader reader,
                diva.graph.GraphView view)
Creates a new Animator using the node and edge mappings in the XML obtained from the specified reader.
Parameters:
reader - the reader that provides the node and edge mappings in XML.
view - the graph view containing the node and edge figures.

Animator

public Animator(java.util.List nodeMappings,
                java.util.List edgeMappings,
                diva.graph.GraphView view)
Creates a new Animator using the specified node and edge mappings.
Parameters:
nodeMappings - the list of sets of node mappings.
edgeMappings - the list of sets of edge mappings.
view - the graph view containing the node and edge figures.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent actionEvent)
Invoked by the timer when the next frame of the animation should be shown.
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
actionEvent - totally ignored by this method.

addAnimationListener

public void addAnimationListener(AnimationListener listener)
Registers the specified animation listener to receive animation events from this animator.
Parameters:
listener - the animation listener to register with this animator.

fireAnimationPaused

protected void fireAnimationPaused()
Notifies all animation listeners that the animation was paused.

fireAnimationStarted

protected void fireAnimationStarted()
Notifies all animation listeners that the animation was started.

fireAnimationStopped

protected void fireAnimationStopped()
Notifies all animation listeners that the animation was stopped.

fireFrameShown

protected void fireFrameShown()
Notifies all animation listeners that a new frame was shown.

getAnimationListeners

public java.util.Iterator getAnimationListeners()
Returns an iterator over the animation listeners registered with this animator.
Returns:
an iterator over the animation listeners registered with this animator.

getDelay

public int getDelay()
Returns the delay between animation steps.
Returns:
the delay between animation steps.

getEdgeMappings

public java.util.List getEdgeMappings()
Returns the list of sets of edge mappings.
Returns:
the list of sets of edge mappings.

getFrame

public int getFrame()
Returns the current frame being shown by this animator.
Returns:
the current frame being shown by this animator.

getFrameCount

public int getFrameCount()
Returns the total number of frames to be shown by this animator.
Returns:
the total number of frames to be shown by this animator.

getGraphView

public diva.graph.GraphView getGraphView()
Returns the graph view used by this animator.
Returns:
the graph view used by this animator.

getNodeMappings

public java.util.List getNodeMappings()
Returns the list of sets of node mappings.
Returns:
the list of sets of node mappings.

isValidFrame

public boolean isValidFrame(int frame)
Returns true if the specified frame number is valid.
Parameters:
frame - the frame number to test for validity.
Returns:
true if frame >= 0 and frame < getFrameCount().

isPaused

public boolean isPaused()
Returns true if the animation is paused.
Returns:
true if the animation is paused.

isStopped

public boolean isStopped()
Returns true if the animation is stopped.
Returns:
true if the animation is stopped.

next

public void next()
Shows the next frame of the animation.

pause

public void pause()
Pauses the animation.

previous

public void previous()
Shows the previous frame of the animation.

removeAnimationListener

public void removeAnimationListener(AnimationListener listener)
Removes the specified animation listener from the list of listeners for this animator.
Parameters:
listener - the animation listener to remove.

setDelay

public void setDelay(int delay)
Sets the delay between animation steps to the specified value.
Parameters:
delay - the delay between animation steps in milliseconds.

showFrame

public void showFrame(int frame)
Shows the specified frame of the animation.
Parameters:
frame - the frame to show.

start

public void start()
Starts the animation.

stop

public void stop()
Stops the animation.