javax.media.j3d
Class Alpha

java.lang.Object
  extended by javax.media.j3d.SceneGraphObject
      extended by javax.media.j3d.NodeComponent
          extended by javax.media.j3d.Alpha

public class Alpha
extends NodeComponent

The alpha NodeComponent object provides common methods for converting a time value into an alpha value (a value in the range 0 to 1). The Alpha object is effectively a function of time that generates alpha values in the range [0,1] when sampled: f(t) = [0,1]. A primary use of the Alpha object is to provide alpha values for Interpolator behaviors. The function f(t) and the characteristics of the Alpha object are determined by user-definable parameters:

Increasing Alpha parameters:

Decreasing Alpha parameters:

See Also:
Interpolator

Field Summary
private  float alphaAtOne
           
private  float alphaAtZero
           
private  float decAlphaRampInternal
           
static int DECREASING_ENABLE
          Specifies that the decreasing component of the alpha is used
private  float decreasingAlpha
           
private  long decreasingAlphaRamp
           
private  float incAlphaRampInternal
           
static int INCREASING_ENABLE
          Specifies that the increasing component of the alpha is used.
private  float increasingAlpha
           
private  long increasingAlphaRamp
           
private  int loopCount
           
private  int mode
          This alpha's mode, specifies whether to process increasing and decreasing alphas.
private  boolean paused
           
private  long pauseTime
           
private  float phaseDelay
           
private  long startTime
           
private  float stopTime
           
private  float triggerTime
           
 
Fields inherited from class javax.media.j3d.NodeComponent
forceDuplicate
 
Fields inherited from class javax.media.j3d.SceneGraphObject
nodeHashtable, retained
 
Constructor Summary
Alpha()
          Constructs an Alpha object with default parameters.
Alpha(int loopCount, int mode, long triggerTime, long phaseDelayDuration, long increasingAlphaDuration, long increasingAlphaRampDuration, long alphaAtOneDuration, long decreasingAlphaDuration, long decreasingAlphaRampDuration, long alphaAtZeroDuration)
          This constructor takes all of the Alpha user-definable parameters.
Alpha(int loopCount, long increasingAlphaDuration)
          This constructor takes only the loopCount and increasingAlphaDuration as parameters and assigns the default values to all of the other parameters.
Alpha(int loopCount, long triggerTime, long phaseDelayDuration, long increasingAlphaDuration, long increasingAlphaRampDuration, long alphaAtOneDuration)
          Constructs a new Alpha object that assumes that the mode is INCREASING_ENABLE.
 
Method Summary
(package private)  Alpha cloneAlpha()
          This internal method returns a clone of the Alpha
private  void computeStopTime()
           
 boolean finished()
          Query to test if this alpha object is past its activity window, that is, if it has finished looping.
 long getAlphaAtOneDuration()
          Retrieves this alpha's alphaAtOneDuration.
 long getAlphaAtZeroDuration()
          Retrieves this alpha's alphaAtZeroDuration.
 long getDecreasingAlphaDuration()
          Retrieves this alpha's decreasingAlphaDuration.
 long getDecreasingAlphaRampDuration()
          Retrieves this alpha's decreasingAlphaRampDuration.
 long getIncreasingAlphaDuration()
          Retrieves this alpha's increasingAlphaDuration.
 long getIncreasingAlphaRampDuration()
          Retrieves this alpha's increasingAlphaRampDuration.
 int getLoopCount()
          Retrieves this alpha's loopCount.
 int getMode()
          Retrieves this alpha's mode.
 long getPauseTime()
          Returns the time at which this alpha was paused.
 long getPhaseDelayDuration()
          Retrieves this alpha's phaseDelayDuration.
 long getStartTime()
          Retrieves this alpha's startTime, the base for all relative time specifications; the default value for startTime is the system start time.
 long getTriggerTime()
          Retrieves this alpha's triggerTime.
 boolean isPaused()
          Returns true if this alpha object is paused.
