home *** CD-ROM | disk | FTP | other *** search
Wrap
import java.applet.Applet; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.Event; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Image; import java.net.URL; import java.util.StringTokenizer; public class NavigatorTicker20 extends Applet implements Runnable { public int messageIndex; public int messageCount = 1; public String message; public String[] msgs; public Font messageF; public int messageX; public int messageY; public int messageW; public int[] msgsW; public URL url_; public String[] msgsURL; public String[] msgsURLTargets; public String[] msgsURLDescriptions; int speed; // $FF: renamed from: t java.lang.Thread public Thread field_0; public boolean active = false; public Color txtCo; public Color linkCo; public Color bgCo; public Color shCo; public Dimension lastS = new Dimension(1, 1); // $FF: renamed from: im java.awt.Image Image field_1; // $FF: renamed from: gr java.awt.Graphics Graphics field_2; boolean display_URL = false; boolean SHADOW = false; boolean BORDER = true; public int shDepth = 2; int mouseX; public void init() { String var1 = ((Applet)this).getParameter("courtesy"); if (!var1.equals("ITS of Egypt http://its.egnet.net")) { System.exit(0); } this.messageCount = (var1 = ((Applet)this).getParameter("count")) == null ? 0 : Integer.valueOf(var1); this.shDepth = (var1 = ((Applet)this).getParameter("shDepth")) == null ? 2 : Integer.valueOf(var1); System.out.println("shDepth = " + this.shDepth); this.SHADOW = (var1 = ((Applet)this).getParameter("shCo")) != null; if (this.SHADOW) { this.shCo = this.readColor(var1, ((Component)this).getBackground()); } this.BORDER = ((Applet)this).getParameter("border") == null; this.msgs = new String[this.messageCount]; this.msgsW = new int[this.messageCount]; this.msgsURL = new String[this.messageCount]; this.msgsURLTargets = new String[this.messageCount]; this.msgsURLDescriptions = new String[this.messageCount]; for(int var2 = 0; var2 < this.messageCount; ++var2) { var1 = ((Applet)this).getParameter("msg" + var2); StringTokenizer var3 = new StringTokenizer(var1, "\\"); this.msgs[var2] = new String(var3.nextToken()); this.msgsURL[var2] = new String(var3.nextToken()); this.msgsURLTargets[var2] = new String(var3.nextToken()); this.msgsURLDescriptions[var2] = new String(var3.nextToken()); } this.speed = (var1 = ((Applet)this).getParameter("speed")) == null ? 10 : Integer.valueOf(var1); this.txtCo = this.readColor(((Applet)this).getParameter("txtco"), this.bgCo); this.linkCo = this.readColor(((Applet)this).getParameter("linkco"), this.bgCo); this.bgCo = this.readColor(((Applet)this).getParameter("bgco"), ((Component)this).getBackground()); } public String[][] gets_parameterInfo() { String[][] var1 = new String[][]{{"count", "int", "Tos_paramal Number of Messages"}, {"msg%N", "String", "Message to display with optional URL delimited by \\"}, {"speed", "int", "animatmion speed in pixels (10)"}, {"txtco", "int[3]", "RGB-Color of Message (black/blue)"}, {"bgco", "int[3]", "RGB-Color of background (getBackground)"}, {"linktco", "int[3]", "RGB-Color of active message (black/blue)"}}; return var1; } public String getAppletInfo() { return "NavigatorTicker.java, V 2, Aug 20/96 by Ahmed Abdel-Hady ahady@idsc.gov.eg"; } public Color readColor(String var1, Color var2) { if (var1 == null) { return var2; } else { StringTokenizer var6 = new StringTokenizer(var1, ","); try { int var3 = Integer.valueOf(var6.nextToken()); int var4 = Integer.valueOf(var6.nextToken()); int var5 = Integer.valueOf(var6.nextToken()); return new Color(var3, var4, var5); } catch (Exception var7) { return var2; } } } public void createParams() { int var1 = ((Component)this).size().width; int var2 = ((Component)this).size().height; this.lastS.width = var1; this.lastS.height = var2; if (this.field_2 != null) { this.field_2.finalize(); } if (this.field_1 != null) { this.field_1 = null; } byte var3 = 14; Font var4 = new Font("TimesRoman", 1, var3); ((Component)this).setFont(var4); FontMetrics var5 = ((Component)this).getFontMetrics(var4); int var6 = var5.getHeight(); var6 = var3 * (var2 - 10) / var6; this.messageF = new Font("TimesRoman", 1, var6); FontMetrics var7 = ((Component)this).getFontMetrics(this.messageF); var6 = var7.getHeight(); this.messageX = var1; this.messageY = (var2 - var6 >> 1) + var7.getAscent(); for(int var8 = 0; var8 < this.messageCount; ++var8) { this.msgsW[var8] = var7.stringWidth(this.msgs[var8]); this.messageW += this.msgsW[var8]; } this.field_1 = ((Component)this).createImage(var1, var2); this.field_2 = this.field_1.getGraphics(); } public void paint(Graphics var1) { this.update(var1); } public synchronized void update(Graphics var1) { if (((Component)this).size().height != this.lastS.height || ((Component)this).size().width != this.lastS.width) { this.createParams(); } this.field_2.setColor(this.bgCo); this.field_2.fillRect(0, 0, this.lastS.width, this.lastS.height); if (this.BORDER) { this.field_2.draw3DRect(2, 2, this.lastS.width - 5, this.lastS.height - 5, false); this.field_2.draw3DRect(3, 3, this.lastS.width - 7, this.lastS.height - 7, false); } this.field_2.clipRect(5, 4, this.lastS.width - 10, this.lastS.height - 8); if (this.display_URL) { int var2 = 0; int var3 = this.mouseX; if (var3 > this.messageX) { var3 -= this.messageX; for(int var4 = 0; var4 < this.messageCount; ++var4) { var2 += this.msgsW[var4]; if (var3 < var2) { this.messageIndex = var4; break; } } } ((Applet)this).showStatus(this.msgsURLDescriptions[this.messageIndex]); } this.field_2.setColor(this.txtCo); this.field_2.setFont(this.messageF); int var5 = 0; for(int var7 = 0; var7 < this.messageCount; ++var7) { if (this.SHADOW) { this.field_2.setColor(this.shCo); this.field_2.drawString(this.msgs[var7], this.messageX + var5 + this.shDepth, this.messageY + this.shDepth); } if (var7 == this.messageIndex && this.display_URL) { this.field_2.setColor(this.linkCo); } else { this.field_2.setColor(this.txtCo); } this.field_2.drawString(this.msgs[var7], this.messageX + var5, this.messageY); var5 += this.msgsW[var7]; } var1.drawImage(this.field_1, 0, 0, this); } public synchronized void nextPos() { this.messageX -= this.speed; if (this.messageX + this.messageW < 0) { this.messageX = this.lastS.width; } ((Component)this).repaint(); } public void run() { Thread.currentThread().setPriority(1); while(this.active) { this.nextPos(); try { Thread.sleep(40L); } catch (InterruptedException var1) { } } } public void start() { if (!this.active) { this.field_0 = new Thread(this); this.active = true; this.field_0.start(); } } public void stop() { this.active = false; this.field_0 = null; } public boolean mouseUp(Event var1, int var2, int var3) { if (this.msgsURL[this.messageIndex].equals("NULL")) { return true; } else { try { this.url_ = new URL(this.msgsURL[this.messageIndex]); } catch (Exception var5) { this.url_ = null; System.out.println("Failed Constructing the URL"); } if (this.url_ == null) { try { this.url_ = new URL(((Applet)this).getDocumentBase(), this.msgsURL[this.messageIndex]); } catch (Exception var4) { this.url_ = null; System.out.println("Failed Constructing the URL"); } } if (this.url_ != null) { if (!this.msgsURLTargets[this.messageIndex].equals("NULL")) { ((Applet)this).getAppletContext().showDocument(this.url_, this.msgsURLTargets[this.messageIndex]); } else { ((Applet)this).getAppletContext().showDocument(this.url_); } } System.out.println("Successful connection !!!!!!!!!!!"); return true; } } public boolean mouseEnter(Event var1, int var2, int var3) { this.display_URL = true; return true; } public boolean mouseExit(Event var1, int var2, int var3) { this.display_URL = false; return true; } public boolean mouseMove(Event var1, int var2, int var3) { this.mouseX = var2; return true; } }