JavaView® v2.00.008

jv.anim
Class PsAnimation

java.lang.Object
  |
  +--jv.object.PsObject
        |
        +--jv.anim.PsAnimation
All Implemented Interfaces:
java.lang.Cloneable, PsUpdateIf, java.lang.Runnable, java.io.Serializable

public class PsAnimation
extends PsObject
implements java.lang.Runnable

Animation manager issues time events and updates its listeners. Classes interested in time event must implement the interface PsTimeListenerIf and register as listeners in an instance this class.

On default, the time variable runs in the interval [0,100].

For usage, see interface PsTimeListenerIf. Since version 2.00 each animation has its own animationPanel.

Version:
21.02.01, 3.30 revised (kp) Now register this object inside its time listeners.
21.01.01, 3.20 revised (kp) Info panel subclassed from PsPanel than PsDialog.
01.12.00, 3.10 revised (kp) Implement two methods to get/set the sleep interval.
16.09.00, 3.00 revised (kp) Interface PsAnimationIf removed, static variable moved to PsAnimation.
06.10.99, 2.51 revised (ur) Let time for LOOP run in min<=time<= max instead of min 12.06.99, 2.50 revised (kp) Use name of dynamic object as title of the animation panel.
06.06.99, 2.50 revised (kp) Start/stop and m_thread handling moved here from info panel.
20.05.99, 2.00 revised (kp) Now each animation has its own animation panel.
00.00.97, 1.00 created (kp)
Author:
Konrad Polthier
See Also:
PsAnimation_IP, PsTimeListenerIf, Serialized Form

Field Summary
static int BACK_FORTH
          Change direction, repeat mode when either end of animation is reached.
static int FAST_FORWARD
          Play animation with speed determined by page increment of time ruler.
static int FAST_REWIND
          Play animation with fast speed determined by page increment of time ruler in backward direction.
static int FORWARD
          Play animation with normal speed determined by line increment of time ruler.
static int LOOP
          Jump to other end, repeat mode when either end of animation is reached.
protected  PsDialog m_animDialog
          Animation dialog with start/stop buttons.
protected  PuDouble m_currentTime
          Current time of the dynamic object.
protected  java.util.Vector m_dynamicList
          Hashtable of time listeners.
protected  boolean m_enableKeys
          Set visibility of key buttons prevKey, nextKey etc. in animation panel.
protected  double m_globalTime
          Global time of the external animation.
protected  int[] m_position
          Default position and size of animation dialog.
protected  int m_repeat
          Determines repeat mode, possible values ONE_WAY, LOOP, BACK_FORTH.
protected  int m_speed
          Speed of animation, possible values FORWARD, REWIND, FAST_FORWARD, FAST_REWIND.
protected  boolean m_syncFlag
          Synchronize with global time if true.
protected  java.lang.Thread m_thread
          Thread contolling the animation.
static int ONE_WAY
          Stop animation, repeat mode when either end of animation is reached.
static int REWIND
          Play animation with normal speed in backward direction determined by line increment of time ruler.
 
Fields inherited from class jv.object.PsObject
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, m_infoPanel, m_name, m_panelList, m_parent, m_tag, m_updateList, NUM_TAGS
 
