/* Java Applet "Julia" computes the invariant lamination for a connected Julia set on the boundary of the Mandelbrot set with variable external angle. This program is released under the GNU GPL; copyright is retained by the author, Danny Calegari. See http://www.gnu.org */ import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.lang.Math; public class julia extends Applet { int angle=20; int count,i,j,k,l,m,n; int x1,x2,y1,y2,radius; double leaf[][] = new double [10000][2]; double a,b,c,d,e,f; double alpha,beta,gamma,delta; Scrollbar exterior_angle = new Scrollbar(Scrollbar.HORIZONTAL,20,10,1,209); public void init() { setLayout( new GridLayout( 15, 2)); add( "North", exterior_angle); exterior_angle.setUnitIncrement(1); exterior_angle.setBlockIncrement(5); add(exterior_angle); ScrAdj sa = new ScrAdj(); exterior_angle.addAdjustmentListener(sa); } public void paint( Graphics graphics ) { graphics.setColor( Color.black ); leaf[1][0] = angle/200.0; leaf[1][1] = leaf[1][0]+0.5; if (leaf[1][1]>1.0){ leaf[1][0] = leaf[1][1]-1.0; leaf[1][1] = leaf[1][1]-0.5; }; e = leaf[1][0]; f = leaf[1][1]; j=1; k=1; for (count=0;count<10;count++){ n=0; for (i=j;i<=k;i++){ leaf[k+(2*(i-j))+1][0] = leaf[i][0]/2.0; leaf[k+(2*(i-j))+1][1] = leaf[i][1]/2.0; leaf[k+(2*(i-j))+2][0] = (leaf[i][0]/2.0) + 0.5; leaf[k+(2*(i-j))+2][1] = (leaf[i][1]/2.0) + 0.5; n=n+2; a = leaf[k+(2*(i-j))+1][0]; b = leaf[k+(2*(i-j))+1][1]; c = leaf[k+(2*(i-j))+2][0]; d = leaf[k+(2*(i-j))+2][1]; if( ((a6.2831852){ alpha=alpha-6.2831852; }; if (alpha<0){ alpha=alpha+6.2831852; }; if (beta>6.2831852){ beta=beta-6.2831852; }; if (beta<0){ beta=beta+6.2831852; }; gamma = (alpha+beta)/2.0; delta = (alpha-beta)/2.0; x1 = (int) (100.0 + (75.0*(Math.cos(gamma))/(Math.cos(delta)))); x2 = (int) (110.0 + (75.0*(Math.sin(gamma))/(Math.cos(delta)))); radius = (int) (75.0*Math.tan(delta)); graphics.drawOval(x1-radius,x2-radius,radius*2,radius*2); }; } class ScrAdj implements AdjustmentListener { public void adjustmentValueChanged(AdjustmentEvent ae) { Scrollbar s = (Scrollbar) ae.getAdjustable(); angle=(ae.getValue()); repaint(); } } }