(package private)  float mfmod(float a, float b)
           
 void pause()
          Pauses this alpha object.
 void pause(long time)
          Pauses this alpha object as of the specified time.
 void resume()
          Resumes this alpha object.
 void resume(long time)
          Resumes this alpha object as of the specified time.
 void setAlphaAtOneDuration(long alphaAtOneDuration)
          Set this alpha object's alphaAtOneDuration to the specified value.
 void setAlphaAtZeroDuration(long alphaAtZeroDuration)
          Set this alpha object's alphaAtZeroDuration to the specified value.
 void setDecreasingAlphaDuration(long decreasingAlphaDuration)
          Set this alpha's decreasingAlphaDuration to that specified in the argument.
 void setDecreasingAlphaRampDuration(long decreasingAlphaRampDuration)
          Set this alpha's decreasingAlphaRampDuration to that specified in the argument.
 void setIncreasingAlphaDuration(long increasingAlphaDuration)
          Set this alpha's increasingAlphaDuration to that specified in the argument.
 void setIncreasingAlphaRampDuration(long increasingAlphaRampDuration)
          Set this alpha's increasingAlphaRampDuration to that specified in the argument.
 void setLoopCount(int loopCount)
          Set this alpha's loopCount to that specified in the argument.
 void setMode(int mode)
          Set this alpha's mode to that specified in the argument.
 void setPhaseDelayDuration(long phaseDelayDuration)
          Set this alpha's phaseDelayDuration to that specified in the argument.
 void setStartTime(long startTime)
          Sets this alpha's startTime to that specified in the argument; startTime sets the base (or zero) for all relative time computations; the default value for startTime is the system start time.
 void setTriggerTime(long triggerTime)
          Set this alpha's triggerTime to that specified in the argument.
 float value()
          This method returns a value between 0.0 and 1.0 inclusive, based on the current time and the time-to-alpha parameters established for this alpha.
 float value(long atTime)
          This method returns a value between 0.0 and 1.0 inclusive, based on the specified time and the time-to-alpha parameters established for this alpha.
 
Methods inherited from class javax.media.j3d.NodeComponent
checkDuplicateNodeComponent, cloneNodeComponent, cloneNodeComponent, createRetained, duplicateAttributes, duplicateChild, duplicateNodeComponent, duplicateNodeComponent, getDuplicateOnCloneTree, setDuplicateOnCloneTree, validateImageIllegalSharing
 
Methods inherited from class javax.media.j3d.SceneGraphObject
capabilityBitsEmpty, checkForLiveOrCompiled, clearCapability, clearCapabilityIsFrequent, clearLive, duplicateSceneGraphObject, getCapability, getCapabilityIsFrequent, getName, getNamePrefix, getNodeComponent, getUserData, isCompiled, isLive, isLiveOrCompiled, setCapability, setCapabilityIsFrequent, setCompiled, setDefaultReadCapabilities, setLive, setName, setUserData, toString, updateNodeReferences
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

loopCount

private int loopCount

INCREASING_ENABLE

public static final int INCREASING_ENABLE
Specifies that the increasing component of the alpha is used.

See Also:
Constant Field Values

DECREASING_ENABLE

public static final int DECREASING_ENABLE
Specifies that the decreasing component of the alpha is used

See Also:
Constant Field Values

mode

private int mode
This alpha's mode, specifies whether to process increasing and decreasing alphas.


triggerTime

private float triggerTime

phaseDelay

private float phaseDelay

increasingAlpha

private float increasingAlpha

increasingAlphaRamp

private long increasingAlphaRamp

incAlphaRampInternal

private float incAlphaRampInternal

alphaAtOne

private float alphaAtOne

decreasingAlpha

private float decreasingAlpha

decreasingAlphaRamp

private long decreasingAlphaRamp

decAlphaRampInternal

private float decAlphaRampInternal

alphaAtZero

private float alphaAtZero

pauseTime

private long pauseTime

paused

private boolean paused

stopTime

private float stopTime

startTime

private long startTime
Constructor Detail

