home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 October / PCO1097.ISO / FilesBBS / FREI / ANI10.EXE / ANI.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-08-19  |  5.9 KB  |  266 lines

  1. import java.applet.Applet;
  2. import java.awt.BorderLayout;
  3. import java.awt.Color;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.awt.Font;
  7. import java.awt.Graphics;
  8. import java.awt.Image;
  9. import java.awt.image.ImageObserver;
  10. import java.net.URL;
  11.  
  12. public final class ANI extends Applet implements Runnable {
  13.    // $FF: renamed from: t java.lang.Thread
  14.    private Thread field_0;
  15.    private int gcCount;
  16.    public int iID = 1024;
  17.    public String agentScriptFile;
  18.    public ANIAgent agent;
  19.    public ANIAgentCanvas agCanvas;
  20.    public ANIStatus status;
  21.    private ANIStatusCanvas stCanvas;
  22.    public Color agentBgColor;
  23.    public Color statusBgColor;
  24.    public Color statusFadeColor;
  25.    public Color helpBgColor;
  26.    public Color helpBorderColor;
  27.    public Color helpTextColor;
  28.    public Font helpTextFont;
  29.    public int iScrollHeight;
  30.    public long lAgentReload;
  31.    public String helpImage;
  32.    public Image helpImg;
  33.    public int wHelpImg;
  34.    public int hHelpImg;
  35.    public boolean fLicense;
  36.    private String chars = new String(" ┬ºa\"b$c%d&e/f(g)h=i?j,k.l-m_n:o;p#q~r+s*t\\u|v<w>[0]123456789x{y}z ");
  37.  
  38.    public void stop() {
  39.       if (this.status != null) {
  40.          this.status.stop();
  41.          this.status = null;
  42.       }
  43.  
  44.       if (this.agent != null) {
  45.          this.agent.stop();
  46.          this.agent = null;
  47.       }
  48.  
  49.       if (this.field_0 != null) {
  50.          this.field_0.stop();
  51.          this.field_0 = null;
  52.       }
  53.  
  54.       System.gc();
  55.    }
  56.  
  57.    public final void wait(int var1) {
  58.       try {
  59.          Thread.sleep((long)var1);
  60.       } catch (InterruptedException var2) {
  61.       }
  62.    }
  63.  
  64.    public String[][] getParameterInfo() {
  65.       String[][] var1 = new String[][]{{"agentscript", "String", "name of agent script file"}, {"agentreloadinterval", "int", "Reload interval for agent script file loading"}, {"agentbackgroundcolor", "int,int,int", "RBG values of the agent area background color"}, {"statusbackgroundcolor", "int,int,int", "RBG values of the status area background color"}, {"statusfadeoutcolor", "int,int,int", "RBG values of the status area fade-out color"}, {"helpimage", "String", "URL or file name of help image"}, {"helpbackgroundcolor", "int,int,int", "RBG values of the help text background color"}, {"helpbordercolor", "int,int,int", "RBG values of the help image border color"}, {"helptextcolor", "int,int,int", "RBG values of the help text color"}};
  66.       return var1;
  67.    }
  68.  
  69.    public final void waitForImage(Image var1) {
  70.       boolean var2 = ((Component)this).prepareImage(var1, this);
  71.       if (!var2) {
  72.          while((((Component)this).checkImage(var1, this) & 224) == 0) {
  73.             this.wait(1);
  74.          }
  75.       }
  76.  
  77.    }
  78.  
  79.    public final Image ANICreateImage(int var1, int var2) {
  80.       Image var3 = ((Component)this).createImage(var1, var2);
  81.       this.waitForImage(var3);
  82.       return var3;
  83.    }
  84.  
  85.    public final void ANIDrawImage(Graphics var1, Image var2, int var3, int var4, ImageObserver var5) {
  86.       if (var2 != null) {
  87.          var1.drawImage(var2, var3, var4, var5);
  88.       }
  89.  
  90.    }
  91.  
  92.    public void start() {
  93.       if (this.field_0 == null) {
  94.          this.field_0 = new Thread(this);
  95.          this.field_0.start();
  96.       }
  97.  
  98.    }
  99.  
  100.    public String getAppletInfo() {
  101.       return "ANI.java, 1.0, (c) 1997 by Stefan Ruettinger";
  102.    }
  103.  
  104.    public void changeAgentScript(String var1) {
  105.       if (!var1.equals(this.agentScriptFile)) {
  106.          this.agent.changeScript(var1);
  107.       }
  108.  
  109.    }
  110.  
  111.    private final int getParameters() {
  112.       this.agentScriptFile = ((Applet)this).getParameter("agentscript");
  113.       this.helpImage = ((Applet)this).getParameter("helpImage");
  114.       String var1;
  115.       if ((var1 = ((Applet)this).getParameter("agentbackgroundcolor")) != null) {
  116.          this.agentBgColor = ANIScript.getColor("agentbackgroundcolor", var1);
  117.       } else {
  118.          this.agentBgColor = Color.white;
  119.       }
  120.  
  121.       if ((var1 = ((Applet)this).getParameter("statusbackgroundcolor")) != null) {
  122.          this.statusBgColor = ANIScript.getColor("statusbackgroundcolor", var1);
  123.       } else {
  124.          this.statusBgColor = new Color(204, 204, 204);
  125.       }
  126.  
  127.       if ((var1 = ((Applet)this).getParameter("statusfadeoutcolor")) != null) {
  128.          this.statusFadeColor = ANIScript.getColor("statusfadeoutcolor", var1);
  129.       } else {
  130.          this.statusFadeColor = new Color(238, 238, 238);
  131.       }
  132.  
  133.       if ((var1 = ((Applet)this).getParameter("helpbackgroundcolor")) != null) {
  134.          this.helpBgColor = ANIScript.getColor("helpbackgroundcolor", var1);
  135.       } else {
  136.          this.helpBgColor = new Color(255, 255, 204);
  137.       }
  138.  
  139.       if ((var1 = ((Applet)this).getParameter("helpbordercolor")) != null) {
  140.          this.helpBorderColor = ANIScript.getColor("helpbordercolor", var1);
  141.       } else {
  142.          this.helpBorderColor = new Color(170, 170, 170);
  143.       }
  144.  
  145.       if ((var1 = ((Applet)this).getParameter("helptextcolor")) != null) {
  146.          this.helpTextColor = ANIScript.getColor("helptextcolor", var1);
  147.       } else {
  148.          this.helpTextColor = Color.black;
  149.       }
  150.  
  151.       if ((var1 = ((Applet)this).getParameter("helptextfont")) != null) {
  152.          String var2 = var1.substring(0, var1.indexOf(","));
  153.          var1 = var1.substring(var1.indexOf(",") + 1);
  154.          int var3 = Integer.parseInt(var1);
  155.          this.helpTextFont = new Font(var2, 0, var3);
  156.       } else {
  157.          this.helpTextFont = new Font("Arial", 0, 10);
  158.       }
  159.  
  160.       if ((var1 = ((Applet)this).getParameter("agentreloadinterval")) != null) {
  161.          this.lAgentReload = (long)(1000 * Integer.parseInt(var1));
  162.       } else {
  163.          this.lAgentReload = -1L;
  164.       }
  165.  
  166.       this.iScrollHeight = -1;
  167.       return 0;
  168.    }
  169.  
  170.    public void run() {
  171.       while(this.field_0 != null) {
  172.          if (!this.fLicense) {
  173.             this.stop();
  174.          } else {
  175.             if (this.status == null) {
  176.                this.status = new ANIStatus(this, this.stCanvas, this.agCanvas);
  177.                this.status.start();
  178.             }
  179.  
  180.             if (this.agent == null && this.agentScriptFile != null) {
  181.                this.agent = new ANIAgent(this, this.agentScriptFile, this.agCanvas);
  182.                this.agent.start();
  183.             }
  184.  
  185.             this.wait(1000);
  186.             ++this.gcCount;
  187.             if (this.gcCount > 300) {
  188.                System.gc();
  189.                this.gcCount = 0;
  190.             }
  191.          }
  192.       }
  193.  
  194.    }
  195.  
  196.    public void init() {
  197.       super.init();
  198.       this.getParameters();
  199.       if (!this.fLicense) {
  200.          URL var1 = ((Applet)this).getCodeBase();
  201.          if (!var1.getProtocol().equals("file")) {
  202.             int var3 = ANILicense.id;
  203.             String var4 = ANILicense.domain;
  204.             String var5 = new String();
  205.             if (var4.length() < 4) {
  206.                return;
  207.             }
  208.  
  209.             if (!var4.substring(0, 1).equals("9")) {
  210.                return;
  211.             }
  212.  
  213.             String var6 = Integer.toString(var3);
  214.             int var8 = 2;
  215.             int var2 = var6.length();
  216.  
  217.             while(true) {
  218.                --var2;
  219.                if (var2 < 0) {
  220.                   String var7 = "000" + Integer.toString(var8);
  221.                   var7 = var7.substring(var7.length() - 3);
  222.                   if (!var4.substring(1, 4).equals(var7)) {
  223.                      return;
  224.                   }
  225.  
  226.                   for(int var13 = 4; var13 < var4.length(); var13 += 2) {
  227.                      String var9 = var4.substring(var13, var13 + 2);
  228.                      int var10 = Integer.parseInt(var9);
  229.                      int var11 = (var3 + var13) / 30;
  230.                      int var12 = var10 - (var3 + var13) + var11 * 30;
  231.                      var5 = var5 + this.chars.substring(var12, var12 + 1);
  232.                   }
  233.  
  234.                   String var16 = var1.getHost().toLowerCase();
  235.                   int var17 = 9;
  236.  
  237.                   for(int var14 = 0; var14 < var16.length(); ++var14) {
  238.                      var17 += this.chars.indexOf(var16.substring(var14, var14 + 1));
  239.                   }
  240.  
  241.                   if (var17 == var3) {
  242.                      String var18 = var16 + var1.getFile().toLowerCase();
  243.                      if (var18.startsWith(var5) && var5.length() > 4) {
  244.                         this.fLicense = true;
  245.                      }
  246.                   }
  247.                   break;
  248.                }
  249.  
  250.                var8 += Integer.parseInt(var6.substring(var2, var2 + 1));
  251.             }
  252.          } else {
  253.             this.fLicense = true;
  254.          }
  255.       }
  256.  
  257.       this.stCanvas = new ANIStatusCanvas(this);
  258.       this.stCanvas.resize(22, ((Component)this).size().height - this.iScrollHeight - 1);
  259.       this.agCanvas = new ANIAgentCanvas(this);
  260.       this.agCanvas.resize(((Component)this).size().width - 22, ((Component)this).size().height - this.iScrollHeight - 1);
  261.       ((Container)this).setLayout(new BorderLayout());
  262.       ((Container)this).add("Center", this.agCanvas);
  263.       ((Container)this).add("East", this.stCanvas);
  264.    }
  265. }
  266.