home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.image.FilteredImageSource;
- import java.net.URL;
-
- public class AmpersandScroll extends Applet implements Runnable {
- Thread animator;
- Image image;
- Image offscreen;
- // $FF: renamed from: og java.awt.Graphics
- Graphics field_0;
- String text;
- String correcthost;
- Color backcolor;
- Color textcolor;
- Font textfont;
- boolean istext;
- boolean isimage;
- boolean registered;
- boolean dropshadow;
- int sleep = 80;
- int textinc = -2;
- int imageinc = -1;
- int imagewidth;
- int imageheight;
- int textwidth;
- int inctext;
- int imageX;
- int width;
- int height;
- int textY;
-
- public void init() {
- System.out.println("Scroller Applet");
- System.out.println("Version 1.2");
- System.out.println("Copyright 1997 Ampersand Internet All Rights Reserved");
- System.out.println("http://www.powerup.com.au/~mgk");
- this.correcthost = "http://www.powerup.com.au/~mgk";
- String var1 = ((Applet)this).getDocumentBase().toString();
- this.registered = true;
- if (!var1.startsWith(this.correcthost)) {
- System.out.println("Licensed for use at " + this.correcthost);
- System.out.println("Contact mgk@powerup.com.au to obtain a license");
- this.registered = false;
- }
-
- this.textfont = ((Component)this).getFont();
- String var2 = "HELVETICA";
- int var3 = 14;
- byte var4 = 0;
- this.height = ((Component)this).size().height;
- this.width = ((Component)this).size().width;
- this.offscreen = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
- this.field_0 = this.offscreen.getGraphics();
- if (((Applet)this).getParameter("sleep") != null) {
- this.sleep = Integer.parseInt(((Applet)this).getParameter("sleep"));
- }
-
- if (((Applet)this).getParameter("image") != null) {
- this.image = this.loadimage(((Applet)this).getParameter("image"));
- this.isimage = true;
- }
-
- if (((Applet)this).getParameter("text") != null) {
- this.text = ((Applet)this).getParameter("text");
- if (((Applet)this).getParameter("pointsize") != null) {
- var3 = Integer.parseInt(((Applet)this).getParameter("pointsize"));
- }
-
- if (((Applet)this).getParameter("fontface") != null) {
- var2 = ((Applet)this).getParameter("fontface");
- }
-
- if (((Applet)this).getParameter("fontweight") != null) {
- if (((Applet)this).getParameter("fontweight").equalsIgnoreCase("bold")) {
- var4 = 1;
- }
-
- if (((Applet)this).getParameter("fontweight").equalsIgnoreCase("italic")) {
- var4 = 2;
- }
-
- if (((Applet)this).getParameter("fontweight").equalsIgnoreCase("bolditalic")) {
- var4 = 3;
- }
- }
-
- if (((Applet)this).getParameter("textinc") != null) {
- this.textinc = Integer.parseInt(((Applet)this).getParameter("textinc"));
- }
-
- this.textfont = new Font(var2, var4, var3);
- this.inctext = this.width;
- this.field_0.setFont(this.textfont);
- this.textwidth = this.field_0.getFontMetrics().stringWidth(this.text);
- String var5 = "center";
- if (((Applet)this).getParameter("alignment") != null) {
- var5 = ((Applet)this).getParameter("alignment");
- }
-
- if (var5.equalsIgnoreCase("top")) {
- this.textY = this.field_0.getFontMetrics().getLeading() + this.field_0.getFontMetrics().getAscent() - this.field_0.getFontMetrics().getDescent() + 1;
- }
-
- if (var5.equalsIgnoreCase("center")) {
- this.textY = (this.height + this.field_0.getFontMetrics().getHeight() - this.field_0.getFontMetrics().getAscent() / 2) / 2;
- }
-
- if (var5.equalsIgnoreCase("bottom")) {
- this.textY = ((Component)this).size().height - this.field_0.getFontMetrics().getDescent() - this.field_0.getFontMetrics().getLeading() - 1;
- }
-
- if (((Applet)this).getParameter("dropshadow") != null && ((Applet)this).getParameter("dropshadow").equalsIgnoreCase("true")) {
- this.dropshadow = true;
- }
-
- this.istext = true;
- }
-
- String var10 = ((Applet)this).getParameter("backcolor");
- if (var10 == null) {
- var10 = "#000000";
- }
-
- String var6 = var10.substring(1, 3);
- int var7 = Integer.valueOf(var6, 16);
- var6 = var10.substring(3, 5);
- int var8 = Integer.valueOf(var6, 16);
- var6 = var10.substring(5, 7);
- int var9 = Integer.valueOf(var6, 16);
- this.backcolor = new Color(var7, var8, var9);
- var10 = ((Applet)this).getParameter("textcolor");
- if (var10 == null) {
- var10 = "#ff0000";
- }
-
- var6 = var10.substring(1, 3);
- var7 = Integer.valueOf(var6, 16);
- var6 = var10.substring(3, 5);
- var8 = Integer.valueOf(var6, 16);
- var6 = var10.substring(5, 7);
- var9 = Integer.valueOf(var6, 16);
- this.textcolor = new Color(var7, var8, var9);
- ((Component)this).setBackground(this.backcolor);
- }
-
- public void start() {
- if (this.isimage) {
- while(this.image.getWidth(this) < 0) {
- }
-
- this.imagewidth = this.image.getWidth(this);
-
- while(this.image.getHeight(this) < 0) {
- }
-
- this.imageheight = this.image.getWidth(this);
- }
-
- if (this.animator == null) {
- this.animator = new Thread(this);
- this.animator.start();
- }
-
- }
-
- public void stop() {
- if (this.animator != null) {
- this.animator.stop();
- this.animator = null;
- }
-
- }
-
- public void run() {
- while(Thread.currentThread() == this.animator) {
- long var1 = System.currentTimeMillis();
- ((Component)this).repaint();
- long var3 = System.currentTimeMillis();
- long var5 = var1 - var3;
- if (var5 > (long)this.sleep) {
- var5 = (long)this.sleep;
- }
-
- try {
- Thread.sleep((long)this.sleep - var5);
- } catch (InterruptedException var7) {
- }
- }
-
- }
-
- public synchronized void update(Graphics var1) {
- this.paint(var1);
- if (this.istext) {
- this.inctext += this.textinc;
- if (this.inctext < -this.textwidth) {
- this.inctext = this.width;
- }
-
- if (this.inctext > this.width) {
- this.inctext = -this.textwidth;
- }
-
- this.field_0.setColor(this.backcolor);
- this.field_0.fillRect(0, 0, this.width, this.height);
- }
-
- if (this.isimage) {
- this.imageX += this.imageinc;
- int var2 = this.imageX;
- if (this.imageX > this.imagewidth || this.imageX < -this.imagewidth) {
- this.imageX = 0;
- }
-
- for(int var3 = -1; var2 + this.imagewidth * (var3 - 1) < this.width; ++var3) {
- for(int var4 = 0; this.imageheight * (var4 - 1) < this.height; ++var4) {
- this.field_0.drawImage(this.image, var2 + this.imagewidth * var3, this.imageheight * var4, this);
- }
- }
- }
-
- if (this.istext) {
- this.field_0.setFont(this.textfont);
- if (this.dropshadow) {
- this.field_0.setColor(Color.black);
- this.field_0.drawString(this.text, this.inctext + 1, this.textY + 1);
- }
-
- this.field_0.setColor(this.textcolor);
- this.field_0.drawString(this.text, this.inctext, this.textY);
- }
-
- if (!this.registered) {
- this.field_0.setFont(new Font("arial", 1, 12));
- this.field_0.setColor(Color.black);
- this.field_0.drawString("Licensed for use at " + this.correcthost, 10, 12);
- this.field_0.drawString("Contact mgk@powerup.com.au to obtain a license", 10, 24);
- this.field_0.setColor(Color.white);
- this.field_0.drawString("Licensed for use at " + this.correcthost, 9, 11);
- this.field_0.drawString("Contact mgk@powerup.com.au to obtain a license", 9, 23);
- this.field_0.setColor(this.backcolor);
- }
-
- this.paint(this.field_0);
- }
-
- public synchronized void paint(Graphics var1) {
- var1.drawImage(this.offscreen, 0, 0, this);
- }
-
- public Image loadimage(String var1) {
- if (var1.toLowerCase().startsWith("http")) {
- try {
- Image var2 = ((Applet)this).getImage(new URL(var1));
- FixDither var3 = new FixDither();
- FilteredImageSource var4 = new FilteredImageSource(var2.getSource(), var3);
- return ((Component)this).createImage(var4);
- } catch (Exception var5) {
- System.out.println(var5 + " loading image in Banner applet");
- }
- } else {
- try {
- Image var7 = ((Applet)this).getImage(((Applet)this).getDocumentBase(), var1);
- FixDither var8 = new FixDither();
- FilteredImageSource var9 = new FilteredImageSource(var7.getSource(), var8);
- return ((Component)this).createImage(var9);
- } catch (Exception var6) {
- System.out.println(var6 + " loading image in Banner applet");
- }
- }
-
- return this.image;
- }
- }
-