//ObliqueOutputPanel.java
import java.awt.*;
import java.awt.event.*;
//import java.lang.*;  

public class ObliqueOutputPanel extends Panel implements ItemListener{
    Oblique_State state;
    private static final Color bgcolor = Color.lightGray.brighter();
    private static final Font labfont=new Font("Sanserif",Font.PLAIN,12);
    private Font titlefont=new Font("Sanserif",Font.BOLD,16);
    Label titlelabel;
    private Complex temp;	
    public Choice c1;
    ObliqueOutputCanvasA pwocA; 
    ObliqueOutputCanvasB pwocB;
    ObliqueOutputCanvasB2 pwocB2;
    ObliqueOutputCanvasB3 pwocB3;
    ObliqueOutputCanvasC pwocC;
        
    public ObliqueOutputPanel(Oblique_State state){
        super();
        setLayout(null);
        setBackground(bgcolor);
        this.state = state;
        titlelabel = new Label("Output",Label.LEFT);
        titlefont = new Font("Sanserif",Font.BOLD,state.font16);
        titlelabel.setFont(titlefont);
        titlelabel.setForeground(Color.blue.darker());
        add(titlelabel);
        titlelabel.setBounds(state.s5,state.s2,state.s70,state.s17);
        

        c1 = new Choice();
        c1.addItem(" Refraction Behavior 1");
        c1.addItem(" Refraction Behavior 2");
        c1.addItem(" Propagation Data");
        c1.addItem(" Field Phasors at (0,0,0)");
        c1.setFont(new java.awt.Font("SanSerif",Font.ITALIC,state.font11));
        // Change ==========================================================
        //c1.setBounds(85,5,200,22);
        c1.setBounds(state.s85,state.s5,state.s200,state.s22);
        //==================================================================
        c1.setBackground(bgcolor.brighter());
        add(c1);
        
        Panel ps1 = new Panel();
        ps1.setBackground(Color.cyan);
        //add(ps1);
        ps1.setBounds(state.s153,state.s4,state.s104,state.s24);
        
        Panel ps2 = new Panel();
        ps2.setBackground(Color.black);
        //add(ps2);
        ps2.setBounds(state.s152,state.s3,state.s106,state.s26);
        
        pwocA = new ObliqueOutputCanvasA(state);
        add(pwocA);
        pwocB = new ObliqueOutputCanvasB(state);
        add(pwocB);
        pwocB2 = new ObliqueOutputCanvasB2(state);
        add(pwocB2);
        pwocB3 = new ObliqueOutputCanvasB3(state);
        add(pwocB3);
        pwocC = new ObliqueOutputCanvasC(state);
        add(pwocC);

        pwocA.setBounds(state.s1,state.s1,state.s200+state.s98-1,state.s200+state.s85);
        pwocB.setBounds(state.s1,state.s1,state.s200+state.s98-1,state.s200+state.s85);
        pwocB2.setBounds(state.s1,state.s1,state.s200+state.s98-1,state.s200+state.s85);
        pwocB3.setBounds(state.s1,state.s1,state.s200+state.s98-1,state.s200+state.s85);
        pwocC.setBounds(state.s1,state.s1,state.s200+state.s98-1,state.s200+state.s85);
        
        pwocA.setVisible(true);
        pwocB.setVisible(false);
        pwocB2.setVisible(false);
        pwocB3.setVisible(false);
        pwocC.setVisible(false);
        
        //pwocA.setBackground(Color.yellow);

        //Listeners
        c1.addItemListener(this);
    }
    public void paint(Graphics g){
        //g.draw3DRect(0,0,getSize().width-1,getSize().height-1,false);  
    }
        
    public void itemStateChanged(ItemEvent evt){
	ItemSelectable ie = evt.getItemSelectable();
	    if(evt.getSource()==c1){
		if(ie.getSelectedObjects()[0]==" Refraction Behavior 1"){
		    pwocA.setVisible(true);
		    pwocB.setVisible(false);
                    pwocB2.setVisible(false);
                    pwocB3.setVisible(false);
                    pwocC.setVisible(false);
		}
		else if(ie.getSelectedObjects()[0]==" Propagation Data"){
		    pwocA.setVisible(false);
		    pwocB.setVisible(true);
                    pwocB2.setVisible(false);
                    pwocB3.setVisible(false);
		    pwocC.setVisible(false);
		}
                else if(ie.getSelectedObjects()[0]==" Propagation Data 2"){
		    pwocA.setVisible(false);
		    pwocB.setVisible(false);
                    pwocB2.setVisible(true);
                    pwocB3.setVisible(false);
		    pwocC.setVisible(false);
		}
                else if(ie.getSelectedObjects()[0]==" Refraction Behavior 2"){
		    pwocA.setVisible(false);
		    pwocB.setVisible(false);
                    pwocB2.setVisible(false);
                    pwocB3.setVisible(true);
		    pwocC.setVisible(false);
		}
                else if(ie.getSelectedObjects()[0]==" Field Phasors at (0,0,0)"){
		    pwocA.setVisible(false);
		    pwocB.setVisible(false);
                    pwocB2.setVisible(false);
                    pwocB3.setVisible(false);
		    pwocC.setVisible(true);
		}
	    }
    }	
	
}//ObliqueOutputPanel.java

class ObliqueOutputCanvasA extends Canvas{
	
	Oblique_State state;
	private Image im;
	private Graphics buf;