Alpha

public Alpha()
Constructs an Alpha object with default parameters. The default values are as follows:


Alpha

public Alpha(int loopCount,
             int mode,
             long triggerTime,
             long phaseDelayDuration,
             long increasingAlphaDuration,
             long increasingAlphaRampDuration,
             long alphaAtOneDuration,
             long decreasingAlphaDuration,
             long decreasingAlphaRampDuration,
             long alphaAtZeroDuration)
This constructor takes all of the Alpha user-definable parameters.

Parameters:
loopCount - number of times to run this alpha; a value of -1 specifies that the alpha loops indefinitely
mode - indicates whether the increasing alpha parameters or the decreasing alpha parameters or both are active. This parameter accepts the following values, INCREASING_ENABLE or DECREASING_ENABLE, which may be ORed together to specify that both are active. The increasing alpha parameters are increasingAlphaDuration, increasingAlphaRampDuration, and alphaAtOneDuration. The decreasing alpha parameters are decreasingAlphaDuration, decreasingAlphaRampDuration, and alphaAtZeroDuration.
triggerTime - time in milliseconds since the start time that this object first triggers
phaseDelayDuration - number of milliseconds to wait after triggerTime before actually starting this alpha
increasingAlphaDuration - period of time during which alpha goes from zero to one
increasingAlphaRampDuration - period of time during which the alpha step size increases at the beginning of the increasingAlphaDuration and, correspondingly, decreases at the end of the increasingAlphaDuration. This value is clamped to half of increasingAlphaDuration. NOTE: a value of zero means that the alpha step size remains constant during the entire increasingAlphaDuration.
alphaAtOneDuration - period of time that alpha stays at one
decreasingAlphaDuration - period of time during which alpha goes from one to zero
decreasingAlphaRampDuration - period of time during which the alpha step size increases at the beginning of the decreasingAlphaDuration and, correspondingly, decreases at the end of the decreasingAlphaDuration. This value is clamped to half of decreasingAlphaDuration. NOTE: a value of zero means that the alpha step size remains constant during the entire decreasingAlphaDuration.
alphaAtZeroDuration - period of time that alpha stays at zero

Alpha

public Alpha(int loopCount,
             long triggerTime,
             long phaseDelayDuration,
             long increasingAlphaDuration,
             long increasingAlphaRampDuration,
             long alphaAtOneDuration)
Constructs a new Alpha object that assumes that the mode is INCREASING_ENABLE.

Parameters:
loopCount - number of times to run this alpha; a value of -1 specifies that the alpha loops indefinitely.
triggerTime - time in milliseconds since the start time that this object first triggers
phaseDelayDuration - number of milliseconds to wait after triggerTime before actually starting this alpha
increasingAlphaDuration - period of time during which alpha goes from zero to one
increasingAlphaRampDuration - period of time during which the alpha step size increases at the beginning of the increasingAlphaDuration and, correspondingly, decreases at the end of the increasingAlphaDuration. This value is clamped to half of increasingAlphaDuration. NOTE: a value of zero means that the alpha step size remains constant during the entire increasingAlphaDuration.
alphaAtOneDuration - period of time that alpha stays at one

Alpha

public Alpha(int loopCount,
             long increasingAlphaDuration)
This constructor takes only the loopCount and increasingAlphaDuration as parameters and assigns the default values to all of the other parameters.

Parameters:
loopCount - number of times to run this alpha; a value of -1 specifies that the alpha loops indefinitely
increasingAlphaDuration - period of time during which alpha goes from zero to one
Method Detail

pause

public void pause()
Pauses this alpha object. The current system time when this method is called will be used in place of the actual current time when calculating subsequent alpha values. This has the effect of freezing the interpolator at the time the method is called.

Since:
Java 3D 1.3

pause

