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.MediaTracker;
- import java.awt.image.ImageObserver;
- import java.net.MalformedURLException;
- import java.net.URL;
-
- public class button extends Applet implements Runnable {
- // $FF: renamed from: w int
- int field_0;
- // $FF: renamed from: h int
- int field_1;
- int start;
- Image offImage;
- Graphics offGraphics;
- Dimension offDimension;
- Thread animationThread;
- String prefex;
- Color color = new Color(0, 0, 0);
- int num_buttons = 1;
- int direction;
- int[] button_x;
- int[] button_y;
- int button_w;
- int button_h;
- int degree = 20;
- int with = 1;
- String[] label;
- String[] link;
- String[] frame;
- Color[] b_clr_light;
- Color[] b_clr_dark;
- int f_size = 12;
- int f_style;
- int[] font_x;
- int[] font_y;
- int f_offset = 1;
- Color f_color;
- Color f_color2;
- Font font1;
- int selected;
- int last;
- int mouse_in;
- int style;
- int position;
- int[] position_is;
- int[] position_be;
- int down;
- int[] image_w;
- int[] image_h;
- int[] image_x;
- int[] image_y;
- Image[] sourceimage;
-
- public void init() {
- this.field_0 = ((Component)this).size().width;
- this.field_1 = ((Component)this).size().height;
- this.prefex = ((Applet)this).getDocumentBase().toString();
-
- try {
- this.num_buttons = Integer.parseInt(((Applet)this).getParameter("buttons"));
- } catch (Exception var21) {
- }
-
- try {
- this.direction = Integer.parseInt(((Applet)this).getParameter("direction"));
- } catch (Exception var20) {
- }
-
- try {
- this.with = Integer.parseInt(((Applet)this).getParameter("border width"));
- } catch (Exception var19) {
- }
-
- try {
- this.position = Integer.parseInt(((Applet)this).getParameter("position"));
- } catch (Exception var18) {
- }
-
- try {
- this.degree = Integer.parseInt(((Applet)this).getParameter("degree"));
- } catch (Exception var17) {
- }
-
- try {
- this.f_offset = Integer.parseInt(((Applet)this).getParameter("f_offset"));
- } catch (Exception var16) {
- }
-
- try {
- this.style = Integer.parseInt(((Applet)this).getParameter("style"));
- } catch (Exception var15) {
- }
-
- String temp_color = ((Applet)this).getParameter("color");
- if (temp_color == null) {
- temp_color = "000000";
- }
-
- this.color = new Color(Integer.parseInt(temp_color, 16));
-
- try {
- this.f_size = Integer.parseInt(((Applet)this).getParameter("f_size"));
- } catch (Exception var14) {
- }
-
- try {
- this.f_style = Integer.parseInt(((Applet)this).getParameter("f_style"));
- } catch (Exception var13) {
- }
-
- String my_font = ((Applet)this).getParameter("font");
- if (my_font == null) {
- my_font = "Helvetica";
- }
-
- String temp_f_color = ((Applet)this).getParameter("f_color");
- if (temp_f_color == null) {
- temp_f_color = "FFFFFF";
- }
-
- this.f_color = new Color(Integer.parseInt(temp_f_color, 16));
- temp_f_color = ((Applet)this).getParameter("f_color2");
- if (temp_f_color == null) {
- temp_f_color = "FFFFFF";
- }
-
- this.f_color2 = new Color(Integer.parseInt(temp_f_color, 16));
- this.image_w = new int[this.num_buttons];
- this.image_h = new int[this.num_buttons];
- this.image_x = new int[this.num_buttons];
- this.image_y = new int[this.num_buttons];
- this.position_is = new int[this.num_buttons];
- this.position_be = new int[this.num_buttons];
- this.sourceimage = new Image[this.num_buttons];
- this.link = new String[this.num_buttons];
- this.label = new String[this.num_buttons];
- this.frame = new String[this.num_buttons];
-
- for(int a = 0; a < this.num_buttons; ++a) {
- this.position_be[a] = 1;
- this.position_is[a] = 0;
- this.image_w[a] = 0;
- this.image_h[a] = 0;
- this.image_x[a] = 0;
- this.image_y[a] = 0;
- this.label[a] = ((Applet)this).getParameter("label " + Integer.toString(a));
- if (this.label[a] == null) {
- this.label[a] = "";
- }
-
- this.link[a] = ((Applet)this).getParameter("link " + Integer.toString(a));
- if (this.link[a] == null) {
- this.link[a] = "";
- }
-
- String imagename = ((Applet)this).getParameter("image " + Integer.toString(a));
- if (imagename == null) {
- imagename = "";
- }
-
- this.frame[a] = ((Applet)this).getParameter("frame " + Integer.toString(a));
- if (this.frame[a] == null) {
- this.frame[a] = "_top";
- }
-
- if (this.frame[a].equalsIgnoreCase("")) {
- this.frame[a] = "_top";
- }
-
- this.sourceimage[a] = ((Applet)this).getImage(((Applet)this).getCodeBase(), imagename);
- this.loadimage(this.sourceimage[a], a);
- this.image_w[a] = this.sourceimage[a].getWidth(this);
- this.image_h[a] = this.sourceimage[a].getHeight(this);
- }
-
- this.button_x = new int[this.num_buttons];
- this.button_y = new int[this.num_buttons];
- if (this.direction == 0) {
- this.button_w = this.field_0 - 1;
- this.button_h = this.field_1 / this.num_buttons;
-
- for(int a = 0; a < this.num_buttons; ++a) {
- this.button_x[a] = 0;
- this.button_y[a] = this.button_h * a;
- }
- } else {
- this.button_h = this.field_1 - 1;
- this.button_w = this.field_0 / this.num_buttons;
-
- for(int a = 0; a < this.num_buttons; ++a) {
- this.button_y[a] = 0;
- this.button_x[a] = this.button_w * a;
- }
- }
-
- int r = this.color.getRed();
- int g = this.color.getGreen();
- int b = this.color.getBlue();
- this.b_clr_dark = new Color[this.with + 1];
- this.b_clr_dark[0] = this.color;
- this.b_clr_light = new Color[this.with + 1];
- this.b_clr_light[0] = this.color;
-
- for(int a = 1; a < this.with + 1; ++a) {
- this.b_clr_dark[a] = new Color(Math.max(0, r - a * this.degree), Math.max(0, g - a * this.degree), Math.max(0, b - a * this.degree));
- this.b_clr_light[a] = new Color(Math.min(255, r + a * this.degree), Math.min(255, g + a * this.degree), Math.min(255, b + a * this.degree));
- }
-
- int style = 0;
- if (this.f_style == 1) {
- style = 1;
- } else if (this.f_style == 2) {
- style = 2;
- }
-
- this.font_x = new int[this.num_buttons];
- this.font_y = new int[this.num_buttons];
- this.font1 = new Font(my_font, style, this.f_size);
- ((Component)this).setFont(this.font1);
- FontMetrics fm = ((Component)this).getFontMetrics(this.font1);
-
- for(int a = 0; a < this.num_buttons; ++a) {
- switch (this.position) {
- case 0:
- this.image_x[a] = this.button_x[a] + (this.button_w - this.image_w[a]) / 2;
- this.image_y[a] = this.button_y[a] + (this.button_h - this.image_h[a]) / 2;
- this.font_x[a] = this.button_x[a] + (this.button_w - fm.stringWidth(this.label[a])) / 2;
- break;
- case 1:
- this.image_x[a] = this.button_x[a] + this.with + this.f_offset;
- this.image_y[a] = this.button_y[a] + (this.button_h - this.image_h[a]) / 2;
- this.font_x[a] = this.image_h[a] + this.button_x[a] + this.with + this.f_offset * 2;
- break;
- case 2:
- this.image_x[a] = this.button_x[a] + this.button_w - this.with - this.image_w[a] - this.f_offset;
- this.image_y[a] = this.button_y[a] + (this.button_h - this.image_h[a]) / 2;
- this.font_x[a] = this.button_x[a] + this.button_w - this.with + 1 - fm.stringWidth(this.label[a]) - this.image_w[a] - this.f_offset * 2;
- }
-
- this.font_y[a] = this.button_y[a] + this.button_h / 2 + fm.getHeight() / 3;
- }
-
- }
-
- public void paintFrame(Graphics g) {
- g.setFont(this.font1);
-
- for(int a = 0; a < this.num_buttons; ++a) {
- if (this.position_be[a] != this.position_is[a]) {
- int dwn = 0;
- this.position_is[a] = this.position_be[a];
- if (this.position_be[a] == 1) {
- dwn = 1;
- }
-
- g.setColor(this.color);
- g.fillRect(this.button_x[a], this.button_y[a], this.button_w, this.button_h);
- if (dwn == 1) {
- g.drawImage(this.sourceimage[a], this.image_x[a], this.image_y[a], this.color, this);
- g.setColor(this.f_color);
- g.drawString(this.label[a], this.font_x[a], this.font_y[a]);
- } else {
- g.drawImage(this.sourceimage[a], this.image_x[a] + 1, this.image_y[a] + 1, this.color, this);
- g.setColor(this.f_color2);
- g.drawString(this.label[a], this.font_x[a] + 1, this.font_y[a] + 1);
- }
-
- for(int b = 0; b < this.with; ++b) {
- if (dwn == 0) {
- g.setColor(this.b_clr_dark[this.with - b]);
- } else {
- g.setColor(this.b_clr_light[this.with - b]);
- }
-
- g.drawLine(this.button_x[a] + b, this.button_y[a] + b, this.button_x[a] + this.button_w - b, this.button_y[a] + b);
- g.drawLine(this.button_x[a] + b, this.button_y[a] + b, this.button_x[a] + b, this.button_y[a] + this.button_h - b);
- if (dwn == 1) {
- g.setColor(this.b_clr_dark[this.with - b]);
- } else {
- g.setColor(this.b_clr_light[this.with - b]);
- }
-
- g.drawLine(this.button_x[a] + b, this.button_y[a] + this.button_h - b, this.button_x[a] + this.button_w - b, this.button_y[a] + this.button_h - b);
- g.drawLine(this.button_x[a] + this.button_w - b, this.button_y[a] + this.button_h - b, this.button_x[a] + this.button_w - b, this.button_y[a] + b);
- }
- } else if (this.style == 0) {
- if (a + 1 == this.mouse_in) {
- g.setColor(this.color);
- g.setColor(this.f_color2);
- g.drawString(this.label[a], this.font_x[a], this.font_y[a]);
- } else {
- g.setColor(this.color);
- g.setColor(this.f_color);
- g.drawString(this.label[a], this.font_x[a], this.font_y[a]);
- }
- }
- }
-
- }
-
- void loadimage(Image img, int btn) {
- MediaTracker mt = new MediaTracker(this);
- mt.addImage(img, 0);
-
- try {
- mt.waitForID(0);
- } catch (InterruptedException var4) {
- }
- }
-
- public boolean mouseDown(Event e, int x, int y) {
- for(int a = 0; a < this.num_buttons; ++a) {
- if (x >= this.button_x[a] && x < this.button_x[a] + this.button_w && y >= this.button_y[a] && y < this.button_y[a] + this.button_h) {
- this.down = 1;
-
- for(int b = 0; b < this.num_buttons; ++b) {
- this.position_be[b] = 1;
- }
-
- this.position_be[a] = 0;
- break;
- }
- }
-
- ((Component)this).repaint();
- return true;
- }
-
- public boolean mouseUp(Event e, int x, int y) {
- for(int a = 0; a < this.num_buttons; ++a) {
- if (x >= this.button_x[a] && x < this.button_x[a] + this.button_w && y >= this.button_y[a] && y < this.button_y[a] + this.button_h) {
- this.down = 0;
- if (this.style == 0) {
- for(int b = 0; b < this.num_buttons; ++b) {
- this.position_be[b] = 1;
- }
- }
-
- if (!this.link[a].equalsIgnoreCase("")) {
- if (this.frame[a].equalsIgnoreCase("")) {
- try {
- URL base_url = ((Applet)this).getDocumentBase();
- URL link_to = new URL(base_url, this.link[a]);
- ((Applet)this).getAppletContext().showDocument(link_to);
- } catch (MalformedURLException var8) {
- }
- } else {
- try {
- URL base_url = ((Applet)this).getDocumentBase();
- URL link_to = new URL(base_url, this.link[a]);
- ((Applet)this).getAppletContext().showDocument(link_to, this.frame[a]);
- } catch (MalformedURLException var7) {
- }
- }
- }
- break;
- }
- }
-
- ((Component)this).repaint();
- return true;
- }
-
- public boolean mouseMove(Event e, int x, int y) {
- for(int a = 0; a < this.num_buttons; ++a) {
- if (x >= this.button_x[a] && x < this.button_x[a] + this.button_w && y >= this.button_y[a] && y < this.button_y[a] + this.button_h) {
- this.mouse_in = a + 1;
- if (this.style == 1 & this.down == 0) {
- for(int b = 0; b < this.num_buttons; ++b) {
- this.position_be[b] = 1;
- }
-
- this.position_be[a] = 0;
- }
- break;
- }
- }
-
- ((Component)this).repaint();
- return true;
- }
-
- public boolean mouseExit(Event e, int x, int y) {
- for(int b = 0; b < this.num_buttons; ++b) {
- this.position_be[b] = 1;
- }
-
- this.down = 0;
- this.mouse_in = 0;
- ((Component)this).repaint();
- return true;
- }
-
- public void update(Graphics g) {
- Dimension dim = ((Component)this).size();
- if (this.offGraphics == null || dim.width != this.offDimension.width || dim.height != this.offDimension.height) {
- this.offDimension = dim;
- this.offImage = ((Component)this).createImage(dim.width, dim.height);
- this.offGraphics = this.offImage.getGraphics();
- this.offGraphics.setColor(this.color);
- this.offGraphics.fillRect(0, 0, this.field_0, this.field_1);
- }
-
- this.paintFrame(this.offGraphics);
- g.drawImage(this.offImage, 0, 0, (ImageObserver)null);
- }
-
- public void start() {
- if (this.animationThread == null) {
- this.animationThread = new Thread(this);
- this.animationThread.start();
- Thread.currentThread().setPriority(10);
- }
-
- }
-
- public void run() {
- for(; this.animationThread != null; ((Component)this).repaint()) {
- try {
- Thread.sleep(400L);
- } catch (InterruptedException var1) {
- }
- }
-
- }
-
- public void paint(Graphics g) {
- if (this.offImage != null) {
- g.drawImage(this.offImage, 0, 0, (ImageObserver)null);
- }
-
- }
- }
-