	public ObliqueOutputCanvasA(Oblique_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){
            Font normalfont = new Font("Sanserif",Font.PLAIN,state.font11);
            Font normalfont2 = new Font("Sanserif",Font.PLAIN,state.font12);
            Font subfont    = new Font("Sanserif",Font.PLAIN,state.font10);
            Font titlefont  =new Font("Sanserif",Font.BOLD,state.font16);
            Font symbfont = new Font("Serif",Font.PLAIN,state.font13);
	
            Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            
	    int x, y, dx, dxx, dy, dyy;
	    Complex temp1, temp2;
	    double temp3, temp4, temp5, ratioZ, test1, test2, test3, factor1;
	    FontMetrics fm;
	    x = state.s10;
	    y = state.s40;
	    dx = state.s75;
	    dxx = state.s15;
	    
	    g.clearRect(0,0,getSize().width,getSize().height);
	    
	    //g.setFont(titlefont);
            //g.setColor(Color.blue.darker());
	    //g.drawString("Output", state.s5, state.s2);

	    g.setFont(normalfont);
	    fm = g.getFontMetrics();
	    dy = state.s15;
	    dyy = dy + state.s4;
	    
	    g.setColor(Color.red.darker());
	    g.drawString("Incident Angle",x+dxx-state.s5,y);	
	    g.drawString("Effective Refraction Angle",x+2*dx-state.s25,y);
	    y += dy;
	    g.setColor(Color.black);
	    MaestroG.subscripter("\u03b8","i"," = "+MaestroA.rounder(state.theta1*180.0/Math.PI,4)+"\u00ba",g,state.font11,x+dxx,y);
	    g.setFont(normalfont);
	    
	    if(state.theta2 != state.theta2){
		g.drawString(" = Undefined",x+2*dx+state.s7,y);
                MaestroG.subscripter("\u03b8","te","",g,state.font11,x+2*dx-state.s5,y);
                g.setFont(normalfont);
	    }
	    else{
		g.drawString(" = "+MaestroA.rounder(state.theta2*180.0/Math.PI,4)+"\u00ba",x+2*dx+state.s12,y);
		MaestroG.subscripter("\u03b8","te","",g,state.font11,x+2*dx-state.s5,y);
		g.setFont(normalfont);
	    }
	    g.drawLine(state.s5,y+dyy/3+state.s3,getSize().width-state.s5,y+dyy/3+state.s3); 
	    y += dyy+dyy/4;
	    x = state.s5;
            dxx = state.s5;
            
	    g.setColor(Color.red.darker());
	    g.drawString("Electric Field",x,y);
            
	    y+= dy;
	    if(state.which == 1){
                g.setColor(Color.yellow);
                g.fillRect(x+dxx-state.s5,y-state.s12,state.s200+state.s85,state.s15);
            }
	    
            g.setColor(Color.blue.darker());
	    g.drawString("Reflection Coefficient",x+dxx,y);
	    g.setColor(Color.black);
	    temp3 = MaestroA.rounder(Complex.Real(state.Reflection_Coef),4);
	    temp4 = MaestroA.rounder(Complex.Imaginary(state.Reflection_Coef),4);
	    temp2 = new Complex(temp3,temp4);
	    
	    g.drawString(" = "+temp2+"",x+dx+dx+state.s7,y);
	    g.setFont(symbfont);
	    g.drawString("\u0393",x+2*dx-state.s5,y);
	    g.setFont(normalfont);
            
	    y+= dy;
    	    if(state.which == 2){
                g.setColor(Color.yellow);
                g.fillRect(x+dxx-state.s5,y-state.s12,state.s200+state.s85,state.s15);
            }
            
            g.setColor(Color.blue.darker());
	    g.drawString("Transmission Coefficient",x+dxx,y);
	    g.setColor(Color.black);
	    
	    temp3 = MaestroA.rounder(Complex.Real(state.Transmission_Coef),4);
	    temp4 = MaestroA.rounder(Complex.Imaginary(state.Transmission_Coef),4);
	    temp2 = new Complex(temp3,temp4);
	    
	    g.setFont(symbfont);
            MaestroG.SerifSymbFirst(" \u03c4","","",g,state.font12,x+dx+dx-state.s5,y);
	    g.setFont(normalfont);
            g.drawString(" = "+temp2+"",x+dx+dx+state.s7,y);
            
	    g.drawLine(state.s5,y+dyy/4,getSize().width - state.s5,y+dyy/4); 
	    y += dyy;
	    
            g.setColor(Color.red.darker());
	    g.drawString("Magnetic Field",x,y);
	    
	    y+= dy;
	    
            if(state.which == 3){
                g.setColor(Color.yellow);
                g.fillRect(x+dxx-state.s5,y-state.s12,state.s200+state.s85,state.s15);
            }
            
            g.setColor(Color.blue.darker());
	    g.drawString("Reflection Coefficient",x+dxx,y);
	    g.setColor(Color.black);
	    
            temp3 = MaestroA.rounder(Complex.Real(state.Reflection_CoefH),4);
	    temp4 = MaestroA.rounder(Complex.Imaginary(state.Reflection_CoefH),4);
	    temp2 = new Complex(temp3,temp4);
	    
	    g.drawString(" = "+temp2+"",x+dx+dx+state.s7,y);
	    g.setFont(symbfont);
	    g.drawString("\u0393",x+2*dx-state.s5,y);
	    g.setFont(normalfont);
	    
	    y+= dy;
    	    
            if(state.which == 4){
                g.setColor(Color.yellow);
                g.fillRect(x+dxx-state.s5,y-state.s12,state.s200+state.s85,state.s15);
            }
            
            g.setColor(Color.blue.darker());
	    g.drawString("Transmission Coefficient",x+dxx,y);
	    g.setColor(Color.black);
	    ratioZ = Complex.Real(Complex.Divide(state.wave_impedance1,state.wave_impedance2));
	    temp3 = MaestroA.rounder(Complex.Real(state.Transmission_CoefH),4);
	    temp4 = MaestroA.rounder(Complex.Imaginary(state.Transmission_CoefH),4);
	    temp2 = new Complex(temp3,temp4);
	    
	    //g.drawString(" \u03c4 = "+temp2+"",x+dx+dx,y);
	    g.setFont(symbfont);
            //g.drawString(" \u03c4 = "+temp2+"",x+dx+dx,y);
            MaestroG.SerifSymbFirst(" \u03c4","","",g,state.font12,x+dx+dx-state.s5,y);
	    g.setFont(normalfont);
	    g.drawString(" = "+temp2+"",x+dx+dx+state.s7,y);
            
	    g.drawLine(5,y+dyy/4,getSize().width - state.s5,y+dyy/4);
	    
	    y += dyy;
	    
	    g.setColor(Color.red.darker());
	    g.drawString("Power",x,y);
	    
	    y+= dy;
            
            if(state.which == 5){
                g.setColor(Color.yellow);
                g.fillRect(x+dxx-state.s5,y-state.s12,state.s200+state.s85,state.s15);
            }
            
	    g.setColor(Color.blue.darker());
	    g.drawString("Reflectivity",x+dxx,y);
	    g.setColor(Color.black);
	    temp3 = Complex.Magnitude(state.Reflection_Coef);
	    temp4 = temp3*temp3;
	    
            g.drawString(" = "+MaestroA.rounder(temp4,6)+"",x+dx+dx+state.s7,y);
	    g.setFont(symbfont);
	    g.drawString("R",x+2*dx-state.s5,y);
	    g.setFont(normalfont);

	    y+= dy;
            
            if(state.which == 6){
                g.setColor(Color.yellow);
                g.fillRect(x+dxx-state.s5,y-state.s12,state.s200+state.s85,state.s15);
            }
            
    	    g.setColor(Color.blue.darker());
	    g.drawString("Transmissivity",x+dxx,y);
	    g.setColor(Color.black);
	    temp5 = 1.0 - temp4;
	    
	    g.drawString(" = "+MaestroA.rounder(temp5,6)+"",x+dx+dx+state.s7,y);
	    g.setFont(symbfont);
	    g.drawString("T",x+2*dx-state.s5,y);
	    g.setFont(normalfont);

	    g.drawLine(state.s5,y+dyy/4,getSize().width-state.s5,y+dyy/4); 
	     
	    y+=dyy;
	    g.setColor(Color.red.darker());
	    //g.drawString("Max. Transmission Angle",x,y);
            g.drawString("Angle of Maximum",x,y);
            g.drawString("Transmission",x,y+state.s13);
            
            g.setFont(normalfont);
            if(state.isPolarizationParallel){
		if(state.mu_r1 == state.mu_r2 && state.conductivity2 == 0.0){
		    temp3 = MaestroA.rounder(Math.atan(Math.sqrt(state.epsilon_r2/state.epsilon_r1))*180.0/Math.PI,4);
		    g.drawString(" = "+MaestroA.rounder(temp3,4)+"\u00ba",x+dx+dx+state.s7,y);
		    MaestroG.subscripter("\u03b8","m","",g,state.font11,x+dx+dx-state.s8,y);
		    g.setFont(normalfont);
		}
		else{
		    test1 = state.mu_r2*state.epsilon_r1/(state.mu_r1*state.epsilon_r2);
		    test2 = state.epsilon_r1*state.epsilon_r1/(state.epsilon_r2*state.epsilon_r2);
		    test3 = (1.0-test1)/(1.0-test2);
		    
                    if(state.isPolarizationParallel){
			MaestroG.subscripter("\u03b8","m","",g,state.font11,x+dx+dx-state.s8,y);
			g.setFont(normalfont);
			g.drawString(" = "+MaestroA.rounder(state.max/100.0,4)+"\u00ba",x+dx+dx+state.s7,y);
		    }
		    else{
			g.drawString(" = Undefined ",x+dx+dx+state.s7,y);
                        MaestroG.subscripter("\u03b8","m","",g,state.s11,x+dx+dx-state.s8,y);
			g.setFont(normalfont);
		    }
		}
	    }
	    else{
		g.setFont(normalfont);
		if(state.mu_r1 == state.mu_r2){
		    g.drawString(" = Undefined ",x+dx+dx+state.s7,y); 
                    MaestroG.subscripter("\u03b8","m","",g,state.font11,x+dx+dx-state.s5,y);
                    g.setFont(normalfont);
		}
		else{
		    test1 = state.mu_r1*state.epsilon_r2/(state.mu_r2*state.epsilon_r1);
		    test2 = state.mu_r1*state.mu_r1/(state.mu_r2*state.mu_r2);
		    test3 = (1.0-test1)/(1.0-test2);
		    if( Math.abs(test3) < 1.0){
			temp3 = 180.0/Math.PI*Math.asin(Math.sqrt((1.0-test1)/(1.0-test2)));
			g.drawString(" = "+MaestroA.rounder(temp3,4)+"\u00ba",x+dx+dx+state.s7,y);
			MaestroG.subscripter("\u03b8","m","",g,state.font11,x+dx+dx-5,y);
			g.setFont(normalfont);
		    }
		    else{
			g.setFont(normalfont);
                        g.drawString(" = Undefined ",x+dx+dx+state.s7,y);
			MaestroG.subscripter("\u03b8","m","",g,state.font11,x+dx+dx-state.s5,y);
			g.setFont(normalfont);
		    }
		}
	    }
	    
	    g.setColor(Color.blue.darker());
	    y += dyy+state.s8;
            //y += dyy;
            
	    g.drawString("Total Reflection Angle", x, y);
	    g.drawString("(Medium 2 Lossless)", x, y+state.s13);
            
            g.setFont(normalfont);
	    factor1 = Math.sqrt(state.mu_r2*state.epsilon_r2/(state.mu_r1*state.epsilon_r1));
	    if((state.mu_r1*state.epsilon_r1) > (state.mu_r2*state.epsilon_r2)){
		    temp3 = Math.asin(factor1)*180.0/Math.PI;
		    g.drawString(" = "+MaestroA.rounder(temp3,4)+"\u00ba",x+dx+dx+state.s7,y);
		    MaestroG.subscripter("\u03b8","c","",g,state.font11,x+dx+dx-state.s5,y);
                    g.setFont(normalfont);
		}
		else{
		    g.drawString(" = Undefined ",x+dx+dx+state.s7,y);
                    MaestroG.subscripter("\u03b8","c","",g,state.font11,x+dx+dx-state.s5,y);
			g.setFont(normalfont);
		}
	}
}

class ObliqueOutputCanvasB extends Canvas{
	
	Oblique_State state;
	private Image im;
	private Graphics buf;

	public ObliqueOutputCanvasB(Oblique_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){
            Font normalfont = new Font("Sanserif",Font.PLAIN,state.font11);
            Font normalfont2 = new Font("Sanserif",Font.PLAIN,state.font12);
            Font subfont    = new Font("Sanserif",Font.PLAIN,state.font10);
            Font titlefont  =new Font("Sanserif",Font.BOLD,state.font16);
            Font symbfont = new Font("Serif",Font.PLAIN,state.font13);
            
	    int x, x2, x3, x4, y, dx, dxx, dy, dyy;
	    Complex temp1, temp2;
	    double temp3, temp4, temp5, ratioZ, test1, test2, test3, factor1;
	    FontMetrics fm;
	    
            dx = state.s80;
	    dxx = state.s55;
            x = state.s30;
            x2 = state.s14;
            x3 = x+dxx+state.s170;
            x4 = state.s14;
	    y = state.s35;

            Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
                    
            g.clearRect(0,0,getSize().width,getSize().height);
	    
	    //g.setFont(titlefont);
            //g.setColor(Color.blue.darker());
	    //g.drawString("Output",state.s20,state.s20);

	    g.setFont(normalfont);
	    fm = g.getFontMetrics();
	    dy = state.s12;
	    dyy = dy;
	    g.setColor(Color.red.darker());
	    
            //--------------------------------------------- MEDIUM 1
            int fonto = state.font11;
            double test;
            
            g.setColor(Color.red.darker());
            g.drawString("Wavelength",x4,y);
	    g.drawString("Medium 1",x3-state.s15,y);
	    g.setColor(Color.black);
            
	    y += dy;
	    test = state.wavelength1;
            MaestroG.subscripterSS2("\u03bb","i","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m",""," ]",g,fonto,x3,y);
	    Write(g,test,fonto,x,y);
            
            y += dyy+state.s1;
            g.setColor(Color.red.darker());
            g.drawString("Impedance",x4,y);
	    g.setColor(Color.black);
	    y += dy;
	    test = state.wave_impedance1.Real();
            MaestroG.subscripterSS2("\u03b7","1","",g,fonto,x2,y);
	    MaestroG.subscripterSS2(" [ \u03a9",""," ]",g,fonto,x3,y);
            Write(g,test,fonto,x,y);
            
            y += dyy+state.s1;
            g.setColor(Color.red.darker());
            g.drawString("Incident wave vector",x4,y);
	    g.setColor(Color.black);
	    y += dy;// Total beta
	    test = state.beta1;
            MaestroG.subscripter3("k","i","","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m","-1"," ]",g,fonto,x3-state.s2,y);
	    Write(g,test,fonto,x,y);
            
            y += dy+state.s1;// z-component
            test = state.beta1_z;
            MaestroG.subscripter3("k","i","x","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m","-1"," ]",g,fonto,x3-state.s2,y);
	    Write(g,test,fonto,x,y);
            
	    y += dy+state.s1;// x-component
            if(state.theta1 < Math.PI*0.5){
                test = state.beta1_x;
            }
            else{
                test = 0.0;
            }
            MaestroG.subscripter3("k","i","z","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m","-1"," ]",g,fonto,x3-state.s2,y);
	    Write(g,test,fonto,x,y);
            
            y += state.s8;
            
            g.setColor(Color.green.darker());
            g.drawLine(state.s10,y,getSize().width-state.s10,y);
            
            //------------------------------------ MEDIUM 2
            
            y += dyy;
            g.setColor(Color.blue.darker());
            g.drawString("Wavelength",x4,y);
	    g.drawString("Medium 2",x3-state.s15,y);
            g.setColor(Color.black);
            
	    y += dy;
	    test = state.wavelength2;
            MaestroG.subscripterSS2("\u03bb","2","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m",""," ]",g,fonto,x3,y);
	    Write(g,test,fonto,x,y);
            
            y += dyy+state.s1;
            g.setColor(Color.blue.darker());
            g.drawString("Impedance",x4,y);
	    g.setColor(Color.black);
	    y += dy; 
	    test = state.wave_impedance2.Real();
            test2 = state.wave_impedance2.Imaginary();
            MaestroG.subscripterSS2("\u03b7","2","",g,fonto,x2,y);
	    MaestroG.subscripterSS2(" [ \u03a9",""," ]",g,fonto,x3,y);
	    WriteC(g,test,test2,fonto,x,y);
            
            y += dyy+state.s1;
            g.setColor(Color.blue.darker());
            g.drawString("Bulk wave number",x4,y);
            MaestroG.subscripterSerif("2\u03c0 / \u03bb","2","",g,state.font11,x4+state.s105,y);
	    g.setColor(Color.black);
	    y += dy;// Total beta in bulk material, no interface
	    test = state.beta2bulk;
            MaestroG.subscripter3("\u03b2","2","","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m","-1"," ]",g,fonto,x3-state.s2,y);
	    Write(g,test,fonto,x,y);
                        
            y += dyy+state.s1;
            g.setColor(Color.blue.darker());
            g.drawString("Refracted wave vector at effective angle",x4,y);
	    g.setColor(Color.black);
            
	    y += dy;// Total beta
	    test = state.beta2;
            MaestroG.subscripter3("k","t","","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m","-1"," ]",g,fonto,x3-state.s2,y);
	    Write(g,test,fonto,x,y);
            
            y += dy+state.s1;// z-component
            test = state.beta1 * Math.sin(state.theta1);
            MaestroG.subscripter3("k","t","x","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m","-1"," ]",g,fonto,x3-state.s2,y);
	    Write(g,test,fonto,x,y);
            
	    y += dy+state.s1;// x-component
            
            double testangle;
            testangle = Math.PI/180.0*state.totalR_angle;
            
            if(state.theta1 < testangle){
                test = state.beta2 * Math.cos(state.theta2);
                MaestroG.subscripter3("k","t","z","","",g,fonto,x2,y);
                MaestroG.superscripter(" [ m","-1"," ]",g,fonto,x3-state.s2,y);
                Write(g,test,fonto,x,y);
            }
            else if(state.theta1 == testangle){
                test = 0.0;
                MaestroG.subscripter3("k","t","z","","",g,fonto,x2,y);
                MaestroG.superscripter(" [ m","-1"," ]",g,fonto,x3-state.s2,y);
                Write(g,test,fonto,x,y);
            }
            else if(state.theta1 > testangle){
                test = state.beta2 * Math.sqrt((state.mu_r1*state.epsilon_r1)/(state.mu_r2*state.epsilon_r2) *
                      (Math.pow(Math.sin(state.theta1),2.0) - (state.mu_r2*state.epsilon_r2)/(state.mu_r1*state.epsilon_r1)));        
                MaestroG.subscripter3("k","t","z","","",g,fonto,x2,y);
                MaestroG.superscripter(" [ m","-1"," ]",g,fonto,x3-state.s2,y);
                WriteI(g,test,fonto,x,y);
            }
            
	    g.setFont(normalfont);
            //-----------------------------------------------------------------------
	}

