
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.event.*;
import java.awt.*; 
import javax.swing.JButton;  
import java.util.Timer;
import java.util.TimerTask; 
import java.util.ArrayList;
import java.awt.Dimension;
import java.awt.*;
 
public class panneaul extends JPanel implements MouseListener
{ 
	static int longueur;
	static int haut; 
	static int coloration=1;

	static double minX=0.;
	static double maxX=0.;
	static double minY=0.;
	static double maxY=0.;
	static double delta=100.;

	static int i;
	static int j;
	static int k;
	
	static boolean flag=false; 	// dessin en cours
	static boolean listen=false; // 1er demarrage
	
	static int blanc=Color.white.getRGB();

	static double[] pilx=new double[200];	// piles des []
	static double[] pily=new double[200];
	static int[] pilc=new int[200];
	static double[] pila=new double[200];
	static double[] pild=new double[200];
	static int nivpil=0;
	
	static boolean manuel=false;	// cycle par cycle
	static boolean show=true;
	
  static String nomcoloration[]=new String[] {"noir et blanc","couleur"};
  
  static String[] nomgroupe;	// noms des groupes de ls
  static String[] nomlsg;			// noms des ls du groupe
  static String nomlsgroupe=new String();	// nom du ls
  
 	static int numls=0;			// numero du ls
	static int numgroupe=0;	// numéro du groupe
	static int numlsg=0;		// numéro du ls dans le groupe
	static int theorder=0;	// profondeur à atteindre
	static int ordermax=5;	// profondeur max pour le calcul automatique
	static int theordermax=1;	// profondeur max ou s'arreter en automatique
	
	static int nbtrans;			// nb d'elements du ls
	static double angle;
	static int sens=1;

	static double coordx;		
	static double coordy;
	static double cap;
	static int indexcolor;
	static int sindexcolor;
	static boolean keepf=true;
	static boolean imprimetout=false;

	static int X;
	static int Y;
	
 	static Timer t=new Timer();
 
 	Dimension dime = Toolkit.getDefaultToolkit().getScreenSize();
  int theight = (int)dime.getHeight();
	int twidth  = (int)dime.getWidth();
 BufferedImage buffimag1 = new BufferedImage(twidth, theight, BufferedImage.TYPE_INT_RGB);
 	private Graphics2D g1=buffimag1.createGraphics();
  
