//PlaneWaveOutputPanel2.java
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.lang.*;  

public class PlaneWaveOutputPanel2 extends Panel implements ItemListener{
	PlaneWave_State state;
	//private static final Color bgcolor = Color.lightGray;
	private static final Color bgcolor = new Color(236,236,236);
	private static final Font labfont=new Font("SanSerif",Font.PLAIN,12);
	private static final Font symbolfont=new Font("Symbol",Font.PLAIN,12);
	private static final Font titlefont=new Font("SanSerif",Font.BOLD,16);
        
        Label titlelabel;	
	public Choice c1;
	public PlaneWaveOutputCanvasD pwocD; 
	
	public PlaneWaveOutputPanel2(PlaneWave_State state){
	    super();
	    this.state = state;
	    setBackground(bgcolor);
	    titlelabel = new Label("Output Data");
	    //add(titlelabel);
	    titlelabel.setBounds(5,5,100,40);    
	    titlelabel.setFont(titlefont);
	    
	    c1 = new Choice();
	    c1.addItem("Output1");
	    c1.addItem("Output2");
	    //add(c1);
	    c1.setBounds(5,50,300,30);
	    
	    pwocD = new PlaneWaveOutputCanvasD(state);
	    add(pwocD);
	    pwocD.setBounds(5,0,826,92);
	    
	    pwocD.setVisible(true);
	    //Listeners
	    c1.addItemListener(this);
	}


public void itemStateChanged(ItemEvent evt){
	ItemSelectable ie = evt.getItemSelectable();
	    if(evt.getSource()==c1){
		
	    }
    }	
}//PlaneWaveOutputPanel.java


class PlaneWaveOutputCanvasD extends Canvas{
	private static final Font normalfont = new Font("SanSerif",Font.PLAIN,11);
	private static final Font normalfont2 = new Font("SanSerif",Font.PLAIN,12);
	
        private static final Font symbolfont = new Font("Serif",Font.PLAIN,11);
	private static final Font subfont    = new Font("SanSerif",Font.PLAIN,10);
        private static final Font font16=new Font("SanSerif",Font.BOLD,16);
        private static final Font font14=new Font("SanSerif",Font.BOLD,14);
	private static final Font font12=new Font("SanSerif",Font.BOLD,12);
	
        PlaneWave_State state;
	private Image im;
	private Graphics buf;

	public PlaneWaveOutputCanvasD(PlaneWave_State state){
	    super();
	    this.state = state;
	}
	
	public void paint(Graphics g){
	    if(im == null){
		im = createImage(getSize().width,getSize().height);
		buf = im.getGraphics();
		drawGraph(buf);
	    }
	    else{
		drawGraph(buf);
	    }
	    g.drawImage(im,0,0,null);
	}
	
