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.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.image.ImageObserver;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.Hashtable;
-
- public class Ticker extends Applet implements Runnable {
- protected char[] separated;
- protected char[][] separateda;
- protected Thread StringThread;
- protected int[] xlocation;
- protected int[][] xlocationa;
- protected int[] xwidth;
- protected int[][] xwidtha;
- protected boolean threadSuspended = false;
- protected int chardelay;
- protected int rundelay;
- protected boolean endofstring = false;
- protected int total_width;
- protected int[] total_widtha;
- protected boolean thread_running;
- protected Color app_bg_color;
- protected Image offScreen;
- protected Graphics offGC;
- protected int applet_width;
- protected int applet_height;
- protected int app_height;
- protected int app_width;
- protected String bgimage_file;
- protected Image bgimage;
- protected boolean tile;
- protected int bgimage_height;
- protected int bgimage_width;
- protected Image tiled_bgimage;
- protected Graphics bg_g;
- // $FF: renamed from: tx java.lang.String
- protected String field_0;
- protected String[] txa;
- protected int xoffset;
- protected int yoffset;
- protected Color textcolor;
- protected boolean horizcenter;
- protected boolean vertcenter;
- protected Font font;
- protected FontMetrics fontmetrics;
- protected boolean underline;
- protected int width;
- protected int[] widtha;
- protected int height;
- protected int ascent;
- protected int descent;
- protected int txcount;
- protected int index;
- protected int cur_xoffset;
- protected int move_dist;
- protected boolean forward = true;
- protected boolean reverse = false;
- Hashtable colors;
-
- public void init() {
- this.app_bg_color = this.GetParmToColor("AppBGColor", (Color)null);
- this.txcount = this.GetParmToInt("TextCount", 0);
- this.field_0 = this.GetParmToString("Text", "");
- this.xoffset = this.GetParmToInt("XOffset", 0);
- this.yoffset = this.GetParmToInt("YOffset", -1);
- this.textcolor = this.GetParmToColor("TextColor", (Color)null);
- this.horizcenter = this.GetParmToBoolean("HorizCenter", false);
- this.vertcenter = this.GetParmToBoolean("VertCenter", false);
- this.font = this.GetParmToFont("Font", "Style", "PointSize");
- if (this.txcount > 0) {
- this.txa = new String[this.txcount];
- }
-
- for(int var1 = 0; var1 < this.txcount; ++var1) {
- this.txa[var1] = this.GetParmToString("Text" + (var1 + 1), "");
- }
-
- this.chardelay = this.GetParmToInt("DelayBetweenChars", 20);
- this.rundelay = this.GetParmToInt("DelayBetweenRuns", 3000);
- this.tile = this.GetParmToBoolean("AppTile", false);
- this.bgimage_file = this.GetParmToString("AppBGImage", (String)null);
- if (this.bgimage_file != null) {
- this.bgimage = this.process(((Applet)this).getDocumentBase(), this.bgimage_file, false);
- this.prepareImage(this.bgimage);
- this.bgimage_width = this.getWidth(this.bgimage, this);
- this.bgimage_height = this.getHeight(this.bgimage, this);
- }
-
- ((Component)this).setFont(this.font);
- this.fontmetrics = ((Component)this).getFontMetrics(this.font);
- this.width = this.fontmetrics.stringWidth(this.field_0);
- this.height = this.fontmetrics.getHeight();
- this.ascent = this.fontmetrics.getMaxAscent();
- this.descent = this.fontmetrics.getDescent();
- if (this.txcount > 0) {
- this.widtha = new int[this.txcount];
- }
-
- for(int var3 = 0; var3 < this.txcount; ++var3) {
- this.widtha[var3] = this.fontmetrics.stringWidth(this.txa[var3]);
- }
-
- if (this.app_bg_color != null) {
- ((Component)this).setBackground(this.app_bg_color);
- } else {
- this.app_bg_color = ((Component)this).getBackground();
- }
-
- if (this.textcolor != null) {
- ((Component)this).setForeground(this.textcolor);
- } else {
- this.textcolor = ((Component)this).getForeground();
- }
-
- this.separated = new char[this.field_0.length()];
- this.xlocation = new int[this.field_0.length()];
- this.xwidth = new int[this.field_0.length()];
- if (this.txcount > 0) {
- this.separateda = new char[this.txcount][];
- this.xlocationa = new int[this.txcount][];
- this.xwidtha = new int[this.txcount][];
- }
-
- for(int var4 = 0; var4 < this.txcount; ++var4) {
- this.separateda[var4] = new char[this.txa[var4].length()];
- this.xlocationa[var4] = new int[this.txa[var4].length()];
- this.xwidtha[var4] = new int[this.txa[var4].length()];
- this.txa[var4].getChars(0, this.txa[var4].length(), this.separateda[var4], 0);
- }
-
- this.field_0.getChars(0, this.field_0.length(), this.separated, 0);
- if (this.txcount > 0) {
- this.total_widtha = new int[this.txcount];
- }
-
- for(int var5 = 0; var5 < this.txcount; ++var5) {
- this.total_widtha[var5] = 0;
- }
-
- for(int var6 = 0; var6 < this.txcount; ++var6) {
- for(int var2 = 0; var2 < this.txa[var6].length(); ++var2) {
- this.xwidtha[var6][var2] = this.fontmetrics.charWidth(this.separateda[var6][var2]);
- int[] var10000 = this.total_widtha;
- var10000[var6] += this.xwidtha[var6][var2];
- if (var2 + 1 < this.txa[var6].length()) {
- this.xlocationa[var6][var2 + 1] = this.total_widtha[var6];
- }
- }
- }
-
- this.total_width = 0;
-
- for(int var7 = 0; var7 < this.field_0.length(); ++var7) {
- this.xwidth[var7] = this.fontmetrics.charWidth(this.separated[var7]);
- this.total_width += this.xwidth[var7];
- if (var7 + 1 < this.field_0.length()) {
- this.xlocation[var7 + 1] = this.total_width;
- }
- }
-
- this.offScreen = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
- this.offGC = this.offScreen.getGraphics();
- this.offGC.setFont(this.font);
- this.move_dist = this.GetParmToInt("MoveDist", 5);
- this.reverse = this.GetParmToBoolean("Reverse", false);
- if (this.reverse) {
- this.forward = false;
- }
-
- }
-
- public void paint(Graphics var1) {
- if (this.applet_width != ((Component)this).size().width || this.applet_height != ((Component)this).size().height) {
- this.applet_width = ((Component)this).size().width;
- this.applet_height = ((Component)this).size().height;
- this.offScreen = ((Component)this).createImage(this.applet_width, this.applet_height);
- this.offGC = this.offScreen.getGraphics();
- this.offGC.setFont(this.font);
- }
-
- if (this.horizcenter) {
- this.xoffset = ((Component)this).size().width / 2 - this.total_width / 2;
- }
-
- if (this.vertcenter) {
- this.yoffset = ((Component)this).size().height / 2 + this.ascent / 3;
- } else if (this.yoffset == -1) {
- this.yoffset = this.height - this.descent;
- }
-
- this.offGC.setColor(((Component)this).getBackground());
- this.offGC.fillRect(0, 0, this.applet_width, this.applet_height);
- this.tilebackground(this.offGC);
- if (this.forward) {
- if (this.widtha[this.index] + this.cur_xoffset > 0) {
- this.cur_xoffset -= this.move_dist;
- this.offGC.setColor(((Component)this).getForeground());
- this.offGC.drawString(this.txa[this.index], this.cur_xoffset, this.yoffset);
- } else {
- this.endofstring = true;
- }
- } else if (this.cur_xoffset < ((Component)this).size().width) {
- this.cur_xoffset += this.move_dist;
- this.offGC.setColor(((Component)this).getForeground());
- this.offGC.drawString(this.txa[this.index], this.cur_xoffset, this.yoffset);
- } else {
- this.endofstring = true;
- }
-
- var1.drawImage(this.offScreen, 0, 0, this);
- }
-
- public void run() {
- this.StringThread.setPriority(1);
-
- while(this.StringThread != null) {
- try {
- Thread.sleep((long)this.chardelay);
- } catch (InterruptedException var2) {
- }
-
- if (this.endofstring) {
- if (this.forward) {
- ++this.index;
- if (this.index == this.txcount) {
- this.index = 0;
- }
- } else {
- --this.index;
- if (this.index < 0) {
- this.index = this.txcount - 1;
- }
- }
-
- try {
- Thread.sleep((long)this.rundelay);
- } catch (InterruptedException var1) {
- }
-
- if (this.forward) {
- this.cur_xoffset = ((Component)this).size().width;
- } else {
- this.cur_xoffset = -this.widtha[this.index];
- }
-
- this.endofstring = false;
- } else {
- ((Component)this).repaint();
- }
- }
-
- }
-
- public boolean keyDown(Event var1, int var2) {
- if (var2 == 109) {
- ++this.move_dist;
- ((Applet)this).getAppletContext().showStatus("New distance: " + this.move_dist);
- return true;
- } else if (var2 == 108) {
- --this.move_dist;
- if (this.move_dist <= 0) {
- this.move_dist = 1;
- }
-
- ((Applet)this).getAppletContext().showStatus("New distance: " + this.move_dist);
- return true;
- } else {
- if (var2 == 102) {
- this.chardelay = (int)((double)this.chardelay * 0.9);
- if (this.chardelay < 10) {
- this.chardelay = 10;
- }
-
- ((Applet)this).getAppletContext().showStatus("Setting image delay to: " + this.chardelay);
- } else if (var2 == 115) {
- if (this.chardelay < 10) {
- ++this.chardelay;
- } else {
- this.chardelay = (int)((double)this.chardelay * 1.1);
- }
-
- ((Applet)this).getAppletContext().showStatus("Setting image delay to: " + this.chardelay);
- } else if (var2 == 70) {
- this.rundelay = (int)((double)this.rundelay * 0.9);
- if (this.rundelay < 10) {
- this.rundelay = 10;
- }
-
- ((Applet)this).getAppletContext().showStatus("Setting run delay to: " + this.rundelay);
- } else if (var2 == 83) {
- if (this.rundelay < 10) {
- ++this.rundelay;
- } else {
- this.rundelay = (int)((double)this.rundelay * 1.1);
- }
-
- ((Applet)this).getAppletContext().showStatus("Setting run delay to: " + this.rundelay);
- }
-
- return true;
- }
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- if ((var1.modifiers & 1) != 0) {
- this.forward = !this.forward;
- } else if (this.StringThread == null) {
- this.StringThread = new Thread(this);
- this.StringThread.start();
- } else {
- this.StringThread = null;
- }
-
- return true;
- }
-
- public void update(Graphics var1) {
- this.paint(var1);
- }
-
- public void start() {
- if (this.StringThread == null) {
- this.endofstring = false;
- this.cur_xoffset = ((Component)this).size().width;
- this.StringThread = new Thread(this);
- this.StringThread.start();
- }
-
- }
-
- public void stop() {
- if (this.StringThread != null) {
- this.StringThread.stop();
- }
-
- this.StringThread = null;
- }
-
- protected void tilebackground(Graphics var1) {
- if (this.bgimage != null) {
- if (!this.isImagePrepared(this.bgimage)) {
- this.loadImageAndWait(this.bgimage);
- }
-
- if (this.app_width != ((Component)this).size().width || this.app_height != ((Component)this).size().height) {
- this.app_width = ((Component)this).size().width;
- this.app_height = ((Component)this).size().height;
- this.tiled_bgimage = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
- this.bg_g = this.tiled_bgimage.getGraphics();
- this.bg_g.setColor(this.app_bg_color);
- this.bg_g.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
- if (this.tile) {
- for(int var2 = -this.bgimage_height; var2 < this.app_height; var2 += this.bgimage_height) {
- for(int var3 = -this.bgimage_width; var3 < this.app_width; var3 += this.bgimage_width) {
- this.bg_g.drawImage(this.bgimage, var3 + 2, var2 + 2, this);
- }
- }
- } else {
- this.bg_g.drawImage(this.bgimage, 0, 0, this);
- }
- }
-
- if (this.tiled_bgimage != null) {
- var1.drawImage(this.tiled_bgimage, 0, 0, this);
- }
-
- }
- }
-
- public int GetParmToInt(String var1, int var2) {
- String var3 = ((Applet)this).getParameter(var1);
- return var3 == null ? var2 : Integer.parseInt(var3);
- }
-
- public String GetParmToString(String var1, String var2) {
- String var3 = ((Applet)this).getParameter(var1);
- return var3 == null ? var2 : var3;
- }
-
- public boolean GetParmToBoolean(String var1, boolean var2) {
- String var3 = ((Applet)this).getParameter(var1);
- return var3 == null ? var2 : var3.equalsIgnoreCase("true");
- }
-
- public Color GetParmToColor(String var1, Color var2) {
- String var4 = ((Applet)this).getParameter(var1);
- if (var4 == null) {
- return var2;
- } else {
- try {
- if (var4.charAt(0) == '#') {
- char[] var5 = new char[var4.length()];
- var4.getChars(0, var4.length(), var5, 0);
- new Color(Integer.parseInt(new String(var5, 1, var4.length() - 1), 16));
- return new Color(Integer.parseInt(new String(var5, 1, var4.length() - 1), 16));
- } else {
- Color var3 = new Color(Integer.parseInt(var4, 16));
- return var3;
- }
- } catch (NumberFormatException var7) {
- String var6 = this.getColor(var4);
- if (var6 != null) {
- return new Color(Integer.parseInt(var6, 16));
- } else {
- System.out.println("Bad color specification: " + ((Throwable)var7).getMessage());
- return null;
- }
- }
- }
- }
-
- public URL GetParmToURL(String var1) {
- Object var2 = null;
- String var3 = ((Applet)this).getParameter(var1);
- if (var3 == null) {
- return null;
- } else {
- try {
- var7 = new URL(var3);
- } catch (MalformedURLException var6) {
- var7 = null;
- }
-
- if (var7 == null) {
- try {
- var7 = new URL(((Applet)this).getDocumentBase(), var3);
- } catch (MalformedURLException var5) {
- var7 = null;
- }
- }
-
- if (var7 == null) {
- try {
- var7 = new URL(((Applet)this).getCodeBase(), var3);
- } catch (MalformedURLException var4) {
- var7 = null;
- }
- }
-
- if (var7 == null) {
- System.out.println("Unable to load URL: " + var3);
- }
-
- return var7;
- }
- }
-
- public Font GetParmToFont(String var1, String var2, String var3) {
- int var6 = -1;
- Font var9 = ((Component)this).getFont();
- String var4 = ((Applet)this).getParameter(var1);
- if (var4 == null) {
- var4 = var9.getName();
- }
-
- String var5 = ((Applet)this).getParameter(var2);
- if (var5 == null) {
- var6 = var9.getStyle();
- }
-
- if (!var4.equalsIgnoreCase("TimesRoman") && !var4.equalsIgnoreCase("Helvetica") && !var4.equalsIgnoreCase("Courier") && !var4.equalsIgnoreCase("Dialog") && !var4.equalsIgnoreCase("DialogInput") && !var4.equalsIgnoreCase("ZapfDingbats")) {
- var4 = var9.getName();
- }
-
- if (var6 == -1) {
- if (var5.equalsIgnoreCase("bold")) {
- var6 = 1;
- } else if (var5.equalsIgnoreCase("italic")) {
- var6 = 2;
- } else if (var5.equalsIgnoreCase("bolditalic")) {
- var6 = 3;
- } else {
- var6 = 0;
- }
- }
-
- String var10 = ((Applet)this).getParameter(var3);
- int var7;
- if (var10 == null) {
- var7 = var9.getSize();
- } else {
- try {
- var7 = Integer.parseInt(var10);
- } catch (NumberFormatException var11) {
- var7 = var9.getSize();
- System.out.println("NumberformatException: " + var10);
- }
- }
-
- Font var8 = new Font(var4, var6, var7);
- return var8;
- }
-
- public String getColor(String var1) {
- if (this.colors == null) {
- this.createHashTable();
- }
-
- return (String)this.colors.get(var1);
- }
-
- public void createHashTable() {
- if (this.colors == null) {
- this.colors = new Hashtable(650);
- this.colors.put("aliceblue", "f0f8ff");
- this.colors.put("antiquewhite", "faebd7");
- this.colors.put("aquamarine", "7fffd4");
- this.colors.put("azure", "f0ffff");
- this.colors.put("beige", "f5f5dc");
- this.colors.put("bisque", "ffe4c4");
- this.colors.put("black", "000000");
- this.colors.put("blanchedalmond", "ffebcd");
- this.colors.put("blue", "0000ff");
- this.colors.put("blueviolet", "8a2be2");
- this.colors.put("brown", "a52a2a");
- this.colors.put("burlywood", "deb887");
- this.colors.put("cadetblue", "5f9ea0");
- this.colors.put("chartreuse", "7fff00");
- this.colors.put("chocolate", "d2691e");
- this.colors.put("coral", "ff7f50");
- this.colors.put("cornflowerblue", "6495ed");
- this.colors.put("cornsilk", "fff8dc");
- this.colors.put("cyan", "00ffff");
- this.colors.put("darkgoldenrod", "b8860b");
- this.colors.put("darkgreen", "006400");
- this.colors.put("darkkhaki", "bdb76b");
- this.colors.put("darkolivegreen", "556b2f");
- this.colors.put("darkorange", "ff8c00");
- this.colors.put("darkorchid", "9932cc");
- this.colors.put("darksalmon", "e9967a");
- this.colors.put("darkseagreen", "8fbc8f");
- this.colors.put("darkslateblue", "483d8b");
- this.colors.put("darkslategray", "2f4f4f");
- this.colors.put("darkslategrey", "2f4f4f");
- this.colors.put("darkturquoise", "00ced1");
- this.colors.put("darkviolet", "9400d3");
- this.colors.put("deeppink", "ff1493");
- this.colors.put("deepskyblue", "00bfff");
- this.colors.put("dimgray", "696969");
- this.colors.put("dimgrey", "696969");
- this.colors.put("dodgerblue", "1e90ff");
- this.colors.put("firebrick", "b22222");
- this.colors.put("floralwhite", "fffaf0");
- this.colors.put("forestgreen", "228b22");
- this.colors.put("green", "00ff00");
- this.colors.put("gainsboro", "dcdcdc");
- this.colors.put("ghostwhite", "f8f8ff");
- this.colors.put("gold", "ffd700");
- this.colors.put("goldenrod", "daa520");
- this.colors.put("gray", "bebebe");
- this.colors.put("honeydew", "f0fff0");
- this.colors.put("hotpink", "ff69b4");
- this.colors.put("indianred", "cd5c5c");
- this.colors.put("ivory", "fffff0");
- this.colors.put("khaki", "f0e68c");
- this.colors.put("lavender", "e6e6fa");
- this.colors.put("lavenderblush", "fff0f5");
- this.colors.put("lawngreen", "7cfc00");
- this.colors.put("lemonchiffon", "fffacd");
- this.colors.put("lightblue", "add8e6");
- this.colors.put("lightcoral", "f08080");
- this.colors.put("lightcyan", "e0ffff");
- this.colors.put("lightgoldenrod", "eedd82");
- this.colors.put("lightgoldenrodyellow", "fafad2");
- this.colors.put("lightgray", "d3d3d3");
- this.colors.put("lightgrey", "d3d3d3");
- this.colors.put("lightpink", "ffb6c1");
- this.colors.put("lightsalmon", "ffa07a");
- this.colors.put("lightseagreen", "20b2aa");
- this.colors.put("lightskyblue", "87cefa");
- this.colors.put("lightslateblue", "8470ff");
- this.colors.put("lightslategray", "778899");
- this.colors.put("lightslategrey", "778899");
- this.colors.put("lightsteelblue", "b0c4de");
- this.colors.put("lightyellow", "ffffe0");
- this.colors.put("limegreen", "32cd32");
- this.colors.put("linen", "faf0e6");
- this.colors.put("magenta", "ff00ff");
- this.colors.put("maroon", "b03060");
- this.colors.put("mediumaquamarine", "66cdaa");
- this.colors.put("mediumblue", "0000cd");
- this.colors.put("mediumorchid", "ba55d3");
- this.colors.put("mediumpurple", "9370db");
- this.colors.put("mediumseagreen", "3cb371");
- this.colors.put("mediumslateblue", "7b68ee");
- this.colors.put("mediumspringgreen", "00fa9a");
- this.colors.put("mediumturquoise", "48d1cc");
- this.colors.put("mediumvioletred", "c71585");
- this.colors.put("midnightblue", "191970");
- this.colors.put("mintcream", "f5fffa");
- this.colors.put("mistyrose", "ffe4e1");
- this.colors.put("moccasin", "ffe4b5");
- this.colors.put("navajowhite", "ffdead");
- this.colors.put("navy", "000080");
- this.colors.put("navyblue", "000080");
- this.colors.put("oldlace", "fdf5e6");
- this.colors.put("olivedrab", "6b8e23");
- this.colors.put("orange", "ffa500");
- this.colors.put("orangered", "ff4500");
- this.colors.put("orchid", "da70d6");
- this.colors.put("palegoldenrod", "eee8aa");
- this.colors.put("palegreen", "98fb98");
- this.colors.put("paleturquoise", "afeeee");
- this.colors.put("palevioletred", "db7093");
- this.colors.put("papayawhip", "ffefd5");
- this.colors.put("peachpuff", "ffdab9");
- this.colors.put("peru", "cd853f");
- this.colors.put("pink", "ffc0cb");
- this.colors.put("plum", "dda0dd");
- this.colors.put("powderblue", "b0e0e6");
- this.colors.put("purple", "a020f0");
- this.colors.put("red", "ff0000");
- this.colors.put("rosybrown", "bc8f8f");
- this.colors.put("royalblue", "4169e1");
- this.colors.put("saddlebrown", "8b4513");
- this.colors.put("salmon", "fa8072");
- this.colors.put("sandybrown", "f4a460");
- this.colors.put("seagreen", "2e8b57");
- this.colors.put("seashell", "fff5ee");
- this.colors.put("sienna", "a0522d");
- this.colors.put("skyblue", "87ceeb");
- this.colors.put("slateblue", "6a5acd");
- this.colors.put("slategray", "708090");
- this.colors.put("slategrey", "708090");
- this.colors.put("snow", "fffafa");
- this.colors.put("springgreen", "00ff7f");
- this.colors.put("steelblue", "4682b4");
- this.colors.put("tan", "d2b48c");
- this.colors.put("thistle", "d8bfd8");
- this.colors.put("tomato", "ff6347");
- this.colors.put("turquoise", "40e0d0");
- this.colors.put("violet", "ee82ee");
- this.colors.put("violetred", "d02090");
- this.colors.put("wheat", "f5deb3");
- this.colors.put("white", "ffffff");
- this.colors.put("whitesmoke", "f5f5f5");
- this.colors.put("yellow", "ffff00");
- this.colors.put("yellowgreen", "9acd32");
- }
- }
-
- public Image process(URL var1, String var2, boolean var3) {
- if (var2 == null) {
- return null;
- } else {
- Image var4 = ((Applet)this).getImage(var1, var2);
- if (var3) {
- this.loadImageAndWait(var4);
- }
-
- return var4;
- }
- }
-
- public boolean isImagePrepared(Image var1) {
- boolean var2 = ((Component)this).prepareImage(var1, this);
- return var2;
- }
-
- public void prepareImage(Image var1) {
- ((Component)this).prepareImage(var1, this);
- }
-
- public synchronized void loadImageAndWait(Image var1) {
- boolean var3 = ((Component)this).prepareImage(var1, this);
- if (!var3) {
- while((((Component)this).checkImage(var1, this) & 32) == 0) {
- try {
- this.wait(100L);
- } catch (InterruptedException var4) {
- }
- }
- }
-
- }
-
- public synchronized int getWidth(Image var1, ImageObserver var2) {
- int var3;
- while((var3 = var1.getWidth(var2)) == -1) {
- try {
- this.wait(100L);
- } catch (InterruptedException var4) {
- }
- }
-
- return var3;
- }
-
- public synchronized int getHeight(Image var1, ImageObserver var2) {
- int var3;
- while((var3 = var1.getHeight(var2)) == -1) {
- try {
- this.wait(100L);
- } catch (InterruptedException var4) {
- }
- }
-
- return var3;
- }
- }
-