home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1996 October / PCO_10.ISO / filesbbs / liquid.arj / ZINGBARS.CL_ / ZINGBARS.CL (.txt)
Encoding:
Java Class File  |  1996-06-04  |  5.5 KB  |  356 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.Graphics;
  6. import java.awt.Image;
  7.  
  8. public class ZingBars extends Applet implements Runnable {
  9.    int direction;
  10.    float xpos;
  11.    float ypos;
  12.    int curr_dir;
  13.    // $FF: renamed from: dx int
  14.    int field_0;
  15.    // $FF: renamed from: dy int
  16.    int field_1;
  17.    // $FF: renamed from: x1 float
  18.    float field_2;
  19.    // $FF: renamed from: y1 float
  20.    float field_3;
  21.    // $FF: renamed from: x2 float
  22.    float field_4;
  23.    // $FF: renamed from: y2 float
  24.    float field_5;
  25.    int realLength;
  26.    int realHeight;
  27.    int col_select;
  28.    int width = 400;
  29.    int height = 40;
  30.    float velocity = 5.0F;
  31.    int fontstyle;
  32.    boolean suspended = false;
  33.    int bar_width = 10;
  34.    Color color;
  35.    Color forecolour;
  36.    Color backcolour;
  37.    Thread killme;
  38.    Image barimage;
  39.    int interval = 10;
  40.    Image offscreen;
  41.    Graphics barGraphics;
  42.    Graphics offscreenG;
  43.  
  44.    public void init() {
  45.       String var1 = ((Applet)this).getParameter("direction");
  46.       this.direction = var1 != null ? Integer.parseInt(var1) : 0;
  47.       var1 = ((Applet)this).getParameter("barwidth");
  48.       this.bar_width = var1 != null ? Integer.parseInt(var1) : 10;
  49.       var1 = ((Applet)this).getParameter("copyright");
  50.       if (var1 == null) {
  51.          System.exit(1);
  52.       } else if (var1.compareTo("LiquidFx") > 0) {
  53.          System.exit(1);
  54.       }
  55.  
  56.       var1 = ((Applet)this).getParameter("width");
  57.       this.width = var1 != null ? Integer.parseInt(var1) : 400;
  58.       var1 = ((Applet)this).getParameter("height");
  59.       this.height = var1 != null ? Integer.parseInt(var1) : 40;
  60.       var1 = ((Applet)this).getParameter("colselect");
  61.       this.col_select = var1 != null ? Integer.parseInt(var1) : 0;
  62.       if (this.col_select > 6) {
  63.          this.col_select = 6;
  64.       }
  65.  
  66.       var1 = ((Applet)this).getParameter("velocity");
  67.       this.velocity = (float)(var1 != null ? Integer.parseInt(var1) : 1);
  68.       this.interval = 20;
  69.       this.velocity /= (float)(1000 / this.interval);
  70.       var1 = ((Applet)this).getParameter("forecolour");
  71.       int var2 = var1 != null ? Integer.parseInt(var1) : 255;
  72.       int var3 = var2 & 255;
  73.       int var4 = (var2 & '\uff00') >> 8;
  74.       int var5 = (var2 & 16711680) >>> 16;
  75.       this.forecolour = new Color(221, 0, 0);
  76.       var1 = ((Applet)this).getParameter("backcolour");
  77.       var2 = var1 != null ? Integer.parseInt(var1) : 255;
  78.       var3 = var2 & 255;
  79.       var4 = (var2 & '\uff00') >> 8;
  80.       var5 = (var2 & 16711680) >>> 16;
  81.       this.backcolour = new Color(var3, var4, var5);
  82.       if (this.direction == 1) {
  83.          this.field_0 = ((Component)this).size().width;
  84.          this.field_1 = this.bar_width;
  85.       } else {
  86.          this.field_1 = ((Component)this).size().height;
  87.          this.field_0 = this.bar_width;
  88.       }
  89.  
  90.       this.barimage = ((Component)this).createImage(this.field_0, this.field_1);
  91.       this.barGraphics = this.barimage.getGraphics();
  92.       this.paint_bar(this.barGraphics);
  93.       this.offscreen = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
  94.       this.offscreenG = this.offscreen.getGraphics();
  95.    }
  96.  
  97.    public void paint(Graphics var1) {
  98.       this.update(var1);
  99.    }
  100.  
  101.    public void start() {
  102.       if (this.killme == null) {
  103.          this.killme = new Thread(this);
  104.          this.killme.start();
  105.       }
  106.  
  107.    }
  108.  
  109.    public void setcoord() {
  110.       if (this.direction == 1) {
  111.          this.field_2 = 0.0F;
  112.          this.field_4 = (float)this.width;
  113.          this.field_3 = this.ypos;
  114.          this.field_5 = this.ypos;
  115.          if (this.curr_dir == 0) {
  116.             this.ypos += this.velocity;
  117.             if (this.ypos + (float)this.bar_width >= (float)this.height) {
  118.                this.curr_dir = 1;
  119.                this.ypos = (float)(this.height - this.bar_width);
  120.                return;
  121.             }
  122.  
  123.             return;
  124.          }
  125.  
  126.          this.ypos -= this.velocity;
  127.          if (this.ypos <= 0.0F) {
  128.             this.curr_dir = 0;
  129.             this.ypos = 0.0F;
  130.             return;
  131.          }
  132.       } else {
  133.          this.field_3 = 0.0F;
  134.          this.field_5 = (float)this.height;
  135.          this.field_2 = this.xpos;
  136.          this.field_4 = this.xpos;
  137.          if (this.curr_dir == 0) {
  138.             this.xpos += this.velocity;
  139.             if (this.xpos + (float)this.bar_width >= (float)this.width) {
  140.                this.curr_dir = 1;
  141.                this.xpos = (float)(this.width - this.bar_width);
  142.                return;
  143.             }
  144.          } else {
  145.             this.xpos -= this.velocity;
  146.             if (this.xpos <= 0.0F) {
  147.                this.curr_dir = 0;
  148.                this.xpos = 0.0F;
  149.             }
  150.          }
  151.       }
  152.  
  153.    }
  154.  
  155.    public void run() {
  156.       while(this.killme != null) {
  157.          try {
  158.             Thread.sleep((long)this.interval);
  159.          } catch (InterruptedException var2) {
  160.          }
  161.  
  162.          this.setcoord();
  163.          Graphics var1 = ((Component)this).getGraphics();
  164.          this.paint(var1);
  165.          ((Component)this).repaint();
  166.       }
  167.  
  168.    }
  169.  
  170.    public synchronized void update(Graphics var1) {
  171.       this.offscreenG.setColor(this.backcolour);
  172.       this.offscreenG.fillRect(0, 0, this.width, this.height);
  173.       this.offscreenG.drawImage(this.barimage, (int)this.field_2, (int)this.field_3, this);
  174.       var1.drawImage(this.offscreen, 0, 0, this);
  175.    }
  176.  
  177.    public boolean handleEvent(Event var1) {
  178.       if (var1.id == 501) {
  179.          if (this.suspended) {
  180.             this.killme.resume();
  181.          } else {
  182.             this.killme.suspend();
  183.          }
  184.  
  185.          this.suspended = !this.suspended;
  186.       }
  187.  
  188.       return true;
  189.    }
  190.  
  191.    public void stop() {
  192.       if (this.killme != null) {
  193.          this.killme.stop();
  194.       }
  195.  
  196.       this.killme = null;
  197.    }
  198.  
  199.    public void paint_bar(Graphics var1) {
  200.       byte var2 = 100;
  201.       float var4 = (float)(255 - var2) / (float)this.bar_width;
  202.       int var5 = 0;
  203.       int var6 = 0;
  204.       int var7 = 0;
  205.       if (this.direction == 1) {
  206.          var1.setColor(this.backcolour);
  207.          var1.drawLine(0, 0, this.width, 0);
  208.          var1.setColor(this.backcolour);
  209.          var1.drawLine(0, this.bar_width - 1, this.width, this.bar_width - 1);
  210.  
  211.          for(int var9 = 1; var9 < this.bar_width / 2; ++var9) {
  212.             switch (this.col_select) {
  213.                case 0:
  214.                   var5 = (int)((float)var2 + (float)var9 * var4);
  215.                   break;
  216.                case 1:
  217.                   var6 = (int)((float)var2 + (float)var9 * var4);
  218.                   break;
  219.                case 2:
  220.                   var7 = (int)((float)var2 + (float)var9 * var4);
  221.                   break;
  222.                case 3:
  223.                   var5 = (int)((float)var2 + (float)var9 * var4);
  224.                   var6 = (int)((float)var2 + (float)var9 * var4);
  225.                   break;
  226.                case 4:
  227.                   var7 = (int)((float)var2 + (float)var9 * var4);
  228.                   var6 = (int)((float)var2 + (float)var9 * var4);
  229.                   break;
  230.                case 5:
  231.                   var7 = (int)((float)var2 + (float)var9 * var4);
  232.                   var5 = (int)((float)var2 + (float)var9 * var4);
  233.                   break;
  234.                case 6:
  235.                   var5 = (int)((float)var2 + (float)var9 * var4);
  236.                   var6 = (int)((float)var2 + (float)var9 * var4);
  237.                   var7 = (int)((float)var2 + (float)var9 * var4);
  238.             }
  239.  
  240.             this.color = new Color(var5, var6, var7);
  241.             var1.setColor(this.color);
  242.             var1.drawLine(0, var9, this.width, var9);
  243.          }
  244.  
  245.          for(int var10 = this.bar_width / 2; var10 < this.bar_width - 1; ++var10) {
  246.             switch (this.col_select) {
  247.                case 0:
  248.                   var5 = (int)(255.0F - (float)var10 * var4);
  249.                   break;
  250.                case 1:
  251.                   var6 = (int)(255.0F - (float)var10 * var4);
  252.                   break;
  253.                case 2:
  254.                   var7 = (int)(255.0F - (float)var10 * var4);
  255.                   break;
  256.                case 3:
  257.                   var5 = (int)(255.0F - (float)var10 * var4);
  258.                   var6 = (int)(255.0F - (float)var10 * var4);
  259.                   break;
  260.                case 4:
  261.                   var7 = (int)(255.0F - (float)var10 * var4);
  262.                   var6 = (int)(255.0F - (float)var10 * var4);
  263.                   break;
  264.                case 5:
  265.                   var7 = (int)(255.0F - (float)var10 * var4);
  266.                   var5 = (int)(255.0F - (float)var10 * var4);
  267.                   break;
  268.                case 6:
  269.                   var5 = (int)(255.0F - (float)var10 * var4);
  270.                   var6 = (int)(255.0F - (float)var10 * var4);
  271.                   var7 = (int)(255.0F - (float)var10 * var4);
  272.             }
  273.  
  274.             this.color = new Color(var5, var6, var7);
  275.             var1.setColor(this.color);
  276.             var1.drawLine(0, var10, this.width, var10);
  277.          }
  278.  
  279.       } else {
  280.          var1.setColor(this.backcolour);
  281.          var1.drawLine(0, 0, 0, this.height);
  282.          var1.setColor(this.backcolour);
  283.          var1.drawLine(this.bar_width - 1, 0, this.bar_width - 1, this.height);
  284.  
  285.          for(int var3 = 1; var3 < this.bar_width - 1; ++var3) {
  286.             switch (this.col_select) {
  287.                case 0:
  288.                   var5 = (int)((float)var2 + (float)var3 * var4);
  289.                   break;
  290.                case 1:
  291.                   var6 = (int)((float)var2 + (float)var3 * var4);
  292.                   break;
  293.                case 2:
  294.                   var7 = (int)((float)var2 + (float)var3 * var4);
  295.                   break;
  296.                case 3:
  297.                   var5 = (int)((float)var2 + (float)var3 * var4);
  298.                   var6 = (int)((float)var2 + (float)var3 * var4);
  299.                   break;
  300.                case 4:
  301.                   var7 = (int)((float)var2 + (float)var3 * var4);
  302.                   var6 = (int)((float)var2 + (float)var3 * var4);
  303.                   break;
  304.                case 5:
  305.                   var7 = (int)((float)var2 + (float)var3 * var4);
  306.                   var5 = (int)((float)var2 + (float)var3 * var4);
  307.                   break;
  308.                case 6:
  309.                   var5 = (int)((float)var2 + (float)var3 * var4);
  310.                   var6 = (int)((float)var2 + (float)var3 * var4);
  311.                   var7 = (int)((float)var2 + (float)var3 * var4);
  312.             }
  313.  
  314.             this.color = new Color(var5, var6, var7);
  315.             var1.setColor(this.color);
  316.             var1.drawLine(var3, 0, var3, this.height);
  317.          }
  318.  
  319.          for(int var8 = this.bar_width / 2; var8 < this.bar_width - 1; ++var8) {
  320.             switch (this.col_select) {
  321.                case 0:
  322.                   var5 = (int)(255.0F - (float)var8 * var4);
  323.                   break;
  324.                case 1:
  325.                   var6 = (int)(255.0F - (float)var8 * var4);
  326.                   break;
  327.                case 2:
  328.                   var7 = (int)(255.0F - (float)var8 * var4);
  329.                   break;
  330.                case 3:
  331.                   var5 = (int)(255.0F - (float)var8 * var4);
  332.                   var6 = (int)(255.0F - (float)var8 * var4);
  333.                   break;
  334.                case 4:
  335.                   var7 = (int)(255.0F - (float)var8 * var4);
  336.                   var6 = (int)(255.0F - (float)var8 * var4);
  337.                   break;
  338.                case 5:
  339.                   var7 = (int)(255.0F - (float)var8 * var4);
  340.                   var5 = (int)(255.0F - (float)var8 * var4);
  341.                   break;
  342.                case 6:
  343.                   var5 = (int)(255.0F - (float)var8 * var4);
  344.                   var6 = (int)(255.0F - (float)var8 * var4);
  345.                   var7 = (int)(255.0F - (float)var8 * var4);
  346.             }
  347.  
  348.             this.color = new Color(var5, var6, var7);
  349.             var1.setColor(this.color);
  350.             var1.drawLine(var8, 0, var8, this.height);
  351.          }
  352.  
  353.       }
  354.    }
  355. }
  356.