/* Orbits.java - A Java applet to display orbits of complex numbers under iteration of the qudratic map * Author: Barry Tolnas * Created: 5/11/2005 */ import java.awt.*; import java.awt.event.*; import java.awt.geom.*; import java.awt.image.*; import javax.swing.*; import javax.swing.event.*; public class Orbits extends JApplet { final int iterations=255; final double centerR = -.5; final double centerI = 0; int width,height; double scale; BufferedImage map; GeneralPath orbit = new GeneralPath(); public void init() { //Create a colormap which contains a gradient // of grey values from black to white byte[] red = new byte[256]; byte[] green = new byte[256]; byte[] blue = new byte[256]; for (int i=0;i<256;i++) red[i]=green[i]=blue[i]=(byte)(256-i); red[1]=0; green[1]=0; blue[1]=0; IndexColorModel colormap = new IndexColorModel(8,256,red,green,blue); width=this.getWidth(); height=this.getHeight(); map = new BufferedImage(width,height,BufferedImage.TYPE_BYTE_INDEXED,colormap); renderMandelbrot(map); OrbitListener listener = new OrbitListener(); addMouseListener(listener); addMouseMotionListener(listener); addComponentListener(new ResizeListener()); } public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g.drawImage(map,0,0,this); g2.setColor(Color.red); g2.draw(orbit); } public void renderMandelbrot(BufferedImage image) { width = image.getWidth(); height= image.getHeight(); scale = 3.0/height; int[] im = new int[width*height]; double x,y,value; for(int py=0;py