/* * Mandel.java * A simple Java Mandelbrot set * Usage: 4) break; yv = 2*xv*yv+y; xv = xx-yy+x; } if (l==max) { data[i+j*width] = 0; } else { data[i+j*width] = (byte)((l%9)+1); } } if ((i%10)==0) { mBitmap = new MemoryImageSource(width,hh,icm,data,0,width); repaint(); kicker.suspend(); } } mBitmap = new MemoryImageSource(width,hh,icm,data,0,width); repaint(); kicker = null; } public void reparam() { } public boolean mouseDown(java.awt.Event evt, int xm, int ym) { if (help) { help = false; repaint(); return true; } else if (changemax) { changemax = false; } if (ym>hh) { reparam(); return true; } double xn = x0+xm/(double)width*(x1-x0); double yn = y0+ym/(double)hh*(y1-y0); double xw = x1-x0; double yw = y1-y0; xw /= zoomfactor*2; yw /= zoomfactor*2; x0 = xn-xw; x1 = xn+xw; y0 = yn-yw; y1 = yn+yw; max = (int)(max * 1.25); if (kicker != null) { kicker.stop(); kicker = null; } kicker = new Thread(this); kicker.start(); return true; } public boolean action(Event e, Object o) { if (e.target instanceof Choice) { help = false; changemax = false; if (((String)o).equals("Reset")) { reset(); } else if (((String)o).equals("Help")) { help(); } else if (((String)o).equals("Change Max")) { changemax(); } ((Choice)e.target).select("Options"); } else if (e.target instanceof TextField) { changemax = false; max = Integer.parseInt(String.valueOf(o)); remove(tf); tf = null; if (kicker != null) { kicker.stop(); kicker = null; } kicker = new Thread(this); kicker.start(); } return true; } public String getAppletInfo() { return "Mandel by Ken Shirriff shirriff@eng.sun.com"; } public String[][] getParameterInfo() { String [][] info = { {"width ","int ", "image width"}, {"height ","int ", "image height"}, {"max ","int ", "max iterations"} }; return info; } }