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

public class ObliqueOutputPanelB extends Panel implements AdjustmentListener{
	Oblique_State state;
	private static final Color bgcolor = Color.white;
	private static final Font labfont=new Font("Sanserif",Font.PLAIN,12);
	private static final Font titlefont=new Font("Sanserif",Font.BOLD,16);
	Label titlelabel, vlabLength;
	private Complex temp;	
        public Choice c1;
	
        public Label Tlabel;
        public ObliqueOutputCanvasD pwocD;
        public ObliqueOutputCanvasE pwocE;
        public ObliqueOutputCanvasF pwocF;
        
        public Scrollbar sliderLength, sliderLength2, sliderT;
        public Panel pT;
        
        public Button Instructions;
        public Button Propagation;
        public Button Dispersion;
        
        public ObliqueOutputPanelB(Oblique_State state){
	    super();
            setLayout(null);
	    setBackground(bgcolor);
	    this.state = state;
            //titlelabel.setForeground(Color.blue.darker());
	    //titlelabel = new Label("",Label.CENTER);
	    //add(titlelabel);
	    //titlelabel.setBounds(15,15,220,35);  
            //titlelabel.setBounds(1,1,150,25);  
	    //titlelabel.setFont(titlefont);
            
            Instructions = new Button("Instructions");
            Instructions.setBackground(new Color(240,240,255));
            add(Instructions);
            int buttonx = 1080;
            int buttony = 272;
            int buttonwide = 100;
            int buttonheight = 27;
            
            Instructions.setBounds(buttonx,buttony,buttonwide,buttonheight);	
            Panel ps7 = new Panel();
                ps7.setBackground(Color.lightGray);
                add(ps7);
                ps7.setBounds(buttonx-1,buttony-1,buttonwide+2,buttonheight+2);
	    
            Panel ps8 = new Panel();
                ps8.setBackground(Color.black);
                add(ps8);
                ps8.setBounds(buttonx-2,buttony-2,buttonwide+4,buttonheight+4);	
            
            sliderT = new Scrollbar(Scrollbar.HORIZONTAL,20,1,5,21);
            sliderT.setBackground(Color.white);
            add(sliderT);
            sliderT.setBounds(715,100,200,15);
            pT = new Panel();
                pT.setBackground(Color.black);
                add(pT);
                pT.setBounds(714,99,202,17);
           sliderT.setVisible(false);
           pT.setVisible(false);
           
           Tlabel = new Label("T = "+MaestroA.rounder(state.T_factor/3.0,2)+" \u03c4",Label.CENTER);
           add(Tlabel); 
           Tlabel.setBounds(715,83,200,15);
           Tlabel.setFont(titlefont);
           Tlabel.setVisible(false);
           
            Propagation = new Button("GO TO  >>  Propagation Properties");
            Propagation.setBackground(new Color(240,240,255));
            add(Propagation);
            
            Dispersion = new Button("GO TO  >>  Modal Dispersion");
            Dispersion.setBackground(new Color(240,240,255));
            add(Dispersion);
            
            buttonx = 730;
            buttony = 272;
            buttonwide = 250;
            buttonheight = 27;
            
            Propagation.setBounds(buttonx,buttony,buttonwide,buttonheight);
            Dispersion.setBounds(buttonx,buttony,buttonwide,buttonheight);
            
            Panel p8 = new Panel();
                p8.setBackground(Color.lightGray);
                add(p8);
                p8.setBounds(buttonx-1,buttony-1,buttonwide+2,buttonheight+2);
	    
            Panel p9 = new Panel();
                p9.setBackground(Color.black);
                add(p9);
                p9.setBounds(buttonx-2,buttony-2,buttonwide+4,buttonheight+4);	
        
            Propagation.setVisible(false);
            Dispersion.setVisible(true);
                
            pwocD = new ObliqueOutputCanvasD(state);
	    add(pwocD);
            
            pwocE = new ObliqueOutputCanvasE(state);
	    add(pwocE);
            
            pwocF = new ObliqueOutputCanvasF(state);
	    add(pwocF);
            
            pwocE.setBounds(5,70,290,241);
            pwocF.setBounds(300,4,909,307);
            pwocD.setBounds(1,1,1212,270);
            
            pwocE.setVisible(false);
            pwocF.setVisible(false);
            pwocD.setVisible(true);
            
            pwocD.setBackground(Color.white);
            pwocE.setBackground(Color.white);
            pwocF.setBackground(Color.white);
            
            vlabLength = new Label("Fiber Length = "+state.fiber_length+" km",Label.LEFT);
            
	    sliderLength = new Scrollbar(Scrollbar.HORIZONTAL,1,1,0,51);
            sliderLength.setBackground(Color.white);
            add(sliderLength);
            
            sliderLength2 = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,1000);
            sliderLength2.setBackground(Color.white);
            add(sliderLength2);
            int xs1 = 20; int ys0 = 5; int ys1 = 25; int ys2 = 45;
            vlabLength.setBounds(xs1,ys0,200,15);
            sliderLength.setBounds(xs1,ys1,260,15);
            sliderLength2.setBounds(xs1,ys2,260,15);
            add(vlabLength); add(sliderLength); add(sliderLength2);
        
            Panel pslider2 = new Panel();
                pslider2.setBackground(Color.cyan);
                add(pslider2);
                pslider2.setBounds(xs1-1,ys1-1,262,17);

            Panel pslider1 = new Panel();
                pslider1.setBackground(Color.black);
                add(pslider1);
                pslider1.setBounds(xs1-2,ys1-2,264,19);

            Panel pslider4 = new Panel();
                pslider4.setBackground(Color.cyan);
                add(pslider4);
                pslider4.setBounds(xs1-1,ys2-1,262,17);

            Panel pslider3 = new Panel();
                pslider3.setBackground(Color.black);
                add(pslider3);
                pslider3.setBounds(xs1-2,ys2-2,264,19);

            //Listeners
	    sliderLength.addAdjustmentListener(this);	
            sliderLength2.addAdjustmentListener(this);
            sliderT.addAdjustmentListener(this);
            
            
	}
	public void paint(Graphics g){
	    //g.draw3DRect(0,0,getSize().width-1,getSize().height-1,false);  
	}
        
        public void adjustmentValueChanged(AdjustmentEvent evt){
            if(evt.getSource()==sliderLength || evt.getSource()==sliderLength2){
                    state.fiber_length = sliderLength.getValue()+sliderLength2.getValue()*0.001;
                    vlabLength.setText("Fiber Length = "+Math.abs((MaestroA.rounder(sliderLength.getValue()+MaestroA.rounder((sliderLength2.getValue())*0.001,3),6)))+" km ");
                    state.ignition();
                    pwocE.repaint();
                    pwocF.repaint();
            }
            if(evt.getSource()==sliderT){
                    state.T_factor = sliderT.getValue()*0.3;
                    //vlabLength.setText("Fiber Length = "+Math.abs((MaestroA.rounder(sliderLength.getValue()+MaestroA.rounder((sliderLength2.getValue())*0.001,3),6)))+" km ");
                    Tlabel.setText("T = "+MaestroA.rounder(state.T_factor/3.0,2)+" \u03c4");
                    state.ignition();
                    pwocE.repaint();
                    pwocF.repaint();
                    //System.out.println(state.T_factor+"   "+sliderT.getValue());
            }
	}

   	
}//ObliqueOutputPanel.java