	//Addition to reduce flicker new routine
	public void update(Graphics g){		// added to avoid clearing
	    paint(g);
	}

	
	public void drawGraph(Graphics g){
	    int x, xnew, xshift, xshiftf, xshift2, xshift3, y, dx, dxx, dy, dyy;
	    double v_normalized, frequency, f_normalized;
	    FontMetrics fm;
	    double temp, temp2;
	    double Efield, Hfield, Ephase, Hphase;
            String unita;
            int fonto = 11;
            frequency = state.frequency;
            
            Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            int xpos2 = 300;
            int xpos3 = 600;
            
	    x = xpos2+30;
            xshift = 20;
            xshiftf = xshift + 5;
            
            xshift2 = 50;
            xshift3 = 24;
	    y = 15;
	    dx = 50;
	    dxx = 15;
	    xnew = 10;
	    
	    g.setFont(normalfont2);
	    fm = g.getFontMetrics();
	    dy = fm.getHeight()-1;
	    dyy = dy+3;
	    g.clearRect(0,0,getSize().width,getSize().height);
            
            g.setColor(Color.white);
            g.fillRect(288,0,250,40);
            
            g.setColor(Color.blue.darker());
            g.drawRect(288,0,250,40);
            
	    g.setColor(Color.black);
	    //g.drawString("Cross-section A",x,y);	
            
            g.setColor(Color.black);
	
                if(frequency < 1.0E3){
		    f_normalized = frequency;
		    MaestroG.subscripterSansItalic2("f",""," = "+MaestroA.rounder(f_normalized,6)+"  Hz","",g,12,x+xshiftf,y);	
		}
		else if(frequency < 1.0E6 && frequency >= 1.0E3  ){
		    f_normalized = frequency/1.0E3;
                    MaestroG.subscripterSansItalic2("f",""," = "+MaestroA.rounder(f_normalized,6)+"  kHz","",g,12,x+xshiftf,y);
		    
		}
		else if(frequency < 1.0E9 && frequency >= 1.0E6 ){
		    f_normalized = frequency/1.0E6;
                    MaestroG.subscripterSansItalic2("f",""," = "+MaestroA.rounder(f_normalized,6)+"  MHz","",g,12,x+xshiftf,y);
		    
		}
		else if(frequency < 1.0E12 && frequency >= 1.0E9 ){
		    f_normalized = frequency/1.0E9;
                    MaestroG.subscripterSansItalic2("f",""," = "+MaestroA.rounder(f_normalized,6)+"  GHz","",g,12,x+xshiftf,y);
		    
		}
		else if(frequency < 1.0E15 && frequency >= 1.0E12 ){
		    f_normalized = frequency/1.0E12;
                    MaestroG.subscripterSansItalic2("f",""," = "+MaestroA.rounder(f_normalized,6)+"  THz","",g,12,x+xshiftf,y);
		    
		}
		else if(frequency < 1.0E18 && frequency >= 1.0E15 ){
		    f_normalized = frequency/1.0E15;
                    MaestroG.subsupspecial2("f",""," = "+MaestroA.rounder(f_normalized,2)+" x 10","3","  THz",g,12,x+xshiftf,y);
		    
		}
                else if(frequency < 1.0E21 && frequency >= 1.0E18 ){
		    f_normalized = frequency/1.0E18;
                    MaestroG.subsupspecial2("f",""," = "+MaestroA.rounder(f_normalized,2)+" x 10","6","  THz",g,12,x+xshiftf,y);
		    
		}
                else if(frequency < 1.0E24 && frequency >= 1.0E21 ){
		    f_normalized = frequency/1.0E21;
                    MaestroG.subsupspecial2("f",""," = "+MaestroA.rounder(f_normalized,2)+" x 10","9","  THz",g,12,x+xshiftf,y);
		    
		}
            y += dyy;
	    
            temp2 = state.total_length*state.wavelength;
            temp = temp2;
            int stringo;
            fonto = 12;
            
            stringo = fm.stringWidth("L = "+MaestroA.rounder(state.total_length,6)+" \u03bb ");
            MaestroG.subscripterSansItalic6("l",""," = "+MaestroA.rounder(state.total_length,6)+" ","\u03bb",g,fonto,x+xshift,y);
            xnew = x + xshift + stringo;
                    if(temp2 >= 1.0E12){
			temp = temp2/1.0E12;
			MaestroG.superscripter("  = "+MaestroA.rounder(temp,1)+" x 10","9"," [ km ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0e12 && temp2 >= 1.0e9){
			temp = temp2/1.0E9;
                        MaestroG.superscripter("  = "+MaestroA.rounder(temp,1)+" x 10","6"," [ km ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0e9 && temp2 >= 1.0e6){
			temp = temp2/1.0E6;
                        MaestroG.superscripter("  = "+MaestroA.rounder(temp,1)+" x 10","3"," [ km ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E6 && temp2 >= 1.0E3){
			temp = temp2/1.0E3;
                        MaestroG.superscripter("  = "+MaestroA.rounder(temp,3),""," [ km ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E3 && temp2 >= 1.0E-1){
                        MaestroG.superscripter("  = "+MaestroA.rounder(temp,5),""," [ m ]",g,fonto,xnew,y);
		    }
		    else if(temp2 <1.0E-1 && temp2 >= 1.0E-2){
			temp = temp2*1.0E2;
                        MaestroG.superscripter("  = "+MaestroA.rounder(temp,5),""," [ cm ]",g,fonto,xnew,y);
		    }
		    else if(temp2 <1.0E2 && temp2 >= 1.0E-4){
			temp = temp2*1.0E3;
                        MaestroG.superscripter("  = "+MaestroA.rounder(temp,5),""," [ mm ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E-4 && temp2 >=1.0E-6 ){
			temp = temp2*1.0E6;
                        MaestroG.superscripter("  = "+MaestroA.rounder(temp,5),""," [ \u00b5 m ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E-6 && temp2 >=1.0E-9){
			temp = temp2*1.0E9;
                        MaestroG.superscripter("  = "+MaestroA.rounder(temp,5),""," [ nm ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E-9 && temp2 >=1.0E-12){
			temp = temp2*1.0E12;
                        MaestroG.superscripter("  = "+MaestroA.rounder(temp,5)+" x 10","-3"," [ nm ]",g,fonto,xnew,y);
		    }	   
		    else if(temp2 < 1.0E-12 && temp2 >=1.0E-15){
			temp = temp2*1.0E15;
			MaestroG.superscripter("  = "+MaestroA.rounder(temp,5)+" x 10","-6"," [ nm ]",g,fonto,xnew,y);
                    }
		    else if(temp2 < 1.0E-15 && temp2 > 0.0){
			temp = temp2*1.0E18;
                        MaestroG.superscripter("  = "+MaestroA.rounder(temp,5)+" x 10","-9"," [ nm ]",g,fonto,xnew,y);
		    }
		    else if(temp2 == 0.0){
                        MaestroG.superscripter("  = "+MaestroA.rounder(temp2,3),""," [ m ]",g,fonto,xnew,y);
		    }
            
            fonto = 11;
            x = 20;
            y = 10;
            g.setFont(normalfont);
	    fm = g.getFontMetrics();
	    
            //MaestroG.subscripter("Phasors","","",g,12,10,y);
	    //y += dy+5;
	    //g.setColor(Color.black);
	    
	    temp2 = state.zpos[0]*state.wavelength;
            temp = temp2;
            //int stringo;
            stringo = fm.stringWidth("zA = "+MaestroA.rounder(state.zpos[0],6)+" \u03bb    ");
            MaestroG.subscripterBold("A)","","",g,12,10,y);
	    MaestroG.subscripterSanSym2("z","A"," = "+MaestroA.rounder(state.zpos[0],6)," \u03bb",g,fonto,x+xshift,y);
            //y += dy;         
            xnew = x + xshift + stringo;
                    if(temp2 >= 1.0E12){
			temp = temp2/1.0E12;
			MaestroG.superscripter(" = "+MaestroA.rounder(temp,1)+" x 10","9"," [ km ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0e12 && temp2 >= 1.0e9){
			temp = temp2/1.0E9;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,1)+" x 10","6"," [ km ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0e9 && temp2 >= 1.0e6){
			temp = temp2/1.0E6;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,1)+" x 10","3"," [ km ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E6 && temp2 >= 1.0E3){
			temp = temp2/1.0E3;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,3),""," [ km ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E3 && temp2 >= 1.0E-1){
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5),""," [ m ]",g,fonto,xnew,y);
		    }
		    else if(temp2 <1.0E-1 && temp2 >= 1.0E-2){
			temp = temp2*1.0E2;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5),""," [ cm ]",g,fonto,xnew,y);
		    }
		    else if(temp2 <1.0E2 && temp2 >= 1.0E-4){
			temp = temp2*1.0E3;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5),""," [ mm ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E-4 && temp2 >=1.0E-6 ){
			temp = temp2*1.0E6;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5),""," [ \u00b5 m ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E-6 && temp2 >=1.0E-9){
			temp = temp2*1.0E9;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5),""," [ nm ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E-9 && temp2 >=1.0E-12){
			temp = temp2*1.0E12;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5)+" x 10","-3"," [ nm ]",g,fonto,xnew,y);
		    }	   
		    else if(temp2 < 1.0E-12 && temp2 >=1.0E-15){
			temp = temp2*1.0E15;
			MaestroG.superscripter(" = "+MaestroA.rounder(temp,5)+" x 10","-6"," [ nm ]",g,fonto,xnew,y);
                    }
		    else if(temp2 < 1.0E-15 && temp2 > 0.0){
			temp = temp2*1.0E18;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5)+" x 10","-9"," [ nm ]",g,fonto,xnew,y);
		    }
		    else if(temp2 == 0.0){
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp2,3),""," [ m ]",g,fonto,xnew,y);
		    }
            
                
                int xVec, yVec, i;
		String stmp1, stmp2;
		int cwidth=5;
	  	
                //stmp1 = "Phasors";
		
                y += dy+5;
                //g.setColor(Color.black);
		//g.drawString(stmp1,x,y);
		//y+= dy;
                g.setColor(Color.red);
                
                unita = "  [ V / m ]";
                Efield = state.Ex*Math.exp(-state.alpha*state.zpos[0]*state.wavelength);
                Ephase = -state.beta*state.zpos[0]*state.wavelength+state.Phix;
                
		MaestroG.subscripter("| E","A"," |",g,fonto,x+xshift3,y);
                printdata(Efield,g,fonto,x+xshift2,y,unita);
                
                y+= dy+2;
                
                MaestroG.subscripterPhase("E","A","",g,fonto,x+xshift,y);
		MaestroG.subscripter("  =  ","",""+MaestroA.rounder(Ephase,5)+" [ rad ]",g,fonto,x+xshift2,y);
                
                y += dy+2;
                
                g.setColor(Color.blue);
                unita = "  [ A / m ]";
                Hfield = state.Hy*Math.exp(-state.alpha*state.zpos[0]*state.wavelength);
                Hphase = -state.beta*state.zpos[0]*state.wavelength+state.Phix-state.wave_impedance.Arg2();
                
                MaestroG.subscripter("| H","A"," |",g,fonto,x+xshift3,y);
		printdata(Hfield,g,fonto,x+xshift2,y,unita);
                y+= dy+2;
                MaestroG.subscripterPhase("H","A","",g,fonto,x+xshift,y);
		MaestroG.subscripter("  =  ","",""+MaestroA.rounder(Hphase,5)+" [ rad ]",g,fonto,x+xshift2,y);
                
            //y += dyy/2;
	    //g.drawLine(10,y,getSize().width-10,y);
            //y += dy+5;
            g.setColor(Color.red.darker());
	    //g.drawString("Cross-section B",x,y);	
	    
            //y += dy;
	    
            
            y =10;
            x = xpos3;
            
            temp2 = state.zpos[1]*state.wavelength;
            temp = temp2;
            
            stringo = fm.stringWidth("zB = "+MaestroA.rounder(state.zpos[1],6)+" \u03bb    ");
            MaestroG.subscripterBold("B)","","",g,12,xpos3-10,y);
	    
	    MaestroG.subscripterSanSym2("z","B"," = "+MaestroA.rounder(state.zpos[1],6)," \u03bb",g,fonto,x+xshift,y);
                     
            xnew = x + xshift + stringo;
                    if(temp2 >= 1.0E12){
			temp = temp2/1.0E12;
			MaestroG.superscripter(" = "+MaestroA.rounder(temp,1)+" x 10","9"," [ km ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0e12 && temp2 >= 1.0e9){
			temp = temp2/1.0E9;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,1)+" x 10","6"," [ km ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0e9 && temp2 >= 1.0e6){
			temp = temp2/1.0E6;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,1)+" x 10","3"," [ km ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E6 && temp2 >= 1.0E3){
			temp = temp2/1.0E3;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,3),""," [ km ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E3 && temp2 >= 1.0E-1){
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5),""," [ m ]",g,fonto,xnew,y);
		    }
		    else if(temp2 <1.0E-1 && temp2 >= 1.0E-2){
			temp = temp2*1.0E2;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5),""," [ cm ]",g,fonto,xnew,y);
		    }
		    else if(temp2 <1.0E2 && temp2 >= 1.0E-4){
			temp = temp2*1.0E3;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5),""," [ mm ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E-4 && temp2 >=1.0E-6 ){
			temp = temp2*1.0E6;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5),""," [ \u00b5 m ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E-6 && temp2 >=1.0E-9){
			temp = temp2*1.0E9;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5),""," [ nm ]",g,fonto,xnew,y);
		    }
		    else if(temp2 < 1.0E-9 && temp2 >=1.0E-12){
			temp = temp2*1.0E12;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5)+" x 10","-3"," [ nm ]",g,fonto,xnew,y);
		    }	   
		    else if(temp2 < 1.0E-12 && temp2 >=1.0E-15){
			temp = temp2*1.0E15;
			MaestroG.superscripter(" = "+MaestroA.rounder(temp,5)+" x 10","-6"," [ nm ]",g,fonto,xnew,y);
                    }
		    else if(temp2 < 1.0E-15 && temp2 > 0.0){
			temp = temp2*1.0E18;
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp,5)+" x 10","-9"," [ nm ]",g,fonto,xnew,y);
		    }
		    else if(temp2 == 0.0){
                        MaestroG.superscripter(" = "+MaestroA.rounder(temp2,3),""," [ m ]",g,fonto,xnew,y);
		    }
            
                y += dy+5;
                //g.setColor(Color.red.darker());
		//g.drawString(stmp1,x,y);
		//y+= dy;
                
                g.setColor(Color.red);
		//MaestroG.subscripter("| E |","B"," = "+MaestroA.rounder(state.Ex*Math.exp(-state.alpha*state.zpos[1]*state.wavelength),6)+"  [ V / m ]",g,fonto,x+xshift,y);
		unita = "  [ V / m ]";
                
                Efield = state.Ex*Math.exp(-state.alpha*state.zpos[1]*state.wavelength);
		Ephase = -state.beta*state.zpos[1]*state.wavelength+state.Phix;
		
                MaestroG.subscripter("| E","B"," |",g,fonto,x+xshift3,y);
		printdata(Efield,g,fonto,x+xshift2,y,unita);
                
                y+= dy+2;
                MaestroG.subscripterPhase("E","B","",g,fonto,x+xshift,y);
		MaestroG.subscripter("  =  ","",""+MaestroA.rounder(Ephase,5)+" [ rad ]",g,fonto,x+xshift2,y);
                                
                g.setColor(Color.blue);
                y += dy+2;
                //MaestroG.subscripter("| H |","B"," = "+MaestroA.rounder(state.Hy*Math.exp(-state.alpha*state.zpos[1]*state.wavelength),6)+"  [ A / m ]",g,fonto,x+xshift,y);
		unita = "  [ A / m ]";
                Hfield = state.Hy*Math.exp(-state.alpha*state.zpos[1]*state.wavelength);
                Hphase = -state.beta*state.zpos[1]*state.wavelength+state.Phix-state.wave_impedance.Arg2();
                
                MaestroG.subscripter("| H","B"," |",g,fonto,x+xshift3,y);
		printdata(Hfield,g,fonto,x+xshift2,y,unita);
                
                y+= dy+2;
                MaestroG.subscripterPhase("H","B","",g,fonto,x+xshift,y);
		MaestroG.subscripter("  =  ","",""+MaestroA.rounder(Hphase,5)+" [ rad ]",g,fonto,x+xshift2,y);
                
	    //g.drawLine(5,y+dyy/2,getSize().width-5,y+dyy/2); 
                
                int yphasor = 60;
                int xphasor = getSize().width/2-1;
                int xborder = 10;
                int yborder = 5;
                String stringa = " Phasor fields on selected phase planes ";
                g.setColor(Color.black);
                g.setFont(font12);
                fm = g.getFontMetrics();
                int widephasor = fm.stringWidth(stringa);
                int heightphasor = 12-1;//fm.Height()*3/4;
                
                int x1 = xphasor-widephasor/2-xborder+widephasor+2*xborder;
                int y1 = yphasor-heightphasor/2;
                int x2 = xphasor-widephasor/2-xborder+widephasor+2*xborder+30;
                int x3 = xphasor-widephasor/2-xborder;
                int x4 = xphasor-widephasor/2-xborder-30;
                
                g.setColor(Color.white);
                g.fillRect(xphasor-widephasor/2-xborder,yphasor-heightphasor-yborder,widephasor+2*xborder,heightphasor+2*yborder);
                g.setColor(Color.black);
                g.drawRect(xphasor-widephasor/2-xborder,yphasor-heightphasor-yborder,widephasor+2*xborder,heightphasor+2*yborder);
                g.drawLine(x3,y1,x4,y1);
                g.drawLine(x1,y1,x2,y1);
                MaestroG.drawArrow(x2,y1,7,g);
                MaestroG.drawArrow(x4,y1,8,g);
                
                g.drawString(stringa,xphasor-widephasor/2,yphasor);
                
                //System.out.println(x1+"  "+x2+"   "+x3+"   "+x4);
	} 
        
        public static void printdata(double field, Graphics g, int fonto, int xinit2, int y, String unita){
            if(field < 1.0e-15 && field != 0.0){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e16,5)+"  x  10","-16"," "+unita,g,fonto,xinit2,y);
	    }
            if(field == 0.0){
		MaestroG.superscripter("  =  0.0",""," "+unita,g,fonto,xinit2,y);
	    }
            if(field >= 1.0e-15 && field < 1.0e-14){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e15,5)+"  x  10","-15"," "+unita,g,fonto,xinit2,y);
	    }
            if(field >= 1.0e-14 && field < 1.0e-13){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e14,5)+"  x  10","-14"," "+unita,g,fonto,xinit2,y);
	    }
            if(field >= 1.0e-13 && field < 1.0e-12){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e13,5)+"  x  10","-13"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e-12 && field < 1.0e-11){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e12,5)+"  x  10","-12"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e-11 && field < 1.0e-10){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e11,5)+"  x  10","-11"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e-10 && field < 1.0e-9){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e10,5)+"  x  10","-10"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e-9 && field < 1.0e-8){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e9,5)+"  x  10","-9"," "+unita,g,fonto,xinit2,y);
	    }
	    
	    if(field >= 1.0e-8 && field < 1.0e-7){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e8,5)+"  x  10","-8"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e-7 && field < 1.0e-6){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e7,5)+"  x  10","-7"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e-6 && field < 1.0e-5){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e6,5)+"  x  10","-6"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e-5 && field < 1.0e-4){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e5,5)+"  x  10","-5"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e-4 && field < 1.0e-3){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e4,5)+"  x  10","-4"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e-3 && field < 1.0e-2){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e3,5)+"  x  10","-3"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e-2 && field < 1.0e-1){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e2,5)+"  x  10","-2"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e-1 && field < 1.0){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e1,5)+"  x  10","-1"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0 && field < 1.0e1){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field,5)+"  ",""," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e1 && field < 1.0e2){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field,5)+"  ",""," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e2 && field < 1.0e3){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-2,5)+"  x  10","2"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e3 && field < 1.0e4){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-3,5)+"  x  10","3"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e4 && field < 1.0e5){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-4,5)+"  x  10","4"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e5 && field < 1.0e6){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-5,5)+"  x  10","5"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e6 && field < 1.0e7){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-6,5)+"  x  10","6"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e7 && field < 1.0e8){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-7,5)+"  x  10","7"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e8 && field < 1.0e9){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-8,5)+"  x  10","8"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e9 && field < 1.0e10){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-9,5)+"  x  10","9"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e10 && field < 1.0e11){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-10,5)+"  x  10","10"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e11 && field < 1.0e12){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-11,5)+"  x  10","11"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e12 && field < 1.0e13){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-12,5)+"  x  10","12"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e13 && field < 1.0e14){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-13,5)+"  x  10","13"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e14 && field < 1.0e15){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-14,5)+"  x  10","14"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e15 && field < 1.0e16){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-15,5)+"  x  10","15"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e16 && field < 1.0e17){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-16,5)+"  x  10","16"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e17 && field < 1.0e18){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-17,5)+"  x  10","17"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e18 && field < 1.0e19){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-18,5)+"  x  10","18"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e19 && field < 1.0e20){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-19,5)+"  x  10","19"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e20 && field < 1.0e21){
		MaestroG.superscripter("  =  "+MaestroA.rounder(field*1.0e-20,5)+"  x  10","20"," "+unita,g,fonto,xinit2,y);
	    }
	    if(field >= 1.0e21){
		MaestroG.superscripter("  =  "+field+"",""," "+unita,g,fonto,xinit2,y);
	    }
        }
        
}