public void pause(long time)
Pauses this alpha object as of the specified time. The specified time will be used in place of the actual current time when calculating subsequent alpha values. This has the effect of freezing the interpolator at the specified time. Note that specifying a time in the future (that is, a time greater than System.currentTimeMillis()) will cause the alpha to immediately advance to that point before pausing. Similarly, specifying a time in the past (that is, a time less than System.currentTimeMillis()) will cause the alpha to immediately revert to that point before pausing.

Parameters:
time - the time at which to pause the alpha
Throws:
java.lang.IllegalArgumentException - if time <= 0
Since:
Java 3D 1.3

resume

public void resume()
Resumes this alpha object. If the alpha object was paused, the difference between the current time and the pause time will be used to adjust the startTime of this alpha. The equation is as follows: Since the alpha object is no longer paused, this has the effect of resuming the interpolator as of the current time. If the alpha object is not paused when this method is called, then this method does nothing--the start time is not adjusted in this case.

Since:
Java 3D 1.3

resume

public void resume(long time)
Resumes this alpha object as of the specified time. If the alpha object was paused, the difference between the specified time and the pause time will be used to adjust the startTime of this alpha. The equation is as follows: Since the alpha object is no longer paused, this has the effect of resuming the interpolator as of the specified time. If the alpha object is not paused when this method is called, then this method does nothing--the start time is not adjusted in this case.

Parameters:
time - the time at which to resume the alpha
Throws:
java.lang.IllegalArgumentException - if time <= 0
Since:
Java 3D 1.3

isPaused

public boolean isPaused()
Returns true if this alpha object is paused.

Returns:
true if this alpha object is paused, false otherwise
Since:
Java 3D 1.3

getPauseTime

public long getPauseTime()
Returns the time at which this alpha was paused.

Returns:
the pause time; returns 0 if this alpha is not paused
Since:
Java 3D 1.3

value

public float value()
This method returns a value between 0.0 and 1.0 inclusive, based on the current time and the time-to-alpha parameters established for this alpha. If this alpha object is paused, the value will be based on the pause time rather than the current time. This method will return the starting alpha value if the alpha has not yet started (that is, if the current time is less than startTime + triggerTime + phaseDelayDuration). This method will return the ending alpha value if the alpha has finished (that is, if the loop count has expired).

Returns:
a value between 0.0 and 1.0 based on the current time

value

public float value(long atTime)
This method returns a value between 0.0 and 1.0 inclusive, based on the specified time and the time-to-alpha parameters established for this alpha. This method will return the starting alpha value if the alpha has not yet started (that is, if the specified time is less than startTime + triggerTime + phaseDelayDuration). This method will return the ending alpha value if the alpha has finished (that is, if the loop count has expired).

Parameters:
atTime - The time for which we wish to compute alpha
Returns:
a value between 0.0 and 1.0 based on the specified time

mfmod

float mfmod(float a,
            float b)

getStartTime

public long getStartTime()
Retrieves this alpha's startTime, the base for all relative time specifications; the default value for startTime is the system start time.

Returns:
this alpha's startTime.

setStartTime

public void setStartTime(long startTime)
Sets this alpha's startTime to that specified in the argument; startTime sets the base (or zero) for all relative time computations; the default value for startTime is the system start time.

Parameters:
startTime - the new startTime value

getLoopCount

public int getLoopCount()
Retrieves this alpha's loopCount.

Returns:
this alpha's loopCount.

setLoopCount

public void setLoopCount(int loopCount)
Set this alpha's loopCount to that specified in the argument.

Parameters:
loopCount - the new loopCount value

getMode

public int getMode()
Retrieves this alpha's mode.

Returns:
this alpha's mode: any combination of INCREASING_ENABLE and DECREASING_ENABLE

setMode

public void setMode(int mode)
Set this alpha's mode to that specified in the argument.

Parameters:
mode - indicates whether the increasing alpha parameters or the decreasing alpha parameters or both are active. This parameter accepts the following values, INCREASING_ENABLE or DECREASING_ENABLE, which may be ORed together to specify that both are active. The increasing alpha parameters are increasingAlphaDuration, increasingAlphaRampDuration, and alphaAtOneDuration. The decreasing alpha parameters are decreasingAlphaDuration, decreasingAlphaRampDuration, and alphaAtZeroDuration.