Constructor Summary
PsAnimation()
           
 
Method Summary
 boolean addTimeListener(PsTimeListenerIf listener)
          Register a new update listener, and in return, register this animation in the time listener.
 void enableKeys(boolean flag)
          Set visibility of key buttons prevKey, nextKey etc. in animation panel.
 PsDialog getAnimationPanel()
          Get animation dialog to start and stop animation interactively.
 double getMaxTime()
          Get maximal time of animation interval.
 double getMinTime()
          Get minimal time of animation interval.
 long getSleepInterval()
          Get the length of the sleep interval between two timer events.
 double getTime()
          Get the current time of the animation.
 double getTimePageIncr()
          Get time increment of fast forward animation play.
 double getTimeStepIncr()
          Get time increment of standard animation play.
 boolean hasAnimationPanel()
          Query if animation has an animation dialog, or if it runs program controlled.
 boolean hasTimeListener(PsTimeListenerIf listener)
          Check whether an instance is a registered listener.
 void init()
          If instance has missing name then assign default name 'object_NUMBER' where number is the total number of already created instances.
 boolean isRunning()
          Check if animation is running.
 boolean removeTimeListener(PsTimeListenerIf listener)
          Remove a registered listener from list of registered listeners.
 void run()
          Do the animation.
 void setAnimationPanel(PsDialog panel)
          Set animation panel, e.g. when different animations join a common panel.
 void setPosition(int[] position)
          Set position and size of animation panel in absolut screen coordinates.
 void setRepeat(int repeat)
          Set repeat mode of animation.
 void setSleepInterval(long newInterval)
          Set the length of the sleep interval between two timer events.
protected  void setSpeed(int speed)
           
 void setTime(double newTime)
          Set the time of the animation and the animation panel.
protected  boolean setTime(PsTimeEvent timeEvent)
          Update all time listener objects with current time.
 void setTimeInterval(double aMin, double aMax)
          Set interval in which time varies.
 void setTimeInterval(double aMin, double aMax, double aLineIncr, double aPageIncr)
          Set interval in which time varies, and increments for time slider.
 void start()
          Start animation in normal speed.
 void start(int speed)
          Start animation with speed PsAnimation.
 void stop()
          Stop animation.
 void synchronize(boolean flag)
          Switch synchronization flag and, if flag==true update currentTime with globalTime.
 boolean update(java.lang.Object event)
          Update the class whenever a child has changed.
 
Methods inherited from class jv.object.PsObject
addInspector, addUpdateListener, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, removeInspector, removeUpdateListener, setName, setParent, setTag, toString, updatePanels
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FORWARD

public static final int FORWARD
Play animation with normal speed determined by line increment of time ruler.

REWIND

public static final int REWIND
Play animation with normal speed in backward direction determined by line increment of time ruler.

FAST_FORWARD

public static final int FAST_FORWARD
Play animation with speed determined by page increment of time ruler.

FAST_REWIND

public static final int FAST_REWIND
Play animation with fast speed determined by page increment of time ruler in backward direction.

ONE_WAY

public static final int ONE_WAY
Stop animation, repeat mode when either end of animation is reached.

LOOP

public static final int LOOP
Jump to other end, repeat mode when either end of animation is reached.

BACK_FORTH

public static final int BACK_FORTH
Change direction, repeat mode when either end of animation is reached.

m_dynamicList

protected java.util.Vector m_dynamicList
Hashtable of time listeners.

m_globalTime

protected double m_globalTime
Global time of the external animation. If dynamic object of 'this' shall be frozen to a specific time, then set m_syncFlag==false. In such a case, m_currentTime shows the time of the dynamic object.

m_currentTime

protected PuDouble m_currentTime
Current time of the dynamic object. If m_syncFlag==false current time may be different from m_globalTime.

m_speed

protected int m_speed
Speed of animation, possible values FORWARD, REWIND, FAST_FORWARD, FAST_REWIND.

m_repeat

protected int m_repeat
Determines repeat mode, possible values ONE_WAY, LOOP, BACK_FORTH.

m_syncFlag

protected boolean m_syncFlag
Synchronize with global time if true. Flag is initialized during construction if user forgets to create constructor in the right way, i.e. forgets to call method init().

m_enableKeys

protected boolean m_enableKeys
Set visibility of key buttons prevKey, nextKey etc. in animation panel.

m_position

protected int[] m_position
Default position and size of animation dialog.

m_animDialog

protected transient PsDialog m_animDialog
Animation dialog with start/stop buttons.

m_thread

protected transient java.lang.Thread m_thread
Thread contolling the animation.
Constructor Detail

PsAnimation

public PsAnimation()
Method Detail

init

