home *** CD-ROM | disk | FTP | other *** search
/ Internet 1996 World Exposition / park.org.s3.amazonaws.com.7z / park.org.s3.amazonaws.com / Japan / NTT / DM- / hotjava / classes / src / Title.java < prev   
Encoding:
Java Source  |  2017-09-21  |  3.4 KB  |  133 lines

  1. /*
  2.  *     [ Title ] alpha 3
  3.  *          Y.Amemoto
  4.  *          Create 1995/12/03
  5.  *
  6.  */
  7.  
  8. import java.io.InputStream;
  9. import java.lang.Integer;
  10. import awt.*;
  11. import browser.*;
  12. import net.www.html.*;
  13.  
  14. public class Title extends Applet implements Runnable {
  15.     String dir;
  16.     Thread kicker = null;
  17.     int pause, move, bgcolor;
  18.     int width, height;
  19.     Image    im;
  20.     Image    img;
  21.     Graphics    offscreen;
  22.     int y, x;
  23.     int imwidth, imheight;
  24.  
  25.     public void init() {
  26.     String at;
  27.         dir = getAttribute("img");
  28.         if (dir == null) dir = "images/title.gif";
  29.         img = getImage(dir);
  30.         imwidth = img.width;
  31.         imheight = img.height;
  32.  
  33.     at = getAttribute("pause");
  34.         if (at == null) pause = 100;
  35.         else            pause = Integer.valueOf(at).intValue();
  36.  
  37.     at = getAttribute("width");
  38.         if (at == null) width = 450;
  39.         else            width = Integer.valueOf(at).intValue();
  40.  
  41.     at = getAttribute("height");
  42.         if (at == null) height = 100;
  43.         else            height = Integer.valueOf(at).intValue();
  44.         resize(width, height);
  45.  
  46.     at = getAttribute("move");
  47.         if (at == null) {
  48.             move = 5;
  49.         }
  50.         else {
  51.             move = Integer.valueOf(at).intValue();
  52.             if (move < 1 || move > 50) {
  53.                 move = 5;
  54.             }
  55.         }
  56.  
  57.     at = getAttribute("bgcolor");
  58.         if (at == null) {
  59.             bgcolor = 1;
  60.         }
  61.         else {
  62.             bgcolor = Integer.valueOf(at).intValue();
  63.             if (bgcolor < 0 || bgcolor > 12){
  64.                 bgcolor = 1;
  65.             }
  66.         }
  67.  
  68.         im = createImage(width, height);
  69.         offscreen = new Graphics(im);
  70.         switch (bgcolor) {
  71.             case 0: offscreen.setForeground(Color.white);
  72.                     break;
  73.             case 1: offscreen.setForeground(Color.lightGray);
  74.                     break;
  75.             case 2: offscreen.setForeground(Color.gray);
  76.                     break;
  77.             case 3: offscreen.setForeground(Color.darkGray);
  78.                     break;
  79.             case 4: offscreen.setForeground(Color.black);
  80.                     break;
  81.             case 5: offscreen.setForeground(Color.red);
  82.                     break;
  83.             case 6: offscreen.setForeground(Color.pink);
  84.                     break;
  85.             case 7: offscreen.setForeground(Color.orange);
  86.                     break;
  87.             case 8: offscreen.setForeground(Color.yellow);
  88.                     break;
  89.             case 9: offscreen.setForeground(Color.green);
  90.                     break;
  91.             case 10: offscreen.setForeground(Color.magenta);
  92.                     break;
  93.             case 11: offscreen.setForeground(Color.cyan);
  94.                     break;
  95.             case 12: offscreen.setForeground(Color.blue);
  96.                     break;
  97.         }
  98.     }
  99.  
  100.     public void run() {
  101.     Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
  102.  
  103.         while (kicker != null) {
  104.             x = imwidth;
  105.             while ( x > -imwidth){
  106.                 x -= move;
  107.                 repaint();
  108.                 Thread.sleep(pause);
  109.             }
  110.     }
  111.     }
  112.  
  113.     public void paint(Graphics g) {
  114.     update(g);
  115.     }
  116.     public void update(Graphics g) {
  117.         offscreen.fillRect(0, 0, width, height);
  118.         offscreen.drawImage(img, x, y);
  119.         g.drawImage(im, 0, 0);
  120.     }
  121.  
  122.     public void start() {
  123.     if (kicker == null) {
  124.         kicker = new Thread(this);
  125.         kicker.start();
  126.     }
  127.     }
  128.  
  129.     public void stop() {
  130.     kicker = null;
  131.     }
  132. }
  133.