        public void Write(Graphics g, double test, int fonto, int x, int y){
            Graphics2D g2d = (Graphics2D)g;
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            //if(test < 1.0e-15){
		//MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e16,5)+"  x  10","-16"," ",g,fonto,x,y);
	    //}
            if(test < 1.0e-15){
		MaestroG.superscripter("  =  0.0",""," ",g,fonto,x,y);
	    }
            else if(test >= 1.0e-15 && test < 1.0e-14){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e15,5)+"  x  10","-15"," ",g,fonto,x,y);
	    }
            else if(test >= 1.0e-14 && test < 1.0e-13){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e14,5)+"  x  10","-14"," ",g,fonto,x,y);
	    }
            else if(test >= 1.0e-13 && test < 1.0e-12){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e13,5)+"  x  10","-13"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-12 && test < 1.0e-11){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e12,5)+"  x  10","-12"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-11 && test < 1.0e-10){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e11,5)+"  x  10","-11"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-10 && test < 1.0e-9){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e10,5)+"  x  10","-10"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-9 && test < 1.0e-8){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e9,5)+"  x  10","-9"," ",g,fonto,x,y);
	    }
	    
	    else if(test >= 1.0e-8 && test < 1.0e-7){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e8,5)+"  x  10","-8"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-7 && test < 1.0e-6){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e7,5)+"  x  10","-7"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-6 && test < 1.0e-5){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e6,5)+"  x  10","-6"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-5 && test < 1.0e-4){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e5,5)+"  x  10","-5"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-4 && test < 1.0e-3){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e4,5)+"  x  10","-4"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-3 && test < 1.0e-2){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e3,5)+"  x  10","-3"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-2 && test < 1.0e-1){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e2,5)+"  x  10","-2"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-1 && test < 1.0){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e1,5)+"  x  10","-1"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0 && test < 1.0e1){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test,5)+"  ",""," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e1 && test < 1.0e2){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test,5)+"  ",""," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e2 && test < 1.0e3){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-2,5)+"  x  10","2"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e3 && test < 1.0e4){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-3,5)+"  x  10","3"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e4 && test < 1.0e5){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-4,5)+"  x  10","4"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e5 && test < 1.0e6){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-5,5)+"  x  10","5"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e6 && test < 1.0e7){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-6,5)+"  x  10","6"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e7 && test < 1.0e8){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-7,5)+"  x  10","7"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e8 && test < 1.0e9){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-8,5)+"  x  10","8"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e9 && test < 1.0e10){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-9,5)+"  x  10","9"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e10 && test < 1.0e11){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-10,5)+"  x  10","10"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e11 && test < 1.0e12){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-11,5)+"  x  10","11"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e12 && test < 1.0e13){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-12,5)+"  x  10","12"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e13 && test < 1.0e14){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-13,5)+"  x  10","13"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e14 && test < 1.0e15){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-14,5)+"  x  10","14"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e15 && test < 1.0e16){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-15,5)+"  x  10","15"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e16 && test < 1.0e17){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-16,5)+"  x  10","16"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e17 && test < 1.0e18){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-17,5)+"  x  10","17"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e18 && test < 1.0e19){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-18,5)+"  x  10","18"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e19 && test < 1.0e20){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-19,5)+"  x  10","19"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e20 && test < 1.0e21){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-20,5)+"  x  10","20"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e21){
		MaestroG.superscripter("  =  "+test+"",""," ",g,fonto,x,y);
	    }
            
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
        }

        public void WriteI(Graphics g, double test, int fonto, int x, int y){
            Graphics2D g2d = (Graphics2D)g;
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
            
            //if(test < 1.0e-15){
		//MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e16,5)+"  x  10","-16"," ",g,fonto,x,y);
	    //}
            if(test < 1.0e-15){
		MaestroG.superscripter("  =  0.0",""," ",g,fonto,x,y);
	    }
            else if(test >= 1.0e-15 && test < 1.0e-14){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e15,5)+"  x  10","-15"," ",g,fonto,x,y);
	    }
            else if(test >= 1.0e-14 && test < 1.0e-13){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e14,5)+"  x  10","-14"," ",g,fonto,x,y);
	    }
            else if(test >= 1.0e-13 && test < 1.0e-12){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e13,5)+"  x  10","-13"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-12 && test < 1.0e-11){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e12,5)+"  x  10","-12"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-11 && test < 1.0e-10){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e11,5)+"  x  10","-11"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-10 && test < 1.0e-9){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e10,5)+"  x  10","-10"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-9 && test < 1.0e-8){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e9,5)+"  x  10","-9"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-8 && test < 1.0e-7){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e8,5)+"  x  10","-8"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-7 && test < 1.0e-6){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e7,5)+"  x  10","-7"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-6 && test < 1.0e-5){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e6,5)+"  x  10","-6"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-5 && test < 1.0e-4){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e5,5)+"  x  10","-5"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-4 && test < 1.0e-3){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e4,5)+"  x  10","-4"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-3 && test < 1.0e-2){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e3,5)+"  x  10","-3"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-2 && test < 1.0e-1){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e2,5)+"  x  10","-2"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-1 && test < 1.0){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e1,5)+"  x  10","-1"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0 && test < 1.0e1){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test,5)+"  ",""," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e1 && test < 1.0e2){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test,5)+"  ",""," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e2 && test < 1.0e3){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-2,5)+"  x  10","2"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e3 && test < 1.0e4){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-3,5)+"  x  10","3"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e4 && test < 1.0e5){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-4,5)+"  x  10","4"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e5 && test < 1.0e6){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-5,5)+"  x  10","5"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e6 && test < 1.0e7){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-6,5)+"  x  10","6"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e7 && test < 1.0e8){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-7,5)+"  x  10","7"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e8 && test < 1.0e9){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-8,5)+"  x  10","8"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e9 && test < 1.0e10){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-9,5)+"  x  10","9"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e10 && test < 1.0e11){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-10,5)+"  x  10","10"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e11 && test < 1.0e12){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-11,5)+"  x  10","11"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e12 && test < 1.0e13){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-12,5)+"  x  10","12"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e13 && test < 1.0e14){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-13,5)+"  x  10","13"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e14 && test < 1.0e15){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-14,5)+"  x  10","14"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e15 && test < 1.0e16){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-15,5)+"  x  10","15"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e16 && test < 1.0e17){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-16,5)+"  x  10","16"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e17 && test < 1.0e18){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-17,5)+"  x  10","17"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e18 && test < 1.0e19){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-18,5)+"  x  10","18"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e19 && test < 1.0e20){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-19,5)+"  x  10","19"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e20 && test < 1.0e21){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-20,5)+"  x  10","20"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e21){
		MaestroG.superscripter("  =  - j "+test+"",""," ",g,fonto,x,y);
	    }
            
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
        }

        public void WriteC(Graphics g, double test, double test2, int fonto, int x, int y){
            Graphics2D g2d = (Graphics2D)g;
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            //===============================================================
            FontMetrics fm;
            g.setFont(new Font("SanSerif",Font.PLAIN,fonto));
            fm = g.getFontMetrics();
		
            int dy = 0;
            int dy1 = fm.stringWidth(" x10-10");
            int dy2 = fm.stringWidth(" x1010");
            
            if(test < 1.0e-15){
		MaestroG.superscripter("  =  0.0",""," ",g,fonto,x,y);
                dy = 0;
	    }
            else if(test >= 1.0e-15 && test < 1.0e-14){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e15,5)+"  x  10","-15"," ",g,fonto,x,y);
                dy = dy1;
	    }
            else if(test >= 1.0e-14 && test < 1.0e-13){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e14,5)+"  x  10","-14"," ",g,fonto,x,y);
                dy = dy1;
	    }
            else if(test >= 1.0e-13 && test < 1.0e-12){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e13,5)+"  x  10","-13"," ",g,fonto,x,y);
                dy = dy1;
	    }
	    else if(test >= 1.0e-12 && test < 1.0e-11){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e12,5)+"  x  10","-12"," ",g,fonto,x,y);
                dy = dy1;
	    }
	    else if(test >= 1.0e-11 && test < 1.0e-10){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e11,5)+"  x  10","-11"," ",g,fonto,x,y);
                dy = dy1;
	    }
	    else if(test >= 1.0e-10 && test < 1.0e-9){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e10,5)+"  x  10","-10"," ",g,fonto,x,y);
                dy = dy1;
	    }
	    else if(test >= 1.0e-9 && test < 1.0e-8){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e9,5)+"  x  10","-9"," ",g,fonto,x,y);
                dy = dy1;
	    }
	    
	    else if(test >= 1.0e-8 && test < 1.0e-7){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e8,5)+"  x  10","-8"," ",g,fonto,x,y);
                dy = dy1;
	    }
	    else if(test >= 1.0e-7 && test < 1.0e-6){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e7,5)+"  x  10","-7"," ",g,fonto,x,y);
                dy = dy1;
	    }
	    else if(test >= 1.0e-6 && test < 1.0e-5){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e6,5)+"  x  10","-6"," ",g,fonto,x,y);
                dy = dy1;
	    }
	    else if(test >= 1.0e-5 && test < 1.0e-4){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e5,5)+"  x  10","-5"," ",g,fonto,x,y);
                dy = dy1;
	    }
	    else if(test >= 1.0e-4 && test < 1.0e-3){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e4,5)+"  x  10","-4"," ",g,fonto,x,y);
                dy = dy1;
	    }
	    else if(test >= 1.0e-3 && test < 1.0e-2){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e3,5)+"  x  10","-3"," ",g,fonto,x,y);
                dy = dy1;
	    }
	    else if(test >= 1.0e-2 && test < 1.0e-1){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e2,5)+"  x  10","-2"," ",g,fonto,x,y);
                dy = dy1;
	    }
	    else if(test >= 1.0e-1 && test < 1.0){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e1,5)+"  x  10","-1"," ",g,fonto,x,y);
                dy = dy1;
	    }
	    else if(test >= 1.0 && test < 1.0e1){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test,5)+"  ",""," ",g,fonto,x,y);
                dy = 0;
	    }
	    else if(test >= 1.0e1 && test < 1.0e2){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test,5)+"  ",""," ",g,fonto,x,y);
                dy = 0;
	    }
	    else if(test >= 1.0e2 && test < 1.0e3){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-2,5)+"  x  10","2"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e3 && test < 1.0e4){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-3,5)+"  x  10","3"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e4 && test < 1.0e5){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-4,5)+"  x  10","4"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e5 && test < 1.0e6){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-5,5)+"  x  10","5"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e6 && test < 1.0e7){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-6,5)+"  x  10","6"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e7 && test < 1.0e8){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-7,5)+"  x  10","7"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e8 && test < 1.0e9){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-8,5)+"  x  10","8"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e9 && test < 1.0e10){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-9,5)+"  x  10","9"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e10 && test < 1.0e11){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-10,5)+"  x  10","10"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e11 && test < 1.0e12){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-11,5)+"  x  10","11"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e12 && test < 1.0e13){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-12,5)+"  x  10","12"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e13 && test < 1.0e14){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-13,5)+"  x  10","13"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e14 && test < 1.0e15){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-14,5)+"  x  10","14"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e15 && test < 1.0e16){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-15,5)+"  x  10","15"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e16 && test < 1.0e17){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-16,5)+"  x  10","16"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e17 && test < 1.0e18){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-17,5)+"  x  10","17"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e18 && test < 1.0e19){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-18,5)+"  x  10","18"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e19 && test < 1.0e20){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-19,5)+"  x  10","19"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e20 && test < 1.0e21){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-20,5)+"  x  10","20"," ",g,fonto,x,y);
                dy = dy2;
	    }
	    else if(test >= 1.0e21){
		MaestroG.superscripter("  =  "+test+"",""," ",g,fonto,x,y);
                dy = 0;
	    }
            //===============================================================
            x = x+fm.stringWidth("  =  0.000000");
            test = test2;
            
            //if(test < 1.0e-15){
		//MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e16,5)+"  x  10","-16"," ",g,fonto,x,y);
	    //}
            if(test < 1.0e-15){
		MaestroG.superscripter("  + j  0.0",""," ",g,fonto,x+dy,y);
	    }
            else if(test >= 1.0e-15 && test < 1.0e-14){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e15,5)+"  x  10","-15"," ",g,fonto,x+dy,y);
	    }
            else if(test >= 1.0e-14 && test < 1.0e-13){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e14,5)+"  x  10","-14"," ",g,fonto,x+dy,y);
	    }
            else if(test >= 1.0e-13 && test < 1.0e-12){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e13,5)+"  x  10","-13"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e-12 && test < 1.0e-11){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e12,5)+"  x  10","-12"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e-11 && test < 1.0e-10){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e11,5)+"  x  10","-11"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e-10 && test < 1.0e-9){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e10,5)+"  x  10","-10"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e-9 && test < 1.0e-8){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e9,5)+"  x  10","-9"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e-8 && test < 1.0e-7){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e8,5)+"  x  10","-8"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e-7 && test < 1.0e-6){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e7,5)+"  x  10","-7"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e-6 && test < 1.0e-5){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e6,5)+"  x  10","-6"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e-5 && test < 1.0e-4){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e5,5)+"  x  10","-5"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e-4 && test < 1.0e-3){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e4,5)+"  x  10","-4"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e-3 && test < 1.0e-2){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e3,5)+"  x  10","-3"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e-2 && test < 1.0e-1){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e2,5)+"  x  10","-2"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e-1 && test < 1.0){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e1,5)+"  x  10","-1"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0 && test < 1.0e1){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test,5)+"  ",""," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e1 && test < 1.0e2){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test,5)+"  ",""," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e2 && test < 1.0e3){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-2,5)+"  x  10","2"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e3 && test < 1.0e4){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-3,5)+"  x  10","3"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e4 && test < 1.0e5){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-4,5)+"  x  10","4"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e5 && test < 1.0e6){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-5,5)+"  x  10","5"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e6 && test < 1.0e7){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-6,5)+"  x  10","6"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e7 && test < 1.0e8){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-7,5)+"  x  10","7"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e8 && test < 1.0e9){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-8,5)+"  x  10","8"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e9 && test < 1.0e10){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-9,5)+"  x  10","9"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e10 && test < 1.0e11){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-10,5)+"  x  10","10"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e11 && test < 1.0e12){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-11,5)+"  x  10","11"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e12 && test < 1.0e13){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-12,5)+"  x  10","12"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e13 && test < 1.0e14){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-13,5)+"  x  10","13"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e14 && test < 1.0e15){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-14,5)+"  x  10","14"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e15 && test < 1.0e16){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-15,5)+"  x  10","15"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e16 && test < 1.0e17){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-16,5)+"  x  10","16"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e17 && test < 1.0e18){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-17,5)+"  x  10","17"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e18 && test < 1.0e19){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-18,5)+"  x  10","18"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e19 && test < 1.0e20){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-19,5)+"  x  10","19"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e20 && test < 1.0e21){
		MaestroG.superscripter("  + j "+MaestroA.rounder(test*1.0e-20,5)+"  x  10","20"," ",g,fonto,x+dy,y);
	    }
	    else if(test >= 1.0e21){
		MaestroG.superscripter("  + j "+test+"",""," ",g,fonto,x+dy,y);
	    }
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
        }
}