public void init()
Description copied from class: PsObject
If instance has missing name then assign default name 'object_NUMBER' where number is the total number of already created instances.
Overrides:
init in class PsObject

addTimeListener

public boolean addTimeListener(PsTimeListenerIf listener)
Register a new update listener, and in return, register this animation in the time listener. This bijective registration allows the time listener to invoke this animation panel.
Parameters:
Listener - to register
Returns:
false if listener already registered.
See Also:
hasTimeListener(PsTimeListenerIf), removeTimeListener(PsTimeListenerIf)

hasTimeListener

public boolean hasTimeListener(PsTimeListenerIf listener)
Check whether an instance is a registered listener.
Returns:
true if registered listener found.
See Also:
addTimeListener(PsTimeListenerIf), removeTimeListener(PsTimeListenerIf)

removeTimeListener

public boolean removeTimeListener(PsTimeListenerIf listener)
Remove a registered listener from list of registered listeners.
Parameters:
Registered - listener
Returns:
false if listener is not registered.
See Also:
addTimeListener(PsTimeListenerIf), hasTimeListener(PsTimeListenerIf)

getSleepInterval

public long getSleepInterval()
Get the length of the sleep interval between two timer events.

setSleepInterval

public void setSleepInterval(long newInterval)
Set the length of the sleep interval between two timer events.

setTimeInterval

public void setTimeInterval(double aMin,
                            double aMax,
                            double aLineIncr,
                            double aPageIncr)
Set interval in which time varies, and increments for time slider.

setTimeInterval

public void setTimeInterval(double aMin,
                            double aMax)
Set interval in which time varies.

getMinTime

public double getMinTime()
Get minimal time of animation interval.

getMaxTime

public double getMaxTime()
Get maximal time of animation interval.

getTimeStepIncr

public double getTimeStepIncr()
Get time increment of standard animation play.

getTimePageIncr

public double getTimePageIncr()
Get time increment of fast forward animation play.

getTime

public double getTime()
Get the current time of the animation.

setTime

public void setTime(double newTime)
Set the time of the animation and the animation panel.

synchronize

public void synchronize(boolean flag)
Switch synchronization flag and, if flag==true update currentTime with globalTime.

setTime

protected boolean setTime(PsTimeEvent timeEvent)
Update all time listener objects with current time.

update

public boolean update(java.lang.Object event)
Update the class whenever a child has changed. Method is usually invoked from the children.
Overrides:
update in class PsObject
Following copied from class: jv.object.PsObject
See Also:
PsObject.setParent(PsUpdateIf), PsObject.getFather(), PsObject.addUpdateListener(PsUpdateIf)

enableKeys

public void enableKeys(boolean flag)
Set visibility of key buttons prevKey, nextKey etc. in animation panel.

getAnimationPanel

public PsDialog getAnimationPanel()
Get animation dialog to start and stop animation interactively.

hasAnimationPanel

public boolean hasAnimationPanel()
Query if animation has an animation dialog, or if it runs program controlled.

setAnimationPanel

public void setAnimationPanel(PsDialog panel)
Set animation panel, e.g. when different animations join a common panel. If different animation panels are used, it is preferred that a subclass of PsAnimation overrides the method getAnimationPanel() and allocates the a animation panel there, instead of calling setAnimationPanel().

setPosition

public void setPosition(int[] position)
Set position and size of animation panel in absolut screen coordinates.

setRepeat

public void setRepeat(int repeat)
Set repeat mode of animation.

setSpeed

protected void setSpeed(int speed)

isRunning

public boolean isRunning()
Check if animation is running.

start

public void start()
Start animation in normal speed.

start

public void start(int speed)
Start animation with speed PsAnimation.[FORWARD, REWIND, FAST_FORWARD, FAST_REWIND].

stop

public void stop()
Stop animation.

run

public void run()
Do the animation.
Specified by:
run in interface java.lang.Runnable

JavaView® v2.00.008

The software JavaView® is copyright protected. All Rights Reserved.