import java.awt.Stroke; import java.applet.*; import java.awt.*; import java.awt.event.*; import static java.lang.Math.*; /** *ATTRATTORE DI LORENZ 3D e stereo applet realizzato nel 08/2008 * * @author Sergio Savoldelli wwww.savoldelli.net * @version numero 2 *******3/20011 * @version numero 3 *******9/20011 */ public class blorenzg2 extends java.applet.Applet implements MouseListener, MouseMotionListener { public double z = 0.02; public double pi=3.14159265; public double yz = 0.002; public double pi2=pi*2; public int mov1,mov2,mov3,mov4,k=6,n1=10,n2=1150,qq,q,a2,modulo,i, N= 3500,step,temp=1; public double x1,y1, z1,x0,z0,y0,xe,ye,ze,xeb,yeb,zeb; public double aa,k0,k02,xe2,ye2,xe2c,ye2c,x,y,xx,yy,t2, ee,r0,r02,val,w1; public double h = 0.001, q3=0; public double a = 6; public double b = 24; public double c = 4; Font font; Panel controlPanel, optionPanelColor, optionPanel0; Scrollbar sliderR, sliderr, sliderO; private boolean movingCircleOut = false; String sliderTextR = " A (1 - 1299): "; String sliderTextr = " B (2 - 100): "; String sliderTextO = " C (1 - 50): "; String sliderTextC = " - Stereo - "; Label sliderLabelR, sliderLabelr, sliderLabelO, sliderLabelC, titleLabel,titolotra; Checkbox insideCheckbox, outsideCheckbox; public double vertx[], verty[], vertz[] ; public int vertxb[],vertyb[],vertzb[],vertbzb[], vertbzc[], vertzc[] ; Graphics imG; Image imBuffer; public void init() { setSize(780, 550); vertx = new double[25500]; verty = new double[25500]; vertz = new double[25500]; vertxb = new int[25500];vertyb = new int[25500];vertzb = new int[25500];vertzc = new int[25500];vertbzc = new int[25500];vertbzb = new int[25500]; setBackground(Color.black); setLayout(new BorderLayout()); q=0; controlPanel = new Panel(); controlPanel.setLayout(new GridLayout(13,1)); add("East", controlPanel); addMouseListener(this); addMouseMotionListener(this); titleLabel = new Label("ATTRATTORE DI LORENZ 3D ", 1); font = new Font("Helvetica", Font.BOLD, 12); titleLabel.setFont(font); titleLabel.setBackground(Color.black); titleLabel.setForeground(Color.red); //////////// titolotra = new Label("CLICK AND DRAG ", 2); font = new Font("Helvetica", Font.BOLD, 12); titolotra.setFont(font); titolotra.setBackground(Color.black); titolotra.setForeground(Color.green); controlPanel.add(titleLabel); controlPanel.add(titolotra); sliderLabelR = new Label(sliderTextR + Integer.toString(n2)); font = new Font("Helvetica", Font.PLAIN, 12); sliderLabelR.setFont(font); sliderLabelR.setBackground(Color.black); sliderLabelR.setForeground(Color.white); controlPanel.add(sliderLabelR); sliderR = new Scrollbar(Scrollbar.HORIZONTAL, n2, 0, 1,1300); controlPanel.add(sliderR); sliderLabelr = new Label(sliderTextr + Integer.toString(n1)); font = new Font("Helvetica", Font.PLAIN, 12); sliderLabelr.setFont(font); sliderLabelr.setBackground(Color.black); sliderLabelr.setForeground(Color.white); controlPanel.add(sliderLabelr); sliderr = new Scrollbar(Scrollbar.HORIZONTAL, n1, 0, 2,101); controlPanel.add(sliderr); sliderLabelO = new Label(sliderTextO + Integer.toString(k)); font = new Font("Helvetica", Font.PLAIN, 12); sliderLabelO.setFont(font); sliderLabelO.setBackground(Color.black); sliderLabelO.setForeground(Color.white); controlPanel.add(sliderLabelO); sliderO = new Scrollbar(Scrollbar.HORIZONTAL, k, 0, 1, 51); controlPanel.add(sliderO); controlPanel.add(new Label(" ")); sliderLabelC = new Label(sliderTextC); CheckboxGroup CircleInOutGroup = new CheckboxGroup (); insideCheckbox = new Checkbox("si", CircleInOutGroup, !movingCircleOut); outsideCheckbox = new Checkbox("no", CircleInOutGroup, movingCircleOut); insideCheckbox.setForeground(Color.green); outsideCheckbox.setForeground(Color.cyan); font = new Font("Helvetica", Font.BOLD, 12); insideCheckbox.setFont(font); outsideCheckbox.setFont(font); optionPanel0 = new Panel(); optionPanel0.setLayout(new GridLayout(1, 3)); font = new Font("Helvetica", Font.BOLD, 12); sliderLabelC.setFont(font); sliderLabelC.setBackground(Color.red); sliderLabelC.setForeground(Color.white); optionPanel0.add(insideCheckbox); optionPanel0.add(outsideCheckbox); controlPanel.add(new Label(" ")); controlPanel.add(sliderLabelC,10); controlPanel.add("East", optionPanel0); } public boolean handleEvent(Event evt) { if (evt.target instanceof Scrollbar) { int value = ((Scrollbar)evt.target).getValue(); if (evt.target == sliderR) { sliderLabelR.setText(sliderTextR + Integer.toString(value)); n2 = value; if (n2 < 1)n2=1; } else if (evt.target == sliderr) { sliderLabelr.setText(sliderTextr + Integer.toString(value)); n1 = value; if (n1 < 1)n1=1; } else if (evt.target == sliderO) { sliderLabelO.setText(sliderTextO + Integer.toString(value)); k = value; } repaint(); } if ( evt.target == insideCheckbox || evt.target == outsideCheckbox) { repaint(); } return true; } public void paint(Graphics g) { imBuffer = createImage (780, 550); imG = imBuffer.getGraphics (); imG.setColor (new Color(0,0,0)); imG.fillRect(0,0,610,550); w1= 0.001; h=0.001+ w1/k; x0 = 0.1+ 0.1/n2; y0 =0.1+ 0.1/n1; z0 =0.1+ 0.1/n1; step= 7-k/10; a= 11; b=24; c= 4.01-4/n1; N=13500; for (i=0;i