KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > prefuse > activity > SlowInSlowOutPacer


1 package prefuse.activity;
2
3 /**
4  * A pacing function that provides slow-in, slow-out animation, where the
5  * animation begins at a slower rate, speeds up through the middle of the
6  * animation, and then slows down again before stopping.
7  *
8  * This is calculated by using an appropriately phased sigmoid function of
9  * the form 1/(1+exp(-x)).
10  *
11  * @author <a HREF="http://jheer.org">jeffrey heer</a>
12  */

13 public class SlowInSlowOutPacer implements Pacer {
14     
15     /**
16      * Pacing function providing slow-in, slow-out animation
17      * @see prefuse.activity.Pacer#pace(double)
18      */

19     public double pace(double f) {
20         return ( f == 0.0 || f == 1.0 ? f : sigmoid(f) );
21     }
22     
23     /**
24      * Computes a normalized sigmoid
25      * @param x input value in the interval [0,1]
26      */

27     private double sigmoid(double x) {
28         x = 12.0*x - 6.0;
29         return (1.0 / (1.0 + Math.exp(-1.0 * x)));
30     }
31
32 } // end of class SlowInSlowOutPacer
33
Popular Tags