getTriggerTime

public long getTriggerTime()
Retrieves this alpha's triggerTime.

Returns:
this alpha's triggerTime.

setTriggerTime

public void setTriggerTime(long triggerTime)
Set this alpha's triggerTime to that specified in the argument.

Parameters:
triggerTime - the new triggerTime

getPhaseDelayDuration

public long getPhaseDelayDuration()
Retrieves this alpha's phaseDelayDuration.

Returns:
this alpha's phaseDelayDuration.

setPhaseDelayDuration

public void setPhaseDelayDuration(long phaseDelayDuration)
Set this alpha's phaseDelayDuration to that specified in the argument.

Parameters:
phaseDelayDuration - the new phaseDelayDuration

getIncreasingAlphaDuration

public long getIncreasingAlphaDuration()
Retrieves this alpha's increasingAlphaDuration.

Returns:
this alpha's increasingAlphaDuration.

setIncreasingAlphaDuration

public void setIncreasingAlphaDuration(long increasingAlphaDuration)
Set this alpha's increasingAlphaDuration to that specified in the argument.

Parameters:
increasingAlphaDuration - the new increasingAlphaDuration

getIncreasingAlphaRampDuration

public long getIncreasingAlphaRampDuration()
Retrieves this alpha's increasingAlphaRampDuration.

Returns:
this alpha's increasingAlphaRampDuration.

setIncreasingAlphaRampDuration

public void setIncreasingAlphaRampDuration(long increasingAlphaRampDuration)
Set this alpha's increasingAlphaRampDuration to that specified in the argument.

Parameters:
increasingAlphaRampDuration - the new increasingAlphaRampDuration

getAlphaAtOneDuration

public long getAlphaAtOneDuration()
Retrieves this alpha's alphaAtOneDuration.

Returns:
this alpha's alphaAtOneDuration.

setAlphaAtOneDuration

public void setAlphaAtOneDuration(long alphaAtOneDuration)
Set this alpha object's alphaAtOneDuration to the specified value.

Parameters:
alphaAtOneDuration - the new alphaAtOneDuration

getDecreasingAlphaDuration

public long getDecreasingAlphaDuration()
Retrieves this alpha's decreasingAlphaDuration.

Returns:
this alpha's decreasingAlphaDuration.

setDecreasingAlphaDuration

public void setDecreasingAlphaDuration(long decreasingAlphaDuration)
Set this alpha's decreasingAlphaDuration to that specified in the argument.

Parameters:
decreasingAlphaDuration - the new decreasingAlphaDuration

getDecreasingAlphaRampDuration

public long getDecreasingAlphaRampDuration()
Retrieves this alpha's decreasingAlphaRampDuration.

Returns:
this alpha's decreasingAlphaRampDuration.

setDecreasingAlphaRampDuration

public void setDecreasingAlphaRampDuration(long decreasingAlphaRampDuration)
Set this alpha's decreasingAlphaRampDuration to that specified in the argument.

Parameters:
decreasingAlphaRampDuration - the new decreasingAlphaRampDuration

getAlphaAtZeroDuration

public long getAlphaAtZeroDuration()
Retrieves this alpha's alphaAtZeroDuration.

Returns:
this alpha's alphaAtZeroDuration.

setAlphaAtZeroDuration

public void setAlphaAtZeroDuration(long alphaAtZeroDuration)
Set this alpha object's alphaAtZeroDuration to the specified value.

Parameters:
alphaAtZeroDuration - the new alphaAtZeroDuration

finished

public boolean finished()
Query to test if this alpha object is past its activity window, that is, if it has finished looping.

Returns:
true if no longer looping, false otherwise

computeStopTime

private final void computeStopTime()

cloneAlpha

Alpha cloneAlpha()
This internal method returns a clone of the Alpha

Returns:
a duplicate of this Alpha


Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.