home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Component;
- import java.awt.Event;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.MediaTracker;
- import java.awt.Rectangle;
- import java.awt.image.FilteredImageSource;
- import java.awt.image.ImageFilter;
- import java.awt.image.ImageObserver;
- import java.awt.image.ImageProducer;
- import java.net.MalformedURLException;
- import java.net.URL;
-
- public class fprotate extends Applet implements Runnable {
- private Thread m_fprotate;
- private Graphics m_Graphics;
- private Image[] m_Images;
- private int m_nCurrImage;
- private int m_nNextImage;
- private int[] m_nImgWidth;
- private int[] m_nImgHeight;
- private boolean m_fAllLoaded;
- private int m_numImages;
- private String[] m_imageString;
- private URL m_docUrl;
- private int m_transitionSteps = 4;
- private Image m_transImage1;
- private Image m_transImage2;
- private Image[] m_transImage;
- private int m_transitionTime;
- private String m_url;
- private String m_target;
- private int m_time;
- private String m_effectString;
- private String m_image;
- private int m_effect;
- private final String PARAM_time;
- private final String PARAM_effect;
- private final String PARAM_image;
- private final String PARAM_url;
- private final String PARAM_target;
-
- public void stop() {
- if (this.m_fprotate != null) {
- this.m_fprotate.stop();
- this.m_fprotate = null;
- }
-
- }
-
- public boolean mouseEnter(Event evt, int x, int y) {
- ((Applet)this).showStatus(this.m_url);
- return true;
- }
-
- public boolean mouseExit(Event evt, int x, int y) {
- ((Applet)this).showStatus("");
- return true;
- }
-
- public void paint(Graphics g) {
- if (this.m_fAllLoaded) {
- Rectangle r = g.getClipRect();
- g.clearRect(r.x, r.y, r.width, r.height);
- this.displayImage(g, this.m_Images[this.m_nCurrImage], this.m_nImgWidth[this.m_nCurrImage], this.m_nImgHeight[this.m_nCurrImage]);
- }
-
- }
-
- public boolean mouseUp(Event evt, int x, int y) {
- return true;
- }
-
- public String[][] getParameterInfo() {
- String[][] info = new String[][]{{"time", "int", "Display time in seconds"}, {"rotatoreffect", "String", "Transition effect"}, {"image" + 1, "String", "Image number 1"}, {"image" + 2, "String", "Image number 2"}, {"url", "String", "Url"}, {"target", "String", "Target frame"}};
- return info;
- }
-
- public void destroy() {
- }
-
- private void displayImage(Graphics g, Image image, int w, int h) {
- if (this.m_fAllLoaded) {
- g.drawImage(image, (((Component)this).size().width - w) / 2, (((Component)this).size().height - h) / 2, (ImageObserver)null);
- }
- }
-
- public fprotate() {
- this.m_transImage = new Image[this.m_transitionSteps];
- this.m_url = "";
- this.m_target = "";
- this.m_time = 3;
- this.m_effectString = "";
- this.m_image = "";
- this.m_effect = 3;
- this.PARAM_time = "time";
- this.PARAM_effect = "rotatoreffect";
- this.PARAM_image = "image";
- this.PARAM_url = "url";
- this.PARAM_target = "target";
- }
-
- public void start() {
- if (this.m_fprotate == null) {
- this.m_fprotate = new Thread(this);
- this.m_fprotate.start();
- }
-
- }
-
- public String getAppletInfo() {
- return "Name: fprotate\r\n" + "Author: Microsoft FrontPage\r\n" + "Created with Microsoft Visual J++ Version 1.1";
- }
-
- public boolean mouseDown(Event evt, int x, int y) {
- if (!this.m_url.equalsIgnoreCase("") && this.m_docUrl != null) {
- if (this.m_target.equalsIgnoreCase("")) {
- ((Applet)this).getAppletContext().showDocument(this.m_docUrl);
- } else {
- ((Applet)this).getAppletContext().showDocument(this.m_docUrl, this.m_target);
- }
- }
-
- return true;
- }
-
- public void run() {
- this.m_nCurrImage = 0;
- if (!this.m_fAllLoaded) {
- ((Component)this).repaint();
- this.m_Graphics = ((Component)this).getGraphics();
- this.m_Images = new Image[this.m_numImages];
- this.m_nImgWidth = new int[this.m_numImages];
- this.m_nImgHeight = new int[this.m_numImages];
- MediaTracker tracker = new MediaTracker(this);
-
- for(int i = 0; i < this.m_numImages; ++i) {
- this.m_Images[i] = ((Applet)this).getImage(((Applet)this).getDocumentBase(), this.m_imageString[i]);
- tracker.addImage(this.m_Images[i], 0);
- }
-
- try {
- tracker.waitForAll();
- this.m_fAllLoaded = !tracker.isErrorAny();
- } catch (InterruptedException var21) {
- }
-
- if (!this.m_fAllLoaded) {
- this.stop();
- return;
- }
-
- for(int i = 0; i < this.m_numImages; ++i) {
- this.m_nImgWidth[i] = this.m_Images[i].getWidth(this);
- this.m_nImgHeight[i] = this.m_Images[i].getHeight(this);
- }
- } else {
- ((Component)this).repaint();
- }
-
- while(true) {
- try {
- int currWidth = this.m_nImgWidth[this.m_nCurrImage];
- int currHeight = this.m_nImgHeight[this.m_nCurrImage];
- int wCurrOffset = (((Component)this).size().width - currWidth) / 2;
- int hCurrOffset = (((Component)this).size().height - currHeight) / 2;
- this.m_nNextImage = this.m_nCurrImage + 1;
- if (this.m_nNextImage == this.m_numImages) {
- this.m_nNextImage = 0;
- }
-
- int nextWidth = this.m_nImgWidth[this.m_nNextImage];
- int nextHeight = this.m_nImgHeight[this.m_nNextImage];
- int wNextOffset = (((Component)this).size().width - nextWidth) / 2;
- int hNextOffset = (((Component)this).size().height - nextHeight) / 2;
- int width = Math.max(currWidth, nextWidth);
- int height = Math.max(currHeight, nextHeight);
- int wTransOffset = (((Component)this).size().width - width) / 2;
- int hTransOffset = (((Component)this).size().height - height) / 2;
- this.m_transImage1 = ((Component)this).createImage(width, height);
- Graphics g1 = this.m_transImage1.getGraphics();
- int wOffset = wCurrOffset - wTransOffset;
- int hOffset = hCurrOffset - hTransOffset;
- g1.drawImage(this.m_Images[this.m_nCurrImage], wOffset, hOffset, (ImageObserver)null);
- int steps = this.m_effect == 0 ? 1 : this.m_transitionSteps;
-
- for(int i = 0; i < steps; ++i) {
- this.m_transImage[i] = ((Component)this).createImage(width, height);
- }
-
- this.m_transImage2 = ((Component)this).createImage(width, height);
- Graphics g2 = this.m_transImage2.getGraphics();
- wOffset = wNextOffset - wTransOffset;
- hOffset = hNextOffset - hTransOffset;
- g2.drawImage(this.m_Images[this.m_nNextImage], wOffset, hOffset, (ImageObserver)null);
- this.displayImage(this.m_Graphics, this.m_transImage1, width, height);
-
- for(int var24 = 0; var24 < steps; ++var24) {
- this.applyEffect(var24, this.m_transitionSteps, width, height, this.m_effect);
- }
-
- int nDelay = this.m_time * 1000;
- if (this.m_time == 0) {
- nDelay = 50;
- }
-
- Thread.sleep((long)nDelay);
-
- for(int var25 = 0; var25 < steps; ++var25) {
- this.displayImage(this.m_Graphics, this.m_transImage[var25], width, height);
- if (this.m_transitionTime > 0) {
- Thread.sleep((long)this.m_transitionTime);
- }
- }
-
- this.m_nCurrImage = this.m_nNextImage;
- } catch (InterruptedException var22) {
- this.stop();
- }
- }
- }
-
- public void init() {
- String param = ((Applet)this).getParameter("time");
- if (param != null) {
- this.m_time = Integer.parseInt(param);
- }
-
- param = ((Applet)this).getParameter("rotatoreffect");
- if (param != null) {
- this.m_effectString = param;
- }
-
- if (this.m_effectString.equalsIgnoreCase("none")) {
- this.m_effect = 0;
- }
-
- if (this.m_effectString.equalsIgnoreCase("blindsHorizontal")) {
- this.m_effect = 1;
- } else if (this.m_effectString.equalsIgnoreCase("blindsVertical")) {
- this.m_effect = 2;
- } else if (this.m_effectString.equalsIgnoreCase("dissolve")) {
- this.m_effect = 3;
- } else if (this.m_effectString.equalsIgnoreCase("boxIn")) {
- this.m_effect = 4;
- } else if (this.m_effectString.equalsIgnoreCase("boxOut")) {
- this.m_effect = 5;
- }
-
- this.m_numImages = 0;
- this.m_imageString = new String[100];
- int i = 1;
-
- do {
- param = ((Applet)this).getParameter("image" + i);
- if (param == null) {
- break;
- }
-
- this.m_imageString[this.m_numImages++] = param;
- ++i;
- } while(i <= 99);
-
- param = ((Applet)this).getParameter("url");
- if (param != null) {
- this.m_url = param;
- }
-
- param = ((Applet)this).getParameter("target");
- if (param != null) {
- this.m_target = param;
- }
-
- try {
- this.m_docUrl = new URL(((Applet)this).getDocumentBase(), this.m_url);
- } catch (MalformedURLException var4) {
- }
-
- }
-
- public void applyEffect(int i, int n, int width, int height, int effect) {
- ImageFilter filter = new fprotatx(i, n, width, height, effect);
- ImageProducer producer = new FilteredImageSource(this.m_transImage2.getSource(), filter);
- this.m_transImage[i] = ((Component)this).createImage(producer);
- }
- }
-