//ObliqueOutputPanel.java
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;

public class ObliqueOutputPanelB extends Panel implements ChangeListener{
	Oblique_State state;
	private static final Color bgcolor = Color.white;
	private Font labfont;
	private Font titlefont;
	Label titlelabel, vlabLength;
	private Complex temp;	
        public Choice c1;
	
        public Label Tlabel;
        public ObliqueOutputCanvasD pwocD;
        public ObliqueOutputCanvasE pwocE;
        public ObliqueOutputCanvasF pwocF;
        
        public JSlider sliderLength, sliderLength2, sliderT;
        public Panel pT, pslider1, pslider2, pslider3, pslider4;
        
        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);
            
            labfont=new Font("Sanserif",Font.PLAIN,state.font12);
            titlefont=new Font("Sanserif",Font.BOLD,state.font16);
	
            Instructions = new Button("Instructions");
            Instructions.setFont(new Font("SanSerif",Font.PLAIN,state.font12));
            Instructions.setBackground(new Color(240,240,255));
            add(Instructions);
            int buttonx = state.s1000+state.s80;
            int buttony = state.s200+state.s72;
            int buttonwide = state.s100;
            int buttonheight = state.s27;
            
            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);	
            
            //================================================== SHOW IF GUIDING
	    sliderT = new JSlider(5,21);
	    sliderT.setValue(20);
            //sliderT = new Scrollbar(Scrollbar.HORIZONTAL,20,1,5,21);
            sliderT.setBackground(Color.white);
            add(sliderT);
            /*
            pT = new Panel();
                pT.setBackground(Color.black);
                add(pT);
	    */ 
            sliderT.setVisible(false);
            //pT.setVisible(false);
            if(state.Guiding){
                sliderT.setBounds(state.s700+state.s15,state.s100,state.s200,state.s15);
                //pT.setBounds(state.s700+state.s15-1,state.s100-1,state.s200+2,state.s15+2);
            }
            else{
                sliderT.setBounds(state.s100000,state.s100000,state.s200,state.s15);
                //pT.setBounds(state.s100000,state.s100000,state.s200+2,state.s15+2);
            }
            //================================================== SHOW IF GUIDING
            Tlabel = new Label("T = "+MaestroA.rounder(state.T_factor/3.0,2)+" \u03c4",Label.CENTER);
            add(Tlabel); 
            
            if(state.Guiding){
                Tlabel.setBounds(state.s700+state.s15,state.s83,state.s200,state.s15);
            }
            else{
                Tlabel.setBounds(state.s100000,state.s100000,state.s200,state.s15);
            }
            Tlabel.setFont(new Font("Serif",Font.ITALIC + Font.BOLD,state.font18));
            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 = state.s700+state.s30;
            buttony = state.s200+state.s72;
            buttonwide = state.s200+state.s50;
            buttonheight = state.s27;
            
            Propagation.setBounds(buttonx,buttony,buttonwide,buttonheight);
            Dispersion.setBounds(buttonx,buttony,buttonwide,buttonheight);
            Propagation.setFont(new Font("SanSerif",Font.PLAIN,state.font12));
            Dispersion.setFont(new Font("SanSerif",Font.PLAIN,state.font12));
            
            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(state.s5,state.s70,state.s200+state.s90,state.s200+state.s41);
            pwocF.setBounds(state.s300,state.s4,state.s900+state.s9,state.s300+state.s7);
            pwocD.setBounds(state.s1,state.s1,state.s1000+state.s200+state.s12,state.s200+state.s70);
            
            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);
            vlabLength.setFont(new Font("SanSerif",Font.PLAIN,state.font12));

	    sliderLength = new JSlider(0,51);
	    sliderLength.setValue(1);
	    //sliderLength = new Scrollbar(Scrollbar.HORIZONTAL,1,1,0,51);
            sliderLength.setBackground(Color.white);
            add(sliderLength);

	    sliderLength2 = new JSlider(0,1000);
	    sliderLength2.setValue(0);
            //sliderLength2 = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,1000);
            sliderLength2.setBackground(Color.white);
            add(sliderLength2);
            int xs1 = state.s20;
            int ys0 = state.s5;
            int ys1 = state.s25;
            int ys2 = state.s45;
            add(vlabLength); add(sliderLength); add(sliderLength2);
	    /*
            pslider2 = new Panel();
                pslider2.setBackground(Color.cyan);
                add(pslider2);

            pslider1 = new Panel();
                pslider1.setBackground(Color.black);
                add(pslider1);
                
            pslider4 = new Panel();
                pslider4.setBackground(Color.cyan);
                add(pslider4);
                
            pslider3 = new Panel();
                pslider3.setBackground(Color.black);
                add(pslider3);
	    */
            if(state.Guiding){
                vlabLength.setBounds(xs1,ys0,state.s200,state.s15);
                sliderLength.setBounds(xs1,ys1,state.s200+state.s60,state.s15);
                sliderLength2.setBounds(xs1,ys2,state.s200+state.s60,state.s15);
		/*
                pslider2.setBounds(xs1-1,ys1-1,state.s200+state.s60+2,state.s15+2);
                pslider1.setBounds(xs1-2,ys1-2,state.s200+state.s60+4,state.s15+4);
                pslider4.setBounds(xs1-1,ys2-1,state.s200+state.s60+2,state.s15+2);
                pslider3.setBounds(xs1-2,ys2-2,state.s200+state.s60+4,state.s15+4);
		*/
            }
            else{
                vlabLength.setBounds(state.s100000,state.s100000,state.s200,state.s15);
                sliderLength.setBounds(state.s100000,state.s100000,state.s200+state.s60,state.s15);
                sliderLength2.setBounds(state.s100000,state.s100000,state.s200+state.s60,state.s15);
		/*
                pslider2.setBounds(state.s100000,state.s100000,state.s200+state.s62,state.s17);
                pslider1.setBounds(state.s100000,state.s100000,state.s200+state.s64,state.s19);
                pslider4.setBounds(state.s100000,state.s100000,state.s200+state.s62,state.s17);
                pslider3.setBounds(state.s100000,state.s100000,state.s200+state.s64,state.s19);
		*/
            }
            
            //Listeners
	    sliderLength.addChangeListener(this);	
            sliderLength2.addChangeListener(this);
            sliderT.addChangeListener(this);
	}
        
	public void paint(Graphics g){
	    //g.draw3DRect(0,0,getSize().width-1,getSize().height-1,false);
	    sliderLength.requestFocusInWindow();
	    sliderLength2.requestFocusInWindow();
	    sliderT.requestFocusInWindow();
	}
        
        public void stateChanged(ChangeEvent 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");
                    Tlabel.setFont(new Font("Serif",Font.ITALIC + Font.BOLD,state.font18));
                    
                    state.ignition();
                    pwocE.repaint();
                    pwocF.repaint();
            }
	}	
}//ObliqueOutputPanel.java

