edu.uiuc.cs397rhc.sound
Class FadeHelper

java.lang.Object
  extended by edu.uiuc.cs397rhc.sound.FadeHelper

public class FadeHelper
extends java.lang.Object

FadeHelper is a encapsulation of a general fading procedure that can be applied to any Fadeable object. To do so, it keeps track of a local multiplier which it expects will be respected by the Fadeable object when updateVolume() is called.

Author:
Pedro DeRose

Constructor Summary
FadeHelper(Fadeable fadeable)
          Creates a new FadeHelper that can be used to fade the volume on the given Fadeable.
 
Method Summary
 void fade(double targetMultiplier)
          Fade from the current multiplier to the target multiplier, over Fadeable's default duration and with Fadeable's default interval between volume changes.
 void fade(double targetMultiplier, long duration)
          Fade from the current multiplier to the target multiplier, over the given duration and with Fadeable's default interval between volume changes.
 void fade(double targetMultiplier, long duration, int steps)
          Fade from the current multiplier to the target multiplier, over the given duration and in the given number of steps.
 double getFadeMultiplier()
          Returns the current multiplier kept by this FadeHelper.
 boolean isFading()
          Whether a fade is in progress.
 void setFadeMultiplier(double multiplier)
          Sets the current multiplier kept by this FadeHelper.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FadeHelper

public FadeHelper(Fadeable fadeable)
Creates a new FadeHelper that can be used to fade the volume on the given Fadeable.

Parameters:
fadeable - the object whose volume is to be faded
Method Detail

getFadeMultiplier

public double getFadeMultiplier()
Returns the current multiplier kept by this FadeHelper. Fading only works if the Fadeable object respects this multiplier when updateVolume() is called.

Returns:
the current multiplier

setFadeMultiplier

public void setFadeMultiplier(double multiplier)
Sets the current multiplier kept by this FadeHelper. Fading only works if the Fadeable object respects this multiplier when updateVolume() is called.

Parameters:
multiplier - the new multiplier

isFading

public boolean isFading()
Whether a fade is in progress.

Returns:
true if a fade is in progress, false otherwise

fade

public void fade(double targetMultiplier)
Fade from the current multiplier to the target multiplier, over Fadeable's default duration and with Fadeable's default interval between volume changes. Fading is done by modifying the local multiplier, then calling the Fadeable object's updateVolume(), which is expected to respect the local multiplier.

Parameters:
targetMultiplier - the target multiplier after the fade

fade

public void fade(double targetMultiplier,
                 long duration)
Fade from the current multiplier to the target multiplier, over the given duration and with Fadeable's default interval between volume changes. Fading is done by modifying the local multiplier, then calling the Fadeable object's updateVolume(), which is expected to respect the local multiplier.

Parameters:
targetMultiplier - the target multiplier after the fade
duration - the duration of the fade in milliseconds

fade

public void fade(double targetMultiplier,
                 long duration,
                 int steps)
Fade from the current multiplier to the target multiplier, over the given duration and in the given number of steps. Fading is done by modifying the local multiplier, then calling the Fadeable object's updateVolume(), which is expected to respect the local multiplier.

Parameters:
targetMultiplier - the target multiplier after the fade
duration - the duration of the fade in milliseconds
steps - the number of volume changes during the fade