home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Canvas;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
-
- public class TextPulseCanvas2 extends Canvas implements Runnable {
- Thread appThread;
- Image osImage;
- Graphics osg;
- Color bkColor;
- Image bkImage;
- Font startFont;
- Font endFont;
- int growthIncrement;
- String message;
- Color fontColor;
- int messageWidth;
- int messageHeight;
- // $FF: renamed from: x int
- int field_0;
- // $FF: renamed from: y int
- int field_1;
- int delayTime;
- Font[] font;
- // $FF: renamed from: fm java.awt.FontMetrics[]
- FontMetrics[] field_2;
- int fontIndex;
- int numFonts;
-
- public TextPulseCanvas2(Applet var1, int var2) {
- this.GetParameters(var1, var2);
-
- try {
- this.Initialize();
- } catch (Exception var4) {
- System.out.println(((Throwable)var4).getMessage());
- }
- }
-
- void GetParameters(Applet var1, int var2) {
- String var3 = var1.getParameter("textPulseBkColor" + var2);
- this.bkColor = AppletParam2.GetColor(var3, (Color)null);
- if (this.bkColor != null) {
- ((Component)this).setBackground(this.bkColor);
- }
-
- var3 = var1.getParameter("textPulseBkImage" + var2);
- this.bkImage = var1.getImage(var1.getCodeBase(), var3);
- var3 = var1.getParameter("textPulseStartFont" + var2);
- this.startFont = AppletParam2.GetJavaFont(var3);
- var3 = var1.getParameter("textPulseEndFont" + var2);
- this.endFont = AppletParam2.GetJavaFont(var3);
- var3 = var1.getParameter("textPulseGrowthIncrement" + var2);
- this.growthIncrement = AppletParam2.GetInt(var3, 1);
- var3 = var1.getParameter("textPulseColor" + var2);
- this.fontColor = AppletParam2.GetColor(var3, Color.black);
- var3 = var1.getParameter("textPulseMessage" + var2);
- this.message = AppletParam2.GetString(var3, "Message");
- var3 = var1.getParameter("textPulseIncrement" + var2);
- this.delayTime = AppletParam2.GetInt(var3, 125);
- }
-
- public void Start() {
- this.appThread = new Thread(this);
- this.appThread.start();
- }
-
- public void Stop() {
- this.appThread.stop();
- this.appThread = null;
- }
-
- public void update(Graphics var1) {
- if (this.osImage == null) {
- this.osImage = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
- this.osg = this.osImage.getGraphics();
- }
-
- this.osg.setColor(((Component)this).getBackground());
- this.osg.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
- if (this.bkImage != null) {
- int var2 = this.bkImage.getWidth(this);
- int var3 = this.bkImage.getHeight(this);
- int var4 = ((Component)this).size().width / var2;
- int var5 = ((Component)this).size().height / var3;
- ++var4;
- ++var5;
-
- for(int var6 = 0; var6 < var5; ++var6) {
- for(int var7 = 0; var7 < var4; ++var7) {
- this.osg.drawImage(this.bkImage, var7 * var2, var6 * var3, this);
- }
- }
- }
-
- this.osg.setColor(this.fontColor);
- this.osg.setFont(this.font[this.fontIndex]);
- this.field_0 = ((Component)this).size().width / 2 - this.messageWidth / 2;
- this.field_1 = ((Component)this).size().height / 2 + this.messageHeight / 2;
- this.osg.drawString(this.message, this.field_0, this.field_1);
- var1.drawImage(this.osImage, 0, 0, this);
- }
-
- public void run() {
- try {
- while(true) {
- ((Component)this).repaint();
- this.UpdateFont();
- Thread.sleep((long)this.delayTime);
- }
- } catch (InterruptedException var1) {
- }
- }
-
- public Dimension minimumSize() {
- return new Dimension(10, 10);
- }
-
- public Dimension preferredSize() {
- return new Dimension(10, 10);
- }
-
- public synchronized void reshape(int var1, int var2, int var3, int var4) {
- super.reshape(var1, var2, var3, var4);
- this.osImage = null;
- this.osg = null;
- }
-
- public boolean imageUpdate(Image var1, int var2, int var3, int var4, int var5, int var6) {
- ((Component)this).repaint();
- return true;
- }
-
- void UpdateFont() {
- if (this.growthIncrement > 0) {
- ++this.fontIndex;
- } else {
- --this.fontIndex;
- }
-
- if (this.fontIndex >= this.numFonts) {
- this.fontIndex = this.numFonts - 1;
- this.growthIncrement = -this.growthIncrement;
- } else if (this.fontIndex < 0) {
- this.fontIndex = 0;
- this.growthIncrement = -this.growthIncrement;
- }
-
- this.messageWidth = this.field_2[this.fontIndex].stringWidth(this.message);
- this.messageHeight = this.field_2[this.fontIndex].getAscent();
- }
-
- void Initialize() throws Exception {
- if (this.startFont == null) {
- throw new Exception("Start font not specified");
- } else if (this.endFont == null) {
- throw new Exception("End font not specified");
- } else if (!this.startFont.getName().equals(this.endFont.getName())) {
- throw new Exception("Start font and end font the same font");
- } else if (this.startFont.getStyle() != this.endFont.getStyle()) {
- throw new Exception("Start font and end font must be the same style");
- } else if (this.startFont.getSize() == this.endFont.getSize()) {
- throw new Exception("Start font and end font cannot be the same size.");
- } else if (this.growthIncrement < 1) {
- throw new Exception("Growth increment must be greater than 0.");
- } else {
- int var1 = this.startFont.getSize();
- int var2 = this.endFont.getSize();
- this.numFonts = 0;
- if (var2 > var1) {
- this.numFonts = (var2 - var1) / this.growthIncrement;
- if ((var2 - var1) % this.growthIncrement != 0) {
- ++this.numFonts;
- }
- } else {
- this.numFonts = (var1 - var2) / this.growthIncrement;
- if ((var1 - var2) % this.growthIncrement != 0) {
- ++this.numFonts;
- }
- }
-
- this.font = new Font[this.numFonts];
- this.field_2 = new FontMetrics[this.numFonts];
-
- for(int var3 = 0; var3 < this.numFonts; ++var3) {
- this.font[var3] = new Font(this.startFont.getName(), this.startFont.getStyle(), this.startFont.getSize() + var3 * this.growthIncrement);
- this.field_2[var3] = ((Component)this).getFontMetrics(this.font[var3]);
- }
-
- this.fontIndex = 0;
- }
- }
- }
-