/* Java aquarium v1.0 * * Java aquarium using CircleWaveFilter. This demo should be JDK 1.0 * compatible and runnable in Netscape 3.0. * * Written by Marcus Hoverby. Copyright (c) 1997 Marcus Hoverby. * You may modify and distribute this example for non-commercial * purposes. This code is provided without warranty. */ import java.awt.*; import java.awt.image.*; import java.applet.*; import java.lang.*; import CircleWaveFilter; public class Aquarium extends Applet implements Runnable { Image im; CircleWaveFilter f; Image[] anim = new Image[10]; Thread animthread = null; int count = -1; boolean calculating = false; public void init() { this.showStatus("Loading picture."); im = this.getImage(this.getDocumentBase(), "aquarium.jpg"); f = new CircleWaveFilter(40.0, 2.5, 80, 200, 320, 238); for (int n = 0; n <= 9; n++) { CircleWaveFilter fc = (CircleWaveFilter)f.clone(); fc.setParam(1.0 - (double)n / 10.0); ImageProducer prod = new FilteredImageSource(im.getSource(), fc); //wave image anim[n] = createImage(prod); } this.showStatus("Calculating animation."); } public void paint(Graphics g) { if (count != -1) g.drawImage(anim[count], 0, 0, this); } public void update(Graphics g) { paint(g); } public void start() { if (animthread == null) { animthread = new Thread(this); animthread.start(); showStatus("Anim started"); } } public void stop() { if ((animthread != null) && animthread.isAlive()) animthread.stop(); animthread = null; } public void run() { while (true) { if (++count == 10) { count = 0; } paint(getGraphics()); try { Thread.sleep(30); } catch (InterruptedException e) { }; } } }