import javax.media.j3d.*;

public class AlphaTest
{
  static public void main(String[] args)
  {
    // Create a simple up-ramp, 2 seconds.
    Alpha a = new Alpha(1, 2000);
    doPrint(a, "INCREASING");

    // Change the alpha to a down-ramp, lasting
    // 1.5 seconds.  This does not work without
    // using the WORKAROUND.
    a.setDecreasingAlphaDuration(1500);
    a.setMode(Alpha.DECREASING_ENABLE);
//    a.setIncreasingAlphaDuration(0);  // WORKAROUND
    a.setStartTime(System.currentTimeMillis());
    doPrint(a, "DECREASING");
  }

  // Print the value of the alpha until it has completed.
  static private void doPrint(Alpha a, String s)
  {
    long start_time = a.getStartTime();
    System.out.println("*********************************");
    System.out.println(s);
    System.out.println("*********************************");
    float lastval=-1f, curval=-1f;
    while (!a.finished() || (curval!=0f && curval!=1f) )
    {
      curval = a.value();
      if ( curval != lastval )
      {
        long time= System.currentTimeMillis() - start_time;
        System.out.println("time= " + time + "  alpha= " + curval );
      }
      lastval = curval;
    }
  }

}

