home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161b.iso / handson / archive / Issue153 / java / copyjava.exe / Boil.class (.txt) next >
Encoding:
Java Class File  |  1999-04-04  |  2.3 KB  |  87 lines

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Graphics;
  5. import java.awt.Image;
  6. import java.awt.MediaTracker;
  7.  
  8. public class Boil extends Applet implements Runnable {
  9.    Image origImg;
  10.    Image backImg;
  11.    // $FF: renamed from: w1 int
  12.    int field_0;
  13.    // $FF: renamed from: h1 int
  14.    int field_1;
  15.    Thread thrBoil;
  16.    private static final int SMUDGE_WIDTH = 40;
  17.    private static final int SMUDGE_HEIGHT = 40;
  18.  
  19.    public void start() {
  20.       if (this.thrBoil == null) {
  21.          this.thrBoil = new Thread(this);
  22.          this.thrBoil.start();
  23.       }
  24.  
  25.    }
  26.  
  27.    public void stop() {
  28.       if (this.thrBoil != null) {
  29.          this.thrBoil.stop();
  30.          this.thrBoil = null;
  31.       }
  32.  
  33.    }
  34.  
  35.    public void run() {
  36.       this.loadImage();
  37.       this.backImg = ((Component)this).createImage(this.field_0, this.field_1);
  38.       Graphics var3 = this.backImg.getGraphics();
  39.       var3.setColor(Color.white);
  40.       var3.drawImage(this.origImg, 0, 0, this);
  41.  
  42.       for(; this.thrBoil != null; ((Component)this).repaint()) {
  43.          int var1 = (int)(Math.random() * (double)this.field_0);
  44.          int var2 = (int)(Math.random() * (double)this.field_1);
  45.          this.smudge(var3, var1, var2);
  46.  
  47.          try {
  48.             Thread.sleep(50L);
  49.          } catch (InterruptedException var4) {
  50.          }
  51.       }
  52.  
  53.    }
  54.  
  55.    public void loadImage() {
  56.       MediaTracker var1 = new MediaTracker(this);
  57.       String var2 = ((Applet)this).getParameter("image");
  58.       this.origImg = ((Applet)this).getImage(((Applet)this).getDocumentBase(), var2);
  59.       var1.addImage(this.origImg, 0);
  60.  
  61.       try {
  62.          var1.waitForID(0);
  63.       } catch (InterruptedException var3) {
  64.       }
  65.  
  66.       this.field_0 = this.origImg.getWidth(this);
  67.       this.field_1 = this.origImg.getHeight(this);
  68.    }
  69.  
  70.    public void smudge(Graphics var1, int var2, int var3) {
  71.       int var4 = (int)(Math.random() * (double)40.0F / (double)10.0F) - 2;
  72.       int var5 = (int)(Math.random() * (double)40.0F / (double)10.0F) - 2;
  73.       var1.copyArea(var2, var3, 40, 40, var4, var5);
  74.    }
  75.  
  76.    public void update(Graphics var1) {
  77.       this.paint(var1);
  78.    }
  79.  
  80.    public void paint(Graphics var1) {
  81.       if (this.backImg != null) {
  82.          var1.drawImage(this.backImg, 0, 0, this);
  83.       }
  84.  
  85.    }
  86. }
  87.