home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Canvas;
- import java.awt.Component;
- import java.awt.Event;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
-
- class onoff extends Canvas {
- Image button;
- Image buttoff;
- MediaTracker tracker;
- private int totalbutt;
- // $FF: renamed from: up boolean
- private boolean field_0 = true;
- private boolean ready = false;
- private boolean holdDown = false;
- static int WRAPBUTTON;
- static int SOUNDBUTTON = 1;
- static int PAUSEBUTTON = 2;
- static int PLAYBUTTON = 3;
- static int FASTBUTTON = 4;
- static int SLOWBUTTON = 5;
- private Thread looperThread;
- private looper mouseHold;
- static int egorSpeed;
- static int maxDelay;
- static int counterInc = 1;
- private int buttonSet;
-
- public onoff(Image var1, Image var2, int var3, boolean var4, boolean var5) {
- this.button = var2;
- this.buttoff = var1;
- this.buttonSet = var3;
- this.holdDown = var4;
- this.field_0 = var5;
- this.tracker = new MediaTracker(this);
- this.tracker.addImage(this.button, 0);
- this.tracker.addImage(this.buttoff, 0);
-
- try {
- this.tracker.waitForID(0);
- } catch (InterruptedException var6) {
- }
-
- this.ready = true;
- }
-
- public static void addEgorSpeed(int var0) {
- egorSpeed = var0;
- }
-
- public static void addMaximumDelay(int var0) {
- maxDelay = var0;
- }
-
- public static void setSpeedInc(int var0) {
- counterInc = var0;
- }
-
- public void newThread(boolean var1) {
- this.mouseHold = new looper(var1, 0, maxDelay, egorSpeed, this);
- this.mouseHold.setInc(counterInc);
- this.mouseHold.start();
- }
-
- public void changeEgorSpeed(int var1) {
- ((egorctr)((Component)this).getParent()).egorSpeed(var1);
- egorSpeed = var1;
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- if (this.buttonSet != PLAYBUTTON && this.buttonSet != PAUSEBUTTON) {
- if (this.buttonSet == FASTBUTTON) {
- this.newThread(false);
- } else if (this.buttonSet == SLOWBUTTON) {
- this.newThread(true);
- }
- } else {
- this.field_0 = true;
- }
-
- this.field_0 = !this.field_0;
- ((Component)this).repaint();
- this.methodChoice();
- return true;
- }
-
- public boolean mouseUp(Event var1, int var2, int var3) {
- if (this.buttonSet == FASTBUTTON || this.buttonSet == SLOWBUTTON) {
- this.mouseHold.stop();
- this.mouseHold.changeLoop(false);
- }
-
- if (!this.holdDown) {
- this.field_0 = true;
- ((Component)this).repaint();
- return true;
- } else {
- return false;
- }
- }
-
- public void buttonUP() {
- this.field_0 = true;
- ((Component)this).repaint();
- }
-
- public void update(Graphics var1) {
- this.paint(var1);
- }
-
- public void paint(Graphics var1) {
- if (this.ready && this.imagesLoaded()) {
- if (this.field_0) {
- var1.drawImage(this.buttoff, 0, 0, ((Component)this).size().width, ((Component)this).size().height, this);
- return;
- }
-
- var1.drawImage(this.button, 0, 0, ((Component)this).size().width, ((Component)this).size().height, this);
- }
-
- }
-
- private boolean imagesLoaded() {
- boolean var1 = false;
- if (this.tracker.isErrorAny()) {
- System.out.println("Tracker Error - onoff");
- return false;
- } else {
- var1 = this.tracker.checkID(0);
- return var1;
- }
- }
-
- private void methodChoice() {
- if (this.buttonSet == WRAPBUTTON) {
- ((egorctr)((Component)this).getParent()).getBehaviour(this.field_0);
- } else if (this.buttonSet == SOUNDBUTTON) {
- ((egorctr)((Component)this).getParent()).egorSound(this.field_0);
- } else if (this.buttonSet == PAUSEBUTTON) {
- ((egorctr)((Component)this).getParent()).playUP();
- } else {
- if (this.buttonSet == PLAYBUTTON) {
- ((egorctr)((Component)this).getParent()).pauseUP();
- }
-
- }
- }
- }
-