class ObliqueOutputCanvasB2 extends Canvas{	
	Oblique_State state;
	private Image im;
	private Graphics buf;

	public ObliqueOutputCanvasB2(Oblique_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){
            Font normalfont = new Font("Sanserif",Font.PLAIN,state.font11);
            Font normalfont2 = new Font("Sanserif",Font.PLAIN,state.font12);
            Font subfont    = new Font("Sanserif",Font.PLAIN,state.font10);
            Font titlefont  =new Font("Sanserif",Font.BOLD,state.font16);
            Font symbfont = new Font("Serif",Font.PLAIN,state.font13);

	    int x, x2, x3, x4, y, dx, dxx, dy, dyy;
	    Complex temp1, temp2;
	    double temp3, temp4, temp5, ratioZ, test1, test2, test3, factor1;
	    FontMetrics fm;
	    
            dx = state.s80;
	    dxx = state.s15;
            x = state.s50;
            x2 = state.s34;
            x3 = x+dxx+state.s150;
            x4 = state.s20;
	    y = state.s30;

            Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
                    
            g.clearRect(0,0,getSize().width,getSize().height);
	    
	    //g.setFont(titlefont);
            //g.setColor(Color.blue.darker());
	    //g.drawString("Output",state.s20,state.s20);

	    g.setFont(normalfont);
	    fm = g.getFontMetrics();
	    dy = state.s13;
	    dyy = dy;
	    g.setColor(Color.red.darker());
	    
	    y+= dy;
	    //--------------------------------------------- MEDIUM 1
            int fonto = state.font11;
            double test;
            
            g.setColor(Color.red.darker());
            g.drawString("Apparent wavelengths",x4,y);
	    g.drawString("Medium 1",x3,y);
	    g.setColor(Color.black);
            
	    y += dy;
	    test = state.wavelength1z;
            
            MaestroG.subscripter3("\u03bb","1","z","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m",""," ]",g,fonto,x+dxx+state.s150,y);
	    
            if(state.theta1 == 0.0){
                g.setFont(normalfont);
                g.drawString("  =  \u221e",x,y);
            }
            else{
                Write(g,test,fonto,x,y);
            }
            
            y += dy;
	    test = state.wavelength1x;
            MaestroG.subscripter3("\u03bb","1","x","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m",""," ]",g,fonto,x+dxx+state.s150,y);
	    
            if(state.theta1 == Math.PI*0.5){
                g.setFont(normalfont);
                g.drawString("  =  \u221e",x,y);
            }
            else{
                Write(g,test,fonto,x,y);
            }
            
            y += dyy+state.s2;
            g.setColor(Color.red.darker());
            g.drawString("Phase velocity",x4,y);
	    g.setColor(Color.black);
	    y += dy;// Total beta
	    test = state.phase_velocity1;
            MaestroG.subscripter3("v","1","","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m s","-1"," ]",g,fonto,x+dxx+state.s150,y);
	    Write(g,test,fonto,x,y);
            
            y += dyy+state.s1;
            g.setColor(Color.red.darker());
            g.drawString("Apparent phase velocities",x4,y);
	    g.setColor(Color.black);
            y += dy+1;// z-component
            test = state.phase_velocity1z;
            MaestroG.subscripter3("v","1","z","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m s","-1"," ]",g,fonto,x+dxx+state.s150,y);
	    if(state.theta1 == 0.0){
                g.setFont(normalfont);
                g.drawString("  =  \u221e",x,y);
            }
            else{
                Write(g,test,fonto,x,y);
            }
	    y += dy+state.s1;// x-component
            
            test = state.phase_velocity1x;
            MaestroG.subscripter3("v","1","x","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m s","-1"," ]",g,fonto,x+dxx+state.s150,y);
	    if(state.theta1 < Math.PI*0.5){
                Write(g,test,fonto,x,y);
            }
            else{
                g.setFont(normalfont);
                g.drawString("  =  \u221e",x,y);
            }
            
            y += state.s8;
            
            g.setColor(Color.green.darker());
            g.drawLine(state.s10,y,getSize().width-state.s10,y);
            
            //------------------------------------ MEDIUM 2
            
            y += dyy;
            g.setColor(Color.blue.darker());
            g.drawString("Apparent wavelengths",x4,y);
	    g.drawString("Medium 2",x3,y);
            g.setColor(Color.black);
            
	    y += dy;
	    test = state.wavelength1z;
            MaestroG.subscripter3("\u03bb","2","z","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m",""," ]",g,fonto,x+dxx+state.s150,y);
	    
            if(state.theta1 == 0.0){
                g.setFont(normalfont);
                g.drawString("  =  \u221e",x,y);
            }
            else if(state.theta1 >= (state.totalR_angle*Math.PI/180.0)){
                test = state.wavelength1z;
                Write(g,test,fonto,x,y);
            }
            else{
                Write(g,test,fonto,x,y);
            }
            
            y += dy;
	    test = state.wavelength2x;
            MaestroG.subscripter3("\u03bb","2","x","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m",""," ]",g,fonto,x+dxx+state.s150,y);
	    if(state.theta1 >= (state.totalR_angle*Math.PI/180.0)){
                g.setFont(normalfont);
                g.drawString("  =  \u221e",x,y);
            }
            else{
                Write(g,test,fonto,x,y);
            }
            
            y += dyy+state.s2;
            g.setColor(Color.blue.darker());
            g.drawString("Bulk phase velocity",x4,y);
	    g.setColor(Color.black);
            
	    y += dy;// Total beta
	    test = state.phase_velocity2;
            MaestroG.subscripter3("v","2","","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m s","-1"," ]",g,fonto,x+dxx+state.s150,y);
	    Write(g,test,fonto,x,y);
            
            y += dyy+state.s2;
            g.setColor(Color.blue.darker());
            g.drawString("Phase velocity along effective refraction direction",x4,y);
	    g.setColor(Color.black);
            
	    y += dy;// Total beta
	    test = state.phase_velocity2_eff;
            MaestroG.subscripter3("v","2e","","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m s","-1"," ]",g,fonto,x+dxx+state.s150,y);
	    Write(g,test,fonto,x,y);
            
            y += dyy+state.s1;
            g.setColor(Color.blue.darker());
            g.drawString("Apparent phase velocities",x4,y);
	    g.setColor(Color.black);
            y += dy+state.s1;// z-component
            
            test = state.phase_velocity2z;
            MaestroG.subscripter3("v","2","z","","",g,fonto,x2,y);
	    MaestroG.superscripter(" [ m s","-1"," ]",g,fonto,x+dxx+state.s150,y);
	    
            if(state.theta1 == 0.0){
                g.setFont(normalfont);
                g.drawString("  =  \u221e",x,y);
            }
            else{
                Write(g,test,fonto,x,y);
            }
            
	    y += dy+state.s1;// x-component
            
            double testangle;
            testangle = Math.PI/180.0*state.totalR_angle;
            
            if(state.theta1 < testangle){
                test = state.phase_velocity2x;
                MaestroG.subscripter3("v","2","x","","",g,fonto,x2,y);
                MaestroG.superscripter(" [ m s","-1"," ]",g,fonto,x+dxx+state.s150,y);
                Write(g,test,fonto,x,y);
            }
            else{
                MaestroG.subscripter3("v","2","x","","",g,fonto,x2,y);
                MaestroG.superscripter(" [ m s","-1"," ]",g,fonto,x+dxx+state.s150,y);
                g.setFont(normalfont);
                g.drawString("  =  \u221e",x,y);
            }
            
	    g.setFont(normalfont);
	    //-----------------------------------------------------------------------
	}

