home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Event;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
-
- public class knightrider extends Applet implements Runnable {
- private Thread engineThread;
- private String lbl;
- private char[] label;
- private int stringLen;
- private int count;
- private int loop;
- private boolean readyToPaint = false;
- private myFont font;
- private boolean toDark = false;
- private boolean userPause = false;
- // $FF: renamed from: x int
- private int field_0;
- private Image offImage;
- private Graphics offGraphics;
- private int bred;
- private int bgreen;
- private int bblue;
- private int fred;
- private int fgreen;
- private int fblue;
- private int red = 255;
- private int blue;
- private int green;
- private int fade;
- private int fadeR;
- private int fadeG;
- private int fadeB;
- private int hiRed;
- private int lowRed;
- private int hiGreen;
- private int lowGreen;
- private int hiBlue;
- private int lowBlue;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_1;
- private int sleepTime;
- private boolean debug = false;
-
- private void dbg(String var1) {
- if (this.debug) {
- System.out.println(var1);
- }
-
- }
-
- public void init() {
- String var1 = ((Applet)this).getParameter("mydebug");
- if ("myyes".equals(var1)) {
- this.debug = true;
- }
-
- var1 = ((Applet)this).getParameter("fontsize");
- int var2 = var1 == null ? 12 : Integer.valueOf(var1);
- var1 = ((Applet)this).getParameter("style");
- int var3 = myFont.getFontStyle(var1);
- var1 = ((Applet)this).getParameter("font");
- String var4 = myFont.getFontName(var1);
- this.font = new myFont(var4, var3, var2);
- var1 = ((Applet)this).getParameter("text");
- this.lbl = var1 == null ? "Sausage Software" : var1;
- this.label = this.lbl.toCharArray();
- this.stringLen = this.lbl.length();
- var1 = ((Applet)this).getParameter("color");
- if (var1 != null) {
- createColor var5 = new createColor(var1, ",");
- var5.getColor();
- this.red = var5.getRed();
- this.green = var5.getGreen();
- this.blue = var5.getBlue();
- }
-
- var1 = ((Applet)this).getParameter("background");
- if (var1 != null) {
- createColor var14 = new createColor(var1, ",");
- var14.getColor();
- this.bred = var14.getRed();
- this.bgreen = var14.getGreen();
- this.bblue = var14.getBlue();
- }
-
- var1 = ((Applet)this).getParameter("speed");
- this.sleepTime = var1 == null ? 50 : Integer.parseInt(var1);
-
- try {
- this.offImage = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
- this.offGraphics = this.offImage.getGraphics();
- } catch (Exception var6) {
- this.offGraphics = null;
- }
-
- this.hiLowColors();
- this.fadeValue();
- this.dbg("fade " + this.fade + " strLen" + this.stringLen);
- }
-
- private void hiLowColors() {
- if (this.red > this.bred) {
- this.hiRed = this.red;
- this.lowRed = this.bred;
- } else {
- this.hiRed = this.bred;
- this.lowRed = this.red;
- }
-
- if (this.green > this.bgreen) {
- this.hiGreen = this.green;
- this.lowGreen = this.bgreen;
- } else {
- this.hiGreen = this.bgreen;
- this.lowGreen = this.green;
- }
-
- if (this.blue > this.bblue) {
- this.hiBlue = this.blue;
- this.lowBlue = this.bblue;
- } else {
- this.hiBlue = this.bblue;
- this.lowBlue = this.blue;
- }
- }
-
- private void fadeValue() {
- int var1 = Math.abs(this.red - this.bred);
- int var2 = Math.abs(this.green - this.bgreen);
- int var3 = Math.abs(this.blue - this.bblue);
- int var4;
- if (var1 >= var2) {
- if (var1 >= var3) {
- var4 = var1;
- } else {
- var4 = var3;
- }
- } else if (var2 >= var3) {
- var4 = var2;
- } else {
- var4 = var3;
- }
-
- this.fadeR = (this.red - this.bred) / this.stringLen;
- this.fadeG = (this.green - this.bgreen) / this.stringLen;
- this.fadeB = (this.blue - this.bblue) / this.stringLen;
- this.dbg("fadeR " + this.fadeR + " fadeG " + this.fadeG + " fadeB " + this.fadeB);
- this.fade = var4 / this.stringLen;
- }
-
- private synchronized void prePaint(Graphics var1) {
- var1.setColor(new Color(this.bred, this.bgreen, this.bblue));
- var1.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
- var1.setFont(this.font);
- this.field_1 = var1.getFontMetrics();
- this.field_0 = ((Component)this).size().width / 2 - this.field_1.stringWidth(this.lbl) / 2;
-
- for(int var2 = 0; var2 < this.stringLen; ++var2) {
- if (this.loop > 0) {
- --this.loop;
- } else {
- this.colorToHigh();
- this.colorToLow();
- if (this.fred >= this.red && this.fblue >= this.blue && this.fgreen >= this.green) {
- this.toDark = true;
- this.fred = this.red;
- this.fgreen = this.green;
- this.fblue = this.blue;
- }
-
- var1.setColor(new Color(this.fred, this.fgreen, this.fblue));
- var1.drawChars(this.label, var2, 1, this.field_0, ((Component)this).size().height / 2 + this.field_1.getHeight() / 2);
- if (this.toDark) {
- this.fred -= this.fadeR;
- this.fgreen -= this.fadeG;
- this.fblue -= this.fadeB;
- } else {
- this.fred += this.fadeR;
- this.fgreen += this.fadeG;
- this.fblue += this.fadeB;
- }
- }
-
- this.field_0 += this.field_1.charWidth(this.label[var2]);
- }
-
- if (this.count > this.stringLen * 2) {
- this.count = 0;
- }
-
- }
-
- private synchronized void colorToHigh() {
- if (this.fred > this.hiRed) {
- this.fred = this.hiRed;
- }
-
- if (this.fgreen > this.hiGreen) {
- this.fgreen = this.hiGreen;
- }
-
- if (this.fblue > this.hiBlue) {
- this.fblue = this.hiBlue;
- }
-
- }
-
- private synchronized void colorToLow() {
- if (this.fred < this.lowRed) {
- this.fred = this.lowRed;
- }
-
- if (this.fgreen < this.lowGreen) {
- this.fgreen = this.lowGreen;
- }
-
- if (this.fblue < this.lowBlue) {
- this.fblue = this.lowBlue;
- }
-
- }
-
- private synchronized void charSetup() {
- if (this.count >= this.stringLen) {
- this.loop = this.count - this.stringLen;
- }
-
- this.dbg(this.loop + " ");
- this.fred = this.red - this.fadeR * this.count;
- this.fgreen = this.green - this.fadeG * this.count;
- this.fblue = this.blue - this.fadeB * this.count++;
- this.toDark = false;
- }
-
- public void update(Graphics var1) {
- if (this.readyToPaint) {
- this.paint(var1);
- }
-
- }
-
- public void paint(Graphics var1) {
- if (this.engineThread != null && this.readyToPaint) {
- if (this.offGraphics != null) {
- this.prePaint(this.offGraphics);
- var1.drawImage(this.offImage, 0, 0, this);
- return;
- }
-
- this.prePaint(var1);
- }
-
- }
-
- public void start() {
- this.engineThread = new Thread(this);
- this.engineThread.start();
- }
-
- public void stop() {
- this.engineThread.stop();
- }
-
- public void run() {
- Thread.currentThread().setPriority(1);
-
- while(true) {
- ((Component)this).repaint();
-
- try {
- Thread.sleep((long)this.sleepTime);
- } catch (Exception var1) {
- }
-
- this.readyToPaint = false;
- this.charSetup();
- this.readyToPaint = true;
- }
- }
-
- 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;
- }
- }
-