  Color[] tabcolor = new Color[] {
  new Color(0), 
  new Color(0xDAA520), //brun 
  new	Color(0xBDB76B), new Color(0x9ACD32),new Color(0x32CD32), new Color(0x90EE90), new Color(0x00FF00),  //green
  new  Color(0xFF0000), //red,
  new  Color(0x4B0082), //violet
  new  Color(0xFF00FF),	//magenta,
  new  Color(0xFFA500), //orange
  new  Color(0xFF4500), //orange rouge
  											//new Color(0xFFFF00), // jaune
  new Color(0x87CEEB), // sky blue
  new  Color(0x0000FF)};	//blue, ;
     
static String ls[][]=new String [][]{
{"Koch","Motif de Koch sur un segment","iter=5","angle=60","axiom=|F","F=F+F--F+F"},
{"Koch","Courbe de Koch vers l'extérieur d'un triangle","iter=5","angle=60","axiom=F--F--F","F=F+F--F+F"},
{"Koch","Courbe de Koch vers l'intérieur d'un triangle","iter=5","angle=60","axiom=F--F--F","F=F-F++F-F"},
{"Koch","Courbe de Koch vers l'intérieur d'un carré","iter=5","angle=60","axiom=\\90F\\90F\\90F\\90F","F=F-F++F-F"},

{"Césaro","ADH155e motif de Césaro sur un segment","iter=4",   "angle=90",  "axiom=d",  "d=d\\88d/176d\\88d"},// Anthony Hanmer 2000 Cesaro variation
  
{"Césaro","ADH155e1 sur l'extérieur d'un carré","iter=4", // Anthony Hanmer 2000 Double Cesaro variation
  "angle=90",  "axiom=d/90d/90d/90d",  "d=d\\88d/176d\\88d"},
  
{"Césaro","ADH155 inversé","iter=4", // Anthony Hanmer 2000 Cesaro variation",
  "angle=8",  "axiom=f",  "f=f++++++++++f--------------------f++++++++++f"},

{"Césaro","sur l'intérieur d'un carré","iter=4",
  "angle=90",  "axiom=d\\90d\\90d\\90d",  "d=d\\88d/176d\\88d"},

{"Césaro","ADH155a sur l'intérieur 4 fois","iter=4", // Anthony Hanmer 2000 Double Cesaro variation
  "angle=8",  "axiom=f+++++++++++f+++++++++++f+++++++++++f",  "f=f++++++++++f--------------------f++++++++++f"},
  
{"Césaro","ADH156_s sur la lettre S","iter=4", // Anthony Hanmer 2000 cesaro alphabet Cesaro variation alphabet:  S
  "angle=10",  "axiom=d\\90d\\90d/90d/90d",  "d=d\\80d/160d\\80d"},

{"Césaro","autre construction","iter=11","angle=34","axiom=FX","X=----F!X!++++++++F!X!----","F="},

{"Césaro","ADH155e6 variante sur un carré - Anthony Hanmer","iter=4", // Anthony Hanmer 2000 Double Cesaro variation
  "angle=90",  "axiom=d\\90d\\90d\\90d",  "d=d\\90@.5d\\62d/178d\\52d/178d\\62d\\90@2d"},
  
{"Césaro","ADH155e7 variante sur un pentagone","iter=4", // Anthony Hanmer 2000 Double Cesaro variation
  "angle=90",  "axiom=d\\72d\\72d\\72d\\72d",  "d=d\\90@.5d\\62d/178d\\52d/178d\\62d\\90@2d"},
  
{"Césaro","ADH155n1 variante sur un carré","iter=4", // Anthony Hanmer 2000 Double Cesaro variation
  "angle=90",  "axiom=d\\90d\\90d\\90d",  "d=ddd\\88d\\88d/176d\\88dd/176d\\88d/176d\\88dd\\88ddd"},

{"Césaro","ROT2 Césaro dissymétrique","iter=4",    // Jaume Bartrolí Row Of Trees inspired on The Algorithmic Beauty Of Plants
"angle=72","axiom=|F","F=@.30F+@I.30@Q.21F--F+@IQ.21@.70F@I.70 "},

{"Césaro","ROT3","iter=4",    // Jaume Bartrolí Row Of Trees inspired on "The Algorithmic Beauty Of Plants"
"angle=12","axiom=|F","F=@.30F+++++++@I.30@Q.21F--------------F+++++++@IQ.21@.70F@I.70 "},

{"Césaro","ROT4","iter=4",    // Jaume Bartrolí Row Of Trees inspired on "The Algorithmic Beauty Of Plants", p. 46, 47 and 48
"angle=120","axiom=D","D=@.3D\\86@I.3@Q.21D/172D\\86@IQ.21@.7D@I.7 "},

{"Césaro","ROT5","iter=4",    // Jaume Bartrolí Row Of Trees inspired on "The Algorithmic Beauty Of Plants", p. 46, 47 and 48
"angle=120","axiom=D","D=@.3D\\88@I.3@Q.21D/176D\\88@IQ.21@.7D@I.7 "},

{"Césaro","ROT6","iter=4",    // Jaume Bartrolí Row Of Trees inspired on  "The Algorithmic Beauty Of Plants", p. 46, 47 and 48
"angle=120","axiom=D","D=@.3D\\89@I.3@Q.21D/178D\\89@IQ.21@.7D@I.7 "},


{"courbes quadratiques de Koch","Koch carré","iter=5","angle=90","Axiom=F+F+F+F","F=FF+F+F+F+F+F-F"},
{"courbes quadratiques de Koch","Koch carré 1","iter=5","angle=90","axiom=F+F+F+F","F=FF+F+F+F+FF"},
{"courbes quadratiques de Koch","Koch carré 2","iter=4","angle=90","axiom=F+F+F+F","F=FF+F-F+F+FF"},
{"courbes quadratiques de Koch","Koch carré 3","iter=4","angle=90","axiom=F+F+F+F","F=-FF+F-F+F+FF"},
{"courbes quadratiques de Koch","Koch carré brisé","iter=5","angle=90","axiom=F+F+F+F","F=FF+F++F+F"},
{"courbes quadratiques de Koch","Koch carré 4","iter=5","angle=90","axiom=F+F+F+F","F=F+FF++F+F"}, 
{"courbes quadratiques de Koch","Koch carré 5","iter=5","angle=90","axiom=F+F+F+F","F=F+F-F+F+F"},
{"courbes quadratiques de Koch","quadratic snowflake","iter=5","angle=90","axiom=F","F=F-F+F+F-F"},
{"courbes quadratiques de Koch","Koch Island","iter=5","angle=90","axiom=F+F+F+F","F=F+F-F-FF+F+F-F"},
{"courbes quadratiques de Koch","quadratic Koch island","iter=3","angle=90","axiom=F+F+F+F","F=F-FF+FF+F+F-F-FF+F+F-F-FF-FF+F"},
// {"courbes quadratiques de Koch","quadratic Koch 2","iter=4","angle=90","axiom=F","F=++XF---F---X+++F+","X=-X---F+++X+++XF--"},
{"courbes quadratiques de Koch","boundary","iter=17","angle=90","axiom=OTUZ","O=FO+F-T","P=++F--U+F-X","Q=>-F+V++F--Q","R=-F+ZFS","S=FW","T=++F--U","U=++F--Y","V=FS","W=FO+F-P","X=++F--Y+F-X","Y=-F+R++F--Q","Z=-F+ZFW","F="}, // voir x

{"courbes couvrant le plan","Peano de base","iter=4","angle=90","axiom=F","F=F-F+F+F+F-F-F-F+F"},
{"courbes couvrant le plan","Peano","iter=4","angle=90","axiom=X", "X=XFYFX+F+YFXFY-F-XFYFX", "Y=YFXFY-F-XFYFX+F+YFXFY"},
{"courbes couvrant le plan","Peano arrondi"  ,"iter=4","angle=45"  ,"axiom=+z"  ,"z=fx"  ,"f="  ,"x=fx-fy-fx+fy+fx+fy+fx+fy+fx-fy-fx-fy-fx-fy-fx+fy+fx"  ,"y=fy"},
{"courbes couvrant le plan","Hilbert","iter=5","angle=90","axiom=X","X=-YF+XFX+FY-","Y=+XF-YFY-FX+"},
{"courbes couvrant le plan","Moore","iter=5","angle=90","axiom=+LFL+F+LFL ","L=-RF+LFL+FR- ","R=+LF-RFR-FL+"},
{"courbes couvrant le plan","fass 1","iter=4","angle=90","axiom=-L","L=$LF+RFR+FL-F-LFLFL-FRFR+","R=$-LFLF+RFRFR+F+RF-LFL-FR"},
{"courbes couvrant le plan","fass 2","iter=3","angle=90","axiom=-L","L=$LFLF+RFR+FLFL-FRF-LFL-FR+F+RF-LFL-FRFRFR+","R=$-LFLFLF+RFR+FL-F-LF+RFR+FLF+RFRF-LFL-FRFR"},
{"courbes couvrant le plan","Courbe de Sierpinski","iter=5","angle=45","axiom=FXY++F++FXY++F","X=XY@Q2-F@IQ2-FXY++F++FXY","Y=>-@Q2F-@IQ2FXY"},
{"courbes couvrant le plan","approximation de Sierpinski","iter=5","angle=90","axiom=F+XF+F+XF","X=XF-F+F-XF+F+XF-F+F-X"},
{"courbes couvrant le plan","lace","iter=6","angle=30","axiom=W","W=$+++X--F--ZFX+","X=---W++F++YFW-","Y=+ZFX--F--Z+++","Z=>-YFW++F++Y---"}, //$
{"courbes couvrant le plan","gosper","iter=5","angle=60","axiom=A","A=A-B--B+A++AA+B-","B=+A-BB--B-A++A+B"},
{"courbes couvrant le plan","quadratic gosper","iter=3","angle=90","axiom=-FR","L=FLFL-FR-FR+FL+FL-FR-FRFL+FR+FLFLFR-FL+FR+FLFL+FR-FLFR-FR-FL+FL+FRFR-","R=+FLFL-FR-FR+FL+FLFR+FL-FRFR-FL-FR+FLFRFR-FL-FRFL+FL+FR-FR-FL+FL+FRFR","F="},
//{"courbes couvrant le plan","Z order-Lebesgue","iter=5","angle=45","axiom=X","Z=F+++@Q2F@IQ2---F","X2=M-@Q2F+@IQ2M","Y4=X:++g++GGG;|X","T2=Y:g--GGG++;Y","U8=T:++g++GGG;|T"],
{"courbes couvrant le plan","Cross Curve","iter=5","angle=90","axiom=1+61+1+61","6=61-1+1-61+1+61-1+1-6"},
{"courbes couvrant le plan","Rect-5 "  ,"iter=5","angle=90"  ,"axiom=x"  ,"x=+fy-fp-fx+fp+fy-fp-fx+fp+fy-"  ,"y=-fx+fp+fy-fp-fx+fp+fy-fp-fx+"  ,"p=fp"  ,"f="},	//it=5
{"courbes couvrant le plan","Rect-3 "  ,"iter=7","angle=90"  ,"axiom=x"  ,"x=+fy-fp-fx+fp+fy-"  ,"y=-fx+fp+fy-fp-fx+"  ,"f="  ,"p=fp"},	//it=7    


{"ouverts","Sierpinski triangle arrondi","iter=8","angle=60","axiom=A","A=B-A-B","B=A+B+A"},
{"ouverts","Peano-tapis de Sierpinski","iter=5","angle=90","axiom=F","F=F-F+F+F+G-F-F-F+F","G=GGG"},
{"ouverts","pentaplexity","iter=5","angle=36","axiom=F++F++F++F++F","F=F++F++F|F-F++F"},
{"ouverts","rings","iter=5","angle=90","axiom=F+F+F+F","F=FF+F+F+F+F+F-F"},

{"dragons","dragon de Heighway","iter=14","angle=90","axiom=FX","X=X+YF+","Y=-FX-Y","F="}, 
{"dragons","dragon arrondi","iter=12","angle=45","axiom=X","X=FX+@.500FZ@2.00+FY","Y=FX-@.500FZ@2.00-FY","Z=FZ","F="},
{"dragons","quartet Peano","iter=5","angle=90","axiom=FB","A=FBFA+HFA+FB-FA","B=FB+FA-FB-JFBFA","H=-","J=+","F="},
{"dragons","Cross5c " ,"iter=5","angle=90"  ,"axiom=x"  ,"x=fx+fy-fx-fxfy+"  ,"y=-fxfy+fy+fx-fy"  ,"f="},
{"dragons","Dekking","iter=5","angle=120","axiom=X+X+X","X=FY+GX-FY","Y=GX+FY-GX","F=","G="},
{"dragons","cross","iter=5","angle=90","axiom=FX","X=FX+FX+FXFY-FY-","Y=+FX+FXFY-FY-FY","F="},
{"dragons","maze dragon","iter=13","angle=90","axiom=SU", "S=$FS+G-X","T=++F--U+G-X","U=++F--U-G+Z","V=FS-G+Z","W=GW+F-T","X=++G--Y+F-T","Y=++G--Y-F+V","Z=GW-F+V","F=","G="},
{"dragons","Courbe de Moore","iter=4","angle=90","axiom=X","X=$5FX+FX+FXFYFX+FXFY-FY-FY-","Y=>5+FX+FX+FXFY-FYFXFY-FY-FY","F="},

{"courbes du C","Levy","iter=15","angle=45","axiom=F","F=+F--F+"},
{"courbes du C","c-curve-1.5 "  ,"iter=20","angle=45"  ,"axiom=f"  ,"f=-@1.5f@I1.5++f-"},
{"courbes du C","c-curve-sl-38 "  ,"iter=25","angle=30"  ,"axiom=x"  ,"d="  ,"x=\\38@0.788010dx@I0.788010/90@0.615661da@I0.615661\\52 "  ,"a=dx"}, //it=25
{"courbes du C","c-curve-sl-32 "  ,"iter=25","angle=36"  ,"axiom=x"  ,"d="  ,"x=\\32@0.848048dx@I0.848048/90@0.529919da@I0.529919\\58 "  ,"a=db"  ,"b=de"  ,"e=dx"},
{"courbes du C","c-curve-sl-25 "  ,"iter=48","angle=60"  ,"axiom=x"
  ,"d="  ,"x=\\25@0.906308dx@I0.906308/90@0.422618da@I0.422618\\65 "  ,"a=db"  ,"b=de"  ,"e=dh"  ,"h=dj"  ,"j=dk"  ,"k=dl"  ,"l=dn"  ,"n=dx"},

{"arborescences","H-fractal","iter=19","angle=90","axiom=X","X=[Y]F[Y]","Y=@0.355[+G++@2.00X]"},
{"arborescences","H-fractal déformé","iter=14","angle=5","axiom=[Y]FF[Z]","Y=@0.70[/85X][\\85X]","Z=@0.70[/95X][\\95X]","X=FY"},
{"arborescences","basic tree","iter=10","angle=45","axiom=--FX","X=F@.600[-FX]+FX"}, 
{"arborescences","Plant 9","iter=4","angle=22.5","axiom=----1","1=1[+1[+1][-1]1] [-1[+1][-1]1] 1 [+1][-1]"},
{"arborescences","fusée","iter=9","angle=90","axiom=+F","F=FF[+F][-F]"},
{"arborescences","Cristal","iter=5","angle=60","axiom=[1]+[1]+[1]+[1]+[1]+[1]","1=111[1][+[1]+1][-[1]-1]"},

{"classiques","ensemble de Cantor","iter=5","angle=0","axiom=1","1=1G1","G=GGG"},
{"classiques","saucisse de Minkowski","iter=5","angle=90","axiom=F","F=F-F+F+FF-F-F+F"},

{"motifs","Z maze triangle","iter=8","angle=120","axiom=X","X=FY+FYFY-FY","Y=FX-FXFX+FX","F="},
{"motifs","iles","iter=3","angle=90","axiom=F-F-F-F","F=F-G+FF-F-FF-FG-FF+G-FF+F+FF+FG+FFF","G=GGGGGG"},
{"motifs","church","iter=5","angle=90","axiom=++F","F=$F+$FF-$F-$FF+$F","F="},
{"motifs","Dekking's church","iter=6","angle=90","axiom=++WZYX","W=FW+F-XFW-F+Z","X=++F--Y-F+Z++F--Y-F+Z","Y=++F--Y+F-X","Z=FW+F-X","F="},
{"motifs","T220 avions à aile delta - Anthony Hanmer ","iter=4", // Anthony Hanmer 2000 Looking to William McWorter's Maze09
  "angle=10",  "axiom=f",	"f=ff+++++++++f++++++++f++++++++++++++++++f--------ff--------f------------------f++++++++f---------ff"},
 
{"motifs","T222","iter=5", // Anthony Hanmer 2000 Looking to William McWorter's Maze09
  "angle=10",  "axiom=f",	"f=ff+++++++++f++++++++f++++++++++++++++++f--------ff--------f------------------f++++++++f---------f"},
  
{"motifs","T228","iter=5", // Anthony Hanmer 2000 Looking to William McWorter's Maze09
  "angle=90",  "axiom=f",  "f=ff+f+f++f-ff-f--f+f-f"},
  
{"motifs","T229","iter=5", // Anthony Hanmer 2000 Looking to William McWorter's Maze09
  "angle=90",  "axiom=f",  "f=f+f+f++f-ff-f--f+f-ff"},
  
{"motifs","T230","iter=5", // Anthony Hanmer 2000 Looking to William McWorter's Maze09
  "angle=90",  "axiom=f",  "f=ff+f+f++f-ff-f--f+f-ff"},
  
{"polygones","pentaplexity","iter=5","angle=36","axiom=F++F++F++F++F","F=F++F++F|F-F++F"},
{"polygones","pentagrams","iter=5","angle=36","axiom=FX++FX++FX++FX++FX","X=[++++@I1.618033989F@.618033989F!X!@I.618033989F]"}, // @
{"polygones","triangle d'or"  ,"iter=5","angle=36"  ,"axiom=|w"
  ,"w=++[-@1.618033989f@I1.618033989++++f]fx--[++@1.618033989f----f]fw--"  ,"w=[--@1.618033989f++++f]fy++"
  ,"x=-[+@1.618033989f@I1.618033989----f]fz++[--@1.618033989f++++f]fy-"  ,"y=--[+@1.618033989f@I1.6180339898----f]fz++[--@1.618033989f++++f]fy++"
  ,"y=[++@1.618033989f----f]fw--"  ,"z=+[-@1.618033989f@I1.618033989++++f]fx--[++@1.618033989f----f]fw+"  ,"f="},
{"polygones","sphinx","iter=5","angle=60","axiom=|X","X=+FF-YFF+FF- - FFF|X|F- - YFFFYFFF|","Y=-FF+XFF-FF++FFF|Y|F++XFFFXFFF|","F=GG","G=G>G"}, // voir x g>g -> ggg
{"polygones","kites and darts","iter=5","angle=36","axiom=WG+XG+WG+XG+WG+XG+WG+XG+WG+X","W=[F][++@1.618033989F][++G---@.618033989G|X-Y|G|W]","X=[F+++@1.618033989F][++@.618033989GZ|X|-G|W]","Y=[+F][@1.618033989F][+G@.618033989|Y+X]","Z=[-F][@1.618033989F][@.618033989G--WG|+Z]","F="}, // voir x

{"Penrose","Penrose 1","iter=5","angle=36","axiom=[X][Y]++[X][Y]++[X][Y]++[X][Y]++[X][Y]","W=YF++ZF----XF[-YF----WF]++","X=+YF- -ZF[---WF--XF]+","Y=-WF++XF[+++YF++ZF]-","Z=- -YF++++WF[+ZF++++XF]- -XF","F="},
{"Penrose","Penrose 2","iter=5","angle=36","axiom=[7]++[7]++[7]++[7]++[7]","6=81++91----71[-81----61]++","7=+81--91[---61--71]+","8=-61++71[+++81++91]-","9=--81++++61[+91++++71]--71","0=A","1=F","F="},
{"Penrose","Penrose 3","iter=5","angle=36","axiom=+WF--XF---YF--ZF","W=YF++ZF----XF[-YF----WF]++","X=+YF--ZF[---WF--XF]+","Y=-WF++XF[+++YF++ZF]-","Z=--YF++++WF[+ZF++++XF]--XF","F=>"},
{"Penrose","Penrose 4","iter=5","angle=36","axiom=[7]++[7]++[7]++[7]++[7]","6=81++91----71[-81----61]++","7=+81--91[---61--71]+","8=-61++71[+++81++91]-","9=--81++++61[+91++++71]--71"},

{"plantes","buisson","iter=5","angle=22.5","axiom=#F","F=FF-[>5-F+F+F]+[>5+F-F-F]"},
{"fougères","arbre","iter=5","angle=22.5","axiom=#X","F=FF","X=F[+X]F[-X]+X"},
{"plantes","arbre 1","iter=8","angle=12","axiom=#FX","X=@.600[>4-FY]+FX","Y=FX+FY-FX"},// controle
{"plantes","arbre 2","iter=8","angle=22.5","axiom=#X","F=FF","X=F-[[X]+X]+F[+FX]-X"},
{"plantes","Plante 1","iter=9","angle=22.5","axiom=#0","0=1 [+0] 1 [-0] 0","1=11"},
{"plantes","Plante 3","iter=8","angle=22.5","axiom=#0","0=1[+0]1[-0]+0 ","1=11"},
{"plantes","Plante 5","iter=6","angle=22.5","axiom=#1","1=1[+1]1[-1]1  "},  
{"plantes","Plante 6","iter=8","angle=22","axiom=#X","X=F[+X][-X]FX","F=FF"},
{"plantes","Alfonseca","iter=5", // Manuel Alfonseca rendered for fractint
  "angle=22.5",  "axiom=\\90A",  "A=f-[A+A]+f[+fA]-A",  "f=ff"},

{"plantes","rameau","iter=5","angle=22.5","axiom=  #Y","X=X[-FFF][+FFF]FX","Y=YFX[+Y][-Y]"},
{"fougères","Weed","iter=5","angle=7.2","axiom=|+++++++++++++x","x=f[@.50+++++++++x]-f[@.40-----------!x]@.60x"},
{"fougères","Fern1 "  ,"iter=33","angle=7.5","axiom=|++++++++++++++fx"	//48  it=35
  ,"x=f+++++++++y--------f@0.8x@I0.8------------------------f++++++++++"  ,"x=+++++++!y!------------------f++++++++++++++++++++++++"  ,"y=z"  ,"z=p"  ,"p=q"  ,"q=@0.35x@I0.35 "},

{"fougères","Fern2 "  ,"iter=33","angle=7.5","axiom=|+++++++++++++++fx"
  ,"x=f+++++++++y--------f@0.8x@I0.8-------!y!-----------------"  ,"x=f-f++++++++++++++++++++++++"  ,"y=z"  ,"z=p"  ,"p=q"  ,"q=@0.35x@I0.35 "},

{"fougères","Fern3 "  ,"iter=33","angle=7.5"  ,"axiom=|+++++++++++++++fx"
  ,"x=f+++++++++y--------f@0.8+x-@I0.8-------!y!-----------------"  ,"x=f-f++++++++++++++++++++++++"  ,"y=z"  ,"z=p"  ,"p=q"  ,"q=@0.35x@I0.35 "},
  
{"fougères","leaf1 "  ,"iter=30","angle=90"  ,"axiom=\\90x"	//it=33
  ,"x=@0.01d@I0.01\\35p/35@0.04d@I0.04@0.85!x!@I0.85\\180@0.05d@I0.05/180 "  ,"p=q"  ,"q=y"  ,"y=@0.55x@I0.55 "},

{"fougères","leaf2 "  ,"iter=30","angle=90"  ,"axiom=\\90x"
  ,"x=@0.01d@I0.01\\35p/35/40r\\40@0.04d@I0.04@0.85!x!@I0.85\\180@0.05d@I0.05/180 "
  ,"p=q"  ,"q=y"  ,"y=@0.55x@I0.55 "  ,"r=s"  ,"s=t"  ,"t=u"  ,"u=v"  ,"v=w"  ,"w=a"  ,"a=b"  ,"b=z"  ,"z=@0.25x@I0.25 "},
 
{"kolams","Stair Curve 1","iter=5","angle=90","axiom=1+1+1+1","1=1+1-1-1+1"},
{"kolams","Stair Curve 2","iter=5","angle=90","axiom=1+1+1+1","1=1-1+1+1-1"},
{"kolams","The snake","iter=5","angle=90","axiom=F+XF+F+XF","X=XF-F-F+XF+F+XF-F-F+X"},
{"kolams","The Anklets of Krishna","iter=5","angle=45","axiom=-X--X","X=XFX--XFX"},

{"spirales","rosace","iter=5","angle=15","axiom=AAAA","A=X+X+X+X+X+X+","X=[F+F+F+F[---X-Y]+++++F++++++++F-F-F-F]","Y=[F+F+F+F[---Y]+++++F++++++++F-F-F-F]"},
{"spirales","SpiralTile","iter=4", // by Herb Savage based on Martin Gardner's "Penrose Tiles to Trapdoor Ciphers"
  "angle=22.5",  "axiom=X++X++X++X++|G|X++X++X++X",  "X=[C12FX+++++@.7653668647C10F@I.7653668647[-----Y]+++++C12F]",  "Y=[C12F+++++@.7653668647C10F@I.7653668647[-----Y]+++++C12F]"},
{"spirales","VoderbergTile","iter=4", // by Herb Savage based on Martin Gardner's "Penrose Tiles to Trapdoor Ciphers", A spiral tiling by Heinz Voderberg
  "angle=12",  "axiom=\\84.1A\\96@4.783386117M@I4.783386117/96A",
  "A=X\\12X\\12X\\12X\\12X\\12X\\12X\\12X\\12X\\12X\\12X\\12X\\12X\\12X\\12X\\12Z",
  "X=[D\\78D\\46.37236@3.393427D@I3.393427/46.37236D\\114[\\168X\\24Y]D\\78D\\46.37236@3.393427D@I3.393427/46.37236D/78D]",
  "Y=[D\\78D\\46.37236@3.393427D@I3.393427/46.37236D/78D\\168[\\192Y]D\\78D\\46.37236@3.393427D@I3.393427/46.37236D]",
  "Z=[D\\78D\\46.37236@3.393427D@I3.393427/46.37236D\\114D\\78D\\46.37236@3.393427D@I3.393427/46.37236D/78D]"},
    
{"dragons spirales","dragon-sl-66", "iter=20","angle=30"  ,"axiom=x" //it=20
  ,"F="  ,"x=\\66@0.406736Fa@I0.406736/90@0.913545Fy@I0.913545\\24 "  ,"y=/24@0.913545Fx@I0.913545\\90@0.406736Fp@I0.406736/66 "
  ,"p=Fq"  ,"q=Fr"  ,"r=Fs"  ,"s=Ft"  ,"t=Fu"  ,"u=Fv"  ,"v=Fw"  ,"w=Fy"  ,"a=Fb"  ,"b=Fe"  ,"e=Fh"  ,"h=Fj"  ,"j=Fk"  ,"k=Fl"  ,"l=Fn"  ,"n=Fx"},
 
{"dragons spirales","dragon-sl-58 "  ,"iter=25","angle=30"  ,"axiom=x"
  ,"d="  ,"x=\\58@0.529919da@I0.529919/90@0.848048dy@I0.848048\\32 "
  ,"y=/32@0.848048dx@I0.848048\\90@0.529919dp@I0.529919/58 "  ,"p=dq"  ,"q=dr"  ,"r=dy"  ,"a=db"  ,"b=de"  ,"e=dx"},
  
{"dragons spirales","dragon-sl-52 "  ,"iter=25","angle=30"  ,"axiom=x"
  ,"d="  ,"x=\\52@0.615661da@I0.615661/90@0.788010dy@I0.788010\\38 "
  ,"y=/38@0.788010dx@I0.788010\\90@0.615661dp@I0.615661/52 "  ,"p=dy"  ,"a=dx"},
  
{"dragons spirales","dragon-sl-38 "  ,"iter=23","angle=30"  ,"axiom=x"	//it=23
  ,"d="  ,"x=\\38@0.788010dx@I0.788010/90@0.615661dp@I0.615661\\52 "
  ,"y=/52@0.615661da@I0.615661\\90@0.788010dy@I0.788010/38 "  ,"p=dy"  ,"a=dx"},
  
{"dragons spirales","dragon-sl-32 "  ,"iter=32","angle=30"  ,"axiom=x"
  ,"d="  ,"x=\\32@0.848048dx@I0.848048/90@0.529919dp@I0.529919\\58 "
  ,"y=/58@0.529919da@I0.529919\\90@0.848048dy@I0.848048/32 "  ,"p=dq"  ,"q=dr"  ,"r=dy"  ,"a=db"  ,"b=de"  ,"e=dx"},

{"dragons spirales","dragon-sl-25 "  ,"iter=67","angle=30"  ,"axiom=x"
  ,"d="  ,"x=\\25@0.906308dx@I0.906308/90@0.422618dp@I0.422618\\65 "
  ,"y=/65@0.422618da@I0.422618\\90@0.906308dy@I0.906308/25 "
  ,"p=dq"  ,"q=dr"  ,"r=ds"  ,"s=dt"  ,"t=du"  ,"u=dv"  ,"v=dw"  ,"w=dy"  ,"a=db"  ,"b=de"  ,"e=dh"  ,"h=dj"  ,"j=dk"  ,"k=dl"  ,"l=dn"  ,"n=dx"},

{"variantes","Pentive3", "iter=5","angle=36","axiom=|q"  ,"f="  ,"p=--fr++++fs--fu"  ,"q=ft++fr----fs++"  ,"r=++fp----fq++ft"  ,"s=fu--fp++++fq--"  ,"t=+fu--fp+"  ,"u=-fq++ft-"},
  
{"variantes","Hex-7-b hexagone arrondi"  ,"iter=4","angle=30"  ,"axiom=fx"
  ,"f="  ,"x=-f++f-x-f--f+y---f--f+y+f++f-x+++f++f-x-f++f-x+++f--f+y--"
  ,"y=+f++f-x-f--f+y+f--f+y---f--f+y---f++f-x+++f++f-x+++f--f+y"},

{"variantes","Tri2m-1 secteur arrondis"  ,"iter=13","angle=45"  ,"axiom=x"  ,"d="  ,"x=\\38!dx!/38dz/52!dp!\\52 "  ,"p=dx"  ,"z=dz"},  //it=13
{"variantes","Tri2m-2 "  ,"iter=13","angle=45"  ,"axiom=x"  ,"d="  ,"x=\\35!dx!/35dz/55!dp!\\55 "  ,"p=dq"  ,"q=dx"  ,"z=dz"},
{"variantes","Tri2m-2-b "  ,"iter=16","angle=45"  ,"axiom=x"  ,"d="  ,"x=dz\\35!dx!/35dz/55!dp!\\55 "  ,"p=dq"  ,"q=dx"  ,"z=dz"}, //it=16
{"variantes","Tri2m-2-c "  ,"iter=16","angle=45"  ,"axiom=x"  ,"x=\\35!dx!/90!dp!\\55 "  ,"p=dq"  ,"q=dx"},
{"variantes","Tri2m-3 "  ,"iter=32","angle=38"  ,"axiom=x"  ,"d="  ,"x=\\32!dx!/32dz/58!dp!\\58 "  ,"p=dq"  ,"q=dr"  ,"r=dx"  ,"z=dz"},	//it=32
{"variantes","Tri-4-b triangle arrondi"  ,"iter=4","angle=60"  ,"axiom=x"  ,"x=fp+fy+fp-fp-fx-fp-fy+fp+fx"  ,"y=fy-fp-fx+fp+fy+fp+fp-fx-fp"  ,"p=fp"  ,"f="},	//it=4

{"variantes","IsoTrap4a zone à motif"  ,"iter=5","angle=30"  ,"axiom=x"
  ,"x=p"  ,"p=++@1.732f@I1.732!p!-fz--fr---@1.732fz@I1.732++++@1.732f@I1.732!q!@1.732fz@I1.732++++@1.732f@I1.732!q!----"
  ,"q=++++@1.732f@I1.732!p!----@1.732fz@I1.732@1.732f@I1.732!p!----@1.732fz@I1.732+++fs++fz+@1.732f@I1.732!q!--"
  ,"r=+++++@1.732f@I1.732!p!----@1.732fz@I1.732@1.732f@I1.732!p!-fz--f!s!--fz-@1.732f@I1.732q+++++"
  ,"s=-----@1.732f@I1.732p+fz++f!r!++fz+@1.732f@I1.732!q!@1.732fz@I1.732++++@1.732f@I1.732!q!-----"  ,"z=fz"  ,"f="},

{"variantes","IsoTrap4b "  ,"iter=4","angle=30"  ,"axiom=+++++r"
  ,"p=++@1.732f@I1.732!p!-fz--fr---@1.732fz@I1.732++++@1.732f@I1.732!q!@1.732fz@I1.732++++@1.732f@I1.732!q!----"
  ,"q=++++@1.732f@I1.732!p!----@1.732fz@I1.732@1.732f@I1.732!p!----@1.732fz@I1.732+++fs++fz+@1.732f@I1.732!q!--"
  ,"r=+++++@1.732f@I1.732!p!----@1.732fz@I1.732@1.732f@I1.732!p!-fz--f!s!--fz-@1.732f@I1.732q+++++"
  ,"s=-----@1.732f@I1.732p+fz++f!r!++fz+@1.732f@I1.732!q!@1.732fz@I1.732++++@1.732f@I1.732!q!-----"  ,"z=fz"  ,"f="},

{"variantes","Tri-2-d triangle rectangle"  ,"iter=11","angle=45"  ,"axiom=r"  ,"r=x"  ,"x=+uf--y-@0.707f@I0.707++"  ,"v=--@0.707f@I0.707+u++fy-"  ,"u=-xf++v+@0.707f@I0.707--"  ,"y=++@0.707f@I0.707-x--fv+"},	//it=13

{"variantes","Tri-2-e "  ,"iter=13","angle=45"  ,"axiom=r"  ,"r=c40x"  ,"x=+fufz--fy-@0.707fz@I0.707++"  ,"v=--@0.707fz@I0.707+fu++fzfy-"  ,"u=-fxfz++fv+@0.707fz@I0.707--"
  ,"y=++@0.707fz@I0.707-fx--fzfv+"  ,"f="  ,"z=fz"},

{"variantes","Tri-4-d "  ,"iter=5","angle=30"  ,"axiom=x"  ,"x=xfy++f++x---f---y-@1.366f@I1.366+++"  ,"y=+++@1.366f@I1.366-x---f---y++f++xfy"},	//it=4

{"variantes","Tri-99-a  secteur à motif"  ,"iter=4","angle=15"  ,"axiom=x"	//24  it=3
  ,"x=++++y----f----z|---@Q2f@IQ2+++z--f------x---@Q2f@IQ2-----y+++@Q2f@IQ2+++++x++++f++++w|+++@Q2f@IQ2---w++f++x"
  ,"y=----x++++f++++w|+++@Q2f@IQ2---w++f++++++y+++@Q2f@IQ2+++++x---@Q2f@IQ2-----y----f----z|---@Q2f@IQ2+++z--f--y"
  ,"z=z--f--y+++@Q2f@IQ2|---y----f----z-----@Q2f@IQ2---w+++++@Q2f@IQ2+++z++++++f++x---@Q2f@IQ2|+++x++++f++++w----"
  ,"w=w++f++x---@Q2f@IQ2|+++x++++f++++w+++++@Q2f@IQ2+++z-----@Q2f@IQ2---w------f--y+++@Q2f@IQ2|---y----f----z++++"},

{"variantes","Tri-9-4-f "  ,"iter=4","angle=30"  ,"axiom=x"	//it=3
  ,"x=fa+fp+++fb-fp-fb-fp++fp---fa---fp-fb+++fp+fa---fp---fa+fp+++fb+++fp--fp+fa"
  ,"y=fb-fp---fa+fp+fa+fp--fp+++fb+++fp+fa---fp-fb+++fp+++fb-fp---fa---fp++fp-fb"
  ,"a=++fy-fp++fp---fx---fp-fy+++fp+fx"  ,"b=--fx+fp--fp+++fy+++fp+fx---fp-fy"  ,"p=fp"  ,"f="},

{"variantes","Tri-4-9-f "  ,"iter=5","angle=30"  ,"axiom=r"  ,"r=x"	//it=4
  ,"x=++fb-fp++fp---fa---fp-fb+++fp+fa"
  ,"y=--fa+fp--fp+++fb+++fp+fa---fp-fb"
  ,"a=fx+fp+++fy-fp-fy-fp++fp---fx---fp-fy+++fp+fx---fp---fx+fp+++fy+++fp--fp+fx"
  ,"b=fy-fp---fx+fp+fx+fp--fp+++fy+++fp+fx---fp-fy+++fp+++fy-fp---fx---fp++fp-fy"  ,"p=fp"  ,"f="},

{"variantes","Tri-9-f "  ,"iter=3","angle=30"  ,"axiom=x"		//it=3
  ,"x=fx+fp+++fy-fp-fy-fp++fp---fx---fp-fy+++fp+fx---fp---fx+fp+++fy+++fp--fp+fx"
  ,"y=fy-fp---fx+fp+fx+fp--fp+++fy+++fp+fx---fp-fy+++fp+++fy-fp---fx---fp++fp-fy"  ,"p=fp"  ,"f="},

{"variantes","Tri-9-b "  ,"iter=3","angle=60"  ,"axiom=x"		//it=3
  ,"x=fp+fp-fx-fp+fp+fy+fp+fx-fp-fy+fp-fp-fx-fp-fy+fp+fx-fp-fy+fp+fx"
  ,"y=fp-fp+fy+fp-fp-fx-fp-fy+fp+fx-fp+fp+fy+fp+fx-fp-fy+fp+fx-fp-fy"  ,"p=fp"  ,"f="},

{"variantes","Tri-4-e "  ,"iter=5","angle=30"  ,"axiom=x"  ,"x=x+f+++y-f---x--@Q3f@IQ3y++"  ,"y=y-f---x+f+++y++@Q3f@IQ3x--"},	//it=4

{"variantes","Tri-4-f ", "iter=5","angle=30"  ,"axiom=x"  ,"x=++fy-fp++fp---fx---fp-fy+++fp+fx"  ,"y=--fx+fp--fp+++fy+++fp+fx---fp-fy "  ,"f="  ,"p=fp"},	//it=3

{"variantes","svatiska","iter=3","angle=90","axiom=f-f-f-f","f=xlylP ","P=f","x=ff+f+ff-f-" ,"l=fff-ff+f+ff-f-ff+fff+f+ff-f-ff","y=+fff+f+ff-f-ff+fff+f+ff-f-fff-ff+f+ff-f-fff-ff+f+ff-f-"},

{"variantes","SnowFlake1","iter=4", // Adrian Mariano from The Fractal Geometry of Nature by Mandelbrot
  "angle=30",  "axiom=FR",  "R=++!FRFU++FU++FU!---@Q3FU|-@IQ3!FRFU!",  "U=!FRFU!|+@Q3FR@IQ3+++!FR--FR--FRFU!--",  "F="},
  
{"variantes","SnowFlake3","iter=2", // Adrian Mariano from The Fractal Geometry of Nature by Mandelbrot
  "angle=30",  "axiom=fx",  "x=++f!x!fy--fx--fy|+@IQ3.0fyf!x!++f!y!++f!y!fx@Q3.0+++f!y!fx",  "y=fyf!x!+++@IQ3.0fyf!x!++f!x!++f!y!fx@Q3.0|+fx--fy--fxf!y!++",  "f="},

{"variantes","cr","iter=4","angle=90","axiom=f","f=f+f-@I10f@10-f+f","q=f"},

{"jointures","Tri-4-9-a triangles arrondis"  ,"iter=4","angle=60"  ,"axiom=r"  ,"r=z"		//it=3
  ,"x=fpa+fp+fz-fp-fz-fp-fw+fp+fz"  ,"y=fpa-fp-fw+fp+fw+fp+fz-fp-fw"
  ,"z=ffffppppbb+fp+fpb+fp+fx-fp-fx-fp-fy+fp+fx-fp-fx-fp-fy+fp+fx-fp-fy+fp+fx"
  ,"w=ffffppppbb-fp-fpb-fp-fy+fp+fy+fp+fx-fp-fy+fp+fy+fp+fx-fp-fy+fp+fx-fp-fy"
  ,"a=ffffffppppppbbb"  ,"b=fffpppaa"  ,"p=fp"  ,"f="},
 
{"jointures","Tri-9-a "  ,"iter=3","angle=60"  ,"axiom=x"	//it=3
  ,"x=ffffwwpp+fp+fw+fp+fx-fp-fx-fp-fy+fp+fx-fp-fx-fp-fy+fp+fx-fp-fy+fp+fx"
  ,"y=ffffwwpp-fp-fw-fp-fy+fp+fy+fp+fx-fp-fy+fp+fy+fp+fx-fp-fy+fp+fx-fp-fy"
  ,"w=fffffffppppwww"  ,"p=fp"  ,"f="},

{"jointures","Tri-4-a "  ,"iter=4","angle=60"  ,"axiom=fx" ,"x=z+f+fx-f-fx-f-fy+f+fx"  ,"y=z-f-fy+f+fy+f+fx-f-fy"   ,"z=fffzz"    },      //it=4   

{"jointures","Rect-2 rectangles"  ,"iter=10","angle=90"  ,"axiom=x"  ,"x=+fy-fp-fz+fp+fy-"  ,"y=-fx+fp+fz-fp-fx+"  ,"z=ffppww"  ,"w=fz"  ,"p=fp"  ,"f="},	//it=10

{"Pythagore","PT1 triangle isocèle - Jaume Bartrolí","iter=6",    // Jaume Bartrolí Pythagorean Tree From "Chaos and Fractals" by Peitgen, Jürgens and Saupe
"angle=45","axiom=|F++F[Z]++F[T]++F","Z=-@IQ2F[Z]++F[T]++F++F","T=---@IQ2F++F[Z]++F[T]++F"},

{"Pythagore","PT2 triangle","iter=6",    // Jaume Bartrolí Pythagorean Tree From "Chaos and Fractals" by Peitgen, Jürgens and Saupe
"angle=30","axiom=|F+++F[Z]+++F[T]+++F","Z=--@.5F[Z]+++F[T]+++F+++F","T=-----@.866F+++F[Z]+++F[T]+++F"},

{"Pythagore","PT3","iter=6",    // Jaume Bartrolí Pythagorean Tree From "Chaos and Fractals" by Peitgen, Jürgens and Saupe
"angle=30","axiom=|F+++F[Z]+++F[T]+++F","Z=--@.5F[P]+++F[Q]+++F+++F","T=-----@.866F+++F[P]+++F[Q]+++F","P=-@.866F[Z]+++F[T]+++F+++F","Q=----@.5F+++F[Z]+++F[T]+++F"},

{"Pythagore","PT4 carré","iter=6",    // Jaume Bartrolí Broccoli-Like Phythagoras Tree From "Chaos and Fractals" by Peitgen, Jürgens and Saupe
"angle=120","axiom=F\\90F[Z]\\90F[T]\\90F","Z=/20@.5320F[Z]\\90F[T]\\90F\\90F","T=/160@.5320F\\90F[Z]\\90F[T]\\90F"},

{"Pythagore","PT10 rectangle","iter=4",   // Jaume Bartrolí Broccoli-Like Phythagoras Tree over a rectangle From "Chaos and Fractals" by Peitgen, Jürgens and Saupe
"angle=120","axiom=DD\\90D[Z]\\90DD[T]\\90D","Z=/20@.532D[Z]\\90DD[T]\\90D\\90DD","T=/160@.532DD\\90D[Z]\\90DD[T]\\90D"},

{"Pythagore","PT13  tronc","iter=4",   // Jaume Bartrolí Phytagorean Tree, From "Chaos and Fractals" by Peitgen, Jürgens and Saupe
"angle=30","axiom=|F+++F[Z]+++G[T]+++F","Z=--@.5F[Z]+++G[T]+++F+++G","T=-----@.866G+++F[Z]+++G[T]+++F"},

{"Pythagore","PT14","iter=4",   // Jaume Bartrolí Phytagorean Tree, using G and over a rectangle From "Chaos and Fractals" by Peitgen, Jürgens and Saupe
"angle=30","axiom=|F+++FF[Z]+++G[T]+++FF","Z=--@.50FF[Z]+++G[T]+++FF+++G","T=-----@.866G+++FF[Z]+++G[T]+++FF"},

{"Pythagore","PT15","iter=4",   // Jaume Bartrolí Phytagorean Tree, From "Chaos and Fractals" by Peitgen, Jürgens and Saupe
"angle=30","axiom=|F+++F[Z]+++G[T]+++F","Z=--@.50F[P]+++G[Q]+++F+++G","T=-----@.866G+++F[P]+++G[Q]+++F","P=-@.866F[Z]+++G[T]+++F+++G","Q=----@.5G+++F[Z]+++G[T]+++F"},

{"x","complex geometry","iter=5","angle=90","axiom=Q","Q=--FR++++FS--FU","Q=FT++FR----FS++","R=++FP----FQ++FT","S=FU--FP++++FQ--","T=+FU--FP+","U=-FQ++FT-","F="}

};
 
//public void init() { 
//	 addMouseListener(this);
//	 System.out.println("init mouselistener");
//} 
	

public void mousePressed(MouseEvent e) 
{ 
System.out.println("mouse event");
int buttonDown = e.getButton();
double vx=e.getX();
double vy=e.getY();

if (buttonDown == MouseEvent.BUTTON3) 
	{// Bouton droit enfoncé
//	double vRC=minX + (maxX - minX)/(double)longueur * (double)vx;
//	double vIC=minY + (maxY - minY)/(double)haut * (double)vy;
	//System.out.println("milieu "+vRC+" "+vIC);
 
 	repaint();
	}
else 
	{ 
	if (buttonDown == MouseEvent.BUTTON2) 
		{
		
		//System.out.println("bouton milieu");}	// Bouton milieu enfoncé 
		}
	else
		{
		if (buttonDown == MouseEvent.BUTTON1) {}//Bouton GAUCHE enfoncé
			{ 
			if (flag==true)
				{flag=false;

        theordermax=theorder+2;
        theorder=0;
 				boolean	smanuel=manuel;
 				manuel=false;
				repaint();
				manuel=smanuel;
				
				} // flag
			} // gauche
		}// milieu
	} //droit
}
 
public void mouseClicked(MouseEvent e) {
	//System.out.println("Clicked");
	}
	//Invoked when a mouse button has been pressed on a component.

public void mouseReleased(MouseEvent e) {
	//System.out.println("Released");
	} 
	//Invoked when a mouse button has been released on a component.

public void mouseEntered(MouseEvent e) {
	//System.out.println("Entered");
	}
	//Invoked when the mouse enters a component.

public void mouseExited(MouseEvent e) {
	//System.out.println("Exited");
	}
	//Invoked when the mouse exits a component.
	
public void dessine(String production,int niveau, boolean pourdebon)
{
int rc0;
int ic0;
int rc1;
int ic1;
double x;
double y;
int color;
double cx=0;
double cy=0;


//System.out.println("dessine       "+production+" "+niveau+" "+theordermax+" "+pourdebon+" "+nbtrans+" "+delta);
	int i=0;
	while (i<production.length())
	{ 
	
	char car=production.charAt(i);
	
	switch (car)
		{ 
		case ' ':{break;}
		case '$':{
			indexcolor=indexcolor-1;
			if (indexcolor==0) 
				{indexcolor=tabcolor.length-1;}
			sindexcolor=1;
			break;}	 
		case '>':{
			sindexcolor=1;
			indexcolor=indexcolor+1;
			if (indexcolor==tabcolor.length) 
				{indexcolor=1;};
			break;}	//color
		case 'c':{
			i=i+1;
			sindexcolor=1;
			indexcolor=production.charAt(i)-'0'+1;
			break;}
		case '@':{
			i=i+1;
			if (production.charAt(i)=='I')
				{i=i+1;
				if (production.charAt(i)=='Q')
					{i=i+1;
					//n		IQn
					int debut=i;
					while ("0123456789.".indexOf(production.charAt(i))>-1)
						{i=i+1;}
						double n=Double.parseDouble(production.substring(debut,i));
					delta=delta/Math.sqrt(n);
					//System.out.println("@IQ "+delta);
					i=i-1;
					}
				else
					{//n   In
					int debut=i;
					while ("0123456789.".indexOf(production.charAt(i))>-1)
						{i=i+1;}
					double n=Double.parseDouble(production.substring(debut,i));
					//System.out.println("@I"+n);
					delta=delta/n;
					i=i-1;
					}
				}
			else
				{ 
				if (production.charAt(i)=='Q')
					{i=i+1;
					//n		Qn
					int debut=i;
					while ("0123456789.".indexOf(production.charAt(i))>-1)
						{i=i+1;}
					double n=Double.parseDouble(production.substring(debut,i));
					delta=delta*Math.sqrt(n);
					//System.out.println("@"+n);
					i=i-1;
					}
				else
					{//n	n
					int debut=i;
					while ("0123456789.".indexOf(production.charAt(i))>-1)
						{i=i+1;}
					//System.out.println("@n="+production.substring(debut,i));
					double n=Double.parseDouble(production.substring(debut,i));
					//System.out.println("@"+n);
					delta=delta*n;
					i=i-1;
					}
				}
			break;}//size
		case '#':{cap=cap+90;break;}
		case '|':{cap=cap+180;break;}
		case '!':{angle=-angle;sens=-sens;break;}
		case '+':{cap=cap-angle;break;}
		case '-':{cap=cap+angle;break;}
		case '/':{	//	 /nn Decrease angle nn degrees
					i=i+1;
					int debut=i;
					while ("0123456789.".indexOf(production.charAt(i))>-1)
						{i=i+1;}
					double n=Double.parseDouble(production.substring(debut,i));
					//System.out.println("/"+n);
					cap=cap-n*sens;		//angle=angle-n;
					i=i-1;break;}	
		case '\\':{		//  \\nn Increase angle nn degrees
					i=i+1;
					int debut=i;
					while ("0123456789.".indexOf(production.charAt(i))>-1)
						{i=i+1;}
					double n=Double.parseDouble(production.substring(debut,i));
					//System.out.println("\\"+n);
					cap=cap+n*sens;	//angle=angle+n;
					i=i-1;
			break;}	   
		case ':':{cx=coordx;cy=coordy;break;}
		case ';':{if (pourdebon==true)
								{rc0= (int) Math.floor((coordx -minX)/(maxX - minX)*(longueur-20));
							ic0= (int) Math.floor((coordy -minY)/(maxY - minY)*(haut-20));
							rc1= (int) Math.floor((cx -minX)/(maxX - minX)*(longueur-20));
							ic1= (int) Math.floor((cy -minY)/(maxY - minY)*(haut-20));
							g1.drawLine(rc0+10,haut-ic0-10,rc1+10,haut-ic1-10);}
							break;}
		case '[':{
			pilx[nivpil]=coordx;
			pily[nivpil]=coordy;
			pila[nivpil]=cap;
			pilc[nivpil]=indexcolor; 
			pild[nivpil]=delta;
			nivpil=nivpil+1;
			break;}
		case ']':{
			if (nivpil>0)
				{nivpil=nivpil-1;
				coordx=pilx[nivpil];
				coordy=pily[nivpil];
				cap=pila[nivpil];
				delta=pild[nivpil];
				indexcolor=pilc[nivpil];}
			break;}
		case '(':{break;}
		case ')':{break;}
		default:{
			if (niveau<theordermax)
				{
				boolean trouve=false;
				String rule="";
				for (int j=5;j<nbtrans;j++)
					{
					k=ls[numls][j].indexOf(""+car+"=");
					if (k==0) 
						{rule=ls[numls][j].substring(k+2);
						trouve=true;
						if (rule.length()>0) {dessine(rule,niveau+1,pourdebon);}
						}
					} // for
				if ((keepf==true) && ((trouve==false) && ((car=='F')||(car=='G')||(car=='g')||(car=='f')||(car=='d')||(car=='D')||(car=='m'))))
						{rule=""+car;
						dessine(rule,niveau+1,pourdebon);
						k=-1;}
				} // if niveau
			else
				{ 
				if ((imprimetout==true) ||((car=='F') || (car=='A') || (car=='B') || (car=='1') || (car=='G')||(car=='g')||(car=='f')||(car=='d')||(car=='D')||(car=='m')))
						{
						x=coordx+delta*Math.cos(cap*Math.PI/180);
						y=coordy+delta*Math.sin(cap*Math.PI/180);
						//System.out.println("x y cap="+x+" "+y+" "+cap);
						if (pourdebon==true)
							{
							if (coloration==0)
								{g1.setColor(Color.black);}
							else
								{g1.setColor(tabcolor[indexcolor]);}
							float  epaisseur;
							switch (niveau)
								{
								case 0:{epaisseur=32;break;}
								case 1:{epaisseur=16;break;}
								case 2:{epaisseur=8;break;}
								case 3:{epaisseur=4;break;}
								case 4:{epaisseur=2;break;}
								default:{epaisseur=1;break;}
								}
							
							g1.setStroke(new BasicStroke( epaisseur , BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER));
							rc0= (int) Math.floor((coordx -minX)/(maxX - minX)*(longueur-20));
							ic0= (int) Math.floor((coordy -minY)/(maxY - minY)*(haut-20));
							rc1= (int) Math.floor((x -minX)/(maxX - minX)*(longueur-20));
							ic1= (int) Math.floor((y -minY)/(maxY - minY)*(haut-20));
							if (car != 'G') {g1.drawLine(rc0+10,haut-ic0-10,rc1+10,haut-ic1-10);}
							//System.out.println("draw "+car+" "+niveau);
							}
						else
							{ 
							if (pourdebon==false)
								{
								if(x<minX) {minX=x;}
								if(x>maxX) {maxX=x;}
								if(y<minY) {minY=y;}
								if(y>maxY) {maxY=y;}
								}
							}//else if pourdebon
						coordx=x;
						coordy=y;
						} // if car
				} // else niveau
			}	// default
		}	// switch
				
/*	for (int j=4;j<nbtrans;j++)
				{
				String rule="";
				k=ls[numls][j].indexOf(""+car+"=");
				if (k==0) {rule=ls[numls][j].substring(k+2);}
					if (niveau<theordermax)
					{dessine(rule,niveau+1,pourdebon);}
				else
					{if (rule.length()>-1)
						{x=coordx+delta*Math.cos(cap*Math.PI/180);
						y=coordy+delta*Math.sin(cap*Math.PI/180);
						//System.out.println("x y cap="+x+" "+y+" "+cap);
						if (pourdebon==true)
							{color=tabcolor[indexcolor];
							g1.setColor(Color.black); 
							rc0= (int) Math.floor((coordx -minX)/(maxX - minX)*(longueur-10));
							ic0= (int) Math.floor((coordy -minY)/(maxY - minY)*(haut-10));
							rc1= (int) Math.floor((x -minX)/(maxX - minX)*(longueur-10));
							ic1= (int) Math.floor((y -minY)/(maxY - minY)*(haut-10)));
							//System.out.println(""+rc0+","+ic0+"  "+rc1+","+ic1);
							if ((car != 'G')&&(car!='g')&&(car!='m')) {g1.drawLine(rc0,haut-ic0,rc1,haut-ic1);}
							}
						else
							{
							if(x<minX) {minX=x;}
							if(x>maxX) {maxX=x;}
							if(y<minY) {minY=y;}
							if(y>maxY) {maxY=y;}
							}//else if
						coordx=x;
						coordy=y;
						}//if
					}//if
				}//for
			}//switch
		}//switch	*/
		
		
	i=i+1;
	}//while
}//dessine

public void paintComponent(Graphics g)
{
sindexcolor=0;
flag=false;
if (listen==false) 
	{
	addMouseListener(this);
	t.schedule(new timetask(),50,800);
	listen=true;
	}
	
nbtrans=ls[numls].length;

String tangle=ls[numls][2].substring(5);
try 
	{ordermax=Integer.parseInt(tangle);}
catch(Exception ee)
	{ordermax=5;}

tangle=ls[numls][3].substring(6);
try 
	{angle=Double.parseDouble(tangle);}
catch(Exception ee)
	{angle=-1;}
double sangle=angle;
String axiom=ls[numls][4].substring(6);

for (X=0;X<longueur-1;X++)
	{ 
	for (Y=0;Y<haut-1;Y++)
		{buffimag1.setRGB(X,Y,blanc);}
	}

cap=0;
coordx=0;
coordy=0;
indexcolor=0;
sens=1;
delta=100.;

minX=0.;
maxX=0.;
minY=0.;
maxY=0.;

dessine(axiom,0,false);	// pour calculer minX, maxX, minY et maxY sans rien dessiner

cap=0;
coordx=0;
coordy=0;
delta=100;
indexcolor=sindexcolor;
angle=sangle;
sens=1;

minX=minX-0.1;
maxX=maxX+0.1;
minY=minY-0.1;
maxY=maxY+0.1;
 
double r=(double) haut/(double) longueur; 
if ((maxX-minX)/longueur > (maxY-minY)/haut)
	{
	double miny=maxY-(maxX-minX)*r;
	minY=miny+(minY-miny)/2;
	maxY=maxY+(minY-miny)/2;
	/*d=((maxY-minY)-(maxX-minX)*r)/(double) 2;
	minY=minY-d;
	maxY=maxY+d;*/
	}
else
	{
	double minx=maxX-(maxY-minY)/r;
	minX=minx+(minX-minx)/2;
	maxX=maxX+(minX-minx)/2;
	/*d=((maxX-minX)-(maxY-minY)/r)/(double) 2;
	minX=minX-d;
	maxX=maxX+d;*/
	}

dessine(axiom,0,true);

 	
g.drawImage(buffimag1, 0, 0, null);  
flag=true;

if (show==true)
	{
	
	}
 
} // paint 

  class timetask extends TimerTask
        	{
        	public void run()  
        		{
    				if (flag==true)
    						{
        				if ((manuel==false) && (theordermax<ordermax)) {theorder=0;theordermax=theordermax+1;repaint();}
        				}
        		}
        	} 

} // class