        public void Write(Graphics g, double test, int fonto, int x, int y){
            Graphics2D g2d = (Graphics2D)g;
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
            //if(test < 1.0e-15){
		//MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e16,5)+"  x  10","-16"," ",g,fonto,x,y);
	    //}
            if(test < 1.0e-15){
		MaestroG.superscripter("  =  0.0",""," ",g,fonto,x,y);
	    }
            else if(test >= 1.0e-15 && test < 1.0e-14){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e15,5)+"  x  10","-15"," ",g,fonto,x,y);
	    }
            else if(test >= 1.0e-14 && test < 1.0e-13){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e14,5)+"  x  10","-14"," ",g,fonto,x,y);
	    }
            else if(test >= 1.0e-13 && test < 1.0e-12){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e13,5)+"  x  10","-13"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-12 && test < 1.0e-11){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e12,5)+"  x  10","-12"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-11 && test < 1.0e-10){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e11,5)+"  x  10","-11"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-10 && test < 1.0e-9){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e10,5)+"  x  10","-10"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-9 && test < 1.0e-8){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e9,5)+"  x  10","-9"," ",g,fonto,x,y);
	    }
	    
	    else if(test >= 1.0e-8 && test < 1.0e-7){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e8,5)+"  x  10","-8"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-7 && test < 1.0e-6){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e7,5)+"  x  10","-7"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-6 && test < 1.0e-5){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e6,5)+"  x  10","-6"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-5 && test < 1.0e-4){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e5,5)+"  x  10","-5"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-4 && test < 1.0e-3){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e4,5)+"  x  10","-4"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-3 && test < 1.0e-2){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e3,5)+"  x  10","-3"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-2 && test < 1.0e-1){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e2,5)+"  x  10","-2"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-1 && test < 1.0){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e1,5)+"  x  10","-1"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0 && test < 1.0e1){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test,5)+"  ",""," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e1 && test < 1.0e2){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test,5)+"  ",""," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e2 && test < 1.0e3){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-2,5)+"  x  10","2"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e3 && test < 1.0e4){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-3,5)+"  x  10","3"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e4 && test < 1.0e5){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-4,5)+"  x  10","4"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e5 && test < 1.0e6){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-5,5)+"  x  10","5"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e6 && test < 1.0e7){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-6,5)+"  x  10","6"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e7 && test < 1.0e8){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-7,5)+"  x  10","7"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e8 && test < 1.0e9){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-8,5)+"  x  10","8"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e9 && test < 1.0e10){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-9,5)+"  x  10","9"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e10 && test < 1.0e11){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-10,5)+"  x  10","10"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e11 && test < 1.0e12){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-11,5)+"  x  10","11"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e12 && test < 1.0e13){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-12,5)+"  x  10","12"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e13 && test < 1.0e14){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-13,5)+"  x  10","13"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e14 && test < 1.0e15){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-14,5)+"  x  10","14"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e15 && test < 1.0e16){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-15,5)+"  x  10","15"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e16 && test < 1.0e17){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-16,5)+"  x  10","16"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e17 && test < 1.0e18){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-17,5)+"  x  10","17"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e18 && test < 1.0e19){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-18,5)+"  x  10","18"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e19 && test < 1.0e20){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-19,5)+"  x  10","19"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e20 && test < 1.0e21){
		MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e-20,5)+"  x  10","20"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e21){
		MaestroG.superscripter("  =  "+test+"",""," ",g,fonto,x,y);
	    }
            
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
        }

        public void WriteI(Graphics g, double test, int fonto, int x, int y){
            Graphics2D g2d = (Graphics2D)g;
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            
            //if(test < 1.0e-15){
		//MaestroG.superscripter("  =  "+MaestroA.rounder(test*1.0e16,5)+"  x  10","-16"," ",g,fonto,x,y);
	    //}
            if(test < 1.0e-15){
		MaestroG.superscripter("  =  0.0",""," ",g,fonto,x,y);
	    }
            else if(test >= 1.0e-15 && test < 1.0e-14){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e15,5)+"  x  10","-15"," ",g,fonto,x,y);
	    }
            else if(test >= 1.0e-14 && test < 1.0e-13){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e14,5)+"  x  10","-14"," ",g,fonto,x,y);
	    }
            else if(test >= 1.0e-13 && test < 1.0e-12){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e13,5)+"  x  10","-13"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-12 && test < 1.0e-11){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e12,5)+"  x  10","-12"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-11 && test < 1.0e-10){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e11,5)+"  x  10","-11"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-10 && test < 1.0e-9){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e10,5)+"  x  10","-10"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-9 && test < 1.0e-8){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e9,5)+"  x  10","-9"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-8 && test < 1.0e-7){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e8,5)+"  x  10","-8"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-7 && test < 1.0e-6){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e7,5)+"  x  10","-7"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-6 && test < 1.0e-5){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e6,5)+"  x  10","-6"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-5 && test < 1.0e-4){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e5,5)+"  x  10","-5"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-4 && test < 1.0e-3){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e4,5)+"  x  10","-4"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-3 && test < 1.0e-2){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e3,5)+"  x  10","-3"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-2 && test < 1.0e-1){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e2,5)+"  x  10","-2"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-1 && test < 1.0){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e1,5)+"  x  10","-1"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0 && test < 1.0e1){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test,5)+"  ",""," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e1 && test < 1.0e2){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test,5)+"  ",""," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e2 && test < 1.0e3){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-2,5)+"  x  10","2"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e3 && test < 1.0e4){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-3,5)+"  x  10","3"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e4 && test < 1.0e5){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-4,5)+"  x  10","4"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e5 && test < 1.0e6){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-5,5)+"  x  10","5"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e6 && test < 1.0e7){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-6,5)+"  x  10","6"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e7 && test < 1.0e8){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-7,5)+"  x  10","7"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e8 && test < 1.0e9){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-8,5)+"  x  10","8"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e9 && test < 1.0e10){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-9,5)+"  x  10","9"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e10 && test < 1.0e11){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-10,5)+"  x  10","10"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e11 && test < 1.0e12){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-11,5)+"  x  10","11"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e12 && test < 1.0e13){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-12,5)+"  x  10","12"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e13 && test < 1.0e14){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-13,5)+"  x  10","13"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e14 && test < 1.0e15){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-14,5)+"  x  10","14"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e15 && test < 1.0e16){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-15,5)+"  x  10","15"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e16 && test < 1.0e17){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-16,5)+"  x  10","16"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e17 && test < 1.0e18){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-17,5)+"  x  10","17"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e18 && test < 1.0e19){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-18,5)+"  x  10","18"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e19 && test < 1.0e20){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-19,5)+"  x  10","19"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e20 && test < 1.0e21){
		MaestroG.superscripter("  =  - j "+MaestroA.rounder(test*1.0e-20,5)+"  x  10","20"," ",g,fonto,x,y);
	    }
	    else if(test >= 1.0e21){
		MaestroG.superscripter("  =  - j "+test+"",""," ",g,fonto,x,y);
	    }
            
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
        }
}