class ObliqueOutputCanvasE 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 static int prec1 = 6;
        public static int prec2 = 6;

	public ObliqueOutputCanvasE(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){
	    int x, x2, x3, x4, x5, xshift, y, ystart, dx, dxx, dy, dyy;
	    FontMetrics fm;
	    x = 10;
            x2 = 110;
            x3 = 570;
            x4 = 720;
            x5 = 900;
	    ystart = 50;
            y = ystart;
	    dx = 80;
	    dxx = 15;
            xshift = 20;
	    g.clearRect(0,0,getSize().width,getSize().height);
	    String unit;
            
            unit = "\u03bcm";
            int fonto = 12;
	    g.setFont(titlefont);
            g.setColor(Color.red.darker());
	    g.drawRect(0,0,getSize().width-1,getSize().height-1);
	    g.setFont(normalfont2);
	    fm = g.getFontMetrics();
	    dy = 25;//fm.getHeight()-1;
	    dyy = dy+5;
	    
            Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            
            y = ystart;
            
	    g.setColor(Color.black);
            MaestroG.subscripterB("Axial Ray","","",g,13,x,y);
            MaestroG.subscripterBSym("\u03b8","2min"," = 0.0\u00ba",g,14,x2,y);
            y += dy;
            g.setColor(Color.blue.darker());
            MaestroG.subscripter("Path Length","","",g,14,x,y);
            MaestroG.subscripterSymFirst2I("l","min"," = "+MaestroA.rounder(state.fiber_length,3)+" [km]",g,14,x+100,y);
            
            y += dy;
            g.setColor(Color.black);
            MaestroG.subscripterB("Slowest Ray","","",g,13,x,y);
            //MaestroG.subscripterBSym("\u03b8","i max"," = "+MaestroA.rounder(state.theta_range,4)+"\u00ba",g,13,x,y);
            MaestroG.subscripterBSym("\u03b8","2max"," = "+MaestroA.rounder(90.0 - state.totalRclad_angle,4)+"\u00ba",g,14,x2,y);
            y += dy;
            g.setColor(Color.blue.darker());
            MaestroG.subscripter("Path Length","","",g,14,x,y);
            MaestroG.subscripterSymFirst2I("l","max"," = "+MaestroA.rounder(state.Lmax,6)+" [km]",g,14,x+100,y);
            
            y += dy;
            g.setColor(Color.black);
            MaestroG.subscripterB("Selected Ray","","",g,13,x,y);
            //MaestroG.subscripterBSym("\u03b8","i max"," = "+MaestroA.rounder(state.theta_range,4)+"\u00ba",g,13,x,y);
            MaestroG.subscripterBSym("\u03b8","2"," = "+Math.abs(MaestroA.rounder(state.theta2*180.0/Math.PI,4))+"\u00ba",g,14,x2,y);
            y += dy;
            g.setColor(Color.blue.darker());
            MaestroG.subscripter("Path Length","","",g,14,x,y);
            MaestroG.subscripterSymFirst2I("l",""," = "+MaestroA.rounder(state.Lray,6)+" [km]",g,14,x+100,y);
            
        }
        
        
            public void Write(Graphics g, double test, int fonto, String unit, 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.superscripterB("  =  0.0",""," "+unit,g,fonto,x,y);
	    }
            else if(test >= 1.0e-15 && test < 1.0e-14){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e15,5)+"  x  10","-15"," "+unit,g,fonto,x,y);
	    }
            else if(test >= 1.0e-14 && test < 1.0e-13){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e14,5)+"  x  10","-14"," "+unit,g,fonto,x,y);
	    }
            else if(test >= 1.0e-13 && test < 1.0e-12){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e13,5)+"  x  10","-13"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-12 && test < 1.0e-11){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e12,5)+"  x  10","-12"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-11 && test < 1.0e-10){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e11,5)+"  x  10","-11"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-10 && test < 1.0e-9){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e10,5)+"  x  10","-10"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-9 && test < 1.0e-8){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e9,5)+"  x  10","-9"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-8 && test < 1.0e-7){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e8,5)+"  x  10","-8"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-7 && test < 1.0e-6){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e7,5)+"  x  10","-7"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-6 && test < 1.0e-5){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e6,5)+"  x  10","-6"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-5 && test < 1.0e-4){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e5,5)+"  x  10","-5"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-4 && test < 1.0e-3){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e4,5)+"  x  10","-4"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-3 && test < 1.0e-2){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e3,5)+"  x  10","-3"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-2 && test < 1.0e-1){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e2,5)+"  x  10","-2"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-1 && test < 1.0){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e1,5)+"  x  10","-1"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0 && test < 1.0e1){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test,5)+"  ",""," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e1 && test < 1.0e2){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test,5)+"  ",""," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e2 && test < 1.0e3){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-2,5)+"  x  10","2"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e3 && test < 1.0e4){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-3,5)+"  x  10","3"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e4 && test < 1.0e5){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-4,5)+"  x  10","4"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e5 && test < 1.0e6){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-5,5)+"  x  10","5"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e6 && test < 1.0e7){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-6,5)+"  x  10","6"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e7 && test < 1.0e8){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-7,5)+"  x  10","7"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e8 && test < 1.0e9){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-8,5)+"  x  10","8"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e9 && test < 1.0e10){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-9,5)+"  x  10","9"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e10 && test < 1.0e11){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-10,5)+"  x  10","10"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e11 && test < 1.0e12){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-11,5)+"  x  10","11"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e12 && test < 1.0e13){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-12,5)+"  x  10","12"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e13 && test < 1.0e14){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-13,5)+"  x  10","13"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e14 && test < 1.0e15){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-14,5)+"  x  10","14"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e15 && test < 1.0e16){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-15,5)+"  x  10","15"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e16 && test < 1.0e17){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-16,5)+"  x  10","16"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e17 && test < 1.0e18){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-17,5)+"  x  10","17"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e18 && test < 1.0e19){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-18,5)+"  x  10","18"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e19 && test < 1.0e20){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-19,5)+"  x  10","19"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e20 && test < 1.0e21){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-20,5)+"  x  10","20"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e21){
		MaestroG.superscripterB("  =  "+test+"",""," "+unit,g,fonto,x,y);
	    }
            
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
        }
            
        public void Write2(Graphics g, double test, int fonto, String unit, 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.superscripterLambdaB("  =  0.0",""," ",""+unit,"2",g,fonto,x,y);
	    }
            else if(test >= 1.0e-15 && test < 1.0e-14){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e15,5)+"  x  10","-15"," ",""+unit,"f",g,fonto,x,y);
	    }
            else if(test >= 1.0e-14 && test < 1.0e-13){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e14,5)+"  x  10","-14"," ",""+unit,"f",g,fonto,x,y);
	    }
            else if(test >= 1.0e-13 && test < 1.0e-12){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e13,5)+"  x  10","-13"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-12 && test < 1.0e-11){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e12,5)+"  x  10","-12"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-11 && test < 1.0e-10){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e11,5)+"  x  10","-11"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-10 && test < 1.0e-9){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e10,5)+"  x  10","-10"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-9 && test < 1.0e-8){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e9,5)+"  x  10","-9"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-8 && test < 1.0e-7){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e8,5)+"  x  10","-8"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-7 && test < 1.0e-6){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e7,5)+"  x  10","-7"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-6 && test < 1.0e-5){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e6,5)+"  x  10","-6"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-5 && test < 1.0e-4){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e5,5)+"  x  10","-5"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-4 && test < 1.0e-3){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e4,5)+"  x  10","-4"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-3 && test < 1.0e-2){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e3,5)+"  x  10","-3"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-2 && test < 1.0e-1){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e2,5)+"  x  10","-2"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-1 && test < 1.0){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e1,5)+"  x  10","-1"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0 && test < 1.0e1){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test,5)+"  ",""," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e1 && test < 1.0e2){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test,5)+"  ",""," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e2 && test < 1.0e3){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-2,5)+"  x  10","2"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e3 && test < 1.0e4){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-3,5)+"  x  10","3"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e4 && test < 1.0e5){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-4,5)+"  x  10","4"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e5 && test < 1.0e6){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-5,5)+"  x  10","5"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e6 && test < 1.0e7){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-6,5)+"  x  10","6"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e7 && test < 1.0e8){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-7,5)+"  x  10","7"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e8 && test < 1.0e9){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-8,5)+"  x  10","8"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e9 && test < 1.0e10){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-9,5)+"  x  10","9"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e10 && test < 1.0e11){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-10,5)+"  x  10","10"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e11 && test < 1.0e12){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-11,5)+"  x  10","11"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e12 && test < 1.0e13){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-12,5)+"  x  10","12"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e13 && test < 1.0e14){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-13,5)+"  x  10","13"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e14 && test < 1.0e15){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-14,5)+"  x  10","14"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e15 && test < 1.0e16){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-15,5)+"  x  10","15"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e16 && test < 1.0e17){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-16,5)+"  x  10","16"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e17 && test < 1.0e18){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-17,5)+"  x  10","17"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e18 && test < 1.0e19){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-18,5)+"  x  10","18"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e19 && test < 1.0e20){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-19,5)+"  x  10","19"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e20 && test < 1.0e21){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-20,5)+"  x  10","20"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e21){
		MaestroG.superscripterLambdaB("  =  "+test+"",""," ",""+unit,"f",g,fonto,x,y);
	    }
            
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
        }

        public void WriteC(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 ObliqueOutputCanvasF 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 static int prec1 = 6;
        public static int prec2 = 6;
        
	public ObliqueOutputCanvasF(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){
	    int x, x2, x3, x4, y, dx, dxx, dy, dyy;
	    Complex temp1, temp2;
	    double temp3, temp4, temp5, ratioZ, test1, test2, test3, factor1;
	    int ystart;
            int fonto = 12;
            
            FontMetrics fm;
	    x = 15;
            x3 = 10;
            x4 = 35;
            x2 = 230;
	    y = 18;
	    dx = 80;
	    dxx = 15;
	    g.clearRect(0,0,getSize().width,getSize().height);
	    
            
            
            //------------------------------  DATA
	    g.setFont(titlefont);
            g.setColor(Color.blue.darker());
	    g.drawRect(0,0,getSize().width-1,getSize().height-1);
	    g.setFont(normalfont2);
	    fm = g.getFontMetrics();
	    dy = 20;//fm.getHeight()-1;
	    dyy = dy+4;
            
            ystart = 117;
            y = ystart;
	    dx = 80;
	    dxx = 15;
            g.clearRect(0,0,getSize().width,getSize().height);
	    String unit;
            
            unit = "\u03bcm";
            g.setFont(titlefont);
            g.setColor(Color.red.darker());
	    g.drawRect(0,0,getSize().width-1,getSize().height-1);
	    g.setFont(normalfont2);
	    fm = g.getFontMetrics();
	    dy = 25;//fm.getHeight()-1;
	    dyy = dy+5;
	    
            Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            
            g.setColor(Color.red);
            MaestroG.subscripterB("Modal","","",g,18,10,20);
            MaestroG.subscripterB("Dispersion","","",g,18,10,42);
            
            y = ystart;
            
	    g.setColor(Color.black);
            MaestroG.subscripterB("Axial Ray","","",g,13,x,y);
            
            y += dy;
            g.setColor(Color.blue.darker());
            MaestroG.subscripter("Travel Time","","",g,14,x,y);
            if(state.Travel_min >= 1.0e-3){
                MaestroG.subscripterSymFirst2I("t","min"," = "+MaestroA.rounder(state.Travel_min,6)+" [s]",g,14,x+100,y);
            }
            else if(state.Travel_min < 1.0e-3 && state.Travel_min >= 1.0e-6){
                MaestroG.subscripterSymFirst2I("t","min"," = "+MaestroA.rounder(state.Travel_min*1.0e6,6)+" [\u03bcs]",g,14,x+100,y);
            }
            else if(state.Travel_min < 1.0e-6){
                MaestroG.subscripterSymFirst2I("t","min"," = "+MaestroA.rounder(state.Travel_min*1.0e9,3)+" [ns]",g,14,x+100,y);
            }
            
            y += dy;
            g.setColor(Color.black);
            MaestroG.subscripterB("Slowest Ray","","",g,13,x,y);
            
            y += dy;
            g.setColor(Color.blue.darker());
            MaestroG.subscripter("Travel Time","","",g,14,x,y);
            //MaestroG.subscripterSymFirst2I("t","max"," = "+MaestroA.rounder(state.Travel_max,6)+" [\u03bcs]",g,14,x+100,y);
            if(state.Travel_max >= 1.0e-3){
                MaestroG.subscripterSymFirst2I("t","max"," = "+MaestroA.rounder(state.Travel_max,6)+" [s]",g,14,x+100,y);
            }
            else if(state.Travel_max < 1.0e-3 && state.Travel_max >= 1.0e-6){
                MaestroG.subscripterSymFirst2I("t","max"," = "+MaestroA.rounder(state.Travel_max*1.0e6,6)+" [\u03bcs]",g,14,x+100,y);
            }
            else if(state.Travel_max < 1.0e-6){
                MaestroG.subscripterSymFirst2I("t","max"," = "+MaestroA.rounder(state.Travel_max*1.0e9,3)+" [ns]",g,14,x+100,y);
            }
            
            y += dy;
            g.setColor(Color.black);
            MaestroG.subscripterB("Selected Ray","","",g,13,x,y);
            
            y += dy;
            g.setColor(Color.blue.darker());
            MaestroG.subscripter("Travel Time","","",g,14,x,y);
            //MaestroG.subscripterSymFirst2I("t",""," = "+MaestroA.rounder(state.Travel_ray,6)+" [\u03bcs]",g,14,x+100,y);
            if(state.Travel_ray >= 1.0e-3){
                MaestroG.subscripterSymFirst2I("t",""," = "+MaestroA.rounder(state.Travel_ray,6)+" [s]",g,14,x+100,y);
            }
            else if(state.Travel_ray < 1.0e-3 && state.Travel_ray >= 1.0e-6){
                MaestroG.subscripterSymFirst2I("t",""," = "+MaestroA.rounder(state.Travel_ray*1.0e6,6)+" [\u03bcs]",g,14,x+100,y);
            }
            else if(state.Travel_ray < 1.0e-6){
                MaestroG.subscripterSymFirst2I("t",""," = "+MaestroA.rounder(state.Travel_ray*1.0e9,3)+" [ns]",g,14,x+100,y);
            }
            
            y = ystart + dy +50;
            int xnew = 530;
            //MaestroG.subscripterB("Core Phase Velocity","","",g,14,x+350,y);
            //MaestroG.subsubsubsubsup3("\u03c5","p"," = ","","","","","",""+MaestroA.rounder((state.c/state.index2/1.0e8),3)+" \u00d7 10","8"," [m/s]",g,14,x+xnew,y);
            
            //y = y + dy;
            g.setColor(Color.blue.darker());
            MaestroG.subscripterB("Total Time Delay","","",g,14,x+350,y);
            //MaestroG.subsubsubsubsup2("\u03c4",""," =  t","max"," - t","min","","","",""," = "+MaestroA.rounder(state.Travel_Delay,6)+" [\u03bcs]",g,14,x+xnew,y);
            if(state.Travel_Delay >= 1.0e-3){
                MaestroG.subsubsubsubsup2("\u03c4",""," =  t","max"," - t","min","","","",""," = "+MaestroA.rounder(state.Travel_Delay,6)+" [s]",g,14,x+xnew,y);
            }
            else if(state.Travel_Delay < 1.0e-3 && state.Travel_Delay >= 1.0e-6){
                MaestroG.subsubsubsubsup2("\u03c4",""," =  t","max"," - t","min","","","",""," = "+MaestroA.rounder(state.Travel_Delay*1.0e6,6)+" [\u03bcs]",g,14,x+xnew,y);
            }
            else if(state.Travel_Delay < 1.0e-6){
                MaestroG.subsubsubsubsup2("\u03c4",""," =  t","max"," - t","min","","","",""," = "+MaestroA.rounder(state.Travel_Delay*1.0e9,3)+" [ns]",g,14,x+xnew,y);
            }
            
             y = y + dy;
            g.setColor(Color.black);
            MaestroG.subscripterB("Minimum Pulse Period","","",g,14,x+350,y);
            
            if(state.Travel_Delay >= 1.0e-3){
                MaestroG.subsubsubsubsup2("T",""," = 2 \u03c4","","","","","","",""," = "+MaestroA.rounder(2.0*state.Travel_Delay,6)+" [s]",g,14,x+xnew,y);
            }
            else if(state.Travel_Delay < 1.0e-3 && state.Travel_Delay >= 1.0e-6){
                MaestroG.subsubsubsubsup2("T",""," = 2 \u03c4","","","","","","",""," = "+MaestroA.rounder(2.0*state.Travel_Delay*1.0e6,6)+" [\u03bcs]",g,14,x+xnew,y);
            }
            else if(state.Travel_Delay < 1.0e-6){
                MaestroG.subsubsubsubsup2("T",""," = 2 \u03c4","","","","","","",""," = "+MaestroA.rounder(2.0*state.Travel_Delay*1.0e9,3)+" [ns]",g,14,x+xnew,y);
            }
            
            y = y + dy;
            g.setColor(Color.red.darker());
            MaestroG.subscripterB("Maximum Data Rate","","",g,14,x+350,y);
            
            if(state.Data_Rate < 1.0e3){
                MaestroG.subsubsubsubsup2("f","P","","","","","","","= ( 2 \u03c4 )","-1"," = "+MaestroA.rounder(state.Data_Rate,3)+" [bits/s]",g,14,x+xnew,y);
            }
            else if(state.Data_Rate >= 1.0e3 && state.Data_Rate < 1.0e6){
                MaestroG.subsubsubsubsup2("f","P","","","","","","","= ( 2 \u03c4 )","-1"," = "+MaestroA.rounder(state.Data_Rate*1.0e-3,3)+" [Kilobits/s]",g,14,x+xnew,y);
            }
	    else if(state.Data_Rate >= 1.0e6 && state.Data_Rate < 1.0e9){
                MaestroG.subsubsubsubsup2("f","P","","","","","","","= ( 2 \u03c4 )","-1"," = "+MaestroA.rounder(state.Data_Rate*1.0e-6,3)+" [Megabits/s]",g,14,x+xnew,y);
            }
            else if(state.Data_Rate >= 1.0e9 && state.Data_Rate < 1.0e12){
                MaestroG.subsubsubsubsup2("f","P","","","","","","","= ( 2 \u03c4 )","-1"," = "+MaestroA.rounder(state.Data_Rate*1.0e-9,3)+" [Gigabits/s]",g,14,x+xnew,y);
            }
            else if(state.Data_Rate >= 1.0e12 && state.Data_Rate < 1.0e15){
                MaestroG.subsubsubsubsup2("f","P","","","","","","","= ( 2 \u03c4 )","-1"," = "+MaestroA.rounder(state.Data_Rate*1.0e-12,3)+" [Terabits/s]",g,14,x+xnew,y);
            }
            else if(state.Data_Rate >= 1.0e15 && state.Lmax != 0.0){
                MaestroG.subsubsubsubsup2("f","P","","","","","","","= ( 2 \u03c4 )","-1"," = "+MaestroA.rounder(state.Data_Rate*1.0e-15,3)+" [Petabits/s]",g,14,x+xnew,y);
            }
            else if(state.Data_Rate >= 1.0e15 && state.Lmax == 0.0){
                MaestroG.subsubsubsubsup2("f","P","","","","","","","= ( 2 \u03c4 )","-1"," = unlimited  (no fiber)",g,14,x+xnew,y);
            }
            
            y += (3*dy/2);
            
            MaestroG.subsubsubsubsup2("SAFETY MARGIN    T",""," \u2265 2 \u03c4","","","","","","","","",g,14,x,y);

            //------------------------------  GRAPH
            int start_fiber, end_fiber;
            int xg1, xg2, xg3, xg4, xg5, xg6, xg7;
            
            //  TRAIN OF RECTANGULAR PULSES
            //int step1 = 10; int step2 = (int)(state.T_factor * 20 - step1);
            //int xg1 = 160; int xg2 = xg1 + step1; int xg3 = xg2 + step2; 
            //int xg4 = xg3 + step1; int xg5 = xg4 + step2; 
            //int xg6 = xg5 + step1; int xg7 = xg6 + step2;
            //int yg2 = 50; int yg1 = 5; start_fiber = xg6;
            
            int step1 = 10; int step2 = (int)(state.T_factor * 20 - step1);
            int yg2 = 50; int yg1 = 5; 
            //xg7 = 160 + 3*step1 + 3*step2;
            xg7 = 430;
            xg6 = xg7 - 20;
            xg5 = xg6 - step1;
            xg4 = xg5 - step2;
            xg3 = xg4 - step1; 
            xg2 = xg3 - step2; 
            xg1 = xg2 - step1;
            start_fiber = xg7;
            
            g.setColor(Color.black);
            g.drawLine(xg1-20, yg2, xg1, yg2);
            g.drawLine(xg1, yg2, xg1, yg1);
            g.drawLine(xg1, yg1, xg2, yg1);
            g.drawLine(xg2, yg1, xg2, yg2);
            g.drawLine(xg2, yg2, xg3, yg2);
            
            g.drawLine(xg3, yg2, xg3, yg1);
            g.drawLine(xg3, yg1, xg4, yg1);
            g.drawLine(xg4, yg1, xg4, yg2);
            g.drawLine(xg4, yg2, xg5, yg2);
            
            g.drawLine(xg5, yg2, xg5, yg1);
            g.drawLine(xg5, yg1, xg6, yg1);
            g.drawLine(xg6, yg1, xg6, yg2);
            g.drawLine(xg6, yg2, xg7, yg2);
            
            // LABELS
            g.drawLine(xg3+step1/2, yg2+5, xg3+step1/2, yg2+21);
            g.drawLine(xg5+step1/2, yg2+5, xg5+step1/2, yg2+21);
            MaestroG.drawArrow(xg3+10+step1/2, yg2+13, 8, g);
            MaestroG.drawArrow(xg5-10+step1/2, yg2+13, 7, g);
            g.drawLine(xg3+step1/2, yg2+13, xg5+step1/2, yg2+13);
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            MaestroG.subscripterSymFirst("T","","",g,16,xg3+(xg5-xg3)/2-5+step1/2,yg2+30);
            
            MaestroG.drawArrow(xg1-10, (yg2+yg1)/2, 7, g);
            MaestroG.drawArrow(xg2+10, (yg2+yg1)/2, 8, g);
            g.drawLine(xg1-15, (yg2+yg1)/2, xg1, (yg2+yg1)/2);
            g.drawLine(xg2+15, (yg2+yg1)/2, xg2, (yg2+yg1)/2);
            MaestroG.subscripterSymFirst("\u03c4","i","",g,18,xg1-33,(yg2+yg1)/2);
            
            step1 = 10; step2 = (int)(state.T_factor * 20 - step1); 
            xg1 = 620; xg2 = xg1 + step1; xg3 = xg2 + step2; 
            xg4 = xg3 + step1; xg5 = xg4 + step2; 
            xg6 = xg5 + step1; xg7 = xg6 + step2;
            end_fiber = xg1 - 20;
            yg2 = 50; yg1 = 5; int yg3 = yg1 + yg2/2; double T_factor0 = 3.5;
            int step3 = (int)(T_factor0 * 20 - step1); 
            
            // OUTPUT PULSES
            Color Colorino = Color.lightGray;
            g.setColor(Color.lightGray);
            drawDashLineThick(g, (double) xg1-20, (double) yg2, (double) xg1, (double) yg2, 1, 5, Colorino);
            drawDashLineThick(g, (double) xg1, (double) yg2, (double) xg1, (double) yg1, 1, 5, Colorino);
            drawDashLineThick(g, (double) xg1, (double) yg1, (double) xg2, (double) yg1, 1, 5, Colorino);
            drawDashLineThick(g, (double) xg2, (double) yg1, (double) xg2, (double) yg2, 1, 5, Colorino);
            drawDashLineThick(g, (double) xg2, (double) yg2, (double) xg3, (double) yg2, 1, 5, Colorino);
            //g.drawLine(xg1-20, yg2, xg1, yg2);
            //g.drawLine(xg1, yg2, xg1, yg1);
            //g.drawLine(xg1, yg1, xg2, yg1);
            //g.drawLine(xg2, yg1, xg2, yg2);
            //g.drawLine(xg2, yg2, xg3, yg2);
            
            drawDashLineThick(g, (double) xg3, (double) yg2, (double) xg3, (double) yg1, 1, 5, Colorino);
            drawDashLineThick(g, (double) xg3, (double) yg1, (double) xg4, (double) yg1, 1, 5, Colorino);
            drawDashLineThick(g, (double) xg4, (double) yg1, (double) xg4, (double) yg2, 1, 5, Colorino);
            drawDashLineThick(g, (double) xg4, (double) yg2, (double) xg5, (double) yg2, 1, 5, Colorino);
            //g.drawLine(xg3, yg2, xg3, yg1);
            //g.drawLine(xg3, yg1, xg4, yg1);
            //g.drawLine(xg4, yg1, xg4, yg2);
            //g.drawLine(xg4, yg2, xg5, yg2);
            
            drawDashLineThick(g, (double) xg5, (double) yg2, (double) xg5, (double) yg1, 1, 5, Colorino);
            drawDashLineThick(g, (double) xg5, (double) yg1, (double) xg6, (double) yg1, 1, 5, Colorino);
            drawDashLineThick(g, (double) xg6, (double) yg1, (double) xg6, (double) yg2, 1, 5, Colorino);
            drawDashLineThick(g, (double) xg6, (double) yg2, (double) xg6+20, (double) yg2, 1, 5, Colorino);
            //g.drawLine(xg5, yg2, xg5, yg1);
            //g.drawLine(xg5, yg1, xg6, yg1);
            //g.drawLine(xg6, yg1, xg6, yg2);
            //g.drawLine(xg6, yg2, xg6+20, yg2);
            
            g.drawLine(xg3+step1/2, yg2+5, xg3+step1/2, yg2+21);
            g.drawLine(xg5+step1/2, yg2+5, xg5+step1/2, yg2+21);
            MaestroG.drawArrow(xg3+10+step1/2, yg2+13, 8, g);
            MaestroG.drawArrow(xg5-10+step1/2, yg2+13, 7, g);
            g.drawLine(xg3+step1/2, yg2+13, xg5+step1/2, yg2+13);
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            MaestroG.subscripterSymFirst("T","","",g,16,xg3+(xg5-xg3)/2-5+step1/2,yg2+30);
            
            //  OUTPUT - BROADENED PULSES (SIMPLE TRIANGLE TO SET THINGS UP)
            g.setColor(Color.red);
            //g.drawLine(xg1+step1/2, yg3, xg1+step1/2-step3/2, yg2);
            //g.drawLine(xg1+step1/2, yg3, xg1+step1/2+step3/2, yg2);
            //==================================================================
            // create new CubicCurve2D.Double
            CubicCurve2D c = new CubicCurve2D.Double();
            // draw CubicCurve2D.Double with set coordinates
            c.setCurve(xg1+step1/2-step3/2, yg2, xg1+step1/2-step3/4, yg2, xg1+step1/2-step3/4, yg3, xg1+step1/2, yg3);
            g2d.draw(c);
            c.setCurve(xg1+step1/2, yg3, xg1+step1/2+step3/4, yg3, xg1+step1/2+step3/4, yg2, xg1+step1/2+step3/2, yg2);
            g2d.draw(c);
            //==================================================================
            //g.drawLine(xg3+step1/2, yg3, xg3+step1/2-step3/2, yg2);
            //g.drawLine(xg3+step1/2, yg3, xg3+step1/2+step3/2, yg2);
            //==================================================================
            // draw CubicCurve2D.Double with set coordinates
            c.setCurve(xg3+step1/2-step3/2, yg2, xg3+step1/2-step3/4, yg2, xg3+step1/2-step3/4, yg3, xg3+step1/2, yg3);
            g2d.draw(c);
            c.setCurve(xg3+step1/2, yg3, xg3+step1/2+step3/4, yg3, xg3+step1/2+step3/4, yg2, xg3+step1/2+step3/2, yg2);
            g2d.draw(c);
            //==================================================================
            //g.drawLine(xg5+step1/2, yg3, xg5+step1/2-step3/2, yg2);
            //g.drawLine(xg5+step1/2, yg3, xg5+step1/2+step3/2, yg2);
            //==================================================================
            // draw CubicCurve2D.Double with set coordinates
            c.setCurve(xg5+step1/2-step3/2, yg2, xg5+step1/2-step3/4, yg2, xg5+step1/2-step3/4, yg3, xg5+step1/2, yg3);
            g2d.draw(c);
            c.setCurve(xg5+step1/2, yg3, xg5+step1/2+step3/4, yg3, xg5+step1/2+step3/4, yg2, xg5+step1/2+step3/2, yg2);
            g2d.draw(c);
            //==================================================================
            // LEGEND FOR TAU
            g.drawLine(xg1+step1/2-step3/2, yg2+5, xg1+step1/2-step3/2, yg2+21);
            g.drawLine(xg1+step1/2+step3/2, yg2+5, xg1+step1/2+step3/2, yg2+21);
            MaestroG.drawArrow(xg1+10+step1/2-step3/2, yg2+13, 8, g);
            MaestroG.drawArrow(xg1-10+step1/2+step3/2, yg2+13, 7, g);
            g.drawLine(xg1+step1/2-step3/2, yg2+13, xg1+step1/2+step3/2, yg2+13);
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            MaestroG.subscripterSymFirst("\u03c4","","",g,18,xg1-5+step1/2,yg2+25);
            
            
            // draw the fiber
            g.setColor(Color.lightGray);
            g.drawOval(end_fiber-25,yg1+(yg2-yg1)/2-10,15,20);
            drawLineThick(g, (double)(start_fiber+17), (double)(yg1+(yg2-yg1)/2), (double)(end_fiber-20), (double)(yg1+(yg2-yg1)/2), 10, Color.gray);
            int rule; float alpha; rule = AlphaComposite.SRC_OVER;
            g2d.setComposite(AlphaComposite.getInstance(rule, 0.5f));
            drawLineThick(g, (double)(start_fiber+15), (double)(yg1+(yg2-yg1)/2), (double)(end_fiber-20), (double)(yg1+(yg2-yg1)/2), 20, new Color(200,200,255));
            g2d.setComposite(AlphaComposite.getInstance(rule, 1.0f));
            g.setColor(Color.gray);
            g.drawOval(start_fiber+5,yg1+(yg2-yg1)/2-10,15,20);
            g.drawArc(end_fiber-25,yg1+(yg2-yg1)/2-10,15,20,270,180);
            drawLineThick(g, (double)(start_fiber+16), (double)(yg1+(yg2-yg1)/2)-10, (double)(end_fiber-20), (double)(yg1+(yg2-yg1)/2)-10, 1, Color.black);
            drawLineThick(g, (double)(start_fiber+16), (double)(yg1+(yg2-yg1)/2)+10, (double)(end_fiber-20), (double)(yg1+(yg2-yg1)/2)+10, 1, Color.black);
            MaestroG.subscripterB("Fiber","","",g,14,start_fiber+(end_fiber-start_fiber)/2-20,yg2+5);
            
            MaestroG.subscripter("The safety margin is used because of pulse spreading. Reduce T to observe","","",g,14,320,140);
            MaestroG.subscripter("how increased data rate may cause interference between consecutive pulses.","","",g,14,320,160);
            
            double test_rate; int xx = 650; int yy = 110;
            g.setColor(Color.blue.darker());
            test_rate = MaestroA.rounder(2.0*state.Data_Rate/(state.T_factor/3.0),3);
            if(test_rate < 1.0e3){
                MaestroG.subscripter("","",""+MaestroA.rounder(test_rate ,3)+" [bits/s]",g,14,xx,yy);
            }
            else if(test_rate >= 1.0e3 && test_rate < 1.0e6){
                MaestroG.subscripter("","",""+MaestroA.rounder(test_rate*1.0e-3,3)+" [Kilobits/s]",g,14,xx,yy);
            }
	    else if(test_rate >= 1.0e6 && test_rate < 1.0e9){
                MaestroG.subscripter("","",""+MaestroA.rounder(test_rate*1.0e-6,3)+" [Megabits/s]",g,14,xx,yy);
            }
            else if(test_rate >= 1.0e9 && test_rate < 1.0e12){
                MaestroG.subscripter("","",""+MaestroA.rounder(test_rate*1.0e-9,3)+" [Gigabits/s]",g,14,xx,yy);
            }
            else if(test_rate >= 1.0e12 && test_rate < 1.0e15){
                MaestroG.subscripter("","",""+MaestroA.rounder(test_rate*1.0e-12,3)+" [Terabits/s]",g,14,xx,yy);
            }
            else if(test_rate >= 1.0e15 && state.Lmax != 0.0){
                MaestroG.subscripter("","",""+MaestroA.rounder(test_rate*1.0e-15,3)+" [Petabits/s]",g,14,xx,yy);
            }
            else if(test_rate >= 1.0e15 && state.Lmax == 0.0){
                MaestroG.subscripter("","","",g,14,xx,yy);
            }
	}
        
        private void drawLineThick(Graphics g, double x1, double y1, double x2, double y2, int thick, Color color){
        Graphics2D g2d = (Graphics2D)g;
        g2d.setPaint(color);
        g2d.setStroke(new BasicStroke(thick,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
        
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
        Line2D.Double line = new Line2D.Double(x1,y1,x2,y2);
        g2d.draw(line);
  
        g2d.setStroke(new BasicStroke(1));
        //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
    }

        
        private void drawDashLineThick(Graphics g, double x1, double y1, double x2, double y2, int thick, int dash, Color color){
        Graphics2D g2d = (Graphics2D)g;
        g2d.setPaint(color);
        g2d.setStroke(new BasicStroke(thick,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
        float[] dashPattern = {dash,dash};
        g2d.setStroke(new BasicStroke(thick,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER,10.0F,dashPattern,0));  
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        
        Line2D.Double line = new Line2D.Double(x1,y1,x2,y2);
        g2d.draw(line);
  
        g2d.setStroke(new BasicStroke(1));g2d.setStroke(new BasicStroke(thick,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
        
        //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
    }
        
        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 WriteC(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 ObliqueOutputCanvasD 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 static int prec1 = 6;
        public static int prec2 = 6;

	public ObliqueOutputCanvasD(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){
	    int x, x2, x3, x4, x5, xshift, y, ystart, dx, dxx, dy, dyy;
	    FontMetrics fm;
	    x = 20;
            x2 = 270;
            x3 = 570;
            x4 = 720;
            x5 = 900;
	    ystart = 70;
            y = ystart;
	    dx = 80;
	    dxx = 15;
            xshift = 20;
	    g.clearRect(0,0,getSize().width,getSize().height);
	    String unit;
            
            unit = "\u03bcm";
            int fonto = 12;
	    g.setFont(titlefont);
            g.setColor(Color.blue.darker());
	    
	    g.setFont(normalfont2);
	    fm = g.getFontMetrics();
	    dy = 25;//fm.getHeight()-1;
	    dyy = dy+5;
	    
            Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            
            g.setColor(Color.red);
            MaestroG.subscripterB("Propagation Properties","","",g,18,10,20);
            
            double test;
            test = state.wavelength1*1.0e6;
            g.setColor(Color.red.darker());
            y = ystart;
            MaestroG.subscripterB("Wavelength - medium 1","","",g,14,x,y);
            y+= dy;
            MaestroG.subscripterBSym("\u03bb","0","",g,14,x,y);
            Write(g,test, 14, unit, x+xshift, y);
            
            test = state.wavelength2*1.0e6;
            g.setColor(Color.blue.darker());
            y+= dyy;
            MaestroG.subscripterB("Wavelength - medium 2","","",g,14,x,y);
            y+= dy;
            MaestroG.subscripterBSym("\u03bb","f","",g,14,x,y);
            Write(g,test, 14, unit, x+xshift, y);
            
            y+= dyy;
            MaestroG.subscripterB("Phase Velocity","","",g,14,x,y);
            y+= dy;
            MaestroG.subsubsubsubsup3B("\u03c5","pf"," = ","","","","","",""+MaestroA.rounder((state.c/state.index2/1.0e8),3)+" \u00d7 10","8"," [m/s]",g,14,x,y);
            
            
            test = state.wavelength3*1.0e6;
            g.setColor(Color.black);
            y+= dyy;
            MaestroG.subscripterB("Wavelength - medium 3","","",g,14,x,y);
            y+= dy;
            MaestroG.subscripterBSym("\u03bb","c","",g,14,x,y);
            Write(g,test, 14, unit, x+xshift, y);
            
            
            //------------------------------------------------------------------
            y = ystart;
            g.setColor(Color.red.darker());
            if(state.Show_index){
                MaestroG.subscripterB("Relative Permittivity - medium 1","","",g,14,x2,y);
                y+= dy;
                MaestroG.subscripterB("\u03b5","r0"," = "+MaestroA.rounder(state.epsilon_r1,6), g, 14, x2, y);
            }
            else{
                MaestroG.subscripterB("Index of Refraction - medium 1","","",g,14,x2,y);
                y+= dy;
                MaestroG.subscripterB("n","0"," = "+MaestroA.rounder(state.index1,6), g, 14, x2, y);
            }
            //------------------------------------------------------------------
            y += dyy;
            g.setColor(Color.blue.darker());
            if(state.Show_index){
                MaestroG.subscripterB("Relative Permittivity - medium 2","","",g,14,x2,y);
                y+= dy;
                MaestroG.subscripterB("\u03b5","rf"," = "+MaestroA.rounder(state.epsilon_r2,6), g, 14, x2, y);
            }
            else{
                MaestroG.subscripterB("Index of Refraction - medium 2","","",g,14,x2,y);
                y+= dy;
                MaestroG.subscripterB("n","f"," = "+MaestroA.rounder(state.index2,6), g, 14, x2, y);
            }
            //------------------------------------------------------------------
            g.setColor(Color.black);
            y+= dyy;
            if(state.Show_index){
                MaestroG.subscripterB("Relative Permittivity - medium 3","","",g,14,x2,y);
                y+= dy;
                MaestroG.subscripterB("\u03b5","rc"," = "+MaestroA.rounder(state.epsilon_r3,6), g, 14, x2, y);
            }
            else{
                MaestroG.subscripterB("Index of Refraction - medium 3","","",g,14,x2,y);
                y+= dy;
                MaestroG.subscripterB("n","c"," = "+MaestroA.rounder(state.index3,6), g, 14, x2, y);
            }
            
            y = ystart;
            g.setColor(Color.black);
	    MaestroG.subscripterB("Ray Angles","","",g,13,x3,y);
            double ninety = 1.570795; // This is MATH.pi-(1.0e-6)
            
            y += dy;
            g.setColor(Color.gray);
            MaestroG.subscripterBSym("\u03b8","i"," = "+Math.abs(MaestroA.rounder(state.theta1*180.0/Math.PI,4))+"\u00ba",g,14,x3,y);
            
            y += dy;
            if(Complex.Imaginary(state.Reflection_Coef)==0.0){
                if(Math.abs(state.theta1) < ninety){
                    MaestroG.subscripterBSym("\u03b8","2"," = "+Math.abs(MaestroA.rounder(state.theta2*180.0/Math.PI,4))+"\u00ba",g,14,x3,y);
                }
                else{
                    MaestroG.subscripterBSym("\u03b8","2"," = undef.",g,14,x3,y);
                }
            }
            else{
                MaestroG.subscripterBSym("\u03b8","2"," = undef.",g,14,x3,y);
            }
    
            y += dy;
            g.setColor(Color.gray);
            if(Complex.Imaginary(state.Reflection_Coef)==0.0){
                if(Math.abs(state.theta1) < ninety){
                    MaestroG.subscripterBSym("\u03b8","3"," = "+MaestroA.rounder(state.theta3*180.0/Math.PI,4)+"\u00ba",g,14,x3,y);
                }
                else{
                    MaestroG.subscripterBSym("\u03b8","3"," = undef.",g,14,x3,y);
                }
            }
            else{
                MaestroG.subscripterBSym("\u03b8","3"," = undef.",g,14,x3,y);
            }
            
            y += dy;
            if(Complex.Imaginary(state.Reflection_Coef)==0.0){
                if(Math.abs(state.theta1_deg) > (state.theta_range)&& Math.abs(state.theta1) < ninety){
                    MaestroG.subscripterBSym("\u03b8","t"," = "+MaestroA.rounder(state.theta4*180.0/Math.PI,4)+"\u00ba",g,14,x3,y);
                }
                else{
                    MaestroG.subscripterBSym("\u03b8","t"," = undef.",g,14,x3,y);
                }
            }
            else{
                MaestroG.subscripterBSym("\u03b8","t"," = undef.",g,14,x3,y);
            }
            
            y = ystart;
            g.setColor(Color.blue.darker());
	    MaestroG.subscripterB("Acceptance Angle","","",g,13,x4,y);
            y = ystart + dy;
            g.setColor(Color.blue);
            MaestroG.subscripterBSym("\u03b8","i max"," = "+MaestroA.rounder(state.theta_range,4)+"\u00ba",g,14,x4,y);
            y += dy;
            MaestroG.subscripterBSym("\u03b8","2 max"," = "+MaestroA.rounder(90.0 - state.totalRclad_angle,4)+"\u00ba",g,14,x4,y);
            
            y = y+3*dy/2;
            g.setColor(Color.blue.darker());
	    MaestroG.subscripterB("Critical Angle","","",g,13,x4,y);
            //y = y+dy-5;
            //MaestroG.subscripterB("Guidance","","",g,13,x4,y);
            y = y + dy;
            g.setColor(Color.blue);
            if(state.critical_angle < 90.0){
                MaestroG.subscripterBSym("\u03b8","3c"," = "+MaestroA.rounder(state.critical_angle,4)+"\u00ba",g,14,x4,y);
            }
            else{
                MaestroG.subscripterBSym("\u03b8","3c"," = undef.",g,14,x4,y);
            }
            //y += dy;
            //MaestroG.subscripterBSym("\u03b8","0 max"," = "+MaestroA.rounder(90.0 - state.totalRclad_angle,4)+"\u00ba",g,14,x4,y);
            
            y = ystart;
            g.setColor(Color.red.darker());
	    MaestroG.subscripterB("Numerical Aperture","","",g,14,x5,y);
            
            y += dy;
            MaestroG.subsubsubsubsup("NA = n","0"," sin ( \u03b8","i max"," ) = ( \u03b5","rf"," - \u03b5","rc"," )","0.5",g,14,x5,y);	
	    y += dy;
            MaestroG.subscripterB("NA = ","",""+MaestroA.rounder(state.numerical_aperture,6),g,13,x5,y);
            
            y+= dyy;
            g.setColor(Color.black);
            test = state.fiber_radius*1.0e6;
            double test2;
            test2 = MaestroA.rounder(state.fiber_radius/state.wavelength2,2);
            g.setFont(new Font("Serif",Font.ITALIC | Font.BOLD,16));
            g.drawString("R",x5,y);
            Write(g,test, 14, unit, x5+xshift, y);
            unit = "\u03bb";
            y+= dy;
            Write2(g,test2, 14, unit, x5+xshift, y);
            
        }
        
            public void Write(Graphics g, double test, int fonto, String unit, 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.superscripterB("  =  0.0",""," "+unit,g,fonto,x,y);
	    }
            else if(test >= 1.0e-15 && test < 1.0e-14){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e15,5)+"  x  10","-15"," "+unit,g,fonto,x,y);
	    }
            else if(test >= 1.0e-14 && test < 1.0e-13){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e14,5)+"  x  10","-14"," "+unit,g,fonto,x,y);
	    }
            else if(test >= 1.0e-13 && test < 1.0e-12){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e13,5)+"  x  10","-13"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-12 && test < 1.0e-11){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e12,5)+"  x  10","-12"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-11 && test < 1.0e-10){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e11,5)+"  x  10","-11"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-10 && test < 1.0e-9){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e10,5)+"  x  10","-10"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-9 && test < 1.0e-8){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e9,5)+"  x  10","-9"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-8 && test < 1.0e-7){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e8,5)+"  x  10","-8"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-7 && test < 1.0e-6){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e7,5)+"  x  10","-7"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-6 && test < 1.0e-5){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e6,5)+"  x  10","-6"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-5 && test < 1.0e-4){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e5,5)+"  x  10","-5"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-4 && test < 1.0e-3){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e4,5)+"  x  10","-4"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-3 && test < 1.0e-2){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e3,5)+"  x  10","-3"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-2 && test < 1.0e-1){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e2,5)+"  x  10","-2"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e-1 && test < 1.0){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e1,5)+"  x  10","-1"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0 && test < 1.0e1){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test,5)+"  ",""," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e1 && test < 1.0e2){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test,5)+"  ",""," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e2 && test < 1.0e3){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-2,5)+"  x  10","2"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e3 && test < 1.0e4){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-3,5)+"  x  10","3"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e4 && test < 1.0e5){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-4,5)+"  x  10","4"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e5 && test < 1.0e6){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-5,5)+"  x  10","5"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e6 && test < 1.0e7){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-6,5)+"  x  10","6"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e7 && test < 1.0e8){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-7,5)+"  x  10","7"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e8 && test < 1.0e9){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-8,5)+"  x  10","8"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e9 && test < 1.0e10){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-9,5)+"  x  10","9"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e10 && test < 1.0e11){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-10,5)+"  x  10","10"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e11 && test < 1.0e12){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-11,5)+"  x  10","11"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e12 && test < 1.0e13){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-12,5)+"  x  10","12"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e13 && test < 1.0e14){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-13,5)+"  x  10","13"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e14 && test < 1.0e15){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-14,5)+"  x  10","14"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e15 && test < 1.0e16){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-15,5)+"  x  10","15"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e16 && test < 1.0e17){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-16,5)+"  x  10","16"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e17 && test < 1.0e18){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-17,5)+"  x  10","17"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e18 && test < 1.0e19){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-18,5)+"  x  10","18"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e19 && test < 1.0e20){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-19,5)+"  x  10","19"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e20 && test < 1.0e21){
		MaestroG.superscripterB("  =  "+MaestroA.rounder(test*1.0e-20,5)+"  x  10","20"," "+unit,g,fonto,x,y);
	    }
	    else if(test >= 1.0e21){
		MaestroG.superscripterB("  =  "+test+"",""," "+unit,g,fonto,x,y);
	    }
            
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
        }
            
        public void Write2(Graphics g, double test, int fonto, String unit, 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.superscripterLambdaB("  =  0.0",""," ",""+unit,"2",g,fonto,x,y);
	    }
            else if(test >= 1.0e-15 && test < 1.0e-14){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e15,5)+"  x  10","-15"," ",""+unit,"f",g,fonto,x,y);
	    }
            else if(test >= 1.0e-14 && test < 1.0e-13){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e14,5)+"  x  10","-14"," ",""+unit,"f",g,fonto,x,y);
	    }
            else if(test >= 1.0e-13 && test < 1.0e-12){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e13,5)+"  x  10","-13"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-12 && test < 1.0e-11){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e12,5)+"  x  10","-12"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-11 && test < 1.0e-10){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e11,5)+"  x  10","-11"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-10 && test < 1.0e-9){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e10,5)+"  x  10","-10"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-9 && test < 1.0e-8){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e9,5)+"  x  10","-9"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-8 && test < 1.0e-7){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e8,5)+"  x  10","-8"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-7 && test < 1.0e-6){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e7,5)+"  x  10","-7"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-6 && test < 1.0e-5){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e6,5)+"  x  10","-6"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-5 && test < 1.0e-4){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e5,5)+"  x  10","-5"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-4 && test < 1.0e-3){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e4,5)+"  x  10","-4"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-3 && test < 1.0e-2){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e3,5)+"  x  10","-3"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-2 && test < 1.0e-1){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e2,5)+"  x  10","-2"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e-1 && test < 1.0){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e1,5)+"  x  10","-1"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0 && test < 1.0e1){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test,5)+"  ",""," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e1 && test < 1.0e2){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test,5)+"  ",""," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e2 && test < 1.0e3){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-2,5)+"  x  10","2"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e3 && test < 1.0e4){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-3,5)+"  x  10","3"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e4 && test < 1.0e5){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-4,5)+"  x  10","4"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e5 && test < 1.0e6){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-5,5)+"  x  10","5"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e6 && test < 1.0e7){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-6,5)+"  x  10","6"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e7 && test < 1.0e8){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-7,5)+"  x  10","7"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e8 && test < 1.0e9){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-8,5)+"  x  10","8"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e9 && test < 1.0e10){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-9,5)+"  x  10","9"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e10 && test < 1.0e11){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-10,5)+"  x  10","10"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e11 && test < 1.0e12){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-11,5)+"  x  10","11"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e12 && test < 1.0e13){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-12,5)+"  x  10","12"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e13 && test < 1.0e14){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-13,5)+"  x  10","13"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e14 && test < 1.0e15){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-14,5)+"  x  10","14"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e15 && test < 1.0e16){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-15,5)+"  x  10","15"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e16 && test < 1.0e17){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-16,5)+"  x  10","16"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e17 && test < 1.0e18){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-17,5)+"  x  10","17"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e18 && test < 1.0e19){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-18,5)+"  x  10","18"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e19 && test < 1.0e20){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-19,5)+"  x  10","19"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e20 && test < 1.0e21){
		MaestroG.superscripterLambdaB("  =  "+MaestroA.rounder(test*1.0e-20,5)+"  x  10","20"," ",""+unit,"f",g,fonto,x,y);
	    }
	    else if(test >= 1.0e21){
		MaestroG.superscripterLambdaB("  =  "+test+"",""," ",""+unit,"f",g,fonto,x,y);
	    }
            
            //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
        }

        public void WriteC(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);
        }
}