import ij.*; import ij.process.*; import ij.gui.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import ij.plugin.*; /* This is an ImageJ plugin version of the "Plasma" applet at http://rsb.info.nih.gov/plasma It creates an animated display by summing four sine waves into an array. */ public class Plasma2_ implements PlugIn { boolean noUpdates = false; boolean showFPS = true; int width =600; int height = 450; int w,h,size; MemoryImageSource source; Thread runThread; long firstFrame, frames, fps; IndexColorModel icm; int[] waveTable; byte[][] paletteTable; byte[] pixels; boolean running = true; ImagePlus imp; public void run(String arg) { init(); } public void init() { w = width/3; h = height/3; pixels = new byte[width*height]; size = (int) ((w+h)/2)*4; waveTable = new int[size]; paletteTable = new byte[3][256]; calculatePaletteTable(); calculateWaveTable(); imp = new ImagePlus("Plasma", new ByteProcessor(width, height, pixels, icm)); imp.show(); firstFrame=System.currentTimeMillis(); run(); } void calculateWaveTable() { for(int i=0;ifirstFrame+4000) { firstFrame=System.currentTimeMillis(); fps=frames; frames=0; } IJ.showStatus((int)((fps+0.5)/4) + " fps"); } }