home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 14 / IOPROG_14.ISO / soft / sdkjava / dxma.exe / DXMA05.cab / samples / da / java / exercises / HelloCycle / HelloCycle.java next >
Encoding:
Java Source  |  1997-11-13  |  1.4 KB  |  44 lines

  1. //
  2. // This applet displays a hello message on a blue background,
  3. // with a color that cycles between time varying and red upon 
  4. // left button events.
  5. //
  6. // Copyright (c) 1997 Microsoft Corporation
  7.  
  8. import com.ms.dxmedia.*;
  9.  
  10. // The createModel method in this class
  11. // is where you construct your animation.
  12. class HelloCycleModel extends Model {
  13.  
  14.   // The mode is a hello message with a time varying
  15.   // color over a solid blue background.
  16.   public void createModel(BvrsToRun blist)
  17.   {
  18.     // construct a color in the HSL space with a time varying hue
  19.     ColorBvr textBvrClr = colorHsl(localTime, toBvr(0.5), toBvr(0.5));
  20.  
  21.     // construct a cyclic behavior that goes from time varying
  22.     // to red and back upon left button presses.
  23.     ColorBvr textClr = ColorBvr.newUninitBvr();
  24.     textClr.init(until(textBvrClr, leftButtonDown, 
  25.       until(red, leftButtonDown, textClr)));
  26.  
  27.     // apply the color to the font.
  28.     FontStyleBvr fs = defaultFont.color(textClr);
  29.       
  30.     ImageBvr helloImg = stringImage(toBvr("Hello, World"), fs);
  31.  
  32.     ImageBvr backImg = solidColorImage(blue);
  33.     
  34.     setImage(overlay(helloImg, backImg));
  35.   }
  36. }
  37.  
  38. // The model you set in this class is the model that will be displayed.
  39. public class HelloCycle extends DXMApplet {
  40.   public void init() {
  41.     super.init() ;
  42.     setModel(new HelloCycleModel());
  43.   }
  44. }