home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
-
- public class CueCards extends Applet implements Runnable {
- static boolean dispCopy;
- Image origImg;
- Image backImg;
- Image animImg;
- // $FF: renamed from: w1 int
- int field_0;
- // $FF: renamed from: h1 int
- int field_1;
- Graphics backG;
- Graphics finG;
- Thread nick;
- int frameNo;
- int frames = 12;
- int period = 50;
- boolean needAnim;
- boolean imLoaded;
- boolean needImage;
- boolean animReady;
- double angle1;
- int imageNo = 1;
- Color backCol;
-
- public void start() {
- if (this.nick == null) {
- this.nick = new Thread(this);
- this.nick.start();
- }
-
- }
-
- public void stop() {
- if (this.nick != null) {
- this.nick.stop();
- this.nick = null;
- }
-
- }
-
- public void loadImage() {
- MediaTracker tracker = new MediaTracker(this);
- String nextImage = ((Applet)this).getParameter("image" + this.imageNo);
- if (nextImage == null) {
- this.imageNo = 1;
- nextImage = ((Applet)this).getParameter("image1");
- }
-
- ++this.imageNo;
- this.imLoaded = false;
- this.origImg = ((Applet)this).getImage(((Applet)this).getDocumentBase(), nextImage);
- tracker.addImage(this.origImg, 0);
-
- try {
- tracker.waitForAll();
- } catch (InterruptedException var5) {
- }
-
- this.field_0 = this.origImg.getWidth(this);
- this.field_1 = this.origImg.getHeight(this);
- }
-
- public void rotateImage(Graphics g, double angle) {
- double twistAngle = angle;
- double quart = (Math.PI / 2D);
- double oct = (Math.PI / 4D);
- if (angle > oct) {
- this.shearY(g, (double)1.0F);
- this.shearX(g, (double)1.0F);
- this.shearY(g, (double)1.0F);
- twistAngle = angle - quart;
- }
-
- this.shearX(g, Math.tan(twistAngle / (double)2.0F));
- this.shearY(g, Math.sin(twistAngle));
- this.shearX(g, Math.tan(twistAngle / (double)2.0F));
- }
-
- public void shearX(Graphics g, double shearing) {
- for(int i = 0; i < this.field_1 << 1; ++i) {
- double l = (double)i * -shearing + (double)this.field_1 * shearing;
- g.copyArea(0, i, this.field_0 * 3 >> 1, 1, (int)l, 0);
- g.drawLine((int)l, i, 0, i);
- g.drawLine((int)l + (this.field_0 * 3 >> 1), i, this.field_0 * 3 >> 1, i);
- }
-
- }
-
- public void run() {
- while(this.nick != null) {
- if (this.needImage) {
- this.needImage = false;
- this.loadImage();
- }
-
- if (this.needAnim) {
- this.needAnim = false;
- this.animReady = false;
- this.createAnim();
- }
-
- ((Component)this).repaint();
- if (this.frameNo < this.frames) {
- if (this.frameNo == this.frames - 1) {
- this.needAnim = true;
- }
-
- ++this.frameNo;
- } else if (this.frameNo >= this.frames) {
- if (this.frameNo == this.frames) {
- this.needImage = true;
- }
-
- if (this.frameNo == (this.frames << 1) - 1) {
- this.frameNo = 0;
- }
-
- ++this.frameNo;
- }
-
- try {
- Thread.sleep(50L);
- } catch (InterruptedException var3) {
- }
- }
-
- }
-
- public void shearY(Graphics g, double shearing) {
- for(int i = 0; i < this.field_0 * 3 >> 1; ++i) {
- double l = (double)i * shearing;
- g.copyArea(i, 0, 1, this.field_1 << 1, 0, (int)l);
- g.drawLine(i, (int)l, i, 0);
- g.drawLine(i, (int)l + (this.field_1 << 1), i, this.field_1 << 1);
- }
-
- }
-
- public void init() {
- if (!dispCopy) {
- System.out.println("cueCards v 1.0 for Java");
- System.out.println("Copyright (c) " + "David Griffiths, 1996. " + "All rights reserved.");
- System.out.println("For more information visit " + "http://www.demon.co.uk/davidg,");
- System.out.println("or contact: " + "dgriffiths@msn.com");
- dispCopy = true;
- }
-
- this.backCol = new Color(Integer.parseInt(((Applet)this).getParameter("bgcolor").substring(1), 16));
- ((Component)this).setBackground(this.backCol);
- this.loadImage();
- }
-
- public void update(Graphics g) {
- this.paint(g);
- }
-
- public void paint(Graphics g) {
- if (this.frameNo < this.frames) {
- g.drawImage(this.origImg, 0, this.frameNo * this.frameNo * this.field_1 / ((this.frames - 1) * (this.frames - 1)) - this.field_1, this);
- } else if (this.frameNo == this.frames && this.animReady) {
- g.drawImage(this.origImg, 0, 0, this);
- } else if (this.frameNo > this.frames && this.animReady) {
- int i = this.frameNo - this.frames;
- g.drawImage(this.animImg, 0, -i * this.field_1, this);
- } else if (this.origImg != null) {
- g.drawImage(this.origImg, 0, 400, this);
- }
-
- }
-
- public void createAnim() {
- System.gc();
- if (this.backImg == null) {
- this.backImg = ((Component)this).createImage(this.field_0 * 3 >> 1, this.field_1 << 1);
- this.backG = this.backImg.getGraphics();
- this.animImg = ((Component)this).createImage(this.field_0, this.frames * this.field_1);
- this.finG = this.animImg.getGraphics();
- this.backG.setColor(this.backCol);
- }
-
- for(int phase = 0; phase < this.frames; ++phase) {
- this.backG.fillRect(0, 0, this.field_0, this.field_1 << 1);
- this.backG.drawImage(this.origImg, 0, 0, this);
- this.rotateImage(this.backG, 1.8849555921538759 * (double)phase * (double)phase / (double)this.frames / (double)this.frames);
- this.finG.drawImage(this.backImg, 0, phase * this.field_1, this);
- }
-
- this.animReady = true;
- }
- }
-