SlowInSlowOutPacer.java :  » Database-Client » prefuse » prefuse » activity » Java Open Source

Java Open Source » Database Client » prefuse 
prefuse » prefuse » activity » SlowInSlowOutPacer.java
package prefuse.activity;

/**
 * A pacing function that provides slow-in, slow-out animation, where the
 * animation begins at a slower rate, speeds up through the middle of the
 * animation, and then slows down again before stopping.
 * 
 * This is calculated by using an appropriately phased sigmoid function of
 * the form 1/(1+exp(-x)).
 *
 * @author <a href="http://jheer.org">jeffrey heer</a>
 */
public class SlowInSlowOutPacer implements Pacer {
    
    /**
     * Pacing function providing slow-in, slow-out animation
     * @see prefuse.activity.Pacer#pace(double)
     */
    public double pace(double f) {
        return ( f == 0.0 || f == 1.0 ? f : sigmoid(f) );
    }
    
    /**
     * Computes a normalized sigmoid
     * @param x input value in the interval [0,1]
     */
    private double sigmoid(double x) {
        x = 12.0*x - 6.0;
        return (1.0 / (1.0 + Math.exp(-1.0 * x)));
    }

} // end of class SlowInSlowOutPacer
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.