class ObliqueOutputCanvasB3 extends Canvas{	
	Oblique_State state;
	private Image im;
	private Graphics buf;

	public ObliqueOutputCanvasB3(Oblique_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){
	    Font normalfont = new Font("Sanserif",Font.PLAIN,state.font11);
            Font normalfont2 = new Font("Sanserif",Font.PLAIN,state.font12);
            Font subfont    = new Font("Sanserif",Font.PLAIN,state.font10);
            Font titlefont  =new Font("Sanserif",Font.BOLD,state.font16);
            Font symbfont = new Font("Serif",Font.PLAIN,state.font13);
            
            int x, y, dx, dxx, dy, dyy;
	    Complex temp1, temp2;
	    double temp3, temp4, temp5, ratioZ, test1, test2, test3, factor1;
	    FontMetrics fm;
	    
            dx = state.s80;
	    dxx = state.s15;
            x = state.s10;
            y = state.s40;

            g.clearRect(0,0,getSize().width,getSize().height);
	    Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            
	    //g.setFont(titlefont);
            //g.setColor(Color.blue.darker());
	    //g.drawString("Output",state.s20,state.s20);

	    g.setFont(normalfont);
	    fm = g.getFontMetrics();
	    dy = state.s15;
	    dyy = dy+state.s3;
	    
	    g.setColor(Color.red.darker());
	    g.drawString("Incident Angle",x+dxx-state.s5,y);	
	    g.drawString("Effective Refraction Angle",x+2*dx-state.s25,y);
	    y += dy;
	    g.setColor(Color.black);
	    MaestroG.subscripter("\u03b8","i"," = "+MaestroA.rounder(state.theta1*180.0/Math.PI,4)+"\u00ba",g,state.font11,x+dxx,y);
	    g.setFont(normalfont);
	    
	    if(state.theta2 != state.theta2){
		g.drawString(" = Undefined",x+2*dx+state.s7,y);
                MaestroG.subscripter("\u03b8","te","",g,11,x+2*dx-state.s5,y);
                g.setFont(normalfont);
	    }
	    else{
		g.drawString(" = "+MaestroA.rounder(state.theta2*180.0/Math.PI,4)+"\u00ba",x+2*dx+state.s7,y);
		MaestroG.subscripter("\u03b8","te","",g,state.font11,x+2*dx-state.s5,y);
		g.setFont(normalfont);
	    }
	    g.drawLine(5,y+dyy/3+state.s3,getSize().width-state.s5,y+dyy/3+state.s3); 
	    y += dyy+dyy/2;
	    //------------------------------------------------------------------
            g.setColor(Color.blue.darker());
	    g.drawString("Refraction Parameters",x+dxx-state.s5,y);
	    y+= dy;
            
            g.setColor(Color.black);
	    
            MaestroG.SanSerifSymbFirstSub("sin (\u03b8","i",")",g,state.font12,x+dxx-state.s5,y);
            MaestroG.subscripter("  =  "+MaestroA.rounder(Math.sin(state.theta1),6),"","",g,state.font12,x+dxx+state.s40,y);
    	    y+= dyy;
                        
            temp3 = MaestroA.rounder(Complex.Real(state.singeom2),6);
	    temp4 = MaestroA.rounder(Complex.Imaginary(state.singeom2),6);
	    temp2 = new Complex(temp3,temp4);
	    
            MaestroG.SanSerifSymbFirstSub("sin (\u03b8","t",")",g,state.font12,x+dxx-state.s5,y);
            MaestroG.subscripter("  =  "+temp2,"","",g,state.font12,x+dxx+state.s40,y);
    	    y+= dyy;
            
            temp3 = MaestroA.rounder(Complex.Real(state.cosgeom2),6);
	    temp4 = MaestroA.rounder(Complex.Imaginary(state.cosgeom2),6);
	    temp2 = new Complex(temp3,temp4);
	    
            MaestroG.SanSerifSymbFirstSub("cos (\u03b8","t",")",g,state.font12,x+dxx-state.s5,y);
            MaestroG.subscripter("  =  "+temp2,"","",g,state.font12,x+dxx+state.s40,y);
            y+= dyy;
            
            Complex prod;
            double prod2;
            prod = Complex.Multiply(new Complex(state.mu_r2,0.0),Complex.Multiply(Complex.Multiply(state.singeom2,state.singeom2),state.epsilon_complex));
            prod2 = Math.sin(state.theta1)*Math.sin(state.theta1)*state.mu_r1*state.epsilon_r1;
	    
            temp3 = MaestroA.rounder(Complex.Real(prod),6);
	    temp4 = MaestroA.rounder(Complex.Imaginary(prod),6);
	    temp2 = new Complex(temp3,temp4);
	    
            MaestroG.subsubsubsubsub2("sin\u00b2","(\u03b8","t",") \u03bc","r2","\u03b5","r2c","","","","","",g,state.font13,x+dxx-state.s5,y);
            MaestroG.subsubsubsubsub2("=  sin\u00b2","(\u03b8","i",") \u03bc","r1","\u03b5","r1","","","","","",g,state.font13,x+dxx+state.s95,y);            
            MaestroG.subscripter(" =  "+MaestroA.rounder(prod2,5),"","",g,state.font12,x+dxx+state.s200,y);
            y+= dy;     
            //------------------------------------------------------------------
	    g.setFont(normalfont);
            
            g.drawLine(state.s5,y,getSize().width-state.s5,y); 
	    y += dy;
	    
            g.setColor(Color.blue.darker());
	    g.drawString("Medium 2",x+state.s200+state.s30,y);
	    //y+= dy;
            
            g.setColor(Color.red.darker());
	    g.drawString("Complex Permittivity",x+dxx-state.s5,y);
	    g.setColor(Color.black);
	    temp3 = MaestroA.rounder(Complex.Real(state.epsilon_complex),6);
	    temp4 = MaestroA.rounder(Complex.Imaginary(state.epsilon_complex),6);
	    temp2 = new Complex(temp3,temp4);
	    
            y+= dy;
	    MaestroG.subsub("\u03b5","r2c"," = ("+temp2+") \u03b5","0"," F/m",g,state.font12,x+dxx-state.s5,y);
            y+= dyy;
    	    //------------------------------------------------------------------
            g.setColor(Color.red.darker());
	    g.setFont(normalfont);
            g.drawString("Effective Attenuation (z-direction)",x+dxx-state.s5,y);
	    g.setColor(Color.black);
	    
            y+= dy;
	    
            g.setFont(symbfont);
            MaestroG.SerifSymbFirst("\u03b1","","",g,state.font14,x+dxx-state.s5,y);
            g.setFont(normalfont2);
            g.drawString("=  "+MaestroA.rounder(state.pwave,6)+" [ Ne/m ]",x+dxx+state.s7,y);
            
            y+= dyy;
    	    //------------------------------------------------------------------
            g.setColor(Color.red.darker());
	    g.setFont(normalfont);
            g.drawString("Bulk attenuation",x+dxx-state.s5,y);
            g.setColor(Color.black);
	    
            y+= dy;
	    
            g.setFont(symbfont);
            MaestroG.SerifSymbFirst("\u03b1","","",g,state.font14,x+dxx-state.s5,y);
            g.setFont(normalfont2);
            g.drawString("=  "+MaestroA.rounder(state.alpha2,6)+" [ Ne/m ]",x+dxx+state.s7,y);
            //------------------------------------------------------------------
	    y += dyy;
	    
            g.setColor(Color.red.darker());
	    
	    y+= dy;
	}
}

