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.Graphics;
- import java.awt.Image;
- import java.util.StringTokenizer;
-
- public class Bullets extends Applet implements Runnable {
- private static final int NONE = 0;
- private static final int LEFT = 1;
- private static final int RIGHT = 2;
- // $FF: renamed from: UP int
- private static final int field_0 = 3;
- private static final int DOWN = 4;
- // $FF: renamed from: IN int
- private static final int field_1 = 5;
- private static final int OUT = 6;
- private static final int CYCLE = 0;
- private static final int FADE = 1;
- private static Bullets threadMaster;
- private static Bullets[] uniqueAppList;
- private long nextUpdateTime;
- private Thread mainThread;
- // $FF: renamed from: R int
- private int field_2;
- // $FF: renamed from: G int
- private int field_3;
- // $FF: renamed from: B int
- private int field_4;
- private int ToR;
- private int ToG;
- private int ToB;
- private int fadeCounter;
- private int fadeAmount = 15;
- private int[] colors;
- private int colorIndex;
- private int displayCounter;
- private int displayColors = 1;
- private int delay;
- private int pauseTime;
- private int smoothness = 5;
- private int effect = 1;
- private int direction;
- private Color currentColor;
- private Color bgColor;
- private Color[] displayList;
- public volatile Graphics offGraphic;
- private Image offImage;
- public volatile Bullets[] slaveList;
- private volatile Bullets master;
- private boolean isBullet = true;
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- System.out.println("uniqueAppList.length is " + uniqueAppList.length);
-
- for(int var4 = 0; var4 < uniqueAppList.length; ++var4) {
- System.out.println("Master " + var4 + " slavelist.length is " + uniqueAppList[var4].slaveList.length);
-
- for(int var5 = 0; var5 < uniqueAppList[var4].slaveList.length; ++var5) {
- System.out.println(uniqueAppList[var4].slaveList[var5].getGraphics());
- }
- }
-
- return true;
- }
-
- public String getAppletInfo() {
- return "Bullets 1.01 - Copyright © 1996, Macromedia, Inc.";
- }
-
- private int convertTime(String var1, String var2, double var3) {
- if (var2 == null) {
- return (int)(var3 * (double)1000.0F);
- } else {
- double var5;
- try {
- var5 = Double.valueOf(var2) * (double)1000.0F;
- } catch (NumberFormatException var7) {
- System.out.println("Invalid value " + var2 + " for parameter '" + var1 + "', using " + var3);
- var5 = var3 * (double)1000.0F;
- }
-
- return (int)var5;
- }
- }
-
- public void init() {
- int var2 = 0;
- String var1 = ((Applet)this).getParameter("bgcolor");
- this.bgColor = new Color(this.getColor(var1, ((Component)this).getBackground().getRGB()));
- this.currentColor = this.bgColor;
- var1 = ((Applet)this).getParameter("fps");
- if (var1 != null) {
- try {
- var2 = Integer.parseInt(var1);
- } catch (NumberFormatException var9) {
- }
- }
-
- this.delay = var2 > 0 ? 1000 / var2 : 100;
- var1 = ((Applet)this).getParameter("style");
- if (var1 != null && var1.equalsIgnoreCase("separator")) {
- this.isBullet = false;
- }
-
- var1 = ((Applet)this).getParameter("smoothness");
- if (var1 != null) {
- try {
- this.smoothness = Integer.parseInt(var1);
- } catch (NumberFormatException var8) {
- }
- }
-
- if (this.smoothness < 1) {
- System.out.println("smoothness value of " + this.smoothness + " is invalid, setting value to 1");
- this.smoothness = 1;
- }
-
- var1 = ((Applet)this).getParameter("fadeAmount");
- if (var1 != null) {
- try {
- this.fadeAmount = Integer.parseInt(var1);
- } catch (NumberFormatException var7) {
- }
- }
-
- if (this.fadeAmount < 1) {
- System.out.println("fadeAmount value of " + this.fadeAmount + " is invalid, setting value to 1");
- this.fadeAmount = 1;
- }
-
- var1 = ((Applet)this).getParameter("displayColors");
- if (var1 != null) {
- try {
- this.displayColors = Integer.parseInt(var1);
- } catch (NumberFormatException var6) {
- }
- }
-
- if (this.displayColors < 1) {
- System.out.println("displayColor value of " + this.displayColors + " is invalid, setting value to 1");
- this.displayColors = 1;
- }
-
- var1 = ((Applet)this).getParameter("effect");
- if (var1 != null) {
- var1 = var1.toLowerCase();
- if (var1.equals("fade")) {
- this.effect = 1;
- this.direction = 0;
- } else if (var1.equals("fadeleft")) {
- this.effect = 1;
- this.direction = 1;
- } else if (var1.equals("faderight")) {
- this.effect = 1;
- this.direction = 2;
- } else if (var1.equals("fadeup")) {
- this.effect = 1;
- this.direction = 3;
- } else if (var1.equals("fadedown")) {
- this.effect = 1;
- this.direction = 4;
- } else if (var1.equals("fadein")) {
- this.effect = 1;
- this.direction = 5;
- } else if (var1.equals("fadeout")) {
- this.effect = 1;
- this.direction = 6;
- } else if (var1.equals("cycleleft")) {
- this.effect = 0;
- this.direction = 1;
- } else if (var1.equals("cycleright")) {
- this.effect = 0;
- this.direction = 2;
- } else if (var1.equals("cycleup")) {
- this.effect = 0;
- this.direction = 3;
- } else if (var1.equals("cycledown")) {
- this.effect = 0;
- this.direction = 4;
- } else if (var1.equals("cyclein")) {
- this.effect = 0;
- this.direction = 5;
- } else if (var1.equals("cycleout")) {
- this.effect = 0;
- this.direction = 6;
- } else if (var1.equals("cycle")) {
- this.effect = 0;
- this.direction = 0;
- }
-
- switch (this.direction) {
- case 0:
- this.displayColors = 1;
- break;
- case 1:
- case 2:
- if (this.displayColors > ((Component)this).size().width) {
- this.displayColors = ((Component)this).size().width;
- }
- break;
- case 3:
- case 4:
- if (this.displayColors > ((Component)this).size().height) {
- this.displayColors = ((Component)this).size().height;
- }
- break;
- case 5:
- case 6:
- if (((Component)this).size().width > ((Component)this).size().height) {
- if (this.displayColors > ((Component)this).size().width / 2) {
- this.displayColors = ((Component)this).size().width / 2;
- }
- } else if (this.displayColors > ((Component)this).size().height / 2) {
- this.displayColors = ((Component)this).size().height / 2;
- }
- }
- }
-
- if (this.displayColors > this.smoothness) {
- this.smoothness = this.displayColors;
- }
-
- this.displayList = new Color[this.smoothness];
-
- for(int var3 = 0; var3 < this.smoothness; ++var3) {
- this.displayList[var3] = this.currentColor;
- }
-
- var1 = ((Applet)this).getParameter("pause");
- this.pauseTime = this.convertTime("pause", var1, (double)0.0F);
- var1 = ((Applet)this).getParameter("colors");
- if (var1 != null && !var1.equalsIgnoreCase("rainbow")) {
- int var4 = 0;
- StringTokenizer var5 = new StringTokenizer(var1, "\t\n\r,");
-
- for(this.colors = new int[var5.countTokens()]; var5.hasMoreTokens(); ++var4) {
- this.colors[var4] = this.getColor(var5.nextToken(), 0);
- }
- } else {
- this.colors = new int[6];
- this.colors[0] = 16711680;
- this.colors[1] = 16762880;
- this.colors[2] = 16776960;
- this.colors[3] = 65280;
- this.colors[4] = 255;
- this.colors[5] = 13107455;
- }
-
- this.displayCounter = this.smoothness;
- this.field_2 = this.bgColor.getRGB() >> 16 & 255;
- this.field_3 = this.bgColor.getRGB() >> 8 & 255;
- this.field_4 = this.bgColor.getRGB() & 255;
- if (this.effect == 1) {
- this.ToR = this.colors[0] >> 16 & 255;
- this.ToG = this.colors[0] >> 8 & 255;
- this.ToB = this.colors[0] & 255;
- }
-
- }
-
- public void start() {
- appStart(this);
- }
-
- public static synchronized void appStart(Bullets var0) {
- if (uniqueAppList != null) {
- for(int var1 = 0; var1 < uniqueAppList.length; ++var1) {
- Bullets var2 = uniqueAppList[var1];
- if (((Component)var0).size().width == ((Component)var2).size().width && ((Component)var0).size().height == ((Component)var2).size().height && var0.effect == var2.effect && var0.bgColor.getRGB() == var2.bgColor.getRGB() && var0.delay == var2.delay && var0.direction == var2.direction && var0.isBullet == var2.isBullet && var0.delay == var2.delay && var0.fadeAmount == var2.fadeAmount && var0.displayColors == var2.displayColors && var0.smoothness == var2.smoothness) {
- var2.addApp(var0);
- return;
- }
- }
- }
-
- var0.master = var0;
- var0.offImage = ((Component)var0).createImage(((Component)var0).size().width, ((Component)var0).size().height);
- var0.offGraphic = var0.offImage.getGraphics();
- var0.offGraphic.setColor(var0.bgColor);
- var0.offGraphic.fillRect(0, 0, ((Component)var0).size().width, ((Component)var0).size().height);
- var0.slaveList = new Bullets[1];
- var0.slaveList[0] = var0;
- if (uniqueAppList == null) {
- uniqueAppList = new Bullets[1];
- uniqueAppList[0] = var0;
- threadMaster = var0;
- threadMaster.mainThread = new Thread(threadMaster);
- threadMaster.mainThread.start();
- } else {
- Bullets[] var3 = new Bullets[uniqueAppList.length + 1];
- System.arraycopy(uniqueAppList, 0, var3, 0, uniqueAppList.length);
- var3[uniqueAppList.length] = var0;
- uniqueAppList = var3;
- }
- }
-
- public static synchronized void stopUniqueApp(Bullets var0) {
- if (var0.slaveList == null) {
- var0.master.removeApp(var0);
- } else if (uniqueAppList.length == 1 && var0.slaveList.length == 1) {
- var0.slaveList = null;
- var0.mainThread.stop();
- threadMaster = null;
- uniqueAppList = null;
- } else {
- if (var0.slaveList.length > 1) {
- for(int var1 = 0; var1 < uniqueAppList.length; ++var1) {
- if (var0 == uniqueAppList[var1]) {
- uniqueAppList[var1] = var0.slaveList[1];
- }
- }
-
- var0.slaveList[1].takeMaster();
- var0.slaveList = null;
- } else {
- Bullets[] var4 = new Bullets[uniqueAppList.length - 1];
- int var2 = 0;
-
- for(int var3 = 0; var3 < uniqueAppList.length; ++var3) {
- if (var0 != uniqueAppList[var3] && uniqueAppList[var3] != null) {
- var4[var2++] = uniqueAppList[var3];
- }
- }
-
- uniqueAppList = var4;
- }
-
- if (threadMaster == var0) {
- var0.mainThread.stop();
- threadMaster = uniqueAppList[0];
- threadMaster.mainThread = new Thread(threadMaster);
- threadMaster.mainThread.start();
- }
-
- }
- }
-
- public synchronized void takeMaster() {
- this.slaveList = new Bullets[this.master.slaveList.length - 1];
- System.arraycopy(this.master.slaveList, 1, this.slaveList, 0, this.slaveList.length);
- this.offGraphic = this.master.offGraphic;
- this.offImage = this.master.offImage;
- this.displayList = this.master.displayList;
- this.currentColor = this.master.currentColor;
- this.displayCounter = this.master.displayCounter;
- this.fadeCounter = this.master.fadeCounter;
- this.field_2 = this.master.field_2;
- this.field_3 = this.master.field_3;
- this.field_4 = this.master.field_4;
- this.ToR = this.master.ToR;
- this.ToG = this.master.ToG;
- this.ToB = this.master.ToB;
-
- for(int var1 = 0; var1 < this.slaveList.length; ++var1) {
- this.slaveList[var1].master = this;
- }
-
- }
-
- public synchronized void addApp(Bullets var1) {
- Bullets[] var2 = new Bullets[this.slaveList.length + 1];
- System.arraycopy(this.slaveList, 0, var2, 0, this.slaveList.length);
- var2[this.slaveList.length] = var1;
- this.slaveList = var2;
- var1.master = this;
- }
-
- public synchronized void removeApp(Bullets var1) {
- if (this.slaveList != null && this.slaveList.length != 1) {
- Bullets[] var2 = new Bullets[this.slaveList.length - 1];
- int var3 = 0;
-
- for(int var4 = 0; var4 < this.slaveList.length; ++var4) {
- if (var1 != this.slaveList[var4] && this.slaveList[var4] != null) {
- var2[var3++] = this.slaveList[var4];
- }
- }
-
- this.slaveList = var2;
- } else {
- this.slaveList = null;
- }
- }
-
- public void stop() {
- stopUniqueApp(this);
- }
-
- public void paint(Graphics var1) {
- if (this.master != null) {
- var1.drawImage(this.master.offImage, 0, 0, this);
- }
-
- }
-
- public int getColor(String var1, int var2) {
- if (var1 == null) {
- return var2;
- } else {
- var1 = var1.toLowerCase().trim();
- if (var1.equals("black")) {
- return 0;
- } else if (var1.equals("blue")) {
- return 255;
- } else if (var1.equals("cyan")) {
- return 65535;
- } else if (var1.equals("darkgray")) {
- return 4210752;
- } else if (var1.equals("gray")) {
- return 8421504;
- } else if (var1.equals("green")) {
- return 65280;
- } else if (var1.equals("lightgray")) {
- return 12632256;
- } else if (var1.equals("magenta")) {
- return 16711935;
- } else if (var1.equals("orange")) {
- return 16762880;
- } else if (var1.equals("pink")) {
- return 16756655;
- } else if (var1.equals("red")) {
- return 16711680;
- } else if (var1.equals("white")) {
- return 16777215;
- } else if (var1.equals("yellow")) {
- return 16776960;
- } else {
- try {
- return Integer.parseInt(var1, 16);
- } catch (NumberFormatException var5) {
- String var3 = var1.substring(1);
-
- try {
- return Integer.parseInt(var3, 16);
- } catch (NumberFormatException var4) {
- System.out.println("Could not parse: '" + var1 + "' into a color");
- System.out.println("Using default value instead");
- return var2;
- }
- }
- }
- }
- }
-
- private static synchronized long updateApps() {
- if (uniqueAppList == null) {
- return 0L;
- } else {
- long var0 = System.currentTimeMillis();
- long var2 = Long.MAX_VALUE;
-
- for(int var4 = 0; var4 < uniqueAppList.length; ++var4) {
- Bullets var5 = uniqueAppList[var4];
- if (var5.nextUpdateTime < var0) {
- var5.draw();
- }
-
- if (var5.nextUpdateTime < var2) {
- var2 = var5.nextUpdateTime;
- }
- }
-
- return var2;
- }
- }
-
- public void run() {
- while(threadMaster == this) {
- long var1 = updateApps() - System.currentTimeMillis();
-
- try {
- if (var1 > 0L) {
- Thread.sleep(var1);
- }
- } catch (InterruptedException var3) {
- }
- }
-
- this.mainThread = null;
- }
-
- private void fadeColor() {
- if (this.field_2 > this.ToR) {
- this.field_2 -= this.fadeAmount;
- if (this.field_2 < this.ToR) {
- this.field_2 = this.ToR;
- }
- } else if (this.field_2 < this.ToR) {
- this.field_2 += this.fadeAmount;
- if (this.field_2 > this.ToR) {
- this.field_2 = this.ToR;
- }
- }
-
- if (this.field_3 > this.ToG) {
- this.field_3 -= this.fadeAmount;
- if (this.field_3 < this.ToG) {
- this.field_3 = this.ToG;
- }
- } else if (this.field_3 < this.ToG) {
- this.field_3 += this.fadeAmount;
- if (this.field_3 > this.ToG) {
- this.field_3 = this.ToG;
- }
- }
-
- if (this.field_4 > this.ToB) {
- this.field_4 -= this.fadeAmount;
- if (this.field_4 < this.ToB) {
- this.field_4 = this.ToB;
- return;
- }
- } else if (this.field_4 < this.ToB) {
- this.field_4 += this.fadeAmount;
- if (this.field_4 > this.ToB) {
- this.field_4 = this.ToB;
- }
- }
-
- }
-
- public synchronized void draw() {
- if (this.slaveList != null) {
- for(int var1 = this.displayList.length; var1 > 1; this.displayList[var1] = this.displayList[var1 - 1]) {
- --var1;
- }
-
- this.displayList[0] = this.currentColor;
- int var2 = this.displayList.length;
- Dimension var3 = ((Component)this).size();
-
- for(int var4 = 0; var4 < this.displayList.length; ++var4) {
- this.offGraphic.setColor(this.displayList[var4]);
- int var5 = var2 * var3.width / this.displayList.length;
- int var6 = var2 * var3.height / this.displayList.length;
- --var2;
- switch (this.direction) {
- case 0:
- if (this.isBullet) {
- this.offGraphic.fillOval(0, 0, var3.width, var3.height);
- } else {
- this.offGraphic.fillRect(0, 0, var3.width, var3.height);
- }
- break;
- case 2:
- this.offGraphic.setColor(this.displayList[var2]);
- case 1:
- if (this.isBullet) {
- if (this.direction == 2) {
- this.offGraphic.setColor(this.displayList[this.displayList.length - 1 - var4 / 2]);
- } else {
- this.offGraphic.setColor(this.displayList[var4 / 2]);
- }
-
- this.offGraphic.fillArc((var3.width - var5) / 2, 0, var5, var3.height, 270, 180);
- if (this.direction == 2) {
- this.offGraphic.setColor(this.displayList[var4 / 2]);
- } else {
- this.offGraphic.setColor(this.displayList[this.displayList.length - 1 - var4 / 2]);
- }
-
- this.offGraphic.fillArc((var3.width - var5) / 2, 0, var5, var3.height, 90, 180);
- } else {
- this.offGraphic.fillRect(0, 0, var5, var3.height);
- }
- break;
- case 4:
- this.offGraphic.setColor(this.displayList[var2]);
- case 3:
- if (this.isBullet) {
- if (this.direction == 4) {
- this.offGraphic.setColor(this.displayList[this.displayList.length - 1 - var4 / 2]);
- } else {
- this.offGraphic.setColor(this.displayList[var4 / 2]);
- }
-
- this.offGraphic.fillArc(0, (var3.height - var6) / 2, var3.width, var6, 180, 180);
- if (this.direction == 4) {
- this.offGraphic.setColor(this.displayList[var4 / 2]);
- } else {
- this.offGraphic.setColor(this.displayList[this.displayList.length - 1 - var4 / 2]);
- }
-
- this.offGraphic.fillArc(0, (var3.height - var6) / 2, var3.width, var6, 0, 180);
- } else {
- this.offGraphic.fillRect(0, 0, var3.width, var6);
- }
- break;
- case 6:
- this.offGraphic.setColor(this.displayList[var2]);
- case 5:
- if (this.isBullet) {
- this.offGraphic.fillOval((var3.width - var5) / 2, (var3.height - var6) / 2, var5, var6);
- } else {
- this.offGraphic.fillRect((var3.width - var5) / 2, (var3.height - var6) / 2, var5, var6);
- }
- }
- }
-
- for(int var8 = 0; var8 < this.slaveList.length; ++var8) {
- try {
- this.slaveList[var8].getGraphics().drawImage(this.offImage, 0, 0, this);
- } catch (Exception var7) {
- }
- }
-
- this.nextUpdateTime = System.currentTimeMillis() + (long)this.delay;
- if (++this.displayCounter > this.displayList.length / this.displayColors) {
- this.displayCounter = 0;
- if (this.effect == 1) {
- if (this.field_2 == this.ToR && this.field_4 == this.ToB && this.field_3 == this.ToG) {
- if (this.pauseTime > 0) {
- if (++this.fadeCounter >= this.displayColors) {
- this.fadeCounter = 0;
- this.nextUpdateTime = System.currentTimeMillis() + (long)this.pauseTime;
- ++this.colorIndex;
- if (this.colorIndex == this.colors.length) {
- this.colorIndex = 0;
- }
-
- this.ToR = this.colors[this.colorIndex] >> 16 & 255;
- this.ToG = this.colors[this.colorIndex] >> 8 & 255;
- this.ToB = this.colors[this.colorIndex] & 255;
- }
- } else {
- ++this.colorIndex;
- if (this.colorIndex == this.colors.length) {
- this.colorIndex = 0;
- }
-
- this.ToR = this.colors[this.colorIndex] >> 16 & 255;
- this.ToG = this.colors[this.colorIndex] >> 8 & 255;
- this.ToB = this.colors[this.colorIndex] & 255;
- }
- } else {
- this.fadeColor();
- }
- } else {
- ++this.colorIndex;
- if (this.colorIndex == this.colors.length) {
- this.colorIndex = 0;
- }
-
- this.field_2 = this.colors[this.colorIndex] >> 16 & 255;
- this.field_3 = this.colors[this.colorIndex] >> 8 & 255;
- this.field_4 = this.colors[this.colorIndex] & 255;
- if (this.pauseTime > 0) {
- this.nextUpdateTime = System.currentTimeMillis() + (long)this.pauseTime;
- }
- }
-
- this.currentColor = new Color(this.field_2, this.field_3, this.field_4);
- }
-
- }
- }
- }
-