class ObliqueOutputCanvasE extends Canvas{
	
	private Font normalfont = new Font("Sanserif",Font.PLAIN,11);
        private Font normalfont2 = new Font("Sanserif",Font.PLAIN,12);
	private Font subfont    = new Font("Sanserif",Font.PLAIN,10);
	private Font titlefont  =new Font("Sanserif",Font.BOLD,16);
	private 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){
	    normalfont = new Font("Sanserif",Font.PLAIN,state.font11);
            normalfont2 = new Font("Sanserif",Font.PLAIN,state.font12);
            subfont = new Font("Sanserif",Font.PLAIN,state.font10);
            titlefont = new Font("Sanserif",Font.BOLD,state.font16);
            symbfont = new Font("Serif",Font.PLAIN,state.font13);
	
            if(state.Guiding){
                int x, x2, x3, x4, x5, xshift, y, ystart, dx, dxx, dy, dyy;
                FontMetrics fm;
                x = state.s10;
                x2 = state.s110;
                x3 = state.s500+state.s70;
                x4 = state.s700+state.s20;
                x5 = state.s900;
                ystart = state.s50;
                y = ystart;
                dx = state.s80;
                dxx = state.s15;
                xshift = state.s20;
                g.clearRect(0,0,getSize().width,getSize().height);
                String unit;

                unit = "\u03bcm";
                int fonto = state.s12;
                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 = state.s28;
                dyy = dy+state.s5;

                Graphics2D g2d = (Graphics2D)g;
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

                y = ystart - state.s20;
                g.setColor(Color.red.darker());
                MaestroG.subscripterB("Guided Rays","","",g,state.font15,x,y);
                y += dy;
                g.setColor(Color.black);
                MaestroG.subscripterB("Axial Ray","","",g,state.font13,x,y);
                MaestroG.subscripterBSym("\u03b8","2min"," = 0.0\u00ba",g,state.font14,x2,y);
                y += dy;
                g.setColor(Color.blue.darker());
                MaestroG.subscripter("Path Length","","",g,state.font14,x,y);
                MaestroG.subscripterSymFirst2I("l","min"," = "+MaestroA.rounder(state.fiber_length,3)+" [km]",g,state.font14,x+state.s100,y);

                y += dy;
                g.setColor(Color.black);
                MaestroG.subscripterB("Slowest Ray","","",g,state.font13,x,y);
                MaestroG.subscripterBSym("\u03b8","2max"," = "+MaestroA.rounder(state.SlowestGuided_theta2_deg,4)+"\u00ba",g,state.font14,x2,y);
                y += dy;
                g.setColor(Color.blue.darker());
                MaestroG.subscripter("Path Length","","",g,state.font14,x,y);
                MaestroG.subscripterSymFirst2I("l","max"," = "+MaestroA.rounder(state.Lmax,6)+" [km]",g,state.font14,x+state.s100,y);

                y += dy;
                if(Math.abs(state.theta2) <= Math.abs(state.SlowestGuided_theta2)){
                    g.setColor(Color.black);
                    MaestroG.subscripterB("Selected Ray","","",g,state.font13,x,y);
                    MaestroG.subscripterBSym("\u03b8","2"," = "+Math.abs(MaestroA.rounder(state.theta2*180.0/Math.PI,4))+"\u00ba",g,state.font14,x2,y);
                    y += dy;
                    g.setColor(Color.blue.darker());
                    MaestroG.subscripter("Path Length","","",g,state.font14,x,y);
                    MaestroG.subscripterSymFirst2I("l",""," = "+MaestroA.rounder(state.Lray,6)+" [km]",g,state.font14,x+state.s100,y);
                }
                else{
                    g.setColor(Color.red.darker());
                    MaestroG.subscripterB("Leaky Ray","","",g,state.font13,x,y);
                    y += dy;
                    g.setColor(Color.black);
                    MaestroG.subscripterB("Selected Ray","","",g,state.font13,x,y);
                    MaestroG.subscripterBSym("\u03b8","2"," = "+Math.abs(MaestroA.rounder(state.theta2*180.0/Math.PI,4))+"\u00ba",g,state.font14,x2,y);
                    y += dy;
                    g.setColor(Color.blue.darker());
                    MaestroG.subscripter("Path Length","","",g,state.font14,x,y);
                    MaestroG.subscripterSymFirst2I("l",""," = "+MaestroA.rounder(state.Lray,6)+" [km]",g,state.font14,x+state.s100,y);
                }
            }
            else{
                //System.out.println("STATE IS NOT GUIDING   Guiding = "+state.Guiding);
                g.clearRect(0,0,getSize().width,getSize().height);
            }
        }
        
            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 Font normalfont;
        private Font normalfont2;
	private Font subfont;
	private Font titlefont;
	private Font symbfont;
	Oblique_State state;
	private Image im;
	private Graphics buf;
        
        public static int prec1 = 6;
        public static int prec2 = 6;

    private BufferedImage greater_or_equal;
        
	public ObliqueOutputCanvasF(Oblique_State state){
	    super();
	    this.state = state;
	    getImages();
	}


    private void getImages() {
        // read in the bullet image, because CHEERPJ does not render this
	//  symbol in any font!  (java to javascript converter)
        try {
            //bullet = ImageIO.read(getClass().getResource("bullet.png"));
	    BufferedImage img =
		ImageIO.read(getClass().getResource("greater_or_equal.png"));
	    int targetWidth = (int) (state.sfactor * img.getWidth());
	    int targetHeight = (int) (state.sfactor * img.getHeight());
	    greater_or_equal =
		new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB);
	    Graphics2D graphics2D = greater_or_equal.createGraphics();
	    graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
					RenderingHints.VALUE_INTERPOLATION_BILINEAR);
	    graphics2D.drawImage(img, 0, 0, targetWidth, targetHeight, 0, 0,
				 img.getWidth(), img.getHeight(), null);
	    graphics2D.dispose();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
	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){
            normalfont = new Font("Sanserif",Font.PLAIN,11);
            normalfont2 = new Font("Sanserif",Font.PLAIN,12);
            subfont = new Font("Sanserif",Font.PLAIN,10);
            titlefont = new Font("Sanserif",Font.BOLD,16);
            symbfont = new Font("Serif",Font.PLAIN,13);
	
	    if(state.Guiding){
                //System.out.println("STATE IS GUIDING   Guiding = "+state.Guiding);
                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 = state.s12;

                FontMetrics fm;
                x = state.s15;
                x3 = state.s10;
                x4 = state.s35;
                x2 = state.s200+state.s30;
                y = state.s18;
                dx = state.s80;
                dxx = state.s15;
                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 = state.s20;//fm.getHeight()-1;
                dyy = dy + state.s4;

                ystart = state.s117;
                y = ystart;
                dx = state.s80;
                dxx = state.s15;
                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 = state.s25;
                dyy = dy + state.s5;

                Graphics2D g2d = (Graphics2D)g;
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

                g.setColor(Color.red);
                MaestroG.subscripterB("Modal","","",g,state.font18,state.s10,state.s20);
                MaestroG.subscripterB("Dispersion","","",g,state.font18,state.s10,state.s42);

                y = ystart;

                g.setColor(Color.black);
                MaestroG.subscripterB("Axial Ray","","",g,state.font13,x,y);

                y += dy;
                g.setColor(Color.blue.darker());
                MaestroG.subscripter("Travel Time","","",g,state.font14,x,y);
                if(state.Travel_min >= 1.0e-3){
                    MaestroG.subscripterSymFirst2I("t","min"," = "+MaestroA.rounder(state.Travel_min,6)+" [s]",g,state.font14,x+state.s100,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,state.font14,x+state.s100,y);
                }
                else if(state.Travel_min < 1.0e-6){
                    MaestroG.subscripterSymFirst2I("t","min"," = "+MaestroA.rounder(state.Travel_min*1.0e9,3)+" [ns]",g,state.font14,x+state.s100,y);
                }

                y += dy;
                g.setColor(Color.black);
                MaestroG.subscripterB("Slowest Ray","","",g,state.font13,x,y);

                y += dy;
                g.setColor(Color.blue.darker());
                MaestroG.subscripter("Travel Time","","",g,state.font14,x,y);
                //MaestroG.subscripterSymFirst2I("t","max"," = "+MaestroA.rounder(state.Travel_max,6)+" [\u03bcs]",g,state.font14,x+s100,y);
                if(state.Travel_max >= 1.0e-3){
                    MaestroG.subscripterSymFirst2I("t","max"," = "+MaestroA.rounder(state.Travel_max,6)+" [s]",g,state.font14,x+state.s100,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,state.font14,x+state.s100,y);
                }
                else if(state.Travel_max < 1.0e-6){
                    MaestroG.subscripterSymFirst2I("t","max"," = "+MaestroA.rounder(state.Travel_max*1.0e9,3)+" [ns]",g,state.font14,x+state.s100,y);
                }

                y += dy;
                g.setColor(Color.black);
                MaestroG.subscripterB("Selected Ray","","",g,state.font13,x,y);

                y += dy;
                g.setColor(Color.blue.darker());
                MaestroG.subscripter("Travel Time","","",g,state.font14,x,y);
                //MaestroG.subscripterSymFirst2I("t",""," = "+MaestroA.rounder(state.Travel_ray,6)+" [\u03bcs]",g,14,x+s100,y);
                if(state.Travel_ray >= 1.0e-3){
                    MaestroG.subscripterSymFirst2I("t",""," = "+MaestroA.rounder(state.Travel_ray,6)+" [s]",g,state.font14,x+state.s100,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,state.font14,x+state.s100,y);
                }
                else if(state.Travel_ray < 1.0e-6){
                    MaestroG.subscripterSymFirst2I("t",""," = "+MaestroA.rounder(state.Travel_ray*1.0e9,3)+" [ns]",g,state.font14,x+state.s100,y);
                }

                y = ystart + dy + state.s50;
                int xnew = state.s500+state.s30;
                
                g.setColor(Color.blue.darker());
                MaestroG.subscripterB("Pulse Spread","","",g,state.font14,x+state.s300+state.s50,y);
                if(state.Travel_Delay >= 1.0e-3){
                    MaestroG.subsubsubsubsup2("\u03c4",""," =  t","max"," - t","min","","","",""," = "+MaestroA.rounder(state.Travel_Delay,6)+" [s]",g,state.font14,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,state.font14,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,state.font14,x+xnew,y);
                }

                 y = y + dy;
                g.setColor(Color.black);
                MaestroG.subscripterB("Minimum Pulse Period","","",g,state.font14,x+state.s300+state.s50,y);

                if(state.Travel_Delay >= 1.0e-3){
                    MaestroG.subsubsubsubsup2("T",""," = 2 \u03c4","","","","","","",""," = "+MaestroA.rounder(2.0*state.Travel_Delay,6)+" [s]",g,state.font14,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,state.font14,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,state.font14,x+xnew,y);
                }

                y = y + dy;
                g.setColor(Color.red.darker());
                MaestroG.subscripterB("Maximum Data Rate","","",g,state.font14,x+state.s300+state.s50,y);

                if(state.Data_Rate < 1.0e3){
                    MaestroG.subsubsubsubsup2("f","P","","","","","","","= ( 2 \u03c4 )","-1"," = "+MaestroA.rounder(state.Data_Rate,3)+" [bits/s]",g,state.font14,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,state.font14,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,state.font14,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,state.font14,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,state.font14,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,state.font14,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,state.font14,x+xnew,y);
                }

                y += (3*dy/2);

                //MaestroG.subsubsubsubsup2("SAFETY MARGIN    T",""," \u2265 2 \u03c4","","","","","","","","",g,state.font14,x,y);
                MaestroG.subsubsubsubsup2("SAFETY MARGIN    T","","   2 \u03c4","","","","","","","","",g,state.font14,x,y);
		g.drawImage(greater_or_equal,x+state.s198,y-greater_or_equal.getHeight(),this);

                //------------------------------  GRAPH
                int start_fiber, end_fiber;
                int xg1, xg2, xg3, xg4, xg5, xg6, xg7;
                int factorTau = state.s18;

                //  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 = state.s10; int step2 = (int)(state.T_factor * factorTau - step1);
                int yg2 = state.s50; int yg1 = state.s5; 
                //xg7 = 160 + 3*step1 + 3*step2;
                xg7 = state.s400+state.s30;
                xg6 = xg7 - factorTau;
                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-factorTau, 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+state.s5, xg3+step1/2, yg2+state.s21);
                g.drawLine(xg5+step1/2, yg2+state.s5, xg5+step1/2, yg2+state.s21);
                
                //MaestroG.drawArrow(xg3+state.s10+step1/2, yg2+state.s13, 8, g);
                //MaestroG.drawArrow(xg5-state.s10+step1/2, yg2+state.s13, 7, g);
                drawArrowScaled( xg3+state.s10+step1/2, yg2+state.s13, 4, state.sfactor, g);
                drawArrowScaled( xg5-state.s10+step1/2, yg2+state.s13, 3, state.sfactor, g);
                
                g.drawLine(xg3+step1/2, yg2+state.s13, xg5+step1/2, yg2+state.s13);
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
                MaestroG.subscripterSymFirst("T","","",g,state.font16,xg3+(xg5-xg3)/2-state.s5+step1/2,yg2+state.s30);

                //MaestroG.drawArrow(xg1-state.s10, (yg2+yg1)/2, 7, g);
                //MaestroG.drawArrow(xg2+state.s10, (yg2+yg1)/2, 8, g);
                drawArrowScaled( xg1-state.s10, (yg2+yg1)/2, 3, state.sfactor, g);
                drawArrowScaled( xg2+state.s10, (yg2+yg1)/2, 4, state.sfactor, g);
                
                g.drawLine(xg1-state.s15, (yg2+yg1)/2, xg1, (yg2+yg1)/2);
                g.drawLine(xg2+state.s15, (yg2+yg1)/2, xg2, (yg2+yg1)/2);
                MaestroG.subscripterSymFirst("\u03c4","i","",g,state.font18,xg1-state.s33,(yg2+yg1)/2);

                step1 = state.s10; step2 = (int)(state.T_factor * factorTau - step1); 
                xg1 = state.s600+state.s20; xg2 = xg1 + step1; xg3 = xg2 + step2; 
                xg4 = xg3 + step1; xg5 = xg4 + step2; 
                xg6 = xg5 + step1; xg7 = xg6 + step2;
                end_fiber = xg1 - factorTau;
                yg2 = state.s50; yg1 = state.s5; int yg3 = yg1 + yg2/2; double T_factor0 = 3.5;
                int step3 = (int)(T_factor0 * factorTau - step1); 

                // OUTPUT PULSES
                Color Colorino = Color.lightGray;
                g.setColor(Color.lightGray);
                drawDashLineThick(g, (double) xg1-factorTau, (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);
                
                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);
                
                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(xg3+step1/2, yg2+state.s5, xg3+step1/2, yg2+state.s21);
                g.drawLine(xg5+step1/2, yg2+state.s5, xg5+step1/2, yg2+state.s21);
                
                //MaestroG.drawArrow(xg3+state.s10+step1/2, yg2+state.s13, 8, g);
                //MaestroG.drawArrow(xg5-state.s10+step1/2, yg2+state.s13, 7, g);
                drawArrowScaled( xg3+state.s10+step1/2, yg2+state.s13, 4, state.sfactor, g);
                drawArrowScaled( xg5-state.s10+step1/2, yg2+state.s13, 3, state.sfactor, g);
                
                g.drawLine(xg3+step1/2, yg2+state.s13, xg5+step1/2, yg2+state.s13);
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
                MaestroG.subscripterSymFirst("T","","",g,state.font16,xg3+(xg5-xg3)/2-state.s5+step1/2,yg2+state.s30);

                //  OUTPUT - BROADENED PULSES (SIMPLE TRIANGLE TO SET THINGS UP)
                g.setColor(Color.red);
                //==================================================================
                // 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);
                // 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);
                // 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+state.s5, xg1+step1/2-step3/2, yg2+state.s21);
                g.drawLine(xg1+step1/2+step3/2, yg2+state.s5, xg1+step1/2+step3/2, yg2+state.s21);
                
                //MaestroG.drawArrow(xg1+state.s10+step1/2-step3/2, yg2+state.s13, 8, g);
                //MaestroG.drawArrow(xg1-state.s10+step1/2+step3/2, yg2+state.s13, 7, g);
                drawArrowScaled( xg1+state.s10+step1/2-step3/2, yg2+state.s13, 4, state.sfactor, g);
                drawArrowScaled( xg1-state.s10+step1/2+step3/2, yg2+state.s13, 3, state.sfactor, g);
                
                g.drawLine(xg1+step1/2-step3/2, yg2+state.s13, xg1+step1/2+step3/2, yg2+state.s13);
                //g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
                MaestroG.subscripterSymFirst("\u03c4","","",g,state.font18,xg1-state.s5+step1/2,yg2+state.s25);

                // draw the fiber
                g.setColor(Color.lightGray);
                g.drawOval(end_fiber-state.s25,yg1+(yg2-yg1)/2-state.s10,state.s15,state.s20);
                drawLineThick(g, (double)(start_fiber+state.s17), (double)(yg1+(yg2-yg1)/2), (double)(end_fiber-state.s20), (double)(yg1+(yg2-yg1)/2), state.s10, Color.gray);
                int rule; float alpha; rule = AlphaComposite.SRC_OVER;
                g2d.setComposite(AlphaComposite.getInstance(rule, 0.5f));
                drawLineThick(g, (double)(start_fiber+state.s15), (double)(yg1+(yg2-yg1)/2), (double)(end_fiber-state.s20), (double)(yg1+(yg2-yg1)/2), state.s20, new Color(200,200,255));
                g2d.setComposite(AlphaComposite.getInstance(rule, 1.0f));
                g.setColor(Color.gray);
                g.drawOval(start_fiber+state.s5,yg1+(yg2-yg1)/2-state.s10,state.s15,state.s20);
                g.drawArc(end_fiber-state.s25,yg1+(yg2-yg1)/2-state.s10,state.s15,state.s20,270,180);
                drawLineThick(g, (double)(start_fiber+state.s16), (double)(yg1+(yg2-yg1)/2)-state.s10, (double)(end_fiber-state.s20), (double)(yg1+(yg2-yg1)/2)-state.s10, 1, Color.black);
                drawLineThick(g, (double)(start_fiber+state.s16), (double)(yg1+(yg2-yg1)/2)+state.s10, (double)(end_fiber-state.s20), (double)(yg1+(yg2-yg1)/2)+state.s10, 1, Color.black);
                MaestroG.subscripterB("Fiber","","",g,state.font14,start_fiber+(end_fiber-start_fiber)/2-state.s20,yg2+state.s5);

                MaestroG.subscripter("The safety margin is used because of pulse spreading. Reduce T to observe","","",g,state.font14,state.s300+state.s20,state.s140);
                MaestroG.subscripter("how increased data rate may cause interference between consecutive pulses.","","",g,state.font14,state.s300+state.s20,state.s160);

                double test_rate; int xx = state.s600+state.s50; int yy = state.s110;
                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,state.font14,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,state.font14,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,state.font14,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,state.font14,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,state.font14,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,state.font14,xx,yy);
                }
                else if(test_rate >= 1.0e15 && state.Lmax == 0.0){
                    MaestroG.subscripter("","","",g,state.font14,xx,yy);
                }
            }
            else{
                //System.out.println("STATE IS NOT GUIDING   Guiding = "+state.Guiding);
                g.clearRect(0,0,getSize().width,getSize().height);

                g.setColor(Color.white);
                g.drawRect(0,0,getSize().width-1,getSize().height-1);
                
                g.setColor(Color.red);
                if(state.epsilon_r2 < state.epsilon_r3){
                    MaestroG.subsubSym("","\u03b5","rf"," < \u03b5","rc","    Guidance Condition Not Established",g,state.font24,state.s10,state.s80);
                }
                else if(state.epsilon_r2 == state.epsilon_r3){
                    MaestroG.subsubSym("","\u03b5","rf"," = \u03b5","rc","    Guidance Condition Not Established",g,state.font24,state.s10,state.s80);
                }
                MaestroG.subsubSym("Please, reduce  ","\u03b5","rc","","","",g,state.font24,state.s10,state.s130);
                
            }
	}
        
        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 drawArrowScaled(int x, int y, int tipo, double sfactor, Graphics g){
            Graphics2D g2d = (Graphics2D)g;
            double s;
            s = sfactor;

            switch (tipo){

              case 1://ArrowUpSmooth
                   g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

                    g.drawLine(x,y-1,x,y+(int)(s*5));
                    //draw oblique arrow head
                    Polygon pH = new Polygon();
                    pH.addPoint(x-(int)(s*2), y-(int)(s*2));
                    pH.addPoint(x+(int)(s*2), y-(int)(s*2));
                    pH.addPoint(x,y-(int)(s*8));
                    g.drawPolygon(pH);
                    g.fillPolygon(pH);

                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);

              break;

              case 2://ArrowDownSmooth
                   g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

                    g.drawLine(x,y+1,x,y-(int)(s*5));
                    //draw oblique arrow head
                    Polygon pJ = new Polygon();
                    pJ.addPoint(x-(int)(s*2), y+(int)(s*2));
                    pJ.addPoint(x+(int)(s*2), y+(int)(s*2));
                    pJ.addPoint(x,y+(int)(s*8));
                    g.drawPolygon(pJ);
                    g.fillPolygon(pJ);

                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
               break;

               case 3://ArrowRightSmooth
                   g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

                    g.drawLine(x+1,y,x-(int)(s*5),y);
                    //draw oblique arrow head
                    Polygon pK = new Polygon();
                    pK.addPoint(x+(int)(s*2), y-(int)(s*2));
                    pK.addPoint(x+(int)(s*2), y+(int)(s*2));
                    pK.addPoint(x+(int)(s*8),y);
                    g.drawPolygon(pK);
                    g.fillPolygon(pK);

                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);

               break;

               case 4://ArrowLeftSmooth
                   g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

                    g.drawLine(x-1,y,x+(int)(s*5),y);
                    //draw oblique arrow head
                    Polygon pL = new Polygon();
                    pL.addPoint(x-(int)(s*2), y-(int)(s*2));
                    pL.addPoint(x-(int)(s*2), y+(int)(s*2));
                    pL.addPoint(x-(int)(s*8),y);
                    g.drawPolygon(pL);
                    g.fillPolygon(pL);

                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);

               break;

               case 5://ArrowOblique 45 degrees pointing NE
                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

                    //draw oblique arrow head
                    Polygon pM = new Polygon();

                    pM.addPoint(x+(int)(s*6),y-(int)(s*6)); // longer arrow
                    pM.addPoint(x+(int)(s*1),y-(int)(s*3));
                    pM.addPoint(x+(int)(s*2),y+(int)(s*1));

                    g.drawPolygon(pM);
                    g.fillPolygon(pM);

                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);

               break;

               case 6://ArrowOblique 45 degrees pointing SW
                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

                    //draw oblique arrow head
                    Polygon pN = new Polygon();

                    pN.addPoint(x-(int)(s*6),y+(int)(s*6)); 
                    pN.addPoint(x-(int)(s*1),y+(int)(s*3));
                    pN.addPoint(x-(int)(s*2),y-(int)(s*2));

                    g.drawPolygon(pN);
                    g.fillPolygon(pN);

                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);

               break;

               case 7://Larger ArrowRightSmooth
                   g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

                    Polygon pR = new Polygon();
                    pR.addPoint(x, y-(int)(s*3));
                    pR.addPoint(x, y+(int)(s*3));
                    pR.addPoint(x+(int)(s*7),y);
                    g.drawPolygon(pR);
                    g.fillPolygon(pR);

                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);

               break;

               case 8://Larger ArrowLeftSmooth
                   g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

                    Polygon pS = new Polygon();
                    pS.addPoint(x, y-(int)(s*3));
                    pS.addPoint(x, y+(int)(s*3));
                    pS.addPoint(x-(int)(s*7),y);
                    g.drawPolygon(pS);
                    g.fillPolygon(pS);

                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);

               break;

               case 9://ArrowUpSmooth
                   g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

                    Polygon pU = new Polygon();
                    pU.addPoint(x-(int)(s*3), y);
                    pU.addPoint(x+(int)(s*3), y);
                    pU.addPoint(x,y-(int)(s*7));
                    g.drawPolygon(pU);
                    g.fillPolygon(pU);

                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);

              break;

              case 10://ArrowDownSmooth
                   g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

                    Polygon pD = new Polygon();
                    pD.addPoint(x-(int)(s*3), y);
                    pD.addPoint(x+(int)(s*3), y);
                    pD.addPoint(x,y+(int)(s*7));
                    g.drawPolygon(pD);
                    g.fillPolygon(pD);

                    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
               break;
            }		
        }

        //-------------------------------------------------------------------------------------------------
    
        
        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 Font normalfont;
        private Font normalfont2;
	private Font subfont;
	private Font titlefont;
	private Font symbfont;
	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){
	    normalfont = new Font("Sanserif",Font.PLAIN,state.font11);
            normalfont2 = new Font("Sanserif",Font.PLAIN,state.font12);
            subfont = new Font("Sanserif",Font.PLAIN,state.font10);
            titlefont = new Font("Sanserif",Font.BOLD,state.font16);
            symbfont = new Font("Serif",Font.PLAIN,state.font13);
            int x, x2, x3, x4, x5, xshift, y, ystart, dx, dxx, dy, dyy;
	    FontMetrics fm;
            
	    x = state.s20;
            x2 = state.s200+state.s70;
            x3 = state.s500+state.s70;
            x4 = state.s700+state.s20;
            x5 = state.s900;
	    ystart = state.s70;
            y = ystart;
	    dx = state.s80;
	    dxx = state.s15;
            xshift = state.s20;
	    g.clearRect(0,0,getSize().width,getSize().height);
	    String unit;
            
            unit = "\u03bcm";
            int fonto = state.font12;
	    g.setFont(titlefont);
            g.setColor(Color.blue.darker());
	    
	    g.setFont(normalfont2);
	    fm = g.getFontMetrics();
	    dy = state.s25;
	    dyy = dy + state.s5;
	    
            Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            
            g.setColor(Color.red);
            MaestroG.subscripterB("Propagation Properties","","",g,state.font18,state.s10,state.s20);
            
            double test;
            test = state.wavelength1*1.0e6;
            g.setColor(Color.red.darker());
            y = ystart;
            MaestroG.subscripterB("Wavelength - medium 1","","",g,state.font14,x,y);
            y+= dy;
            MaestroG.subscripterBSym("\u03bb","0","",g,state.font14,x,y);
            Write(g,test, state.font14, unit, x+xshift, y);
            
            test = state.wavelength2*1.0e6;
            g.setColor(Color.blue.darker());
            y+= dyy;
            MaestroG.subscripterB("Wavelength - medium 2","","",g,state.font14,x,y);
            y+= dy;
            MaestroG.subscripterBSym("\u03bb","f","",g,state.font14,x,y);
            Write(g,test, state.font14, unit, x+xshift, y);
            
            y+= dyy;
            MaestroG.subscripterB("Phase Velocity","","",g,state.font14,x,y);
            y+= dy;
            MaestroG.subsubsubsubsup3B("\u03c5","pf"," = ","","","","","",""+MaestroA.rounder((state.c/state.index2/1.0e8),3)+" \u00d7 10","8"," [m/s]",g,state.font14,x,y);
            
            
            test = state.wavelength3*1.0e6;
            g.setColor(Color.black);
            y+= dyy;
            MaestroG.subscripterB("Wavelength - medium 3","","",g,state.font14,x,y);
            y+= dy;
            MaestroG.subscripterBSym("\u03bb","c","",g,state.font14,x,y);
            Write(g,test, state.font14, unit, x+xshift, y);
            
            
            //------------------------------------------------------------------
            y = ystart;
            g.setColor(Color.red.darker());
            if(state.Show_index){
                MaestroG.subscripterB("Relative Permittivity - medium 1","","",g,state.font14,x2,y);
                y+= dy;
                MaestroG.subscripterB("\u03b5","r0"," = "+MaestroA.rounder(state.epsilon_r1,6), g, state.font14, x2, y);
            }
            else{
                MaestroG.subscripterB("Index of Refraction - medium 1","","",g,state.font14,x2,y);
                y+= dy;
                MaestroG.subscripterB("n","0"," = "+MaestroA.rounder(state.index1,6), g, state.font14, x2, y);
            }
            //------------------------------------------------------------------
            y += dyy;
            g.setColor(Color.blue.darker());
            if(state.Show_index){
                MaestroG.subscripterB("Relative Permittivity - medium 2","","",g,state.font14,x2,y);
                y+= dy;
                MaestroG.subscripterB("\u03b5","rf"," = "+MaestroA.rounder(state.epsilon_r2,6), g, state.font14, x2, y);
            }
            else{
                MaestroG.subscripterB("Index of Refraction - medium 2","","",g,state.font14,x2,y);
                y+= dy;
                MaestroG.subscripterB("n","f"," = "+MaestroA.rounder(state.index2,6), g, state.font14, x2, y);
            }
            //------------------------------------------------------------------
            g.setColor(Color.black);
            y+= dyy;
            if(state.Show_index){
                MaestroG.subscripterB("Relative Permittivity - medium 3","","",g,state.font14,x2,y);
                y+= dy;
                MaestroG.subscripterB("\u03b5","rc"," = "+MaestroA.rounder(state.epsilon_r3,6), g, state.font14, x2, y);
            }
            else{
                MaestroG.subscripterB("Index of Refraction - medium 3","","",g,state.font14,x2,y);
                y+= dy;
                MaestroG.subscripterB("n","c"," = "+MaestroA.rounder(state.index3,6), g, state.font14, x2, y);
            }
            
            y = ystart;
            g.setColor(Color.black);
	    MaestroG.subscripterB("Ray Angles","","",g,state.font13,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,state.font14,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,state.font14,x3,y);
                }
                else{
                    MaestroG.subscripterBSym("\u03b8","2"," = undef.",g,state.font14,x3,y);
                }
            }
            else{
                MaestroG.subscripterBSym("\u03b8","2"," = undef.",g,state.font14,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,state.font14,x3,y);
                }
                else{
                    MaestroG.subscripterBSym("\u03b8","3"," = undef.",g,state.font14,x3,y);
                }
            }
            else{
                MaestroG.subscripterBSym("\u03b8","3"," = undef.",g,state.font14,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,state.font14,x3,y);
                }
                else{
                    MaestroG.subscripterBSym("\u03b8","t"," = undef.",g,state.font14,x3,y);
                }
            }
            else{
                MaestroG.subscripterBSym("\u03b8","t"," = undef.",g,state.font14,x3,y);
            }
            
            y = ystart;
            g.setColor(Color.blue.darker());
	    MaestroG.subscripterB("Acceptance Angle","","",g,state.font13,x4,y);
            y = ystart + dy;
            g.setColor(Color.blue);
            MaestroG.subscripterBSym("\u03b8","i max"," = "+MaestroA.rounder(state.theta_range,4)+"\u00ba",g,state.font14,x4,y);
            y += dy;
            MaestroG.subscripterBSym("\u03b8","2 max"," = "+MaestroA.rounder(90.0 - state.totalRclad_angle,4)+"\u00ba",g,state.font14,x4,y);
            
            y = y+3*dy/2;
            g.setColor(Color.blue.darker());
	    MaestroG.subscripterB("Critical Angle","","",g,state.font13,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,state.font14,x4,y);
            }
            else{
                MaestroG.subscripterBSym("\u03b8","3c"," = undef.",g,state.font14,x4,y);
            }
            
            y = ystart;
            g.setColor(Color.red.darker());
	    MaestroG.subscripterB("Numerical Aperture","","",g,state.font14,x5,y);
            
            y += dy;
            MaestroG.subsubsubsubsup("NA = n","0"," sin ( \u03b8","i max"," ) = ( \u03b5","rf"," - \u03b5","rc"," )","0.5",g,state.font14,x5,y);	
	    y += dy;
            MaestroG.subscripterB("NA = ","",""+MaestroA.rounder(state.numerical_aperture,6),g,state.font13,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,state.font16));
            g.drawString("R",x5,y);
            Write(g,test, state.font14, unit, x5+xshift, y);
            unit = "\u03bb";
            y+= dy;
            Write2(g,test2, state.font14, 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);
        }
}
