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.Rectangle;
-
- public class RTLScroll extends Applet implements Runnable {
- boolean gSok;
- int speed = 10;
- int jump = 1;
- int size = 14;
- int advance;
- String message = "Specify a message in the Applet parameters.";
- Font font = new Font("Times", 1, 14);
- // $FF: renamed from: x int
- int field_0;
- // $FF: renamed from: y int
- int field_1;
- Color textcolor = new Color(255);
- Color bgcolor = new Color(16777215);
- Image offscreen;
- int imagewidth;
- int imageheight;
- int stringwidth;
- int stringheight;
- int stringascent;
- Thread animator;
- boolean please_stop;
-
- public void start() {
- this.animator = new Thread(this);
- this.animator.start();
- }
-
- public void stop() {
- if (this.animator != null) {
- this.animator.stop();
- }
-
- this.animator = null;
- }
-
- public boolean mouseDown(Event e, int x, int y) {
- if (this.animator != null) {
- this.please_stop = true;
- } else {
- this.please_stop = false;
- this.start();
- }
-
- return true;
- }
-
- public void drawBackground(Graphics gr, Color c) {
- Dimension size = ((Component)this).size();
- int w = size.width;
- int h = size.height;
- gr.setColor(this.bgcolor);
- gr.fillRect(0, 0, w, h);
- }
-
- public void run() {
- while(!this.please_stop) {
- Dimension d = ((Component)this).size();
- if (this.offscreen == null || this.imagewidth != d.width || this.imageheight != d.height) {
- this.offscreen = ((Component)this).createImage(d.width, d.height);
- this.imagewidth = d.width;
- this.imageheight = d.height;
- }
-
- if (this.field_0 <= -this.stringwidth) {
- this.field_0 = d.width;
- ((Component)this).repaint();
- }
-
- Rectangle oldrect = new Rectangle(this.field_0, this.field_1 - this.stringascent, this.stringwidth, this.stringheight);
- this.field_0 = (this.field_0 - this.jump) % d.width;
- Rectangle newrect = new Rectangle(this.field_0, this.field_1 - this.stringascent, this.stringwidth, this.stringheight);
- Rectangle r = newrect.union(oldrect);
- Graphics g = this.offscreen.getGraphics();
- g.clipRect(r.x, r.y, r.width, r.height);
- this.paint(g);
- g = ((Component)this).getGraphics();
- g.clipRect(r.x, r.y, r.width, r.height);
- g.drawImage(this.offscreen, 0, 0, this);
-
- try {
- Thread.sleep((long)this.speed);
- } catch (InterruptedException var8) {
- }
- }
-
- this.animator = null;
- }
-
- public void init() {
- Dimension d = ((Component)this).size();
- String crstr = "Copyright (c) 1997 OpenCube Technologies";
- String paramStr = ((Applet)this).getParameter("Notice");
- if (paramStr != null) {
- if (paramStr.equals(crstr)) {
- this.gSok = true;
- } else {
- this.gSok = false;
- }
- } else {
- this.gSok = false;
- }
-
- paramStr = ((Applet)this).getParameter("jump");
- if (paramStr != null) {
- this.jump = Integer.parseInt(paramStr);
- }
-
- paramStr = ((Applet)this).getParameter("message");
- if (paramStr != null) {
- this.message = paramStr;
- }
-
- paramStr = ((Applet)this).getParameter("size");
- if (paramStr != null) {
- this.size = Integer.parseInt(paramStr);
- }
-
- paramStr = ((Applet)this).getParameter("font");
- if (paramStr != null) {
- this.font = new Font(paramStr, 1, this.size);
- }
-
- paramStr = ((Applet)this).getParameter("textcolor");
- if (paramStr != null) {
- this.textcolor = new Color(Integer.parseInt(paramStr));
- }
-
- paramStr = ((Applet)this).getParameter("bgcolor");
- if (paramStr != null) {
- this.bgcolor = new Color(Integer.parseInt(paramStr));
- }
-
- paramStr = ((Applet)this).getParameter("speed");
- if (paramStr != null) {
- this.speed = Integer.parseInt(paramStr);
- }
-
- if (this.gSok) {
- FontMetrics fm = ((Component)this).getFontMetrics(this.font);
- this.stringwidth = fm.stringWidth(this.message);
- this.stringheight = fm.getHeight();
- this.stringascent = fm.getAscent();
- this.advance = fm.getMaxAdvance();
- this.field_1 = (d.height + this.stringascent) / 2;
- this.field_0 = d.width;
- ((Component)this).setBackground(this.bgcolor);
- } else {
- try {
- Thread.sleep(1000L);
- } catch (InterruptedException var6) {
- }
-
- System.exit(0);
- }
-
- }
-
- public void paint(Graphics g) {
- this.drawBackground(g, this.bgcolor);
- g.setColor(this.textcolor);
- g.setFont(this.font);
- g.drawString(this.message, this.field_0, this.field_1);
- }
- }
-