class ObliqueOutputCanvasC 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 subfont    = new Font("Sanserif",Font.PLAIN,10);
	private static final Font titlefont  =new Font("Sanserif",Font.BOLD,16);
	private static final Font symbfont = new Font("Serif",Font.PLAIN,13);
	Oblique_State state;
	private Image im;
	private Graphics buf;

	public ObliqueOutputCanvasC(Oblique_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){
            Font normalfont  = new Font("Sanserif",Font.PLAIN,state.font11);
            Font normalfont2 = new Font("Sanserif",Font.PLAIN,state.font12);
            Font subfont     = new Font("Sanserif",Font.PLAIN,state.font10);
            Font titlefont   = new Font("Sanserif",Font.BOLD,state.font16);
            Font symbfont    = new Font("Serif",Font.PLAIN,state.font13);
            
            Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            
	    int x, x2, x3, x4, y, dx, dxx, dy, dyy;
	    Complex temp1, temp2;
	    double temp3, temp4, temp5, ratioZ, test1, test2, test3, factor1;
	    FontMetrics fm;
	    
            x = state.s5;
            x3 = state.s10;
            x4 = state.s35;
            x2 = state.s200+state.s30;
            y = state.s25;
	    dx = state.s80;
	    dxx = state.s15;
            
	    g.clearRect(0,0,getSize().width,getSize().height);
	    int fonto = state.font11;
            
	    g.setFont(normalfont2);
	    fm = g.getFontMetrics();
	    dy = state.s13;
	    dyy = dy+state.s4;
	    
            double radiusH = state.s6;
            double xpos = x+state.s10;
            double ypos2 = y+dy;
            double xpos2 = x+state.s10;
            double ypos = y+dy;
            
            y+=dy+state.s5;
	    
	    if(state.isPolarizationParallel){
                g.setColor(Color.blue);
                g.setFont(normalfont2);
                fm = g.getFontMetrics();
                g.drawString("Parallel Polarization ( TM )",x4,y);
                y+= dyy;
                
                double R1, R2;
                Complex R3;
                R1 = MaestroA.rounder(Complex.Real(state.Reflection_CoefH),6);
                R2 = MaestroA.rounder(Complex.Imaginary(state.Reflection_CoefH),6);
                R3 = new Complex(R1,R2);
                    
                double T1, T2;
                Complex T3;
                T1 = MaestroA.rounder(Complex.Real(state.Transmission_CoefH),6);
                T2 = MaestroA.rounder(Complex.Imaginary(state.Transmission_CoefH),6);
                T3 = new Complex(T1,T2);
                
                double RE1, RE2;
                Complex RE3;
                RE1 = MaestroA.rounder(Complex.Real(state.Reflection_Coef),6);
                RE2 = MaestroA.rounder(Complex.Imaginary(state.Reflection_Coef),6);
                RE3 = new Complex(RE1,RE2);
                    
                double TE1, TE2;
                Complex TE3;
                TE1 = MaestroA.rounder(Complex.Real(state.Transmission_Coef),6);
                TE2 = MaestroA.rounder(Complex.Imaginary(state.Transmission_Coef),6);
                TE3 = new Complex(TE1,TE2);
                
                if(state.IsVectorIn){
                    //MaestroG.fillCircleThick(g, xpos2, ypos2, radiusH, state.s2, Color.white);
                    //MaestroG.drawLineThick(g, xpos2-(double)(radiusH/2), ypos2-(double)(radiusH/2),
                    //                xpos2 + (double)(radiusH/2), ypos2 + (double)(radiusH/2), state.s1, Color.blue);
                    //MaestroG.drawLineThick(g, xpos2+(double)(radiusH/2),
                    //                ypos2-(double)(radiusH/2),
                    //                xpos2 - (double)(radiusH/2),
                    //                ypos2 + (double)(radiusH/2), state.s1,Color.blue);
                    //MaestroG.drawCircleThick(g, xpos2, ypos2, radiusH, state.s2, Color.blue);
                    
                    MaestroG.fillCircleThick(g, xpos, ypos, radiusH+state.s1, state.s2, Color.blue);
                    MaestroG.fillCircleThick(g, xpos, ypos, radiusH, state.s2, Color.white);
                    MaestroG.drawLineThick(g, xpos2-(double)(radiusH/2), ypos2-(double)(radiusH/2),
                                    xpos2 + (double)(radiusH/2), ypos2 + (double)(radiusH/2), state.s1, Color.blue);
                    MaestroG.drawLineThick(g, xpos2+(double)(radiusH/2),
                                    ypos2-(double)(radiusH/2),
                                    xpos2 - (double)(radiusH/2),
                                    ypos2 + (double)(radiusH/2), state.s1,Color.blue);           
                    
                    g.setColor(Color.black);
                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            
                    MaestroG.subsubsub("Incident Wave","","","","","","",g,state.font12,x3,y);
                    y+= dyy;
                    g.setColor(Color.blue);
                    MaestroG.subsubsubUn3("","H","y"," = - H","0"," y","^","  A/m",g,fonto,x3,y);
                    y+= dyy;
                    
                    g.setColor(Color.magenta.darker());
                    
                    MaestroG.subsubsubUn3("","E","x"," = "+MaestroA.rounder((-1.0)*Complex.Real(state.wave_impedance1)*Math.cos(state.theta1),6)+" H","0"," x","^","  V/m",g,fonto,x3,y);
                    y+= dyy;
                    MaestroG.subsubsubUn3("","E","z"," = "+MaestroA.rounder(Complex.Real(state.wave_impedance1)*Math.sin(state.theta1),6)+" H","0"," z","^","  V/m",g,fonto,x3,y);
                    
                    y+= dyy+state.s5;
                    
                    g.setColor(Color.black);
                    MaestroG.subsubsub("Reflected Wave","","","","","","",g,state.font12,x3,y);
                    y+= dyy;
                   
                    g.setColor(Color.blue);
                    MaestroG.subsubsubUn3("","H","y"," = ( "+Complex.Multiply(R3,new Complex(-1.0,0.0))+" ) H","0"," y","^","  A/m",g,fonto,x3,y);
                    
                    y+= dyy;
                    
                    g.setColor(Color.magenta.darker());
                        
                    String tmpx, tmpz;
                    Complex Ctempx, Ctempz;
                    Ctempz = Complex.Multiply(Complex.Multiply(Math.cos(state.theta1),RE3),state.wave_impedance1);
                    Ctempx = Complex.Multiply(Complex.Multiply(Math.sin(state.theta1),RE3),state.wave_impedance1);
                        
                    if(Ctempz.Imaginary()>=0.0){
                        tmpz = String.valueOf(MaestroA.rounder((-1.0)*Ctempz.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }
                    else {
                        tmpz = String.valueOf(MaestroA.rounder((-1.0)*Ctempz.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }
                        
                    MaestroG.subsubsubUn3("","E","x"," = ( "+tmpz+" ) H","0"," x","^","  V/m",g,fonto,x3,y);
                        
                    y+= dyy;
                    if(Ctempx.Imaginary()>=0.0){
                        tmpx = String.valueOf(MaestroA.rounder((-1.0)*Ctempx.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    else {
                        tmpx = String.valueOf(MaestroA.rounder((-1.0)*Ctempx.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    MaestroG.subsubsubUn3("","E","z"," = ( "+tmpx+" ) H","0"," z","^","  V/m",g,fonto,x3,y); 
                    
                    y+= dyy+state.s5;
                    
                    g.setColor(Color.black);
                    MaestroG.subsubsub("Transmitted Wave","","","","","","",g,state.font12,x3,y);
                    y+= dyy;
                        
                    g.setColor(Color.blue);
                    MaestroG.subsubsubUn3("","H","y"," = ( "+Complex.Multiply(T3,new Complex(-1.0,0.0))+" ) H","0"," y","^","  A/m",g,fonto,x3,y);
                    
                    y+= dyy;
                    
                    g.setColor(Color.magenta.darker());
                    
                    Ctempz = Complex.Multiply(Complex.Multiply(state.cosgeom2,TE3),state.wave_impedance1);
                    Ctempx = Complex.Multiply((-1.0),Complex.Multiply(Complex.Multiply(state.singeom2,TE3),state.wave_impedance1));
                    //Ctempx = Complex.Multiply(state.epsilon_complex,Complex.Multiply((-1.0),Complex.Multiply(Complex.Multiply(state.singeom2,TE3),state.wave_impedance1)));
                    //System.out.println(Complex.Multiply(state.singeom2,TE3)+"   singeom2 ="+state.singeom2+"   TE3 = "+TE3);
                    if(Ctempz.Imaginary()>=0.0){
                        tmpz = String.valueOf(MaestroA.rounder((-1.0)*Ctempz.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }
                    else {
                        tmpz = String.valueOf(MaestroA.rounder((-1.0)*Ctempz.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }

                    MaestroG.subsubsubUn3("","E","x"," = ( "+tmpz+" ) H","0"," x","^","  V/m",g,fonto,x3,y);

                    y+= dyy;

                    if(Ctempx.Imaginary()>=0.0){
                        tmpx = String.valueOf(MaestroA.rounder((-1.0)*Ctempx.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    else {
                        tmpx = String.valueOf(MaestroA.rounder((-1.0)*Ctempx.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    MaestroG.subsubsubUn3("","E","z"," = ( "+tmpx+" ) H","0"," z","^","  V/m",g,fonto,x3,y);     
                }
                else{// flip incident direction
                    MaestroG.fillCircleThick(g, xpos, ypos, radiusH+state.s1, state.s2, Color.blue);
                    MaestroG.fillCircleThick(g, xpos, ypos, radiusH, state.s2, Color.white);
                    MaestroG.fillCircleThick(g, xpos, ypos, state.s2, state.s2, Color.blue);
                    
                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            
                    g.setColor(Color.black);
                    MaestroG.subsubsub("Incident Wave","","","","","","",g,state.font12,x3,y);
                    y+= dyy;
                    g.setColor(Color.blue);
                    MaestroG.subsubsubUn3("","H","y"," = H","0"," y","^","  A/m",g,fonto,x3,y);
                    y+= dyy;
                    
                    g.setColor(Color.magenta.darker());
                    MaestroG.subsubsubUn3("","E","x"," = "+MaestroA.rounder(Complex.Real(state.wave_impedance1)*Math.cos(state.theta1),6)+" H","0"," x","^","  V/m",g,fonto,x3,y);
                    y+= dyy;
                    MaestroG.subsubsubUn3("","E","z"," = "+MaestroA.rounder((-1.0)*Complex.Real(state.wave_impedance1)*Math.sin(state.theta1),6)+" H","0"," z","^","  V/m",g,fonto,x3,y);
                    
                    y+= dyy+state.s5;
                    
                    g.setColor(Color.black);
                    MaestroG.subsubsub("Reflected Wave","","","","","","",g,state.font12,x3,y);
                    y+= dyy;
                    
                    g.setColor(Color.blue);
                    MaestroG.subsubsubUn3("","H","y"," = ( "+R3+" ) H","0"," y","^","  A/m",g,fonto,x3,y);
                    y+= dyy;
                    
                    g.setColor(Color.magenta.darker());
                    String tmpx, tmpz;
                    Complex Ctempx, Ctempz;
                    Ctempz = Complex.Multiply(Complex.Multiply(Math.cos(state.theta1),RE3),state.wave_impedance1);
                    Ctempx = Complex.Multiply(Complex.Multiply(Math.sin(state.theta1),RE3),state.wave_impedance1);
                    if(Ctempz.Imaginary()>=0.0){
                        tmpz = String.valueOf(MaestroA.rounder(Ctempz.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }
                    else {
                        tmpz = String.valueOf(MaestroA.rounder(Ctempz.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }
                    MaestroG.subsubsubUn3("","E","x"," = ( "+tmpz+" ) H","0"," x","^","  V/m",g,fonto,x3,y);
                    y+= dyy;
                    if(Ctempx.Imaginary()>=0.0){
                        tmpx = String.valueOf(MaestroA.rounder(Ctempx.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    else {
                        tmpx = String.valueOf(MaestroA.rounder(Ctempx.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    MaestroG.subsubsubUn3("","E","z"," = ( "+tmpx+" ) H","0"," z","^","  V/m",g,fonto,x3,y); 
                    
                    y+= dyy+state.s5;
                    g.setColor(Color.black);
                    MaestroG.subsubsub("Transmitted Wave","","","","","","",g,state.font12,x3,y);
                    y+= dyy;
                    
                    g.setColor(Color.blue);
                    MaestroG.subsubsubUn3("","H","y"," = ( "+T3+" ) H","0"," y","^","  A/m",g,fonto,x3,y);
                    
                    y+= dyy;
                    g.setColor(Color.magenta.darker());
                    Ctempz = Complex.Multiply(Complex.Multiply(state.cosgeom2,TE3),state.wave_impedance1);
                    Ctempx = Complex.Multiply((-1.0),Complex.Multiply(Complex.Multiply(state.singeom2,TE3),state.wave_impedance1));
                    if(Ctempz.Imaginary()>=0.0){
                        tmpz = String.valueOf(MaestroA.rounder(Ctempz.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }
                    else {
                        tmpz = String.valueOf(MaestroA.rounder(Ctempz.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }
                    MaestroG.subsubsubUn3("","E","x"," = ( "+tmpz+" ) H","0"," x","^","  V/m",g,fonto,x3,y);
                    y+= dyy;
                    if(Ctempx.Imaginary()>=0.0){
                        tmpx = String.valueOf(MaestroA.rounder(Ctempx.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    else {
                        tmpx = String.valueOf(MaestroA.rounder(Ctempx.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    MaestroG.subsubsubUn3("","E","z"," = ( "+tmpx+" ) H","0"," z","^","  V/m",g,fonto,x3,y); 
                    
                }
            }
            else{
                g.setColor(Color.magenta.darker());
                g.drawString("Perpendicular Polarization ( TE )",x4,y);
                y+= dyy;
                g.setFont(normalfont);
                fm = g.getFontMetrics();
                
                double R1, R2;
                Complex R3;
                R1 = MaestroA.rounder(Complex.Real(state.Reflection_Coef),6);
                R2 = MaestroA.rounder(Complex.Imaginary(state.Reflection_Coef),6);
                R3 = new Complex(R1,R2);
                    
                double T1, T2;
                Complex T3;
                T1 = MaestroA.rounder(Complex.Real(state.Transmission_Coef),6);
                T2 = MaestroA.rounder(Complex.Imaginary(state.Transmission_Coef),6);
                T3 = new Complex(T1,T2);
                
                double RE1, RE2;
                Complex RE3;
                RE1 = MaestroA.rounder(Complex.Real(state.Reflection_CoefH),6);
                RE2 = MaestroA.rounder(Complex.Imaginary(state.Reflection_CoefH),6);
                RE3 = new Complex(RE1,RE2);
                    
                double TE1, TE2;
                Complex TE3;
                TE1 = MaestroA.rounder(Complex.Real(state.Transmission_CoefH),6);
                TE2 = MaestroA.rounder(Complex.Imaginary(state.Transmission_CoefH),6);
                TE3 = new Complex(TE1,TE2);
                
                if(state.IsVectorIn){
                    MaestroG.fillCircleThick(g, xpos, ypos, radiusH+state.s1, state.s2, Color.magenta.darker());
                    MaestroG.fillCircleThick(g, xpos, ypos, radiusH, state.s2, Color.white);
                    
                    //MaestroG.fillCircleThick(g, xpos2, ypos2, radiusH, state.s2, Color.white);
                    MaestroG.drawLineThick(g, xpos2-(double)(radiusH/2), ypos2-(double)(radiusH/2),
                                    xpos2 + (double)(radiusH/2), ypos2 + (double)(radiusH/2), state.s1, Color.magenta.darker());
                    MaestroG.drawLineThick(g, xpos2+(double)(radiusH/2),
                                    ypos2-(double)(radiusH/2),
                                    xpos2 - (double)(radiusH/2),
                                    ypos2 + (double)(radiusH/2), state.s1,Color.magenta.darker());           
                    //MaestroG.drawCircleThick(g, xpos2, ypos2, radiusH, state.s2, Color.magenta.darker());
                    
                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            
                    g.setColor(Color.black);
                    g.setColor(Color.black);
                    MaestroG.subsubsub("Incident Wave","","","","","","",g,state.font12,x3,y);
                    y+= dyy;
                    g.setColor(Color.magenta.darker());
                    MaestroG.subsubsubUn3("","E","y"," = - E","0"," y","^","  V/m",g,fonto,x3,y);
                    y+= dyy;
                    g.setColor(Color.blue);
                    MaestroG.subsubsubUn3("","H","x"," = "+MaestroA.rounder(1.0/Complex.Real(state.wave_impedance1)*Math.cos(state.theta1),6)+" E","0"," x","^","  A/m",g,fonto,x3,y);
                    y+= dyy;
                    MaestroG.subsubsubUn3("","H","z"," = "+MaestroA.rounder((-1.0)/Complex.Real(state.wave_impedance1)*Math.sin(state.theta1),6)+" E","0"," z","^","  A/m",g,fonto,x3,y);
                    
                    y+= dyy+state.s5;
                    g.setColor(Color.black);
                    MaestroG.subsubsub("Reflected Wave","","","","","","",g,state.font12,x3,y);
                    y+= dyy;
                    g.setColor(Color.magenta.darker());
                    MaestroG.subsubsubUn3("","E","y"," = ( "+Complex.Multiply(R3,new Complex(-1.0,0.0))+" ) E","0"," y","^","  V/m",g,fonto,x3,y);                        
                    
                    y+= dyy;
                    g.setColor(Color.blue);
                    
                    String tmpx, tmpz;
                    Complex Ctempx, Ctempz;
                    Ctempz = Complex.Divide(Complex.Multiply(Math.cos(state.theta1),RE3),state.wave_impedance1);
                    Ctempx = Complex.Divide(Complex.Multiply(Math.sin(state.theta1),RE3),state.wave_impedance1);
                    if(Ctempz.Imaginary()>=0.0){
                        tmpz = String.valueOf(MaestroA.rounder(Ctempz.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }
                    else {
                        tmpz = String.valueOf(MaestroA.rounder(Ctempz.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }
                    MaestroG.subsubsubUn3("","H","x"," = ( "+tmpz+" ) E","0"," x","^","  A/m",g,fonto,x3,y);
                    y+= dyy;
                    if(Ctempx.Imaginary()>=0.0){
                        tmpx = String.valueOf(MaestroA.rounder(Ctempx.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    else {
                        tmpx = String.valueOf(MaestroA.rounder(Ctempx.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    MaestroG.subsubsubUn3("","H","z"," = ( "+tmpx+" ) E","0"," z","^","  A/m",g,fonto,x3,y); 
                    y+= dyy+state.s5;
                    
                    g.setColor(Color.black);
                    MaestroG.subsubsub("Transmitted Wave","","","","","","",g,state.font12,x3,y);
                    y+= dyy;
                    
                    g.setColor(Color.magenta.darker());
                    MaestroG.subsubsubUn3("","E","y"," = ( "+Complex.Multiply(T3,new Complex(-1.0,0.0))+" ) E","0"," y","^","  V/m",g,fonto,x3,y);
                    y+= dyy;                    
                    g.setColor(Color.blue);
                        
                    Ctempz = Complex.Divide(Complex.Multiply(state.cosgeom2,TE3),state.wave_impedance1);
                    Ctempx = Complex.Multiply((-1.0),Complex.Divide(Complex.Multiply(state.singeom2,TE3),state.wave_impedance1));

                    if(Ctempz.Imaginary()>=0.0){
                        tmpz = String.valueOf(MaestroA.rounder(Ctempz.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }
                    else {
                        tmpz = String.valueOf(MaestroA.rounder(Ctempz.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }

                    MaestroG.subsubsubUn3("","H","x"," = ( "+tmpz+" ) E","0"," x","^","  A/m",g,fonto,x3,y);

                    y+= dyy;
                    if(Ctempx.Imaginary()>=0.0){
                        tmpx = String.valueOf(MaestroA.rounder(Ctempx.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    else {
                        tmpx = String.valueOf(MaestroA.rounder(Ctempx.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    MaestroG.subsubsubUn3("","H","z"," = ( "+tmpx+" ) E","0"," z","^","  A/m",g,fonto,x3,y); 
                }
                else{// flip incident direction
                    MaestroG.fillCircleThick(g, xpos, ypos, radiusH+state.s1, state.s2, Color.magenta.darker());
                    MaestroG.fillCircleThick(g, xpos, ypos, radiusH, state.s2, Color.white);
                    MaestroG.fillCircleThick(g, xpos, ypos, state.s2, state.s2, Color.magenta.darker());
                    
                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            
                    g.setColor(Color.black);
                     
                    MaestroG.subsubsub("Incident Wave","","","","","","",g,state.font12,x3,y);
                    y+= dyy;
                    g.setColor(Color.magenta.darker());
                    MaestroG.subsubsubUn3("","E","y"," = E","0"," y","^","  V/m",g,fonto,x3,y);
                    y+= dyy;
                    g.setColor(Color.blue);
                    MaestroG.subsubsubUn3("","H","x"," = "+MaestroA.rounder((-1.0)/Complex.Real(state.wave_impedance1)*Math.cos(state.theta1),6)+" E","0"," x","^","  A/m",g,fonto,x3,y);
                    y+= dyy;
                    MaestroG.subsubsubUn3("","H","z"," = "+MaestroA.rounder(1.0/Complex.Real(state.wave_impedance1)*Math.sin(state.theta1),6)+" E","0"," z","^","  A/m",g,fonto,x3,y);
                    
                    y+= dyy+state.s5;
                    
                    g.setColor(Color.black);
                    MaestroG.subsubsub("Reflected Wave","","","","","","",g,state.font12,x3,y);
                    y+= dyy;
                        
                    g.setColor(Color.magenta.darker());
                    MaestroG.subsubsubUn3("","E","y"," = ( "+R3+" ) E","0"," y","^","  V/m",g,fonto,x3,y);
                    
                    y+= dyy;
                    g.setColor(Color.blue);
                    String tmpx, tmpz;
                    Complex Ctempx, Ctempz;
                    Ctempz = Complex.Divide(Complex.Multiply(Math.cos(state.theta1),RE3),state.wave_impedance1);
                    Ctempx = Complex.Multiply((-1.0),Complex.Divide(Complex.Multiply(Math.sin(state.theta1),RE3),state.wave_impedance1));

                    if(Ctempz.Imaginary()>=0.0){
                        tmpz = String.valueOf(MaestroA.rounder((-1.0)*Ctempz.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }
                    else {
                        tmpz = String.valueOf(MaestroA.rounder((-1.0)*Ctempz.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }

                    MaestroG.subsubsubUn3("","H","x"," = ( "+tmpz+" ) E","0"," x","^","  A/m",g,fonto,x3,y);
                    y+= dyy;
                    if(Ctempx.Imaginary()>=0.0){
                        tmpx = String.valueOf(MaestroA.rounder((-1.0)*Ctempx.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    else {
                        tmpx = String.valueOf(MaestroA.rounder((-1.0)*Ctempx.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    MaestroG.subsubsubUn3("","H","z"," = ( "+tmpx+" ) E","0"," z","^","  A/m",g,fonto,x3,y); 
                    
                    y+= dyy+state.s5;
                    
                    g.setColor(Color.black);
                    MaestroG.subsubsub("Transmitted Wave","","","","","","",g,state.font12,x3,y);
                    y+= dyy;
                    g.setColor(Color.magenta.darker());
                    MaestroG.subsubsubUn3("","E","y"," = ( "+T3+" ) E","0"," y","^","  V/m",g,fonto,x3,y);
                    y+= dyy;
                    g.setColor(Color.blue);
                    
                    Ctempz = Complex.Divide(Complex.Multiply(state.cosgeom2,TE3),state.wave_impedance1);
                    Ctempx = Complex.Multiply((-1.0),Complex.Divide(Complex.Multiply(state.singeom2,TE3),state.wave_impedance1));

                    if(Ctempz.Imaginary()>=0.0){
                        tmpz = String.valueOf(MaestroA.rounder((-1.0)*Ctempz.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }
                    else {
                        tmpz = String.valueOf(MaestroA.rounder((-1.0)*Ctempz.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempz.Imaginary()),6));
                    }

                    MaestroG.subsubsubUn3("","H","x"," = ( "+tmpz+" ) E","0"," x","^","  A/m",g,fonto,x3,y);


                    y+= dyy;
                    if(Ctempx.Imaginary()>=0.0){
                        tmpx = String.valueOf(MaestroA.rounder((-1.0)*Ctempx.Real(),6))+" - j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }
                    else {
                        tmpx = String.valueOf(MaestroA.rounder((-1.0)*Ctempx.Real(),6))+" + j "+String.valueOf(MaestroA.rounder(Math.abs(Ctempx.Imaginary()),6));
                    }

                    MaestroG.subsubsubUn3("","H","z"," = ( "+tmpx+" ) E","0"," z","^","  A/m",g,fonto,x3,y);    
                }
            }
	}
}