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

  1. import java.awt.Graphics;
  2. import java.awt.Image;
  3. import java.awt.MediaTracker;
  4. import java.net.URL;
  5.  
  6. public final class ANIStatus implements Runnable {
  7.    public static final int ST_IMAGES = 6;
  8.    public static final int IMG_AUDIO = 0;
  9.    public static final int IMG_AUDIOOFF = 1;
  10.    public static final int IMG_DOCOFF = 2;
  11.    public static final int IMG_DOC = 3;
  12.    public static final int IMG_LOADINGOFF = 4;
  13.    public static final int IMG_LOADING = 5;
  14.    private ANI Applet;
  15.    // $FF: renamed from: t java.lang.Thread
  16.    private Thread field_0;
  17.    private ANIStatusCanvas canvas;
  18.    private ANIAgentCanvas aCanvas;
  19.    private MediaTracker tracker;
  20.    private Image stImgLoad;
  21.    private boolean fImgsToLoad;
  22.    private boolean fRepaint = true;
  23.    public Image[] stImgs;
  24.    public boolean fAudio = true;
  25.    public boolean fLoading;
  26.    public boolean fDoc;
  27.    public boolean fLoadingOn;
  28.    private long lLoadingNextChange;
  29.    public boolean fDocOn;
  30.    private long lDocNextChange;
  31.    private int iDocRemaining;
  32.    private int iImgsMoving;
  33.    private Image helpImgLoad;
  34.  
  35.    public void stop() {
  36.       if (this.field_0 != null) {
  37.          this.field_0.stop();
  38.          this.field_0 = null;
  39.       }
  40.  
  41.    }
  42.  
  43.    public ANIStatus(ANI var1, ANIStatusCanvas var2, ANIAgentCanvas var3) {
  44.       this.Applet = var1;
  45.       this.canvas = var2;
  46.       this.aCanvas = var3;
  47.       this.stImgs = new Image[6];
  48.       this.tracker = new MediaTracker(this.Applet);
  49.  
  50.       try {
  51.          URL var4 = new URL(this.Applet.getCodeBase(), "ANIStati.gif");
  52.          this.stImgLoad = this.Applet.getImage(var4);
  53.          this.tracker.addImage(this.stImgLoad, 1);
  54.          if (this.Applet.helpImage != null) {
  55.             this.helpImgLoad = this.Applet.getImage(ANIScript.getURL("HelpImage", this.Applet.helpImage, this.Applet.getDocumentBase()));
  56.             this.tracker.addImage(this.helpImgLoad, 2);
  57.          }
  58.  
  59.          this.fImgsToLoad = true;
  60.       } catch (Exception var5) {
  61.       }
  62.    }
  63.  
  64.    private final void repaintAgent() {
  65.       int var1 = 200;
  66.       this.aCanvas.fStatusPaint = true;
  67.       this.aCanvas.fUpdate = true;
  68.       this.aCanvas.repaint();
  69.  
  70.       while(this.aCanvas.fUpdate) {
  71.          --var1;
  72.          if (var1 <= 0) {
  73.             break;
  74.          }
  75.  
  76.          this.wait(1);
  77.       }
  78.  
  79.       this.aCanvas.fUpdate = false;
  80.    }
  81.  
  82.    public void setAudioFlag(boolean var1) {
  83.       if (var1 != this.fAudio) {
  84.          this.fAudio = var1;
  85.          this.fRepaint = true;
  86.       }
  87.  
  88.    }
  89.  
  90.    private final void wait(int var1) {
  91.       try {
  92.          Thread.sleep((long)var1);
  93.       } catch (InterruptedException var2) {
  94.       }
  95.    }
  96.  
  97.    public void setLoadingFlag(boolean var1) {
  98.       if (var1 != this.fLoading) {
  99.          this.fLoading = var1;
  100.          this.fLoadingOn = var1;
  101.          if (this.fLoading) {
  102.             this.lLoadingNextChange = System.currentTimeMillis() + 1000L;
  103.          }
  104.  
  105.          ++this.iImgsMoving;
  106.          this.fRepaint = true;
  107.       }
  108.  
  109.    }
  110.  
  111.    public void setLinkingFlag(boolean var1) {
  112.       if (var1 != this.fDoc) {
  113.          if (this.aCanvas.fOS != var1) {
  114.             ++this.iImgsMoving;
  115.          }
  116.  
  117.          this.fDoc = var1;
  118.          this.fDocOn = var1;
  119.          this.aCanvas.fOS = var1;
  120.          if (this.fDoc) {
  121.             this.lDocNextChange = System.currentTimeMillis() + 1000L;
  122.             this.iDocRemaining = 3;
  123.          }
  124.  
  125.          this.fRepaint = true;
  126.       }
  127.  
  128.    }
  129.  
  130.    public void start() {
  131.       if (this.field_0 == null) {
  132.          this.field_0 = new Thread(this);
  133.          this.field_0.start();
  134.       }
  135.  
  136.    }
  137.  
  138.    private final void repaintCanvas() {
  139.       int var1 = 200;
  140.       this.canvas.fUpdate = true;
  141.       this.canvas.repaint();
  142.  
  143.       while(this.canvas.fUpdate) {
  144.          --var1;
  145.          if (var1 <= 0) {
  146.             break;
  147.          }
  148.  
  149.          this.wait(1);
  150.       }
  151.  
  152.       this.canvas.fUpdate = false;
  153.       this.fRepaint = false;
  154.    }
  155.  
  156.    public void run() {
  157.       while(this.field_0 != null) {
  158.          if (this.fImgsToLoad) {
  159.             boolean var1 = this.tracker.checkID(1, true);
  160.             if (!var1) {
  161.                this.fImgsToLoad = true;
  162.             } else {
  163.                this.fImgsToLoad = false;
  164.                if (!this.tracker.isErrorID(1)) {
  165.                   this.Applet.waitForImage(this.stImgLoad);
  166.                   int var5 = 0;
  167.  
  168.                   do {
  169.                      this.stImgs[var5] = this.Applet.ANICreateImage(16, 16);
  170.                      Graphics var4 = this.stImgs[var5].getGraphics();
  171.                      this.Applet.ANIDrawImage(var4, this.stImgLoad, -var5 * 16, 0, this.canvas);
  172.                      ++var5;
  173.                   } while(var5 < 6);
  174.  
  175.                   this.aCanvas.imgLS = this.Applet.ANICreateImage(62, 23);
  176.                   Graphics var7 = this.aCanvas.imgLS.getGraphics();
  177.                   this.Applet.ANIDrawImage(var7, this.stImgLoad, 0, -16, this.canvas);
  178.                   this.aCanvas.imgOS = this.Applet.ANICreateImage(55, 14);
  179.                   var7 = this.aCanvas.imgOS.getGraphics();
  180.                   this.Applet.ANIDrawImage(var7, this.stImgLoad, 0, -39, this.canvas);
  181.                   this.fRepaint = true;
  182.                }
  183.             }
  184.  
  185.             if (this.Applet.helpImage != null) {
  186.                var1 = this.tracker.checkID(2, true);
  187.                if (var1) {
  188.                   if (!this.tracker.isErrorID(2)) {
  189.                      this.Applet.waitForImage(this.helpImgLoad);
  190.                      this.Applet.wHelpImg = this.helpImgLoad.getWidth(this.Applet);
  191.                      this.Applet.hHelpImg = this.helpImgLoad.getHeight(this.Applet);
  192.                      this.Applet.helpImg = this.helpImgLoad;
  193.                   }
  194.                } else {
  195.                   this.fImgsToLoad = true;
  196.                }
  197.             }
  198.          }
  199.  
  200.          long var2 = System.currentTimeMillis();
  201.          if (this.fLoading && var2 > this.lLoadingNextChange) {
  202.             if (this.fLoadingOn) {
  203.                this.lLoadingNextChange = var2 + 500L;
  204.             } else {
  205.                this.lLoadingNextChange = var2 + 1000L;
  206.             }
  207.  
  208.             this.fLoadingOn = !this.fLoadingOn;
  209.             this.fRepaint = true;
  210.          }
  211.  
  212.          if (this.fDoc && var2 > this.lDocNextChange) {
  213.             if (this.fDocOn) {
  214.                this.lDocNextChange = var2 + 500L;
  215.             } else {
  216.                this.lDocNextChange = var2 + 1000L;
  217.                if ((this.iDocRemaining += -1) < 0) {
  218.                   this.fDoc = false;
  219.                   this.fDocOn = true;
  220.                   ++this.iImgsMoving;
  221.                }
  222.             }
  223.  
  224.             this.fDocOn = !this.fDocOn;
  225.             this.fRepaint = true;
  226.          }
  227.  
  228.          if (this.fRepaint) {
  229.             this.repaintCanvas();
  230.          }
  231.  
  232.          if (this.iImgsMoving != 0 && !this.fImgsToLoad) {
  233.             if (this.fLoading && !this.aCanvas.fLS && this.Applet.agent.fScriptLoaded) {
  234.                this.aCanvas.fLS = true;
  235.             }
  236.  
  237.             if (!this.aCanvas.fLS && !this.aCanvas.fOS) {
  238.                this.wait(250);
  239.             } else {
  240.                boolean var9 = false;
  241.                if (this.aCanvas.fLS) {
  242.                   if (this.fLoading && this.aCanvas.xLS > this.aCanvas.wOld - 62) {
  243.                      this.aCanvas.xLS = Math.max(this.aCanvas.xLS - 3, this.aCanvas.wOld - 62);
  244.                      var9 = true;
  245.                   }
  246.  
  247.                   if (!this.fLoading && this.aCanvas.xLS < this.aCanvas.wOld) {
  248.                      this.aCanvas.xLS = Math.min(this.aCanvas.xLS + 3, this.aCanvas.wOld);
  249.                      var9 = true;
  250.                   }
  251.  
  252.                   if (!var9) {
  253.                      this.iImgsMoving += -1;
  254.                      if (!this.fLoading) {
  255.                         this.aCanvas.fLS = false;
  256.                      }
  257.                   }
  258.                }
  259.  
  260.                if (this.aCanvas.fOS) {
  261.                   var9 = false;
  262.                   if (this.fDoc && this.aCanvas.xOS > this.aCanvas.wOld - 55) {
  263.                      this.aCanvas.xOS = Math.max(this.aCanvas.xOS - 3, this.aCanvas.wOld - 55);
  264.                      var9 = true;
  265.                   }
  266.  
  267.                   if (!this.fDoc && this.aCanvas.xOS < this.aCanvas.wOld) {
  268.                      this.aCanvas.xOS = Math.min(this.aCanvas.xOS + 3, this.aCanvas.wOld);
  269.                      var9 = true;
  270.                   }
  271.  
  272.                   if (!var9) {
  273.                      this.iImgsMoving += -1;
  274.                      if (!this.fDoc) {
  275.                         this.aCanvas.fOS = false;
  276.                      }
  277.                   }
  278.                }
  279.  
  280.                this.repaintAgent();
  281.             }
  282.          } else {
  283.             if (this.fLoading) {
  284.                this.repaintAgent();
  285.             }
  286.  
  287.             this.wait(250);
  288.          }
  289.       }
  290.  
  291.    }
  292. }
  293.