Jeospace API

org.jeospace.navigation
Class Alpha

java.lang.Object
  extended byorg.jeospace.navigation.Alpha

public class Alpha
extends java.lang.Object

Generator of alpha values (ranging 0.0 to 1.0) for interpolators. This object is designed for synchronous operation; the fraction value is update in response to an external object calling it's tick() method. The alpha may run forward or backward depending on the direction constant value. The alpha's primary (fraction) value is incremented or decremented by the increment value for each tick(). The fraction value may be modified by a behavior function specified by the behavior constant.

Version:
$Revision: 1.1.1.1 $
Author:
Rex Melton

Field Summary
static int ACCELERATE
          Behavior constant indicating that the alpha value accelerates or ramps up from it's beginning to end.
static int ACCELERATE_DECELERATE
          Behavior constant indicating that the alpha value accelerates for the first half of it's operation then decelerates for the second half.
protected  int behaviour
          Modifier of the fraction.
static int CONTINUOUS
          Loop count value indicating that the Alpha should run continuously
static int DECELERATE
          Behavior constant indicating that the alpha value decelerates or ramps down from it's beginning to end.
static boolean DECREMENT
          Direction constant indicating that the alpha will decrement
protected  double fraction
          The base value of the alpha which determines it's begin and end points.
protected  double increment
          The value to increment (or decrement) the fraction by.
static boolean INCREMENT
          Direction constant indicating that the alpha will increment
static int LINEAR
          Behavior constant indicating that the alpha value is a linear function of the fraction value.
protected  int loopCount
          The number of iterations to perform
static int STOP
          Loop count value indicating that the Alpha should stop
 
Constructor Summary
Alpha()
          Default Constructor.
Alpha(double fraction, double increment, int behaviour, int loopCount)
          Constructor
 
Method Summary
 int getBehaviour()
          Return the behavior constant
 double getFraction()
          Return the fraction value
 int getLoopCount()
          Return the loop count
 double getValue()
          Return the alpha value.
 void set(double fraction, double increment, int behaviour, int loopCount)
          Set the alpha parameters
 void setBehaviour(int behaviour)
          Set the alpha behavior
 void setFraction(double fraction)
          Set the fraction value
 void setIncrement(double increment)
          Set the increment value
 void setLoopCount(int loopCount)
          Set the loop count to the argument value
 boolean tick(boolean up_or_down)
          Update the fraction value by the increment, in the direction of the argument
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INCREMENT

public static final boolean INCREMENT
Direction constant indicating that the alpha will increment

See Also:
Constant Field Values

DECREMENT

public static final boolean DECREMENT
Direction constant indicating that the alpha will decrement

See Also:
Constant Field Values

LINEAR

public static final int LINEAR
Behavior constant indicating that the alpha value is a linear function of the fraction value.

See Also:
Constant Field Values

ACCELERATE

public static final int ACCELERATE
Behavior constant indicating that the alpha value accelerates or ramps up from it's beginning to end. The function is:
( 1.0 - Math.cos( fraction * Math.PI/2 ) )

See Also:
Constant Field Values

DECELERATE

public static final int DECELERATE
Behavior constant indicating that the alpha value decelerates or ramps down from it's beginning to end. The function is:
( Math.sin( fraction * Math.PI/2 ) )

See Also:
Constant Field Values

ACCELERATE_DECELERATE

public static final int ACCELERATE_DECELERATE
Behavior constant indicating that the alpha value accelerates for the first half of it's operation then decelerates for the second half. The function is:
( 0.5 * ( 1.0 - Math.cos( fraction * Math.PI ) ) )

See Also:
Constant Field Values

CONTINUOUS

public static final int CONTINUOUS
Loop count value indicating that the Alpha should run continuously

See Also:
Constant Field Values

STOP

public static final int STOP
Loop count value indicating that the Alpha should stop

See Also:
Constant Field Values

fraction

protected double fraction
The base value of the alpha which determines it's begin and end points.


increment

protected double increment
The value to increment (or decrement) the fraction by.


behaviour

protected int behaviour
Modifier of the fraction. Must be one of the defined behavior constants.


loopCount

protected int loopCount
The number of iterations to perform

Constructor Detail

Alpha

public Alpha()
Default Constructor. Instantiates an Alpha with the default values of:
fraction = 0.0
increment = 0.01
behavior = ACCELERATE_DECELERATE
loopCount = 1


Alpha

public Alpha(double fraction,
             double increment,
             int behaviour,
             int loopCount)
Constructor

Parameters:
fraction - The fraction value
increment - The increment value
behaviour - A behavior constant
loopCount - The number of cycles to perform
Method Detail

set

public void set(double fraction,
                double increment,
                int behaviour,
                int loopCount)
Set the alpha parameters

Parameters:
fraction - The fraction value
increment - The increment value
behaviour - A behavior constant
loopCount - The number of cycles to perform

setFraction

public void setFraction(double fraction)
Set the fraction value

Parameters:
fraction - The fraction value

setIncrement

public void setIncrement(double increment)
Set the increment value

Parameters:
increment - The increment value

setBehaviour

public void setBehaviour(int behaviour)
Set the alpha behavior

Parameters:
behaviour - A behavior constant

setLoopCount

public void setLoopCount(int loopCount)
Set the loop count to the argument value

Parameters:
loopCount - The number of cycles to perform

tick

public boolean tick(boolean up_or_down)
Update the fraction value by the increment, in the direction of the argument

Parameters:
up_or_down - Flag indicating whether the fraction should be incremented or decremented by the increment value. true for increment, false for decrement.
Returns:
true if the alpha has reached it's final value, false if not.

getFraction

public double getFraction()
Return the fraction value

Returns:
the fraction value

getBehaviour

public int getBehaviour()
Return the behavior constant

Returns:
the behavior constant

getLoopCount

public int getLoopCount()
Return the loop count

Returns:
the loop count

getValue

public double getValue()
Return the alpha value. This is the fraction value, modified by the behavior.

Returns:
the alpha value

Jeospace API

Copyright © 2006 - jeospace.org