org.gicentre.utils.network.traer.animation
Class Smoother

java.lang.Object
  extended by org.gicentre.utils.network.traer.animation.Smoother
All Implemented Interfaces:
Tickable

public class Smoother
extends java.lang.Object
implements Tickable

A single smoother for transitions towards a target over time. It is a normalised one-pole filter that transitions towards a target at a rate determined by its smoothness

Version:
31st July 2012.
Author:
Jeffrey Traer Bernstein with Minor Modifications by Jo Wood.

Constructor Summary
Smoother(float smoothness)
          Creates a smoother with the given smoothness.
Smoother(float smoothness, float start)
          Creates a smoother with the given smoothness and start value.
 
Method Summary
 float getTarget()
          Reports the target value aimed at by this smoother at a rate determined by the smoothness.
 float getValue()
          Reports the current value of the smoother.
 void setSmoothness(float smoothness)
          Sets the smoothness value that determines the rate of transition towards a target.
 void setTarget(float target)
          Sets the target value aimed at by the smoother.
 void setValue(float x)
          Move the smoother to the given target value immediately regardless of the smoothness value.
 void tick()
          Advances the time used by the smoother to move towards its target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Smoother

public Smoother(float smoothness)
Creates a smoother with the given smoothness.

Parameters:
smoothness - The smoothness of the transition towards a target. It is scaled between 0 and 1. A value of 0 has abrupt changes, 1 is very smooth. A value of 0.9 gives nice workable smoothness for typical animations.

Smoother

public Smoother(float smoothness,
                float start)
Creates a smoother with the given smoothness and start value.

Parameters:
smoothness - The smoothness of the transition towards a target. It is scaled between 0 and 1. A value of 0 has abrupt changes, 1 is very smooth. A value of 0.9 gives nice workable smoothness for typical animations.
start - Start value that will move towards a target.
Method Detail

setSmoothness

public final void setSmoothness(float smoothness)
Sets the smoothness value that determines the rate of transition towards a target.

Specified by:
setSmoothness in interface Tickable
Parameters:
smoothness - The smoothness of the transition towards a target. It is scaled between 0 and 1. A value of 0 has abrupt changes, 1 is very smooth. A value of 0.9 gives nice workable smoothness for typical animations.

tick

public final void tick()
Advances the time used by the smoother to move towards its target.

Specified by:
tick in interface Tickable

setTarget

public final void setTarget(float target)
Sets the target value aimed at by the smoother.

Parameters:
target - Target value aimed at by the smoother.

getTarget

public final float getTarget()
Reports the target value aimed at by this smoother at a rate determined by the smoothness.

Returns:
Target of the smoother.

setValue

public void setValue(float x)
Move the smoother to the given target value immediately regardless of the smoothness value.

Parameters:
x - New target value to jump to.

getValue

public final float getValue()
Reports the current value of the smoother. This will be somewhere between the source and target depending on the smoothness and number of times tick() has been called.

Returns:
Current value of the smoother.


giCentre Utilities V.3.3, API documentation generated 6th April, 2013