nl.knowledgeplaza.util.thread
Class AnimatedTransition

java.lang.Object
  extended by java.lang.Thread
      extended by nl.knowledgeplaza.util.thread.AnimatedTransition
All Implemented Interfaces:
java.lang.Runnable

public abstract class AnimatedTransition
extends java.lang.Thread

Version:
$Revision: 1.2 $
See Also:
This class adds that the progress runs inside the swing thread with an invokeAndWait.

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
static java.lang.String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AnimatedTransition()
           
 
Method Summary
static AnimatedTransition appendTransition(AnimatedTransition previousAnimatedTransition, AnimatedTransition newAnimatedTransition, double startValue, double endValue, double stepSize, double stepFactor, int minimumStepDelay)
          Start the animation after the previous has finished
static AnimatedTransition appendTransition(AnimatedTransition previousAnimatedTransition, AnimatedTransition newAnimatedTransition, double startValue, double endValue, double stepSize, int minimumStepDelay)
          Start the animation after the previous has finished
protected  void begin()
          for initializing
protected  void done()
          For cleaning up (like setting the animation variable to null) When this method is executed, it only means that the animation is finished, NOT that it has reached its end value!
protected  void doProcess(double v)
          here the process method is called, a hookin for the swing version
 boolean getAnimate()
           
 double getEndValue()
           
 int getMinimumStepDelay()
           
 double getStartValue()
           
 double getStepFactor()
           
 double getStepSize()
           
 double getValue()
           
 boolean isAnimating()
          are we currently animating
static AnimatedTransition newTransition(AnimatedTransition previousAnimatedTransition, AnimatedTransition newAnimatedTransition, double startValue, double endValue, double stepSize, double stepFactor, int minimumStepDelay)
          Stop the current transaction and when stopped, start a new.
static AnimatedTransition newTransition(AnimatedTransition previousAnimatedTransition, AnimatedTransition newAnimatedTransition, double startValue, double endValue, double stepSize, int minimumStepDelay)
          Stop the current transaction and when stopped, start a new.
protected abstract  void progress(double value)
          here it happens
 void run()
          This is the actual animation
 void setAnimate(boolean v)
          animate
 void setEndValue(double v)
          The step size in the progress
 void setMinimumStepDelay(int v)
          The minimum time between each step (milliseconds)
 void setStartValue(double v)
          The step size in the progress
 void setStepFactor(double v)
          This allows for non linear transition: the value - endvalue is divided by step factor, if this value is larger than stepsize, this value is used
 void setStepSize(double v)
          The step size in the progress
protected  void setValue(double v)
          The current value of the transition
protected  void waitForThreadToFinish(java.lang.Thread t)
          The swing version of AnimatedTransition does this without blocking the swing thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SOURCECODE_VERSION

public static final java.lang.String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values
Constructor Detail

AnimatedTransition

public AnimatedTransition()
Method Detail

setAnimate

public void setAnimate(boolean v)
animate


getAnimate

public boolean getAnimate()

isAnimating

public boolean isAnimating()
are we currently animating


setStartValue

public void setStartValue(double v)
The step size in the progress


getStartValue

public double getStartValue()

setEndValue

public void setEndValue(double v)
The step size in the progress


getEndValue

public double getEndValue()

setStepSize

public void setStepSize(double v)
The step size in the progress


getStepSize

public double getStepSize()

setStepFactor

public void setStepFactor(double v)
This allows for non linear transition: the value - endvalue is divided by step factor, if this value is larger than stepsize, this value is used


getStepFactor

public double getStepFactor()

setMinimumStepDelay

public void setMinimumStepDelay(int v)
The minimum time between each step (milliseconds)


getMinimumStepDelay

public int getMinimumStepDelay()

setValue

protected void setValue(double v)
The current value of the transition


getValue

public double getValue()

doProcess

protected void doProcess(double v)
here the process method is called, a hookin for the swing version


begin

protected void begin()
for initializing


progress

protected abstract void progress(double value)
here it happens


done

protected void done()
For cleaning up (like setting the animation variable to null) When this method is executed, it only means that the animation is finished, NOT that it has reached its end value!


run

public void run()
This is the actual animation

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

newTransition

public static AnimatedTransition newTransition(AnimatedTransition previousAnimatedTransition,
                                               AnimatedTransition newAnimatedTransition,
                                               double startValue,
                                               double endValue,
                                               double stepSize,
                                               int minimumStepDelay)
Stop the current transaction and when stopped, start a new.

Parameters:
previousAnimatedTransition -
newAnimatedTransition -
startValue - if Double.MIN_VALUE is provided, the start value will be the value of the previous animation after it has stopped
endValue -
stepSize -
minimumStepDelay -

newTransition

public static AnimatedTransition newTransition(AnimatedTransition previousAnimatedTransition,
                                               AnimatedTransition newAnimatedTransition,
                                               double startValue,
                                               double endValue,
                                               double stepSize,
                                               double stepFactor,
                                               int minimumStepDelay)
Stop the current transaction and when stopped, start a new.

Parameters:
previousAnimatedTransition -
newAnimatedTransition -
startValue - if Double.MIN_VALUE is provided, the start value will be the value of the previous animation after it has stopped
endValue -
stepSize -
stepFactor -
minimumStepDelay -

appendTransition

public static AnimatedTransition appendTransition(AnimatedTransition previousAnimatedTransition,
                                                  AnimatedTransition newAnimatedTransition,
                                                  double startValue,
                                                  double endValue,
                                                  double stepSize,
                                                  int minimumStepDelay)
Start the animation after the previous has finished

Parameters:
previousAnimatedTransition -
newAnimatedTransition -
startValue -
endValue -
stepSize -
minimumStepDelay -
Returns:

appendTransition

public static AnimatedTransition appendTransition(AnimatedTransition previousAnimatedTransition,
                                                  AnimatedTransition newAnimatedTransition,
                                                  double startValue,
                                                  double endValue,
                                                  double stepSize,
                                                  double stepFactor,
                                                  int minimumStepDelay)
Start the animation after the previous has finished

Parameters:
previousAnimatedTransition -
newAnimatedTransition -
startValue -
endValue -
stepSize -
minimumStepDelay -
Returns:

waitForThreadToFinish

protected void waitForThreadToFinish(java.lang.Thread t)
The swing version of AnimatedTransition does this without blocking the swing thread. This version will block swing! This is not static, so it can be overridden.



Copyright © 2010 KnowledgePlaza. All Rights Reserved.