home *** CD-ROM | disk | FTP | other *** search
Wrap
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.net.MalformedURLException; import java.net.URL; public class Lake extends Applet implements Runnable { Thread m_Lake; private Graphics m_Graphics; private Graphics m_WaveGraphics; private Image m_Image; private Image m_Overlay; private Image m_WaveImage; private int m_nCurrImage; private int m_nImgWidth; private int m_nImgHeight; private int m_nOvlWidth; private int m_nOvlHeight; private boolean m_fAllLoaded; private boolean m_tAnimate = true; private final int NUM_FRAMES = 12; private String m_ImageName = ""; private String m_OverlayName = ""; private URL m_HRef; private String m_Frame = "_self"; private final String PARAM_image = "image"; private final String PARAM_overlay = "overlay"; private final String PARAM_href = "href"; private final String PARAM_target = "target"; public void createAnimation() { Image var1 = ((Component)this).createImage(this.m_nImgWidth, this.m_nImgHeight + 1); Graphics var2 = var1.getGraphics(); var2.drawImage(this.m_Image, 0, 1, this); for(int var3 = 0; var3 < this.m_nImgHeight >> 1; ++var3) { var2.copyArea(0, var3, this.m_nImgWidth, 1, 0, this.m_nImgHeight - var3); var2.copyArea(0, this.m_nImgHeight - 1 - var3, this.m_nImgWidth, 1, 0, -this.m_nImgHeight + 1 + (var3 << 1)); var2.copyArea(0, this.m_nImgHeight, this.m_nImgWidth, 1, 0, -1 - var3); } this.m_WaveImage = ((Component)this).createImage(13 * this.m_nImgWidth, this.m_nImgHeight); this.m_WaveGraphics = this.m_WaveImage.getGraphics(); this.m_WaveGraphics.drawImage(var1, 12 * this.m_nImgWidth, 0, this); int var5 = 0; do { this.makeWaves(this.m_WaveGraphics, var5); ++var5; } while(var5 < 12); var2.drawImage(this.m_Image, 0, 1, this); if (!"".equals(this.m_OverlayName)) { var2.drawImage(this.m_Overlay, this.m_nImgWidth - this.m_nOvlWidth >> 1, this.m_nImgHeight - (this.m_nOvlHeight >> 1), this); } this.m_Image = var1; } public void start() { if (this.m_Lake == null) { this.m_Lake = new Thread(this); this.m_Lake.start(); } } public String[][] getParameterInfo() { String[][] var1 = new String[][]{{"image", "String", "JPG or GIF file to reflect"}, {"overlay", "String", "JPG or GIF file to use as overlay"}, {"href", "URL", "URL to link to"}, {"target", "String", "Target frame"}}; return var1; } public void stop() { if (this.m_Lake != null) { this.m_Lake.stop(); this.m_Lake = null; } } private void displayImage(Graphics var1) { if (this.m_fAllLoaded) { if (this.m_WaveImage != null) { var1.drawImage(this.m_WaveImage, -this.m_nCurrImage * this.m_nImgWidth, this.m_nImgHeight, this); var1.drawImage(this.m_WaveImage, (12 - this.m_nCurrImage) * this.m_nImgWidth, this.m_nImgHeight, this); } var1.drawImage(this.m_Image, 0, -1, this); } } public String getAppletInfo() { return "Name: Lake v3.0\r\n" + "Author: David Griffiths\r\n" + "Created with Microsoft Visual J++ Version 1.0"; } public boolean mouseUp(Event var1, int var2, int var3) { super.mouseUp(var1, var2, var3); if (this.m_HRef == null) { this.m_tAnimate = !this.m_tAnimate; } else { ((Applet)this).showStatus("" + this.m_HRef); ((Applet)this).getAppletContext().showDocument(this.m_HRef, this.m_Frame); } return true; } public void run() { this.m_nCurrImage = 0; if (!this.m_fAllLoaded) { ((Component)this).repaint(); this.m_Graphics = ((Component)this).getGraphics(); MediaTracker var1 = new MediaTracker(this); this.m_Image = ((Applet)this).getImage(((Applet)this).getDocumentBase(), this.m_ImageName); if (!"".equals(this.m_OverlayName)) { this.m_Overlay = ((Applet)this).getImage(((Applet)this).getDocumentBase(), this.m_OverlayName); } var1.addImage(this.m_Image, 0); if (!"".equals(this.m_OverlayName)) { var1.addImage(this.m_Overlay, 1); } try { var1.waitForAll(); this.m_fAllLoaded = !var1.isErrorAny(); } catch (InterruptedException var3) { } if (!this.m_fAllLoaded) { this.stop(); this.m_Graphics.drawString("Error loading images!", 10, 40); return; } this.m_nImgWidth = this.m_Image.getWidth(this); this.m_nImgHeight = this.m_Image.getHeight(this); if (!"".equals(this.m_OverlayName)) { this.m_nOvlWidth = this.m_Overlay.getWidth(this); this.m_nOvlHeight = this.m_Overlay.getHeight(this); } this.createAnimation(); } ((Component)this).repaint(); while(true) { try { for(; this.m_tAnimate; Thread.sleep(50L)) { this.displayImage(this.m_Graphics); if (++this.m_nCurrImage == 12) { this.m_nCurrImage = 0; } } Thread.sleep(500L); } catch (InterruptedException var4) { this.stop(); } } } public void makeWaves(Graphics var1, int var2) { double var3 = (Math.PI * 2D) * (double)var2 / (double)12.0F; int var5 = (12 - var2) * this.m_nImgWidth; for(int var7 = 0; var7 < this.m_nImgHeight; ++var7) { int var6 = (int)((double)(this.m_nImgHeight / 14) * ((double)var7 + (double)28.0F) * Math.sin((double)(this.m_nImgHeight / 14 * (this.m_nImgHeight - var7)) / (double)(var7 + 1) + var3) / (double)this.m_nImgHeight); if (var7 < -var6) { var1.copyArea(12 * this.m_nImgWidth, var7, this.m_nImgWidth, 1, -var5, 0); } else { var1.copyArea(12 * this.m_nImgWidth, var7 + var6, this.m_nImgWidth, 1, -var5, -var6); } } if (!"".equals(this.m_OverlayName)) { var1.drawImage(this.m_Overlay, var2 * this.m_nImgWidth + (this.m_nImgWidth - this.m_nOvlWidth >> 1), -this.m_nOvlHeight >> 1, this); } } public void destroy() { } public void init() { String var1 = ((Applet)this).getParameter("image"); if (var1 != null) { this.m_ImageName = var1; } var1 = ((Applet)this).getParameter("overlay"); if (var1 != null) { this.m_OverlayName = var1; } var1 = ((Applet)this).getParameter("href"); if (var1 != null) { try { this.m_HRef = new URL(((Applet)this).getDocumentBase(), var1); } catch (MalformedURLException var3) { ((Applet)this).getAppletContext().showStatus("Bad URL: " + var1); return; } } var1 = ((Applet)this).getParameter("target"); if (var1 != null) { this.m_Frame = var1; } } public void paint(Graphics var1) { if (this.m_fAllLoaded) { this.displayImage(var1); } else { var1.drawString("Loading images...", 10, 20); } } }