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.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.Polygon;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.StringTokenizer;
- import java.util.Vector;
-
- public class FadeText extends Applet implements Runnable {
- Thread m_SlidingM;
- Image off2;
- Image off;
- Graphics g_off;
- Graphics g_off2;
- Font font;
- // $FF: renamed from: fm java.awt.FontMetrics
- FontMetrics field_0;
- URL goURL;
- // $FF: renamed from: d java.awt.Dimension
- Dimension field_1;
- int font_style;
- int center_x;
- int m_num_msg;
- // $FF: renamed from: k int
- int field_2;
- boolean gSok;
- boolean mouse_in;
- boolean bad_descrips;
- boolean first_pass = true;
- boolean multi_line;
- private int m_size = 24;
- private int m_delay = 2000;
- private String m_messagefont = "Arial";
- private boolean m_bold;
- private boolean m_italic;
- private String[] m_msg;
- private Color[] m_cur_textcolor;
- private Color[] m_cur_bgcolor;
- private Color m_bgcolor;
- private Color m_textcolor;
- private int[] m_cur_size;
- private int[] m_cur_delay;
- private String[] m_cur_desturl;
- private String m_desturl;
- private String m_loadwhere;
- private String[] m_cur_loadwhere;
- private boolean m_xcenter;
- private int m_xoffset;
- private boolean[] m_cur_xcenter;
- private int m_b_thick;
- private int[] m_cur_b_thick;
- private Color m_b_color;
- private Color[] m_cur_b_color;
- private int[] m_cur_color_jump;
- private int m_color_jump;
- private int m_color_delay;
- private int[] m_cur_color_delay;
-
- public void start() {
- if (this.m_SlidingM == null) {
- this.m_SlidingM = new Thread(this);
- this.m_SlidingM.start();
- }
-
- }
-
- public void stop() {
- if (this.m_SlidingM != null) {
- this.m_SlidingM.stop();
- this.m_SlidingM = null;
- }
-
- }
-
- public boolean mouseExit(Event e, int x, int y) {
- this.mouse_in = false;
- return true;
- }
-
- public boolean mouseEnter(Event e, int x, int y) {
- this.mouse_in = true;
- return true;
- }
-
- public boolean mouseUp(Event e, int x, int y) {
- if (this.mouse_in && this.m_cur_desturl[this.field_2] != null) {
- try {
- this.goURL = new URL(this.m_cur_desturl[this.field_2]);
- } catch (MalformedURLException var6) {
- }
-
- ((Applet)this).getAppletContext().showDocument(this.goURL, this.m_cur_loadwhere[this.field_2]);
- }
-
- return true;
- }
-
- public void run() {
- while(true) {
- try {
- this.DrawSlide(((Component)this).getGraphics());
- } catch (InterruptedException var3) {
- this.stop();
- }
- }
- }
-
- public FadeText() {
- this.m_bgcolor = Color.white;
- this.m_textcolor = Color.black;
- this.m_loadwhere = "_self";
- this.m_xcenter = true;
- this.m_xoffset = 5;
- this.m_b_color = Color.black;
- this.m_color_jump = 1;
- }
-
- public Color ConvertColor(String temp) {
- int r = 0;
- int g = 0;
- int b = 0;
- temp.trim();
- StringTokenizer st = new StringTokenizer(temp, ",");
- if (st.countTokens() > 3) {
- return Color.black;
- } else {
- while(st.hasMoreTokens()) {
- r = Integer.parseInt(st.nextToken().trim());
- g = Integer.parseInt(st.nextToken().trim());
- b = Integer.parseInt(st.nextToken().trim());
- }
-
- StringTokenizer var9 = null;
- if (r > 255) {
- r = 255;
- }
-
- if (g > 255) {
- g = 255;
- }
-
- if (b > 255) {
- b = 255;
- }
-
- Color ctemp = new Color(r, g, b);
- return ctemp;
- }
- }
-
- public String[] MessageParser(String temp) {
- Vector v_the = new Vector();
- String s_build = "";
- int s_length = 0;
- String s_temp = "";
- boolean first_run = true;
- boolean last_line = false;
- temp.trim();
-
- for(StringTokenizer st = new StringTokenizer(temp, " "); st.hasMoreTokens(); first_run = false) {
- s_temp = st.nextToken();
- if (s_temp != null) {
- }
-
- s_length += this.field_0.stringWidth(s_temp + " ");
- if (s_length < this.field_1.width - (this.m_cur_b_thick[this.field_2] * 2 + this.m_xoffset * 2)) {
- if (first_run) {
- s_build = s_temp;
- } else {
- s_build = s_build + " " + s_temp;
- }
-
- last_line = true;
- } else {
- v_the.addElement(s_build);
- if (!st.hasMoreTokens()) {
- v_the.addElement(s_temp);
- } else {
- s_length = this.field_0.stringWidth(s_temp + " ");
- s_build = s_temp;
- }
-
- last_line = false;
- }
- }
-
- if (last_line) {
- v_the.addElement(s_build);
- }
-
- String[] the_string = new String[v_the.size()];
- v_the.copyInto(the_string);
- return the_string;
- }
-
- public void init() {
- String crstr = "Fading Messages, Copyright (c) 1997 OpenCube Technologies - Freeware";
- this.field_1 = ((Component)this).size();
- int i = 0;
- String param = ((Applet)this).getParameter("Notice");
- if (param != null && param.equals(crstr)) {
- this.gSok = true;
- }
-
- param = ((Applet)this).getParameter("loadwhere");
- if (param != null) {
- this.m_loadwhere = param;
- }
-
- param = ((Applet)this).getParameter("desturl");
- if (param != null) {
- this.m_desturl = param;
- }
-
- param = ((Applet)this).getParameter("delay");
- if (param != null) {
- this.m_delay = Integer.parseInt(param);
- }
-
- param = ((Applet)this).getParameter("colordelay");
- if (param != null) {
- this.m_color_delay = Integer.parseInt(param);
- }
-
- param = ((Applet)this).getParameter("colorjump");
- if (param != null) {
- this.m_delay = Integer.parseInt(param);
- }
-
- param = ((Applet)this).getParameter("size");
- if (param != null) {
- this.m_size = Integer.parseInt(param);
- }
-
- param = ((Applet)this).getParameter("xoffset");
- if (param != null) {
- this.m_xoffset = Integer.parseInt(param);
- }
-
- param = ((Applet)this).getParameter("borderthickness");
- if (param != null) {
- this.m_b_thick = Integer.parseInt(param);
- }
-
- param = ((Applet)this).getParameter("font");
- if (param != null) {
- this.m_messagefont = param;
- }
-
- param = ((Applet)this).getParameter("textcolor");
- if (param != null) {
- this.m_textcolor = this.ConvertColor(param);
- }
-
- param = ((Applet)this).getParameter("bgcolor");
- if (param != null) {
- this.m_bgcolor = this.ConvertColor(param);
- ((Component)this).setBackground(this.m_bgcolor);
- } else {
- this.m_bgcolor = Color.white;
- ((Component)this).setBackground(this.m_bgcolor);
- }
-
- param = ((Applet)this).getParameter("bordercolor");
- if (param != null) {
- this.m_b_color = this.ConvertColor(param);
- }
-
- param = ((Applet)this).getParameter("italic");
- if (param != null) {
- this.m_italic = Boolean.valueOf(param);
- }
-
- param = ((Applet)this).getParameter("centertext");
- if (param != null) {
- this.m_xcenter = Boolean.valueOf(param);
- }
-
- param = ((Applet)this).getParameter("bold");
- if (param != null) {
- this.m_bold = Boolean.valueOf(param);
- }
-
- if (this.m_bold) {
- ++this.font_style;
- }
-
- if (this.m_italic) {
- this.font_style += 2;
- }
-
- while(((Applet)this).getParameter("desc" + i) != null) {
- ++i;
- ++this.m_num_msg;
- }
-
- if (this.m_num_msg < 1) {
- this.m_num_msg = 1;
- this.bad_descrips = true;
- }
-
- this.m_msg = new String[this.m_num_msg];
- this.m_cur_textcolor = new Color[this.m_num_msg];
- this.m_cur_bgcolor = new Color[this.m_num_msg];
- this.m_cur_size = new int[this.m_num_msg];
- this.m_cur_delay = new int[this.m_num_msg];
- this.m_cur_desturl = new String[this.m_num_msg];
- this.m_cur_loadwhere = new String[this.m_num_msg];
- this.m_cur_xcenter = new boolean[this.m_num_msg];
- this.m_cur_b_color = new Color[this.m_num_msg];
- this.m_cur_b_thick = new int[this.m_num_msg];
- this.m_cur_color_jump = new int[this.m_num_msg];
- this.m_cur_color_delay = new int[this.m_num_msg];
-
- for(int var32 = 0; var32 < this.m_num_msg; ++var32) {
- param = ((Applet)this).getParameter("desc" + var32);
- if (param != null) {
- this.m_msg[var32] = new String(param);
- } else {
- this.m_msg[var32] = new String(" ");
- }
-
- param = ((Applet)this).getParameter("textcolor" + var32);
- if (param != null) {
- this.m_cur_textcolor[var32] = this.ConvertColor(param);
- } else {
- this.m_cur_textcolor[var32] = this.m_textcolor;
- }
-
- param = ((Applet)this).getParameter("bgcolor" + var32);
- if (param != null) {
- this.m_cur_bgcolor[var32] = this.ConvertColor(param);
- } else {
- this.m_cur_bgcolor[var32] = this.m_bgcolor;
- }
-
- param = ((Applet)this).getParameter("size" + var32);
- if (param != null) {
- this.m_cur_size[var32] = Integer.parseInt(param);
- } else {
- this.m_cur_size[var32] = this.m_size;
- }
-
- param = ((Applet)this).getParameter("colorjump" + var32);
- if (param != null) {
- this.m_cur_color_jump[var32] = Integer.parseInt(param);
- } else {
- this.m_cur_color_jump[var32] = this.m_color_jump;
- }
-
- param = ((Applet)this).getParameter("delay" + var32);
- if (param != null) {
- this.m_cur_delay[var32] = Integer.parseInt(param);
- } else {
- this.m_cur_delay[var32] = this.m_delay;
- }
-
- param = ((Applet)this).getParameter("colordelay" + var32);
- if (param != null) {
- this.m_cur_color_delay[var32] = Integer.parseInt(param);
- } else {
- this.m_cur_color_delay[var32] = this.m_color_delay;
- }
-
- param = ((Applet)this).getParameter("desturl" + var32);
- if (param != null) {
- this.m_cur_desturl[var32] = param;
- } else {
- this.m_cur_desturl[var32] = this.m_desturl;
- }
-
- param = ((Applet)this).getParameter("loadwhere" + var32);
- if (param != null) {
- this.m_cur_loadwhere[var32] = param;
- } else {
- this.m_cur_loadwhere[var32] = this.m_loadwhere;
- }
-
- param = ((Applet)this).getParameter("centertext" + var32);
- if (param != null) {
- this.m_cur_xcenter[var32] = Boolean.valueOf(param);
- } else {
- this.m_cur_xcenter[var32] = this.m_xcenter;
- }
-
- param = ((Applet)this).getParameter("bordercolor" + var32);
- if (param != null) {
- this.m_cur_b_color[var32] = this.ConvertColor(param);
- } else {
- this.m_cur_b_color[var32] = this.m_b_color;
- }
-
- param = ((Applet)this).getParameter("borderthickness" + var32);
- if (param != null) {
- this.m_cur_b_thick[var32] = Integer.parseInt(param);
- } else {
- this.m_cur_b_thick[var32] = this.m_b_thick;
- }
- }
-
- if (this.bad_descrips) {
- this.m_msg[0] = "Must include 'desc0' tag at a minimum in order for this applet to function.";
- this.m_cur_delay[0] = 30000;
- }
-
- ((Component)this).setFont(this.font = new Font(this.m_messagefont, this.font_style, this.m_size));
- this.field_0 = ((Component)this).getFontMetrics(this.font);
- this.off = ((Component)this).createImage(this.field_1.width, this.field_1.height);
- this.g_off = this.off.getGraphics();
- this.g_off.setFont(this.font = new Font(this.m_messagefont, this.font_style, this.m_size));
- }
-
- public void paint(Graphics g) {
- g.drawImage(this.off, 0, 0, this);
- }
-
- public void DrawSlide(Graphics g) {
- int i = 0;
- double y_pos = (double)0.0F;
- double y_ratio = (double)this.field_1.height / (double)this.field_1.width;
- new Polygon();
- String[] v_message = new String[0];
- int message_height = 0;
- if (!this.gSok) {
- int y = (this.field_1.height - this.m_size) / 2 + this.m_size;
- g.drawString("Invalid 'Notice' Param", 0, y);
- this.g_off.drawString("Invalid 'Notice' Param", 0, y);
- } else {
- for(this.field_2 = 0; this.field_2 < this.m_num_msg; ++this.field_2) {
- this.g_off.setFont(this.font = new Font(this.m_messagefont, this.font_style, this.m_cur_size[this.field_2]));
- this.field_0 = ((Component)this).getFontMetrics(this.font);
- int y = this.field_1.height / 2 + (this.field_0.getAscent() + this.field_0.getLeading()) / 2;
- if (this.field_0.stringWidth(this.m_msg[this.field_2]) > this.field_1.width - (this.m_cur_b_thick[this.field_2] * 2 + this.m_xoffset * 2)) {
- this.multi_line = true;
- v_message = this.MessageParser(this.m_msg[this.field_2]);
- this.g_off.setColor(this.m_cur_bgcolor[this.field_2]);
- this.g_off.fillRect(0, 0, this.field_1.width, this.field_1.height);
- if (this.m_cur_b_thick[this.field_2] > 0) {
- this.g_off.setColor(this.m_cur_b_color[this.field_2]);
- if (this.m_cur_b_thick[this.field_2] == 1) {
- this.g_off.drawRect(0, 0, this.field_1.width - 1, this.field_1.height - 1);
- } else {
- Polygon var28 = new Polygon();
- var28.addPoint(0, 0);
- var28.addPoint(this.field_1.width, 0);
- var28.addPoint(this.field_1.width, this.field_1.height);
- var28.addPoint(0, this.field_1.height);
- var28.addPoint(0, 0);
- var28.addPoint(this.m_cur_b_thick[this.field_2], this.m_cur_b_thick[this.field_2]);
- var28.addPoint(this.field_1.width - this.m_cur_b_thick[this.field_2], this.m_cur_b_thick[this.field_2]);
- var28.addPoint(this.field_1.width - this.m_cur_b_thick[this.field_2], this.field_1.height - this.m_cur_b_thick[this.field_2]);
- var28.addPoint(this.m_cur_b_thick[this.field_2], this.field_1.height - this.m_cur_b_thick[this.field_2]);
- var28.addPoint(this.m_cur_b_thick[this.field_2], this.m_cur_b_thick[this.field_2]);
- this.g_off.fillPolygon(var28);
- }
- }
-
- this.g_off.setColor(this.m_cur_textcolor[this.field_2]);
- message_height = this.field_0.getHeight() * v_message.length;
- if (message_height > this.field_1.height - this.m_cur_b_thick[this.field_2] * 2) {
- this.g_off.setFont(this.font = new Font(this.m_messagefont, this.font_style, 12));
- this.g_off.drawString("Error - Cannot Fit, Please Resize", this.field_1.width / 2 - this.field_0.stringWidth("Error - Cannot Fit, Please Resize") / 2, y);
- this.g_off.setFont(this.font = new Font(this.m_messagefont, this.font_style, this.m_size));
- } else {
- int message_start = this.field_1.height / 2 - message_height / 2;
-
- for(int l = 0; l < v_message.length; ++l) {
- this.g_off.setColor(this.m_cur_textcolor[this.field_2]);
- if (this.m_cur_xcenter[this.field_2]) {
- this.g_off.drawString(v_message[l], this.field_1.width / 2 - this.field_0.stringWidth(v_message[l]) / 2, message_start + (l + 1) * this.field_0.getHeight());
- } else {
- this.g_off.drawString(v_message[l], this.m_xoffset + this.m_cur_b_thick[this.field_2], message_start + (l + 1) * this.field_0.getHeight());
- }
- }
- }
- } else {
- this.multi_line = false;
- if (this.m_cur_xcenter[this.field_2]) {
- this.center_x = this.field_1.width / 2 - this.field_0.stringWidth(this.m_msg[this.field_2]) / 2;
- } else {
- this.center_x = this.m_xoffset + this.m_cur_b_thick[this.field_2];
- }
-
- this.g_off.setColor(this.m_cur_bgcolor[this.field_2]);
- this.g_off.fillRect(0, 0, this.field_1.width, this.field_1.height);
- if (this.m_cur_b_thick[this.field_2] > 0) {
- this.g_off.setColor(this.m_cur_b_color[this.field_2]);
- if (this.m_cur_b_thick[this.field_2] == 1) {
- this.g_off.drawRect(0, 0, this.field_1.width - 1, this.field_1.height - 1);
- } else {
- Polygon frame = new Polygon();
- frame.addPoint(0, 0);
- frame.addPoint(this.field_1.width, 0);
- frame.addPoint(this.field_1.width, this.field_1.height);
- frame.addPoint(0, this.field_1.height);
- frame.addPoint(0, 0);
- frame.addPoint(this.m_cur_b_thick[this.field_2], this.m_cur_b_thick[this.field_2]);
- frame.addPoint(this.field_1.width - this.m_cur_b_thick[this.field_2], this.m_cur_b_thick[this.field_2]);
- frame.addPoint(this.field_1.width - this.m_cur_b_thick[this.field_2], this.field_1.height - this.m_cur_b_thick[this.field_2]);
- frame.addPoint(this.m_cur_b_thick[this.field_2], this.field_1.height - this.m_cur_b_thick[this.field_2]);
- frame.addPoint(this.m_cur_b_thick[this.field_2], this.m_cur_b_thick[this.field_2]);
- this.g_off.fillPolygon(frame);
- }
- }
-
- this.g_off.setColor(this.m_cur_textcolor[this.field_2]);
- this.g_off.drawString(this.m_msg[this.field_2], this.center_x, y);
- }
-
- int fade_jumps = 0;
- boolean fade_up = false;
- int max_r = this.m_cur_textcolor[this.field_2].getRed();
- int max_g = this.m_cur_textcolor[this.field_2].getGreen();
- int max_b = this.m_cur_textcolor[this.field_2].getBlue();
- int maxb_r = this.m_cur_bgcolor[this.field_2].getRed();
- int maxb_g = this.m_cur_bgcolor[this.field_2].getGreen();
- int maxb_b = this.m_cur_bgcolor[this.field_2].getBlue();
- if (max_r + max_g + max_b > maxb_r + maxb_g + maxb_b) {
- fade_up = true;
- } else {
- fade_up = false;
- }
-
- fade_jumps = 255;
-
- for(int var25 = 0; var25 < fade_jumps; var25 += this.m_cur_color_jump[this.field_2]) {
- try {
- Thread.sleep((long)this.m_cur_color_delay[this.field_2]);
- } catch (InterruptedException var24) {
- }
-
- if (fade_up) {
- if (maxb_r < max_r) {
- maxb_r += this.m_cur_color_jump[this.field_2];
- }
-
- if (maxb_g < max_g) {
- maxb_g += this.m_cur_color_jump[this.field_2];
- }
-
- if (maxb_b < max_b) {
- maxb_b += this.m_cur_color_jump[this.field_2];
- }
-
- Color fade = new Color(maxb_r, maxb_g, maxb_b);
- this.g_off.setColor(fade);
- } else {
- if (maxb_r > max_r) {
- maxb_r -= this.m_cur_color_jump[this.field_2];
- }
-
- if (maxb_g > max_g) {
- maxb_g -= this.m_cur_color_jump[this.field_2];
- }
-
- if (maxb_b > max_b) {
- maxb_b -= this.m_cur_color_jump[this.field_2];
- }
-
- Color fade = new Color(maxb_r, maxb_g, maxb_b);
- this.g_off.setColor(fade);
- }
-
- if (this.multi_line) {
- int message_start = this.field_1.height / 2 - message_height / 2;
-
- for(int l = 0; l < v_message.length; ++l) {
- if (this.m_cur_xcenter[this.field_2]) {
- this.g_off.drawString(v_message[l], this.field_1.width / 2 - this.field_0.stringWidth(v_message[l]) / 2, message_start + (l + 1) * this.field_0.getHeight());
- } else {
- this.g_off.drawString(v_message[l], this.m_xoffset + this.m_cur_b_thick[this.field_2], message_start + (l + 1) * this.field_0.getHeight());
- }
- }
- } else {
- this.g_off.drawString(this.m_msg[this.field_2], this.center_x, y);
- }
-
- g.drawImage(this.off, 0, 0, this);
- }
-
- maxb_r = this.m_cur_bgcolor[this.field_2].getRed();
- maxb_g = this.m_cur_bgcolor[this.field_2].getGreen();
- maxb_b = this.m_cur_bgcolor[this.field_2].getBlue();
-
- try {
- Thread.sleep((long)this.m_cur_delay[this.field_2]);
- } catch (InterruptedException var23) {
- }
-
- for(int var26 = 0; var26 < fade_jumps; var26 += this.m_cur_color_jump[this.field_2]) {
- try {
- Thread.sleep((long)this.m_cur_color_delay[this.field_2]);
- } catch (InterruptedException var22) {
- }
-
- if (fade_up) {
- if (max_r > maxb_r) {
- max_r -= this.m_cur_color_jump[this.field_2];
- }
-
- if (max_g > maxb_g) {
- max_g -= this.m_cur_color_jump[this.field_2];
- }
-
- if (max_b > maxb_b) {
- max_b -= this.m_cur_color_jump[this.field_2];
- }
-
- Color fade = new Color(max_r, max_g, max_b);
- this.g_off.setColor(fade);
- } else {
- if (max_r < maxb_r) {
- max_r += this.m_cur_color_jump[this.field_2];
- }
-
- if (max_g < maxb_g) {
- max_g += this.m_cur_color_jump[this.field_2];
- }
-
- if (max_b < maxb_b) {
- max_b += this.m_cur_color_jump[this.field_2];
- }
-
- Color fade = new Color(max_r, max_g, max_b);
- this.g_off.setColor(fade);
- }
-
- if (this.multi_line) {
- int message_start = this.field_1.height / 2 - message_height / 2;
-
- for(int l = 0; l < v_message.length; ++l) {
- if (this.m_cur_xcenter[this.field_2]) {
- this.g_off.drawString(v_message[l], this.field_1.width / 2 - this.field_0.stringWidth(v_message[l]) / 2, message_start + (l + 1) * this.field_0.getHeight());
- } else {
- this.g_off.drawString(v_message[l], this.m_xoffset + this.m_cur_b_thick[this.field_2], message_start + (l + 1) * this.field_0.getHeight());
- }
- }
- } else {
- this.g_off.drawString(this.m_msg[this.field_2], this.center_x, y);
- }
-
- g.drawImage(this.off, 0, 0, this);
- }
- }
-
- }
- }
- }
-