home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Frame;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.LayoutManager;
- import java.awt.MediaTracker;
- import java.awt.Rectangle;
- import java.awt.Toolkit;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.Random;
- import java.util.Vector;
-
- public class NGMotto extends Applet implements Runnable {
- private static int PARAM_message;
- private static int PARAM_direction = 1;
- private static int PARAM_url = 2;
- private static int PARAM_fontName = 3;
- private static int PARAM_fontSize = 4;
- private static int PARAM_fontStyle = 5;
- private static int PARAM_fontPadding = 6;
- private static int PARAM_background = 7;
- private static int PARAM_foreground = 8;
- private static int PARAM_image = 9;
- private static int PARAM_imageAttribute = 10;
- private static int PARAM_charEffects = 11;
- private static int PARAM_seed = 12;
- private static int PARAM_pause = 13;
- private static int PARAM_rotationfactor = 14;
- private static int PARAM_radius = 15;
- private static int PARAM_x = 16;
- private static int PARAM_y = 17;
- private static double RAD = (180D / Math.PI);
- private boolean random;
- private boolean fixed;
- private boolean clockwise;
- private boolean center;
- private boolean tile;
- private boolean scale;
- private boolean loaded;
- private double rotationfactor;
- private int pause;
- private int message_beg;
- private int increment;
- // $FF: renamed from: cH int
- private int field_0;
- private int fontSize;
- private int fontStyle;
- private int randCount;
- private int fontPadding;
- private int parm_radius;
- private int parm_x;
- private int parm_y;
- private int parm_seed;
- private int imageWidth;
- private int imageHeight;
- private int centered_XCorner;
- private int centered_YCorner;
- // $FF: renamed from: mX int[]
- private int[] field_1;
- private Color background;
- private Color foreground;
- private Color[] randColors;
- private Dimension appletSize;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_2;
- private Frame browserFrame;
- private Graphics bufferGraphics;
- private Image buffer;
- private Image image;
- private MediaTracker tracker;
- private Rectangle[] rectangles;
- private String message;
- private String fontName;
- private String imageName;
- // $FF: renamed from: m java.lang.String[]
- private String[] field_3;
- private Thread animator;
- private URL url;
- // $FF: renamed from: p java.lang.String[][]
- public String[][] field_4 = new String[][]{{"message", " Без гнева и пристрастия "}, {"direction", "counterclockwise"}, {"url", "http://ng.ru"}, {"fontname", "Courier"}, {"fontsize", "16"}, {"fontstyle", "BOLD"}, {"fontpadding", "0"}, {"background", "FFFFFF"}, {"foreground", "FFFFFF"}, {"image", "nglogosm.gif"}, {"imageattribute", "center"}, {"effects", "randomcolors"}, {"seed", "100"}, {"pause", "10"}, {"rotationfactor", "0"}, {"radius", "85"}, {"x", "100"}, {"y", ""}};
-
- public void init() {
- ((Container)this).setLayout((LayoutManager)null);
- this.appletSize = ((Component)this).size();
-
- try {
- this.browserFrame = (Frame)((Component)this).getParent();
- } catch (Exception var38) {
- this.browserFrame = null;
- }
-
- this.getParameters();
- this.buffer = ((Component)this).createImage(this.appletSize.width, this.appletSize.height);
- this.setBufferGraphics();
- Dimension var1 = new Dimension(this.field_2.getMaxAdvance() + 2 * this.field_2.getLeading() + this.fontPadding, this.field_2.getMaxAscent() + this.field_2.getMaxDescent() + 2 * this.field_2.getLeading() + this.fontPadding);
- int var2 = var1.width > var1.height ? var1.width : var1.height;
- int var7 = this.appletSize.width > this.appletSize.height ? this.appletSize.height : this.appletSize.width;
- int var4;
- int var3 = var4 = var7 / 2;
- if (this.parm_x != -1000000) {
- var3 = this.parm_x;
- }
-
- if (this.parm_y != -1000000) {
- var4 = this.parm_y;
- }
-
- double var5 = (double)(var3 - var7 / 4 / 2);
- if (this.parm_radius > -1) {
- var5 = (double)this.parm_radius;
- }
-
- Vector var8 = Vrato.circle(var3, var4, var5, 1);
- double var9 = Math.atan2((double)var2, var5) * RAD;
- double var11 = (double)360.0F / var9;
- double var13 = Math.atan2((double)var2 * this.rotationfactor, var5) * RAD;
- double var15 = (double)360.0F / var13;
- double var17 = (double)var8.size() / var15;
- if (var17 < (double)1.0F) {
- var17 = (double)1.0F;
- }
-
- if (this.rotationfactor > (double)1.0F) {
- var11 = var15;
- }
-
- double var19 = (double)var1.width + (double)this.field_2.getLeading();
- double var21 = (double)var1.height;
- Rectangle[] var23 = new Rectangle[var8.size()];
- int var24 = (int)Math.rint(((Dvoto)var8.lastElement()).x - var19 / (double)2.0F);
- int var25 = (int)Math.rint(((Dvoto)var8.lastElement()).y - var21 / (double)2.0F);
- int var28 = -1;
- double var29 = var17;
-
- int var39;
- for(var39 = 0; (int)var29 < var8.size() && (var39 = (int)Math.rint(var29)) < var8.size(); var29 += var17) {
- int var26 = (int)Math.rint(((Dvoto)var8.elementAt(var39)).x - var19 / (double)2.0F);
- int var27 = (int)Math.rint(((Dvoto)var8.elementAt(var39)).y - var21 / (double)2.0F);
- if (var26 != var24 || var27 != var25) {
- ++var28;
- var23[var28] = new Rectangle(var26, var27, (int)var19, (int)var21);
- var24 = var26;
- var25 = var27;
- }
- }
-
- System.arraycopy(var23, 0, this.rectangles = new Rectangle[var28 + 1], 0, var28 + 1);
- this.increment = this.rectangles.length / (int)var11;
- if (this.message.length() > (int)var11) {
- this.message = this.message.substring(0, (int)var11);
- }
-
- this.message_beg = this.clockwise ? 0 : this.message.length() * this.increment - this.increment;
- this.field_3 = new String[this.message.length()];
- this.field_1 = new int[this.field_3.length];
- int var32 = this.field_2.getMaxAscent();
- this.field_0 = (var1.height - (var32 + this.field_2.getMaxDescent() + this.field_2.getLeading())) / 2 + var32;
- char[] var33 = this.message.toCharArray();
-
- for(int var34 = 0; var34 < this.message.length(); ++var34) {
- this.field_3[var34] = new String(var33, var34, 1);
- this.field_1[var34] = (var1.width - this.field_2.charWidth(this.message.charAt(var34))) / 2;
- }
-
- if (!this.field_4[PARAM_charEffects][1].equals("")) {
- this.buildColorArray();
- }
-
- if (!this.imageName.equals("")) {
- this.tracker = new MediaTracker(this);
- this.image = ((Applet)this).getImage(((Applet)this).getDocumentBase(), this.imageName);
- this.tracker.addImage(this.image, 0);
- this.loaded = false;
- } else {
- this.image = null;
- this.loaded = false;
- }
-
- if (this.image != null && !this.loaded) {
- try {
- this.tracker.waitForID(0);
- } catch (InterruptedException var37) {
- }
-
- if (this.tracker.isErrorID(0)) {
- ((Applet)this).showStatus("Error loading image " + this.imageName + ", quitting.");
- return;
- }
-
- this.loaded = true;
-
- while((this.imageWidth = this.image.getWidth(this)) < 0) {
- try {
- Thread.sleep(100L);
- } catch (InterruptedException var36) {
- }
- }
-
- while((this.imageHeight = this.image.getHeight(this)) < 0) {
- try {
- Thread.sleep(100L);
- } catch (InterruptedException var35) {
- }
- }
-
- if (this.center) {
- this.centered_XCorner = this.appletSize.width / 2 - this.imageWidth / 2;
- if (this.centered_XCorner < 0) {
- this.centered_XCorner = 0;
- }
-
- this.centered_YCorner = this.appletSize.height / 2 - this.imageHeight / 2;
- if (this.centered_YCorner < 0) {
- this.centered_YCorner = 0;
- }
- }
- }
-
- }
-
- private void setBufferGraphics() {
- this.bufferGraphics = this.buffer.getGraphics();
- this.field_2 = this.bufferGraphics.getFontMetrics(new Font(this.fontName, this.fontStyle, this.fontSize));
- this.bufferGraphics.setFont(this.field_2.getFont());
- this.bufferGraphics.setColor(this.background);
- this.bufferGraphics.fillRect(0, 0, this.appletSize.width, this.appletSize.height);
- }
-
- public void destroy() {
- }
-
- public void update(Graphics var1) {
- if (this.image != null) {
- if (this.scale) {
- this.bufferGraphics.drawImage(this.image, 0, 0, this.appletSize.width, this.appletSize.height, 0, 0, 100, 100, this);
- } else if (this.tile) {
- for(int var2 = 0; var2 < this.appletSize.width; var2 += this.imageWidth) {
- for(int var3 = 0; var3 < this.appletSize.height; var3 += this.imageHeight) {
- this.bufferGraphics.drawImage(this.image, var2, var3, this);
- }
- }
- } else if (this.center) {
- this.bufferGraphics.setColor(this.background);
- this.bufferGraphics.fillRect(0, 0, this.appletSize.width, this.appletSize.height);
- this.bufferGraphics.drawImage(this.image, this.centered_XCorner, this.centered_YCorner, this);
- } else {
- this.bufferGraphics.setColor(this.background);
- this.bufferGraphics.fillRect(0, 0, this.appletSize.width, this.appletSize.height);
- this.bufferGraphics.drawImage(this.image, 0, 0, this);
- }
- } else {
- this.bufferGraphics.setColor(this.background);
- this.bufferGraphics.fillRect(0, 0, this.appletSize.width, this.appletSize.height);
- }
-
- if (!this.random || !this.fixed) {
- this.bufferGraphics.setColor(this.foreground);
- }
-
- if (this.clockwise) {
- int var5 = 0;
-
- for(int var7 = this.message_beg; var5 < this.field_3.length; var7 += this.increment) {
- int var4 = var7 >= this.rectangles.length ? var7 - this.rectangles.length : var7;
- if (this.random) {
- this.bufferGraphics.setColor(this.randColors[this.randCount]);
- if (this.randCount < this.randColors.length - 1) {
- ++this.randCount;
- } else {
- this.randCount = 0;
- }
- }
-
- if (this.fixed) {
- this.bufferGraphics.setColor(this.randColors[var5]);
- }
-
- this.bufferGraphics.drawString(this.field_3[var5], this.rectangles[var4].x + this.field_1[var5], this.rectangles[var4].y + this.field_0);
- ++var5;
- }
-
- this.message_beg = this.message_beg + 1 >= this.rectangles.length ? 0 : this.message_beg + 1;
- } else {
- int var6 = this.message.length() - 1;
-
- for(int var8 = this.message_beg; var6 > -1; var8 -= this.increment) {
- int var9 = var8 < 0 ? var8 + this.rectangles.length : var8;
- if (this.random) {
- this.bufferGraphics.setColor(this.randColors[this.randCount]);
- if (this.randCount < this.randColors.length - 1) {
- ++this.randCount;
- } else {
- this.randCount = 0;
- }
- }
-
- if (this.fixed) {
- this.bufferGraphics.setColor(this.randColors[var6]);
- }
-
- this.bufferGraphics.drawString(this.field_3[var6], this.rectangles[var9].x + this.field_1[var6], this.rectangles[var9].y + this.field_0);
- --var6;
- }
-
- this.message_beg = this.message_beg - 1 < 0 ? this.rectangles.length - 1 : this.message_beg - 1;
- }
-
- this.paint(var1);
- }
-
- public void paint(Graphics var1) {
- var1.drawImage(this.buffer, 0, 0, this);
- var1.dispose();
- }
-
- public void start() {
- if (this.animator == null) {
- Thread var1 = Thread.currentThread();
- var1.setPriority(2);
- this.animator = new Thread(this);
- this.animator.setPriority(1);
- this.animator.start();
- }
-
- }
-
- public void stop() {
- if (this.animator != null) {
- this.animator.stop();
- this.animator = null;
- }
-
- }
-
- public void run() {
- while(this.animator != null) {
- ((Component)this).repaint();
-
- try {
- Thread.sleep((long)this.pause);
- } catch (InterruptedException var1) {
- }
- }
-
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- try {
- if (this.url != null) {
- ((Applet)this).getAppletContext().showDocument(this.url);
- }
- } catch (Exception var6) {
- } finally {
- ;
- }
-
- return true;
- }
-
- public boolean mouseEnter(Event var1, int var2, int var3) {
- if (this.field_4[PARAM_url][1] != null && !this.field_4[PARAM_url][1].equals("")) {
- ((Applet)this).showStatus(this.field_4[PARAM_url][1]);
- if (this.browserFrame != null) {
- this.browserFrame.setCursor(12);
- }
- }
-
- return true;
- }
-
- public boolean mouseExit(Event var1, int var2, int var3) {
- ((Applet)this).showStatus("");
- return true;
- }
-
- private void buildColorArray() {
- Color[] var3 = new Color[]{Color.black, Color.black, Color.black, Color.black, Color.black, Color.red, Color.black, Color.black, Color.black, Color.black, Color.white};
- this.randCount = 0;
- boolean var5 = this.random = this.fixed = false;
- String var7 = this.field_4[PARAM_charEffects][1].toUpperCase();
- if (var7.equals("RANDOMPASTELS")) {
- this.random = true;
- var5 = true;
- } else if (var7.equals("RANDOMCOLORS")) {
- this.random = true;
- } else if (var7.equals("FIXEDPASTELS")) {
- this.fixed = true;
- var5 = true;
- } else if (var7.equals("FIXEDCOLORS")) {
- this.fixed = true;
- }
-
- this.randColors = new Color[this.random ? 100 : this.field_3.length];
- boolean var4;
- Random var6;
- if (var4 = this.parm_seed != -1000000) {
- var6 = new Random((long)this.parm_seed);
- } else {
- var6 = null;
- }
-
- if (var5) {
- for(int var10 = 0; var10 < this.randColors.length; ++var10) {
- double var9 = var4 ? var6.nextDouble() : Math.random();
- this.randColors[var10] = Color.getHSBColor((float)var9, 0.3F, 0.99F);
- }
-
- } else {
- for(int var8 = 0; var8 < this.randColors.length; ++var8) {
- while(true) {
- double var1 = var4 ? var6.nextDouble() : Math.random();
- this.randColors[var8] = var3[(int)Math.ceil(var1 * (double)11.0F) - 1];
- if (this.randColors[var8] != this.background) {
- break;
- }
- }
- }
-
- }
- }
-
- private void getParameters() {
- for(int var2 = 0; var2 < this.field_4.length; ++var2) {
- String var1 = ((Applet)this).getParameter(this.field_4[var2][0]);
- if (var1 != null) {
- this.field_4[var2][1] = var1;
- }
- }
-
- this.message = this.field_4[PARAM_message][1];
- this.imageName = this.field_4[PARAM_image][1];
- this.fontName = this.field_4[PARAM_fontName][1];
- String[] var3 = Toolkit.getDefaultToolkit().getFontList();
-
- for(int var4 = 0; var4 < var3.length; ++var4) {
- if (this.field_4[PARAM_fontName][1].equalsIgnoreCase(var3[var4])) {
- this.fontName = var3[var4];
- break;
- }
- }
-
- if (this.field_4[PARAM_fontStyle][1].equalsIgnoreCase("PLAIN")) {
- this.fontStyle = 0;
- } else if (this.field_4[PARAM_fontStyle][1].equalsIgnoreCase("BOLD")) {
- this.fontStyle = 1;
- } else if (this.field_4[PARAM_fontStyle][1].equalsIgnoreCase("ITALIC")) {
- this.fontStyle = 2;
- } else {
- this.fontStyle = 0;
- }
-
- this.fontSize = this.parse(this.field_4[PARAM_fontSize][1], 12);
- this.pause = this.parse(this.field_4[PARAM_pause][1], 100);
- this.rotationfactor = (double)this.parse(this.field_4[PARAM_rotationfactor][1], 100) * 0.01;
- this.parm_radius = this.parse(this.field_4[PARAM_radius][1], -1);
- this.fontPadding = this.parse(this.field_4[PARAM_fontPadding][1], 0);
- this.parm_x = this.parse(this.field_4[PARAM_x][1], -1000000);
- this.parm_y = this.parse(this.field_4[PARAM_y][1], -1000000);
- this.parm_seed = this.parse(this.field_4[PARAM_seed][1], -1000000);
- this.clockwise = this.field_4[PARAM_direction][1].equalsIgnoreCase("CLOCKWISE");
- this.scale = this.field_4[PARAM_imageAttribute][1].equalsIgnoreCase("SCALE");
- this.tile = this.field_4[PARAM_imageAttribute][1].equalsIgnoreCase("TILE");
- this.center = this.field_4[PARAM_imageAttribute][1].equalsIgnoreCase("CENTER");
- this.background = this.getColor(this.field_4[PARAM_background][1], Color.black);
- this.foreground = this.getColor(this.field_4[PARAM_foreground][1], Color.white);
-
- try {
- this.url = new URL(this.field_4[PARAM_url][1]);
- } catch (MalformedURLException var5) {
- this.url = null;
- }
- }
-
- private int parse(String var1, int var2) {
- try {
- return Integer.parseInt(var1);
- } catch (NumberFormatException var3) {
- return var2;
- }
- }
-
- private Color getColor(String var1, Color var2) {
- try {
- return new Color(this.HexToInt(var1.substring(0, 2)), this.HexToInt(var1.substring(2, 4)), this.HexToInt(var1.substring(4)));
- } catch (Exception var3) {
- return var2;
- }
- }
-
- public int HexToInt(String var1) {
- int var2 = 0;
- if (var1.substring(0, 1).equalsIgnoreCase("a")) {
- var2 = 160;
- } else if (var1.substring(0, 1).equalsIgnoreCase("b")) {
- var2 = 176;
- } else if (var1.substring(0, 1).equalsIgnoreCase("c")) {
- var2 = 192;
- } else if (var1.substring(0, 1).equalsIgnoreCase("d")) {
- var2 = 208;
- } else if (var1.substring(0, 1).equalsIgnoreCase("e")) {
- var2 = 224;
- } else if (var1.substring(0, 1).equalsIgnoreCase("f")) {
- var2 = 240;
- } else {
- var2 = Integer.valueOf(var1.substring(0, 1)) * 16;
- }
-
- if (var1.substring(1).equalsIgnoreCase("a")) {
- var2 += 10;
- } else if (var1.substring(1).equalsIgnoreCase("b")) {
- var2 += 11;
- } else if (var1.substring(1).equalsIgnoreCase("c")) {
- var2 += 12;
- } else if (var1.substring(1).equalsIgnoreCase("d")) {
- var2 += 13;
- } else if (var1.substring(1).equalsIgnoreCase("e")) {
- var2 += 14;
- } else if (var1.substring(1).equalsIgnoreCase("f")) {
- var2 += 15;
- } else {
- var2 += Integer.valueOf(var1.substring(1));
- }
-
- return var2;
- }
- }
-