home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1998 October / DPPCPRO1098.ISO / Hotdog / files / snagpack.exe / WAVY.CLASS (.txt) < prev    next >
Encoding:
Java Class File  |  1997-11-21  |  5.1 KB  |  254 lines

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Event;
  5. import java.awt.FontMetrics;
  6. import java.awt.Graphics;
  7. import java.awt.Image;
  8.  
  9. public class wavy extends Applet implements Runnable {
  10.    private Thread engineThread;
  11.    private String lbl;
  12.    private char[] label;
  13.    private int stringLen;
  14.    private int count;
  15.    private int loop;
  16.    private int speed;
  17.    private int sleepTime;
  18.    private int jumpheight;
  19.    private myFont font;
  20.    private boolean userPause;
  21.    private int bred;
  22.    private int bgreen;
  23.    private int bblue;
  24.    private int fred;
  25.    private int fgreen;
  26.    private int fblue;
  27.    private int red = 255;
  28.    private int blue;
  29.    private int green;
  30.    private int fade;
  31.    private int jump_char;
  32.    private int char_up = -1;
  33.    private int movey;
  34.    private boolean doneMove;
  35.    private boolean yUp = true;
  36.    private boolean goingUp = true;
  37.    private boolean stayDown;
  38.    private boolean readyToPaint;
  39.    private boolean popcorn;
  40.    private int height;
  41.    // $FF: renamed from: x int
  42.    private int field_0;
  43.    // $FF: renamed from: y int
  44.    private int field_1;
  45.    private int org_y;
  46.    // $FF: renamed from: fm java.awt.FontMetrics
  47.    private FontMetrics field_2;
  48.    private Image offImage;
  49.    private Graphics offGraphics;
  50.    private boolean matched;
  51.    private boolean unreg = true;
  52.    private boolean debug;
  53.  
  54.    public void stop() {
  55.       if (this.engineThread != null && this.engineThread.isAlive()) {
  56.          this.engineThread.stop();
  57.       }
  58.  
  59.       this.engineThread = null;
  60.    }
  61.  
  62.    private void prePaint(Graphics var1) {
  63.       var1.setColor(new Color(this.bred, this.bgreen, this.bblue));
  64.       var1.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
  65.       var1.setColor(new Color(this.red, this.green, this.blue));
  66.       var1.setFont(this.font);
  67.       this.field_2 = var1.getFontMetrics();
  68.       this.field_0 = ((Component)this).size().width / 2 - this.field_2.stringWidth(this.lbl) / 2;
  69.  
  70.       for(int var2 = 0; var2 < this.stringLen; ++var2) {
  71.          var1.drawChars(this.label, var2, 1, this.field_0, this.movey);
  72.          this.field_0 += this.field_2.charWidth(this.label[var2]);
  73.          if (this.yUp) {
  74.             this.movey -= this.speed;
  75.          } else {
  76.             this.movey += this.speed;
  77.          }
  78.  
  79.          if (this.movey < this.height) {
  80.             this.yUp = false;
  81.          } else if (this.movey > this.org_y) {
  82.             this.movey = this.org_y;
  83.             this.yUp = true;
  84.          }
  85.       }
  86.  
  87.    }
  88.  
  89.    private void xyUpdate() {
  90.       this.movey = this.field_1;
  91.       if (this.goingUp) {
  92.          this.field_1 -= this.speed;
  93.       } else {
  94.          this.field_1 += this.speed;
  95.       }
  96.  
  97.       if (this.field_1 < this.height) {
  98.          this.goingUp = false;
  99.       } else if (this.field_1 > this.org_y) {
  100.          this.goingUp = true;
  101.          this.field_1 = this.org_y;
  102.       }
  103.  
  104.       this.yUp = this.goingUp;
  105.    }
  106.  
  107.    public void paint(Graphics var1) {
  108.       if (this.offGraphics != null) {
  109.          this.prePaint(this.offGraphics);
  110.          var1.drawImage(this.offImage, 0, 0, this);
  111.       } else {
  112.          this.prePaint(var1);
  113.       }
  114.  
  115.    }
  116.  
  117.    private void dbg(String var1) {
  118.       if (this.debug) {
  119.          System.out.println(var1);
  120.       }
  121.  
  122.    }
  123.  
  124.    public void update(Graphics var1) {
  125.       if (this.readyToPaint) {
  126.          this.paint(var1);
  127.       }
  128.  
  129.    }
  130.  
  131.    public void start() {
  132.       if (this.engineThread == null) {
  133.          this.engineThread = new Thread(this);
  134.       }
  135.  
  136.       this.engineThread.start();
  137.    }
  138.  
  139.    public String getAppletInfo() {
  140.       return "Swami - wavy.class v1.0 Copyright (c) Sausage SoftWare 1996";
  141.    }
  142.  
  143.    public void run() {
  144.       Thread.currentThread().setPriority(1);
  145.  
  146.       while(true) {
  147.          if (this.unreg) {
  148.             ((Applet)this).getAppletContext().showStatus("Unregistered version. Copyright (c) Sausage Software 1996");
  149.          }
  150.  
  151.          ((Component)this).repaint();
  152.  
  153.          try {
  154.             Thread.sleep((long)this.sleepTime);
  155.          } catch (Exception var1) {
  156.          }
  157.  
  158.          this.readyToPaint = false;
  159.          this.xyUpdate();
  160.          this.readyToPaint = true;
  161.       }
  162.    }
  163.  
  164.    public void init() {
  165.       String var1 = ((Applet)this).getParameter("fontsize");
  166.       int var2 = var1 == null ? 12 : Integer.valueOf(var1);
  167.       int var3 = 0;
  168.       var1 = ((Applet)this).getParameter("style");
  169.       var3 = myFont.getFontStyle(var1);
  170.       var1 = ((Applet)this).getParameter("font");
  171.       String var4 = myFont.getFontName(var1);
  172.       this.dbg(var4);
  173.       this.font = new myFont(var4, var3, var2);
  174.       var1 = ((Applet)this).getParameter("text");
  175.       this.lbl = var1 == null ? "Sausage Software" : var1;
  176.       this.label = this.lbl.toCharArray();
  177.       this.stringLen = this.lbl.length();
  178.       String var5 = ((Applet)this).getParameter("reguser");
  179.       if (var5 == null) {
  180.          ver.NotRegistered();
  181.       }
  182.  
  183.       if (var5.toLowerCase().equals("unregistered")) {
  184.          this.unreg = true;
  185.       } else {
  186.          this.unreg = false;
  187.       }
  188.  
  189.       String var6 = ((Applet)this).getParameter("serialid");
  190.       if (var6 == null) {
  191.          ver.NotRegistered();
  192.       }
  193.  
  194.       ver var7 = new ver(var5, var6);
  195.       this.matched = var7.verifyUser(this.lbl);
  196.       if (!this.matched) {
  197.          ver.NotRegistered();
  198.       }
  199.  
  200.       var1 = ((Applet)this).getParameter("vertical");
  201.       this.speed = var1 == null ? 5 : Integer.parseInt(var1);
  202.       var1 = ((Applet)this).getParameter("jumpheight");
  203.       this.jumpheight = var1 == null ? this.speed * 3 : Integer.parseInt(var1);
  204.       var1 = ((Applet)this).getParameter("color");
  205.       if (var1 != null) {
  206.          createColor var8 = new createColor(var1, ",");
  207.          var8.getColor();
  208.          this.red = var8.getRed();
  209.          this.green = var8.getGreen();
  210.          this.blue = var8.getBlue();
  211.       }
  212.  
  213.       var1 = ((Applet)this).getParameter("background");
  214.       if (var1 != null) {
  215.          createColor var19 = new createColor(var1, ",");
  216.          var19.getColor();
  217.          this.bred = var19.getRed();
  218.          this.bgreen = var19.getGreen();
  219.          this.bblue = var19.getBlue();
  220.       }
  221.  
  222.       var1 = ((Applet)this).getParameter("speed");
  223.       this.sleepTime = var1 == null ? 0 : Integer.parseInt(var1);
  224.  
  225.       try {
  226.          this.offImage = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
  227.          this.offGraphics = this.offImage.getGraphics();
  228.       } catch (Exception var9) {
  229.          this.offGraphics = null;
  230.       }
  231.  
  232.       this.field_1 = ((Component)this).size().height / 2 + var2 / 2;
  233.       this.movey = this.org_y = this.field_1;
  234.       this.height = this.field_1 - this.jumpheight;
  235.    }
  236.  
  237.    public boolean handleEvent(Event var1) {
  238.       if (var1.id == 501) {
  239.          if (this.userPause) {
  240.             this.engineThread.resume();
  241.          } else {
  242.             this.engineThread.suspend();
  243.          }
  244.  
  245.          this.userPause = !this.userPause;
  246.       } else if (var1.id == 201) {
  247.          this.stop();
  248.          System.exit(0);
  249.       }
  250.  
  251.       return true;
  252.    }
  253. }
  254.