home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1998 October / DPPCPRO1098.ISO / Hotdog / files / snagpack.exe / ONOFF.CLASS (.txt) < prev    next >
Encoding:
Java Class File  |  1996-09-09  |  3.4 KB  |  150 lines

  1. import java.awt.Canvas;
  2. import java.awt.Component;
  3. import java.awt.Event;
  4. import java.awt.Graphics;
  5. import java.awt.Image;
  6. import java.awt.MediaTracker;
  7.  
  8. class onoff extends Canvas {
  9.    Image button;
  10.    Image buttoff;
  11.    MediaTracker tracker;
  12.    private int totalbutt;
  13.    // $FF: renamed from: up boolean
  14.    private boolean field_0 = true;
  15.    private boolean ready = false;
  16.    private boolean holdDown = false;
  17.    static int WRAPBUTTON;
  18.    static int SOUNDBUTTON = 1;
  19.    static int PAUSEBUTTON = 2;
  20.    static int PLAYBUTTON = 3;
  21.    static int FASTBUTTON = 4;
  22.    static int SLOWBUTTON = 5;
  23.    private Thread looperThread;
  24.    private looper mouseHold;
  25.    static int egorSpeed;
  26.    static int maxDelay;
  27.    static int counterInc = 1;
  28.    private int buttonSet;
  29.  
  30.    public onoff(Image var1, Image var2, int var3, boolean var4, boolean var5) {
  31.       this.button = var2;
  32.       this.buttoff = var1;
  33.       this.buttonSet = var3;
  34.       this.holdDown = var4;
  35.       this.field_0 = var5;
  36.       this.tracker = new MediaTracker(this);
  37.       this.tracker.addImage(this.button, 0);
  38.       this.tracker.addImage(this.buttoff, 0);
  39.  
  40.       try {
  41.          this.tracker.waitForID(0);
  42.       } catch (InterruptedException var6) {
  43.       }
  44.  
  45.       this.ready = true;
  46.    }
  47.  
  48.    public static void addEgorSpeed(int var0) {
  49.       egorSpeed = var0;
  50.    }
  51.  
  52.    public static void addMaximumDelay(int var0) {
  53.       maxDelay = var0;
  54.    }
  55.  
  56.    public static void setSpeedInc(int var0) {
  57.       counterInc = var0;
  58.    }
  59.  
  60.    public void newThread(boolean var1) {
  61.       this.mouseHold = new looper(var1, 0, maxDelay, egorSpeed, this);
  62.       this.mouseHold.setInc(counterInc);
  63.       this.mouseHold.start();
  64.    }
  65.  
  66.    public void changeEgorSpeed(int var1) {
  67.       ((egorctr)((Component)this).getParent()).egorSpeed(var1);
  68.       egorSpeed = var1;
  69.    }
  70.  
  71.    public boolean mouseDown(Event var1, int var2, int var3) {
  72.       if (this.buttonSet != PLAYBUTTON && this.buttonSet != PAUSEBUTTON) {
  73.          if (this.buttonSet == FASTBUTTON) {
  74.             this.newThread(false);
  75.          } else if (this.buttonSet == SLOWBUTTON) {
  76.             this.newThread(true);
  77.          }
  78.       } else {
  79.          this.field_0 = true;
  80.       }
  81.  
  82.       this.field_0 = !this.field_0;
  83.       ((Component)this).repaint();
  84.       this.methodChoice();
  85.       return true;
  86.    }
  87.  
  88.    public boolean mouseUp(Event var1, int var2, int var3) {
  89.       if (this.buttonSet == FASTBUTTON || this.buttonSet == SLOWBUTTON) {
  90.          this.mouseHold.stop();
  91.          this.mouseHold.changeLoop(false);
  92.       }
  93.  
  94.       if (!this.holdDown) {
  95.          this.field_0 = true;
  96.          ((Component)this).repaint();
  97.          return true;
  98.       } else {
  99.          return false;
  100.       }
  101.    }
  102.  
  103.    public void buttonUP() {
  104.       this.field_0 = true;
  105.       ((Component)this).repaint();
  106.    }
  107.  
  108.    public void update(Graphics var1) {
  109.       this.paint(var1);
  110.    }
  111.  
  112.    public void paint(Graphics var1) {
  113.       if (this.ready && this.imagesLoaded()) {
  114.          if (this.field_0) {
  115.             var1.drawImage(this.buttoff, 0, 0, ((Component)this).size().width, ((Component)this).size().height, this);
  116.             return;
  117.          }
  118.  
  119.          var1.drawImage(this.button, 0, 0, ((Component)this).size().width, ((Component)this).size().height, this);
  120.       }
  121.  
  122.    }
  123.  
  124.    private boolean imagesLoaded() {
  125.       boolean var1 = false;
  126.       if (this.tracker.isErrorAny()) {
  127.          System.out.println("Tracker Error - onoff");
  128.          return false;
  129.       } else {
  130.          var1 = this.tracker.checkID(0);
  131.          return var1;
  132.       }
  133.    }
  134.  
  135.    private void methodChoice() {
  136.       if (this.buttonSet == WRAPBUTTON) {
  137.          ((egorctr)((Component)this).getParent()).getBehaviour(this.field_0);
  138.       } else if (this.buttonSet == SOUNDBUTTON) {
  139.          ((egorctr)((Component)this).getParent()).egorSound(this.field_0);
  140.       } else if (this.buttonSet == PAUSEBUTTON) {
  141.          ((egorctr)((Component)this).getParent()).playUP();
  142.       } else {
  143.          if (this.buttonSet == PLAYBUTTON) {
  144.             ((egorctr)((Component)this).getParent()).pauseUP();
  145.          }
  146.  
  147.       }
  148.    }
  149. }
  150.