home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.image.ImageObserver;
-
- public class bounce extends Applet implements Runnable {
- // $FF: renamed from: s java.lang.String
- private String field_0;
- private int stringLength;
- private Thread engineThread;
- private boolean userPause;
- private boolean readyToPaint = true;
- private Graphics offGraphics;
- private Image offImage;
- private int x_coord;
- private int y_coord = 10;
- private int sleepTime = 100;
- private int stepx = 10;
- private int stepy = 1;
- private myFont font;
- private int fontsize = 20;
- private int fontstyle;
- private Color foreGroundColor;
- private Color backGroundColor;
- // $FF: renamed from: up boolean
- private boolean field_1 = true;
- private boolean dir_right = true;
- private boolean matched;
- private boolean unreg = true;
- private Dimension offScrSize;
- private boolean debug;
-
- private synchronized void detecter(int var1, int var2) {
- int var3 = this.dir_right ? this.x_coord + var1 + this.stepx : this.x_coord - this.stepx;
- int var4 = this.field_1 ? this.y_coord - this.stepy - var2 : this.y_coord + this.stepy;
- if (var4 <= 0) {
- this.field_1 = false;
- } else if (var4 >= ((Component)this).size().height) {
- this.field_1 = true;
- }
-
- if (var3 <= 0) {
- this.dir_right = true;
- } else if (var3 >= ((Component)this).size().width) {
- this.dir_right = false;
- }
-
- this.y_coord = this.field_1 ? this.y_coord - this.stepy : this.y_coord + this.stepy;
- this.x_coord = this.dir_right ? this.x_coord + this.stepx : this.x_coord - this.stepx;
- }
-
- public void stop() {
- if (this.engineThread != null && this.engineThread.isAlive()) {
- this.engineThread.stop();
- }
-
- this.engineThread = null;
- }
-
- private void NotRegistered() {
- System.out.println("Program not registered");
- System.exit(0);
- }
-
- public synchronized void prePaint(Graphics var1) {
- var1.setColor(this.backGroundColor);
- var1.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
- var1.setFont(this.font);
- var1.setColor(this.foreGroundColor);
- FontMetrics var2 = var1.getFontMetrics();
- var1.drawString(this.field_0, this.x_coord, this.y_coord);
- this.detecter(var2.stringWidth(this.field_0), var2.getAscent() - var2.getLeading());
- }
-
- public void paint(Graphics var1) {
- if (this.engineThread != null) {
- if (this.offGraphics != null) {
- this.prePaint(this.offGraphics);
- var1.drawImage(this.offImage, 0, 0, this);
- } else {
- this.prePaint(var1);
- }
- }
-
- }
-
- private void dbg(String var1) {
- if (this.debug) {
- System.out.println(var1);
- }
-
- }
-
- public synchronized void update(Graphics var1) {
- Dimension var2 = ((Component)this).size();
- if (this.offImage == null || var2.width != this.offScrSize.width || var2.height != this.offScrSize.height) {
- this.offImage = ((Component)this).createImage(var2.width, var2.height);
- this.offGraphics = this.offImage.getGraphics();
- this.offGraphics.setFont(((Component)this).getFont());
- this.offScrSize = var2;
- }
-
- if (this.readyToPaint) {
- this.paint(this.offGraphics);
- var1.drawImage(this.offImage, 0, 0, (ImageObserver)null);
- }
-
- }
-
- public void start() {
- if (this.engineThread == null) {
- this.engineThread = new Thread(this);
- }
-
- this.engineThread.start();
- }
-
- public String getAppletInfo() {
- return "Swami - bounce.class v1.0 Copyright (c)Sausage SoftWare 1996";
- }
-
- public void run() {
- Thread.currentThread().setPriority(1);
-
- while(true) {
- if (this.unreg) {
- ((Applet)this).getAppletContext().showStatus("Unregistered version. Copyright (c) Sausage Software 1996");
- }
-
- ((Component)this).repaint();
-
- try {
- Thread.sleep((long)this.sleepTime);
- } catch (Exception var1) {
- }
- }
- }
-
- public void init() {
- this.field_0 = ((Applet)this).getParameter("text");
- if (this.field_0 == null) {
- this.field_0 = "Sausage Software";
- }
-
- this.stringLength = this.field_0.length();
- String var1 = ((Applet)this).getParameter("reguser");
- if (var1 == null) {
- this.NotRegistered();
- }
-
- if (var1.toLowerCase().equals("unregistered")) {
- this.unreg = true;
- } else {
- this.unreg = false;
- }
-
- String var2 = ((Applet)this).getParameter("serialid");
- if (var2 == null) {
- this.NotRegistered();
- }
-
- ver var3 = new ver(var1, var2);
- this.matched = var3.verifyUser(this.field_0);
- if (!this.matched) {
- this.NotRegistered();
- }
-
- String var4 = ((Applet)this).getParameter("font");
- Object var5 = null;
- String var15 = myFont.getFontName(var4);
- this.dbg(var15);
- var4 = ((Applet)this).getParameter("fontsize");
- if (var4 != null) {
- this.fontsize = Integer.parseInt(var4);
- }
-
- var4 = ((Applet)this).getParameter("style");
- this.fontstyle = myFont.getFontStyle(var4);
- this.font = new myFont(var15, this.fontstyle, this.fontsize);
- var4 = ((Applet)this).getParameter("color");
- if (var4 != null) {
- createColor var6 = new createColor(var4, ",");
- this.foreGroundColor = var6.getColor();
- } else {
- this.foreGroundColor = new Color(255, 0, 0);
- }
-
- var4 = ((Applet)this).getParameter("background");
- if (var4 != null) {
- createColor var16 = new createColor(var4, ",");
- this.backGroundColor = var16.getColor();
- } else {
- this.backGroundColor = new Color(0, 0, 0);
- }
-
- var4 = ((Applet)this).getParameter("horizontal");
- if (this.field_0 != null) {
- this.stepx = Integer.valueOf(var4);
- }
-
- var4 = ((Applet)this).getParameter("vertical");
- if (var4 != null) {
- this.stepy = Integer.valueOf(var4);
- }
-
- var4 = ((Applet)this).getParameter("speed");
- if (var4 != null) {
- this.sleepTime = Integer.parseInt(var4);
- }
-
- var4 = ((Applet)this).getParameter("startPosition");
- int var17 = var4 != null ? Integer.parseInt(var4) : 0;
- this.x_coord = 0;
- this.y_coord = ((Component)this).size().height - var17;
- this.dbg("finish init");
- }
-
- public boolean handleEvent(Event var1) {
- if (var1.id == 501) {
- if (this.userPause) {
- this.engineThread.resume();
- } else {
- this.engineThread.suspend();
- }
-
- this.userPause = !this.userPause;
- } else if (var1.id == 201) {
- this.stop();
- System.exit(0);
- }
-
- return true;
- }
- }
-