//Trans_OutputPanel.java
/* A Java class for
 * LossyWide.java
 * Electromagnetic Transmission Line Applet
 * Applet without Smith Chart - Prepared by Umberto Ravaioli 
 * for 6th edition of Fundamentals of Applied Electromagnetics Book
 * May 2009 - All Rights Reserved
 */ 
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;

public class Trans_OutputPanel extends Panel implements ItemListener{
    private static final Color bgcolor = new Color(236,236,236);
    //private static final Font symbolfont=new Font("Serif",Font.PLAIN,12);
    //private static final Font titlefont=new Font("SanSerif",Font.BOLD,16);
    public static Font symbolfont;
    public static Font titlefont;
    public static Font normalfont;
    public static Font normalfontSerif;
    Label titlelabel;
    public Choice c1;
    public SpaceDependentCanvas canvas1;
    public SpaceIndependentCanvas canvas2;
    
    Trans_State state;
    public Trans_OutputPanel(Trans_State state){
	super();
	this.state = state;
	titlelabel = new Label("Output",Label.CENTER);
	setLayout(null);
	add(titlelabel);
	titlelabel.setFont(new Font("SanSerif",Font.BOLD,state.font14));
    
	setBackground(bgcolor);
	
	c1 = new Choice();
	c1.addItem("     Transmission Line Data 1");
	c1.addItem("     Transmission Line Data 2");
	c1.setBackground(bgcolor);
        c1.setFont(new Font("SanSerif",Font.ITALIC,state.font12));
	
	canvas1 = new SpaceDependentCanvas(state);
	canvas2 = new SpaceIndependentCanvas(state);
	
	add(titlelabel);
	add(c1);
	add(canvas1);
	add(canvas2);
	
	titlelabel.setBounds(state.s10,state.s5,state.s60,state.s19);
	c1.setBounds(state.s80,state.s5,state.s220,state.s20);
	canvas1.setBounds(state.s8,state.s33,state.s296,state.s250);
	canvas2.setBounds(state.s8,state.s33,state.s296,state.s250);
	
	//Listeners
	c1.addItemListener(this);
    }
    
    public void itemStateChanged(ItemEvent evt){
	ItemSelectable ie = evt.getItemSelectable();
	    if(evt.getSource()==c1){
		if(ie.getSelectedObjects()[0]=="     Transmission Line Data 1"){
		    canvas1.setVisible(true);
		    canvas2.setVisible(false);
		    //canvas3.setVisible(false);
		}
		else if(ie.getSelectedObjects()[0]=="     Transmission Line Data 2"){
		    canvas1.setVisible(false);
		    canvas2.setVisible(true);
		    //canvas3.setVisible(false);
		}
	    }
    }	
    
    public void paint(Graphics g){
	    g.clearRect(0,0,getSize().width,getSize().height);
	    g.setColor(bgcolor.darker());
	    g.fillRect(0,getSize().height-2,getSize().width,2);
	    g.fillRect(getSize().width-2,0,2,getSize().height);
	    g.setColor(bgcolor.brighter());
	    g.fillRect(0,0,2,getSize().height-1);
	    g.fillRect(0,0,getSize().width-2,2);
	}
}

class SpaceDependentCanvas extends Canvas{
    //private static final Font normalfont = new Font("SanSerif",Font.PLAIN,11);
    //private static final Font normalfontSerif = new Font("Serif",Font.PLAIN,13);
    //private static final Font symbolfont=new Font("Serif",Font.PLAIN,12);
    //public static final Font normalfont = Trans_OutputPanel.normalfont;
    //public static final Font normalfontSerif = Trans_OutputPanel.normalfontSerif;
    //public static final Font symbolfont = Trans_OutputPanel.symbolfont;
	Trans_State state;
	private Image im;
	private Graphics buf;
    
    private BufferedImage angle_img;

	public SpaceDependentCanvas(Trans_State state){
	    super();
	    this.state = state;
	    getImages();
	}

    private void getImages() {
        // read in character images that CHEERPJ will not render
	//   (java to javascript converter)
	double font11_factor = 11.0 * state.sfactor;
	long fontsize = Math.round(font11_factor);
	if (fontsize > 30) fontsize = 30;
	else if (fontsize < 11) fontsize = 11;
	String filename = "angle_"+String.valueOf(fontsize)+".png";
        try {
	    angle_img = ImageIO.read(getClass().getResource(filename));
            //angle_img = ImageIO.read(getClass().getResource("angle.png"));
        } 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){
	//public void paint(Graphics g){
	    int x, y, dx, dxx, dy, dyy, stepx;
            double tempR = 0.0; double tempX = 0.0;
            boolean Gamma_plusone, Gamma_minusone;
            Font newfont = new Font("Serif",Font.PLAIN,state.font11);
            Font newfontSS = new Font("SanSerif",Font.PLAIN,state.font11);
            //Font symbolfont = Trans_OutputPanel.symbolfont;
            FontMetrics fm;
		
            Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);

            String alpha, Ohm, lambda, infinity, Gamma, plusj, minusj, 
                   sign, plusr, minusr, signr;

            alpha="\u03b1";
            lambda="\u03bb";
            Ohm="\u03a9";
            infinity="\u221e";
            Gamma="\u0393";

            plusj =" + j ";
            minusj=" - j ";
            plusr ="";
            minusr =" - ";
                
            Gamma_plusone = false;
            Gamma_minusone = false;
	    Complex tempc;
	    
	    double temp, Tolerance;
	    
            Tolerance = 1.0E-10;
	    x = state.s10;
	    y = state.s15;
	    dx = state.s45;
            dxx = state.s15;
	    
	    g.setFont(newfontSS);
	    fm = g.getFontMetrics();
	    
            dy = fm.getHeight();
	    dyy = dy + state.s7;
	    
            g.clearRect(0,0,getSize().width,getSize().height);
	    g.setColor(Color.blue);
	    g.drawString("Cursor",x,y);
	    
	    g.setColor(Color.black);
	    double testlength = state.xpos*state.wavelength;
	    int range = 7;
	    if(state.lineLength < 1.0){
		range = 7;
	    }
	    else if(state.lineLength >= 1.0 && state.lineLength < 10.0){
		range = 6;
	    }
	    else if(state.lineLength >= 10.0 && state.lineLength < 100.0){
		range = 5;
	    }
	    else if(state.lineLength >= 100.0 && state.lineLength < 1000.0){
		range = 4;
	    }
	    else if(state.lineLength >= 1000.0 && state.lineLength < 10000.0){
		range = 3;
	    }
	    else if(state.lineLength >= 10000.0 && state.lineLength < 100000.0){
		range = 2;
	    }
	    else if(state.lineLength >= 100000.0){
		range = 1;
	    }
	    
	    
          if(testlength == 0.0){
                g.drawString("    d   = "+MaestroA.rounder(state.xpos,range)+"      = "+MaestroA.rounder(state.xpos*state.wavelength,6)+" m",x+dx,y);	
                g.setFont(newfont);
                g.drawString(""+lambda,x+dx+fm.stringWidth("    d   = "+MaestroA.rounder(state.xpos,range))+state.s4,y);
          } 
          else{
            
            if(testlength < 1.0E-9 && testlength > 0.0){
		g.drawString("    d   = "+MaestroA.rounder(state.xpos,range)+"      = "+MaestroA.rounder(state.xpos*state.wavelength*1.0e9,8)+" nm",x+dx,y);	
	    }
	    else if(testlength < 1.0E-6 && testlength >= 1.0E-9){
		g.drawString("    d   = "+MaestroA.rounder(state.xpos,range)+"      = "+MaestroA.rounder(state.xpos*state.wavelength*1.0e9,4)+" nm",x+dx,y);	
	    }
	    else if(testlength < 1.0E-3 && testlength >= 1.0E-6){
		g.drawString("    d   = "+MaestroA.rounder(state.xpos,range)+"      = "+MaestroA.rounder(state.xpos*state.wavelength*1.0e6,4)+" \u00b5m",x+dx,y);	
	    }
	    else if(testlength < 1.0 && testlength >= 1.0E-3){
		g.drawString("    d   = "+MaestroA.rounder(state.xpos,range)+"      = "+MaestroA.rounder(state.xpos*state.wavelength*1000,4)+" mm",x+dx,y);	
	    }
	    else if((testlength < 1000.0 && testlength >= 1.0 )){
		g.drawString("    d   = "+MaestroA.rounder(state.xpos,range)+"      = "+MaestroA.rounder(state.xpos*state.wavelength,6)+" m",x+dx,y);	
	    }
	    else if(testlength >= 1000.0 && testlength < 1.0E6){
		g.drawString("    d   = "+MaestroA.rounder(state.xpos,range)+"      = "+MaestroA.rounder(state.xpos*state.wavelength/1000.0,4)+" km",x+dx,y);	
	    }
	    else if(testlength >= 1.0E6 && testlength < 1.0E9){
		g.drawString("    d   = "+MaestroA.rounder(state.xpos,range)+"      = "+MaestroA.rounder(state.xpos*state.wavelength/1.0E6,4)+" Mm",x+dx,y);	
	    }
	    else if(testlength >= 1.0E9){
		g.drawString("    d   = "+MaestroA.rounder(state.xpos,range)+"      = "+MaestroA.rounder(state.xpos*state.wavelength/1.0E9,4)+" Gm",x+dx,y);	
	    }
	    
	    g.setFont(newfont);
	    g.drawString(""+lambda,x+dx+fm.stringWidth("    d   = "+MaestroA.rounder(state.xpos,range))+4,y);
          }
            
            g.setFont(newfontSS);
	    
	    g.setColor(Color.white);	
	    g.drawLine(state.s5,y+dyy/5,getSize().width-state.s5,y+dyy/4);
	    
            dx = state.s25;
	    y += dyy;
            dx = state.s75;
            
            double testmag = Complex.Magnitude(state.Zin);
            Complex Zmag = state.Zin;

            double testmag2 = Complex.Magnitude(state.Yin);
            Complex Ymag = state.Yin;
            
                if(Complex.Real(state.Gammain) > 0.999999 && Math.abs(Complex.Imaginary(state.Gammain)) < 0.000001){
		    Gamma_plusone = true;
		    Gamma_minusone = false;
		}
		else if(Complex.Real(state.Gammain) < -0.999999 && Math.abs(Complex.Imaginary(state.Gammain)) < 0.000001){
		    Gamma_plusone = false;
		    Gamma_minusone = true;
		}
		else{
		    Gamma_plusone = false;
		    Gamma_minusone = false;
		}
	    
            g.setColor(Color.red);
            g.drawString("Impedance",x,y);
            //g.drawString("  [ "+Ohm+" ]",x,y+dy);  
            MaestroG.SansNosansSymb2("",""," [ "+Ohm+" ]",g,state.font10,x,y+dy);

            g.setColor(Color.black); 
            	MaestroG.subscripter("Z","","(d)",g,state.font11,x+dx,y);
                int xinit2, xinit3;
                xinit2 = x+dxx+state.s90;
                    
                if((state.IsLoadOpen || state.IsLoadImaginary) && Gamma_plusone){
		    //MaestroG.subscripter("= "+infinity,"","",g,state.font11,xinit2,y);
                    MaestroG.subscripterInfinityOne("= ","","","",g,state.font11,xinit2,y);

                    g.drawString("=  (Open Circuit)  " ,xinit2,y+dy);
                    y+=dy;
		}
		else if((state.IsLoadOpen || state.IsLoadImaginary) && Gamma_minusone){
		    MaestroG.subscripter("= 0.0 + j 0.0","","",g,state.font11,xinit2,y);
                    //MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+0.0+" rad",g,state.font11,xinit2,y+dy);
		    MaestroG.TxtImgTxt("= 0.0",angle_img,""+0.0+" rad",g,state.font11,xinit2,y+dy,this);
                    y+=dy;
		}
		else if((state.IsLoadShort || state.IsLoadImaginary) && Gamma_plusone){
		    //MaestroG.subscripter("= "+infinity,"","",g,state.font11,xinit2,y);
                    MaestroG.subscripterInfinityOne("= ","","","",g,state.font11,xinit2,y);

                    g.drawString("=  (Open Circuit)  " ,xinit2,y+dy);
                    y+=dy;
		}
		else if((state.IsLoadShort || state.IsLoadImaginary) && Gamma_minusone){
		    MaestroG.subscripter("= 0.0 + j 0.0","","",g,state.font11,xinit2,y);
                    //MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+0.0+" rad",g,state.font11,xinit2,y+dy);
		    MaestroG.TxtImgTxt("= 0.0",angle_img,""+0.0+" rad",g,state.font11,xinit2,y+dy,this);
                    y+=dy;
		}
   
		else{
                    
                    tempR=0.0; tempX=0.0;
                    stepx = 0;
                    
		    if(Complex.Imaginary(state.Zin) >= 0.0){sign = plusj;}
		    else{sign = minusj;}
		    
		    if((state.IsLoadImaginary || state.IsLoadOpen || state.IsLoadShort)){
			if(state.IsLossLess){
                            tempR = 0.0;
                        }
                        else{
                            tempR = state.Zin.Real();
                        }
		    }
		    else if(state.IsLoadRegular){
			tempR = state.Zin.Real();
		    }
                    
                    if(state.IsLoadReal && state.xpos == 0.0){
                        tempX = 0.0;
                    }
                    else{
                        tempX = Math.abs(state.Zin.Imaginary());
                    }
		    
                    if(Math.abs(tempX) < (Math.abs(tempR)*Tolerance)){tempX = 0.0;}
                    
                    if(tempR < 1.0E3 && tempR >= 1.0E-3){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR,6),"","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR,6));
		    }
		    else if(tempR == 0.0){
			MaestroG.superscripter("= 0.0","","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= 0.0 ");
		    }
		    else if(tempR < 1.0E6 && tempR >= 1.0E3){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-3,2)+"x 10 3");
		    }
		    else if(tempR < 1.0E9 && tempR >= 1.0E6){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-6,2)+"x 10 6");
		    }
		    else if(tempR < 1.0E12 && tempR >= 1.0E9){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-9,2)+"x 10 9");
		    }
		    else if(tempR < 1.0E15 && tempR >= 1.0E12){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-12,2)+"x 10 12");
		    }
		    else if(tempR < 1.0E18 && tempR >= 1.0E15){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-15,2)+"x 10 15");
		    }
		    else if(tempR < 1.0E21 && tempR >= 1.0E18){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-18,2)+"x 10 18");
		    }
		    else if(tempR < 1.0E24 && tempR >= 1.0E21){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-21,2)+"x 10 21");
		    }
		    else if(tempR < 1.0E27 && tempR >= 1.0E24){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-24,2)+"x 10 24");
		    }
		    else if(tempR < 1.0E30 && tempR >= 1.0E27){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-27,2)+"x 10 27");
		    }
		    else if(tempR >= 1.0E30){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-30,2)+"x 10 30");
		    }
		    else if(tempR < 1.0E-3 && tempR >= 1.0E-6){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E6,2)+"x 10 -6");
		    }
		    else if(tempR < 1.0E-6 && tempR >= 1.0E-9){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E9,2)+"x 10 -9");
		    }
		    else if(tempR < 1.0E-9 && tempR >= 1.0E-12){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E12,2)+"x 10 -12");
		    }
		    else if(tempR < 1.0E-12 && tempR >= 1.0E-15){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E15,2)+"x 10 -15");
		    }
		    else if(tempR < 1.0E-15 && tempR >= 1.0E-18){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E18,2)+"x 10 -18");
		    }
		    else if(tempR < 1.0E-18 && tempR >= 1.0E-21){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E21,2)+"x 10 -21");
		    }
		    else if(tempR < 1.0E-21 && tempR >= 1.0E-24){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E24,2)+"x 10 -24");
		    }
                    else if(tempR < 1.0E-24 && tempR >= 1.0E-27){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E27,2)+"x 10 -27");
		    }
                    else if(tempR < 1.0E-27 && tempR >= 1.0E-30){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E30,2)+"x 10 -30");
		    }
                    else if(tempR < 1.0E-30 && tempR != 0.0){
			MaestroG.superscripter("= 0.0","","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= 0.0");
		    }
		    
		    xinit3 = xinit2+stepx;
		    
		    if(tempX < 1.0E3 && tempX >= 1.0E-3){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX,6),"","",g,state.font11,xinit3,y);
		    }
		    else if(tempX == 0.0){
			MaestroG.superscripter(" + j 0.0","","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E6 && tempX >= 1.0E3){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-3,2)+" x 10","3","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E9 && tempX >= 1.0E6){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-6,2)+" x 10","6","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E12 && tempX >= 1.0E9){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-9,2)+" x 10","9","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E15 && tempX >= 1.0E12){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-12,2)+" x 10","12","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E18 && tempX >= 1.0E15){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-15,2)+" x 10","15","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E21 && tempX >= 1.0E18){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-18,2)+" x 10","18","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E24 && tempX >= 1.0E21){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-21,2)+" x 10","21","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E27 && tempX >= 1.0E24){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-24,2)+" x 10","24","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E30 && tempX >= 1.0E27){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-27,2)+" x 10","27","",g,state.font11,xinit3,y);
		    }
		    else if(tempX >= 1.0E30){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-30,2)+" x 10","30","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-3 && tempX >= 1.0E-6){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E6,2)+" x 10","-6","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-6 && tempX >= 1.0E-9){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E9,2)+" x 10","-9","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-9 && tempX >= 1.0E-12){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E12,2)+" x 10","-12","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-12 && tempX >= 1.0E-15){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E15,2)+" x 10","-15","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-15 && tempX >= 1.0E-18){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E18,2)+" x 10","-18","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-18 && tempX >= 1.0E-21){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E21,2)+" x 10","-21","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-21 && tempX >= 1.0E-24){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E24,2)+" x 10","-24","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-24 && tempX >= 1.0E-27){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E27,2)+" x 10","-27","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-27 && tempX >= 1.0E-30){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E30,2)+" x 10","-30","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-30 && tempX != 0.0){
			MaestroG.superscripter(sign+" 0.0","","",g,state.font11,xinit3,y);
		    }
		//}
                
                ///-----------------------------------------------------------------------       
                
                y += dy;
           	    
		    tempR = Complex.Magnitude(state.Zin);
                    double dtmp2;
     
                    if(tempR == 0.0){dtmp2 = 0.0;}
                    else{dtmp2=MaestroA.rounder(state.Zin.Arg2(),4);}
                
                    		    
		    if(tempR < 1.0E3 && tempR >= 1.0E-3){
                        //MaestroG.SansMiditalic("= "+MaestroA.rounder(tempR,6),"  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= "+MaestroA.rounder(tempR,6),angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR == 0.0){
			//MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= 0.0",angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E6 && tempR >= 1.0E3){
                        //MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E9 && tempR >= 1.0E6){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E12 && tempR >= 1.0E9){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E15 && tempR >= 1.0E12){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E18 && tempR >= 1.0E15){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E21 && tempR >= 1.0E18){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E24 && tempR >= 1.0E21){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E27 && tempR >= 1.0E24){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E30 && tempR >= 1.0E27){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR >= 1.0E30){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-3 && tempR >= 1.0E-6){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-6 && tempR >= 1.0E-9){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-9 && tempR >= 1.0E-12){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-12 && tempR >= 1.0E-15){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-15 && tempR >= 1.0E-18){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-18 && tempR >= 1.0E-21){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-21 && tempR >= 1.0E-24){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-24 && tempR >= 1.0E-27){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-27 && tempR >= 1.0E-30){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-30 && tempR != 0.0){
			//MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= 0.0",angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
            }
  
            //-----------------------------------------------------------------
	    g.setColor(new Color(120,120,120));
	    g.drawLine(state.s5,y+dyy/5,getSize().width-state.s5,y+dyy/4);
	    
	    y += dyy;
	    
	    g.setColor(Color.red);
	    g.drawString("Admittance",x,y);
	    g.drawString("  [ S ]",x,y+dy);
	    
	    g.setColor(Color.black);
	    
            MaestroG.subscripter("Y","","(d)",g,state.font11,x+dx,y);
               
                xinit2 = x+dxx+state.s90;
                    
                if((state.IsLoadOpen || state.IsLoadImaginary) && Gamma_plusone){
		    MaestroG.subscripter("= 0.0 + j 0.0","","",g,state.font11,xinit2,y);
                    //MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+0.0+" rad",g,state.font11,xinit2,y+dy);
		    MaestroG.TxtImgTxt("= 0.0",angle_img,""+0.0+" rad",g,state.font11,xinit2,y+dy,this);
                    y+=dy;
		}
		else if((state.IsLoadOpen || state.IsLoadImaginary) && Gamma_minusone){
                    //MaestroG.subscripter("= "+infinity,"","",g,state.font11,xinit2,y);
                    MaestroG.subscripterInfinityOne("= ","","","",g,state.font11,xinit2,y);

                    g.drawString("=  (Short Circuit)  " ,xinit2,y+dy);
                    y+=dy;
		}
		else if((state.IsLoadShort || state.IsLoadImaginary) && Gamma_plusone){
		    MaestroG.subscripter("= 0.0 + j 0.0","","",g,state.font11,xinit2,y);
                    //MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+0.0+" rad",g,state.font11,xinit2,y+dy);
		    MaestroG.TxtImgTxt("= 0.0",angle_img,""+0.0+" rad",g,state.font11,xinit2,y+dy,this);
                    y+=dy;
		}
		else if((state.IsLoadShort || state.IsLoadImaginary) && Gamma_minusone){
		    //MaestroG.subscripter("= "+infinity,"","",g,state.font11,xinit2,y);
                    MaestroG.subscripterInfinityOne("= ","","","",g,state.font11,xinit2,y);
                    g.drawString("=  (Short Circuit)  " ,xinit2,y+dy);
                    y+=dy;
		}
   
		else{
                
                    tempR=0.0; tempX=0.0;
                    stepx = 0;
                    
		    if(Complex.Imaginary(state.Yin) >= 0.0){sign = plusj;}
		    else{sign = minusj;}
		    
		    if(state.IsLoadImaginary || state.IsLoadOpen || state.IsLoadShort){
			if(state.IsLossLess){
                            tempR = 0.0;
                        }
                        else{
                            tempR = state.Yin.Real();
                        }
		    }
		    else if(state.IsLoadRegular){
			tempR = state.Yin.Real();
		    }
                    
                    if(state.IsLoadReal && state.xpos == 0.0){
                        tempX = 0.0;
                    }
                    else{
                        tempX = Math.abs(state.Yin.Imaginary());
                    }
                    
                    if(Math.abs(tempX) < (Math.abs(tempR)*Tolerance)){tempX = 0.0;}
                    		    
		    if(tempR < 1.0E3 && tempR >= 1.0E-3){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR,6),"","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR,6));
		    }
		    else if(tempR == 0.0){
			MaestroG.superscripter("= 0.0","","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= 0.0 ");
		    }
		    else if(tempR < 1.0E6 && tempR >= 1.0E3){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-3,2)+"x 10 3");
		    }
		    else if(tempR < 1.0E9 && tempR >= 1.0E6){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-6,2)+"x 10 6");
		    }
		    else if(tempR < 1.0E12 && tempR >= 1.0E9){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-9,2)+"x 10 9");
		    }
		    else if(tempR < 1.0E15 && tempR >= 1.0E12){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-12,2)+"x 10 12");
		    }
		    else if(tempR < 1.0E18 && tempR >= 1.0E15){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-15,2)+"x 10 15");
		    }
		    else if(tempR < 1.0E21 && tempR >= 1.0E18){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-18,2)+"x 10 18");
		    }
		    else if(tempR < 1.0E24 && tempR >= 1.0E21){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-21,2)+"x 10 21");
		    }
		    else if(tempR < 1.0E27 && tempR >= 1.0E24){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-24,2)+"x 10 24");
		    }
		    else if(tempR < 1.0E30 && tempR >= 1.0E27){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-27,2)+"x 10 27");
		    }
		    else if(tempR >= 1.0E30){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E-30,2)+"x 10 30");
		    }
		    else if(tempR < 1.0E-3 && tempR >= 1.0E-6){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E6,2)+"x 10 -6");
		    }
		    else if(tempR < 1.0E-6 && tempR >= 1.0E-9){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E9,2)+"x 10 -9");
		    }
		    else if(tempR < 1.0E-9 && tempR >= 1.0E-12){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E12,2)+"x 10 -12");
		    }
		    else if(tempR < 1.0E-12 && tempR >= 1.0E-15){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E15,2)+"x 10 -15");
		    }
		    else if(tempR < 1.0E-15 && tempR >= 1.0E-18){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E18,2)+"x 10 -18");
		    }
		    else if(tempR < 1.0E-18 && tempR >= 1.0E-21){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E21,2)+"x 10 -21");
		    }
		    else if(tempR < 1.0E-21 && tempR >= 1.0E-24){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E24,2)+"x 10 -24");
		    }
                    else if(tempR < 1.0E-24 && tempR >= 1.0E-27){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E27,2)+"x 10 -27");
		    }
                    else if(tempR < 1.0E-27 && tempR >= 1.0E-30){
			MaestroG.superscripter("= "+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+MaestroA.rounder(tempR*1.0E30,2)+"x 10 -30");
		    }
                    else if(tempR < 1.0E-30 && tempR != 0.0){
			MaestroG.superscripter("= 0.0","","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= 0.0");
		    }
		    
		    xinit3 = xinit2+stepx;
		    
		    if(tempX < 1.0E3 && tempX >= 1.0E-3){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX,6),"","",g,state.font11,xinit3,y);
		    }
		    else if(tempX == 0.0){
			MaestroG.superscripter(" + j 0.0","","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E6 && tempX >= 1.0E3){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-3,2)+" x 10","3","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E9 && tempX >= 1.0E6){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-6,2)+" x 10","6","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E12 && tempX >= 1.0E9){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-9,2)+" x 10","9","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E15 && tempX >= 1.0E12){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-12,2)+" x 10","12","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E18 && tempX >= 1.0E15){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-15,2)+" x 10","15","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E21 && tempX >= 1.0E18){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-18,2)+" x 10","18","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E24 && tempX >= 1.0E21){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-21,2)+" x 10","21","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E27 && tempX >= 1.0E24){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-24,2)+" x 10","24","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E30 && tempX >= 1.0E27){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-27,2)+" x 10","27","",g,state.font11,xinit3,y);
		    }
		    else if(tempX >= 1.0E30){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-30,2)+" x 10","30","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-3 && tempX >= 1.0E-6){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E6,2)+" x 10","-6","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-6 && tempX >= 1.0E-9){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E9,2)+" x 10","-9","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-9 && tempX >= 1.0E-12){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E12,2)+" x 10","-12","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-12 && tempX >= 1.0E-15){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E15,2)+" x 10","-15","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-15 && tempX >= 1.0E-18){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E18,2)+" x 10","-18","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-18 && tempX >= 1.0E-21){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E21,2)+" x 10","-21","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-21 && tempX >= 1.0E-24){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E24,2)+" x 10","-24","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-24 && tempX >= 1.0E-27){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E27,2)+" x 10","-27","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-27 && tempX >= 1.0E-30){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E30,2)+" x 10","-30","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-30 && tempX != 0.0){
			MaestroG.superscripter(sign+" 0.0","","",g,state.font11,xinit3,y);
		    }
		//}
                
                ///-----------------------------------------------------------------------       
                
                y += dy;
           	    
		    tempR = Complex.Magnitude(state.Yin);
                    double dtmp2;
     
                    if(tempR == 0.0){dtmp2 = 0.0;}
                    else{dtmp2=MaestroA.rounder(state.Yin.Arg2(),4);}
                
                    		    
		    if(tempR < 1.0E3 && tempR >= 1.0E-3){
                        //MaestroG.SansMiditalic("= "+MaestroA.rounder(tempR,6),"  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= "+MaestroA.rounder(tempR,6),angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR == 0.0){
			//MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= 0.0",angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E6 && tempR >= 1.0E3){
                        //MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E9 && tempR >= 1.0E6){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E12 && tempR >= 1.0E9){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E15 && tempR >= 1.0E12){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E18 && tempR >= 1.0E15){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E21 && tempR >= 1.0E18){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E24 && tempR >= 1.0E21){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E27 && tempR >= 1.0E24){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E30 && tempR >= 1.0E27){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR >= 1.0E30){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-3 && tempR >= 1.0E-6){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-6 && tempR >= 1.0E-9){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-9 && tempR >= 1.0E-12){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-12 && tempR >= 1.0E-15){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-15 && tempR >= 1.0E-18){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-18 && tempR >= 1.0E-21){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-21 && tempR >= 1.0E-24){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-24 && tempR >= 1.0E-27){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-27 && tempR >= 1.0E-30){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-30 && tempR != 0.0){
			//MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= 0.0",angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
            }
            
            //-----------------------------------------------------------------
	    g.setColor(Color.white);	
            g.drawLine(state.s5,y+dyy/5,getSize().width-state.s5,y+dyy/4);
	    y += dyy;
	    
	    g.setColor(Color.red);	    	    
	    g.drawString("Reflection",x,y);
            g.drawString("Coefficient",x,y+dy);
	    	    
	    g.setColor(Color.black);
	                
            MaestroG.subscripterSS3("  "+Gamma,"d","",g,state.font11,x+dx,y);
	    g.drawString("= "+state.Gammain.toString(Complex.CARTESIAN,8,false),xinit2,y);
	    y += dy;
	    
	    /*
            g.drawString("         = "+state.Gammain.toString(Complex.CARTESIAN,6,false),x+dx,y);
	    y += dy;
	    
	    g.drawString("         = "+state.Gammain.toString(Complex.POLAR_RADIAN,6,5),x+dx,y);
	    y += dy;
	    g.drawString("         = "+state.Gammain.toString(Complex.POLAR_DEGREE,6,5),x+dx,y);    
            */
            
            double gtmp1, gtmp2, gtmp3;
            gtmp1=MaestroA.rounder(state.Gammain.Magnitude(),8);
            if(gtmp1 == 0.0){gtmp2 = 0.0; gtmp3 = 0.0;}
            else{
                   gtmp2=MaestroA.rounder(state.Gammain.Arg2(),6);
                   gtmp3=MaestroA.rounder(state.Gammain.Arg2()*180/Math.PI,6);
	    }
	    //MaestroG.SansMiditalic("= "+gtmp1,"  \u2220 ",""+gtmp2+" rad",g,state.font11,xinit2,y);
	    MaestroG.TxtImgTxt("= "+gtmp1,angle_img,""+gtmp2+" rad",g,state.font11,xinit2,y,this);
	     
	    y += dy;
	    //MaestroG.SansMiditalic("= "+gtmp1,"  \u2220 ",""+gtmp3+" \u00ba",g,state.font11,xinit2,y);
	    MaestroG.TxtImgTxt("= "+gtmp1,angle_img,""+gtmp3+" \u00ba",g,state.font11,xinit2,y,this);
	    
    
                
	    g.setColor(new Color(120,120,120));
	    g.drawLine(state.s5,y+dyy/5,getSize().width-state.s5,y+dyy/4);    
	    y += dyy;
            
            g.setColor(Color.red);
	    g.drawString("Voltage",x,y);
            g.drawString("  [ V ]",x,y+dy); 
            g.setColor(Color.black);
            
            MaestroG.subscripterWavy("V","","(d)",g,state.font11,x+dx,y);
            tempR=0.0; tempX=0.0;
            stepx = 0;
                    
                    if(Complex.Real(state.Vin) >= 0.0){signr = plusr;}
		    else{signr = minusr;}
		    if(Complex.Imaginary(state.Vin) >= 0.0){sign = plusj;}
		    else{sign = minusj;}
		    
		    //if(state.IsLoadImaginary || state.IsLoadOpen || state.IsLoadShort){
			//tempR = 0.0;
		    //}
		    //else if(state.IsLoadRegular){
			tempR = Math.abs(state.Vin.Real());
		    //}
		    tempX = Math.abs(state.Vin.Imaginary());
		    
                    if(Math.abs(tempX) < (Math.abs(tempR)*Tolerance)){tempX = 0.0;}
                    if(Math.abs(tempR) < (Math.abs(tempX)*Tolerance)){tempR = 0.0;}
                    
                        
		    if(tempR < 1.0E3 && tempR >= 1.0E-3){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR,6),"","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR,6));
		    }
		    else if(tempR == 0.0){
			MaestroG.superscripter("= 0.0","","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= 0.0 ");
		    }
		    else if(tempR < 1.0E6 && tempR >= 1.0E3){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-3,2)+"x 10 3");
		    }
		    else if(tempR < 1.0E9 && tempR >= 1.0E6){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-6,2)+"x 10 6");
		    }
		    else if(tempR < 1.0E12 && tempR >= 1.0E9){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-9,2)+"x 10 9");
		    }
		    else if(tempR < 1.0E15 && tempR >= 1.0E12){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-12,2)+"x 10 12");
		    }
		    else if(tempR < 1.0E18 && tempR >= 1.0E15){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-15,2)+"x 10 15");
		    }
		    else if(tempR < 1.0E21 && tempR >= 1.0E18){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-18,2)+"x 10 18");
		    }
		    else if(tempR < 1.0E24 && tempR >= 1.0E21){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-21,2)+"x 10 21");
		    }
		    else if(tempR < 1.0E27 && tempR >= 1.0E24){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-24,2)+"x 10 24");
		    }
		    else if(tempR < 1.0E30 && tempR >= 1.0E27){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-27,2)+"x 10 27");
		    }
		    else if(tempR >= 1.0E30){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-30,2)+"x 10 30");
		    }
		    else if(tempR < 1.0E-3 && tempR >= 1.0E-6){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E6,2)+"x 10 -6");
		    }
		    else if(tempR < 1.0E-6 && tempR >= 1.0E-9){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E9,2)+"x 10 -9");
		    }
		    else if(tempR < 1.0E-9 && tempR >= 1.0E-12){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E12,2)+"x 10 -12");
		    }
		    else if(tempR < 1.0E-12 && tempR >= 1.0E-15){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E15,2)+"x 10 -15");
		    }
		    else if(tempR < 1.0E-15 && tempR >= 1.0E-18){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E18,2)+"x 10 -18");
		    }
		    else if(tempR < 1.0E-18 && tempR >= 1.0E-21){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E21,2)+"x 10 -21");
		    }
		    else if(tempR < 1.0E-21 && tempR >= 1.0E-24){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E24,2)+"x 10 -24");
		    }
                    else if(tempR < 1.0E-24 && tempR >= 1.0E-27){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E27,2)+"x 10 -27");
		    }
                    else if(tempR < 1.0E-27 && tempR >= 1.0E-30){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E30,2)+"x 10 -30");
		    }
                    else if(tempR < 1.0E-30 && tempR != 0.0){
			MaestroG.superscripter("= 0.0","","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= 0.0");
		    }
		    
		    xinit3 = xinit2+stepx;
		    
		    if(tempX < 1.0E3 && tempX >= 1.0E-3){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX,6),"","",g,state.font11,xinit3,y);
		    }
		    else if(tempX == 0.0){
			MaestroG.superscripter(" + j 0.0","","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E6 && tempX >= 1.0E3){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-3,2)+" x 10","3","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E9 && tempX >= 1.0E6){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-6,2)+" x 10","6","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E12 && tempX >= 1.0E9){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-9,2)+" x 10","9","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E15 && tempX >= 1.0E12){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-12,2)+" x 10","12","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E18 && tempX >= 1.0E15){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-15,2)+" x 10","15","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E21 && tempX >= 1.0E18){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-18,2)+" x 10","18","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E24 && tempX >= 1.0E21){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-21,2)+" x 10","21","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E27 && tempX >= 1.0E24){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-24,2)+" x 10","24","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E30 && tempX >= 1.0E27){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-27,2)+" x 10","27","",g,state.font11,xinit3,y);
		    }
		    else if(tempX >= 1.0E30){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-30,2)+" x 10","30","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-3 && tempX >= 1.0E-6){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E6,2)+" x 10","-6","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-6 && tempX >= 1.0E-9){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E9,2)+" x 10","-9","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-9 && tempX >= 1.0E-12){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E12,2)+" x 10","-12","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-12 && tempX >= 1.0E-15){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E15,2)+" x 10","-15","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-15 && tempX >= 1.0E-18){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E18,2)+" x 10","-18","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-18 && tempX >= 1.0E-21){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E21,2)+" x 10","-21","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-21 && tempX >= 1.0E-24){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E24,2)+" x 10","-24","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-24 && tempX >= 1.0E-27){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E27,2)+" x 10","-27","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-27 && tempX >= 1.0E-30){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E30,2)+" x 10","-30","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-30 && tempX != 0.0){
			MaestroG.superscripter(sign+" 0.0","","",g,state.font11,xinit3,y);
		    }
		//}
                
                ///-----------------------------------------------------------------------       
                
                y += dy;
           	    
		    tempR = Complex.Magnitude(state.Vin);
                    double dtmp2;
     
                    if(tempR == 0.0){dtmp2 = 0.0;}
                    else{dtmp2=MaestroA.rounder(state.Vin.Arg2(),4);}
                
       
		    if(tempR < 1.0E3 && tempR >= 1.0E-3){
                        //MaestroG.SansMiditalic("= "+MaestroA.rounder(tempR,6),"  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= "+MaestroA.rounder(tempR,6),angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR == 0.0){
			//MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= 0.0",angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E6 && tempR >= 1.0E3){
                        //MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
                     }
		    else if(tempR < 1.0E9 && tempR >= 1.0E6){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
 		    }
		    else if(tempR < 1.0E12 && tempR >= 1.0E9){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
 		    }
		    else if(tempR < 1.0E15 && tempR >= 1.0E12){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
 		    }
		    else if(tempR < 1.0E18 && tempR >= 1.0E15){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
 		    }
		    else if(tempR < 1.0E21 && tempR >= 1.0E18){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
 		    }
		    else if(tempR < 1.0E24 && tempR >= 1.0E21){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
 		    }
		    else if(tempR < 1.0E27 && tempR >= 1.0E24){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
 		    }
		    else if(tempR < 1.0E30 && tempR >= 1.0E27){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
 		    }
		    else if(tempR >= 1.0E30){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
 		    }
		    else if(tempR < 1.0E-3 && tempR >= 1.0E-6){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-6 && tempR >= 1.0E-9){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-9 && tempR >= 1.0E-12){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-12 && tempR >= 1.0E-15){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-15 && tempR >= 1.0E-18){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-18 && tempR >= 1.0E-21){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-21 && tempR >= 1.0E-24){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-24 && tempR >= 1.0E-27){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-27 && tempR >= 1.0E-30){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-30 && tempR != 0.0){
			//MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= 0.0",angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    //--------------------------------------------------------------------------------------------------------------------------
            
	    g.setColor(Color.white);	
	    g.drawLine(state.s5,y+dyy/5,getSize().width-state.s5,y+dyy/4);    
	    y += dyy;
	    //-----------------------------------------------------------------
               
            g.setColor(Color.red);
	    g.drawString("Current",x,y);
            g.drawString("  [ A ]",x,y+dy); 
            g.setColor(Color.black);
            
            MaestroG.subscripterSSWavyC("I","","(d)",g,state.font11,x+dx,y);
            
            tempR=0.0; tempX=0.0;
            stepx = 0;
                    
                    if(Complex.Real(state.Iin) >= 0.0){signr = plusr;}
		    else{signr = minusr;}
		    if(Complex.Imaginary(state.Iin) >= 0.0){sign = plusj;}
		    else{sign = minusj;}
		    
		    //if(state.IsLoadImaginary || state.IsLoadOpen || state.IsLoadShort){
			//tempR = 0.0;
		    //}
		    //else if(state.IsLoadRegular){
			tempR = Math.abs(state.Iin.Real());
		    //}
		    
                    tempX = Math.abs(state.Iin.Imaginary());
		        
                    if(Math.abs(tempX) < (Math.abs(tempR)*Tolerance)){tempX = 0.0;}
                    if(Math.abs(tempR) < (Math.abs(tempX)*Tolerance)){tempR = 0.0;}
                                            
		    if(tempR < 1.0E3 && tempR >= 1.0E-3){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR,6),"","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR,6));
		    }
		    else if(tempR == 0.0){
			MaestroG.superscripter("= 0.0","","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= 0.0 ");
		    }
		    else if(tempR < 1.0E6 && tempR >= 1.0E3){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-3,2)+"x 10 3");
		    }
		    else if(tempR < 1.0E9 && tempR >= 1.0E6){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-6,2)+"x 10 6");
		    }
		    else if(tempR < 1.0E12 && tempR >= 1.0E9){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-9,2)+"x 10 9");
		    }
		    else if(tempR < 1.0E15 && tempR >= 1.0E12){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-12,2)+"x 10 12");
		    }
		    else if(tempR < 1.0E18 && tempR >= 1.0E15){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-15,2)+"x 10 15");
		    }
		    else if(tempR < 1.0E21 && tempR >= 1.0E18){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-18,2)+"x 10 18");
		    }
		    else if(tempR < 1.0E24 && tempR >= 1.0E21){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-21,2)+"x 10 21");
		    }
		    else if(tempR < 1.0E27 && tempR >= 1.0E24){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-24,2)+"x 10 24");
		    }
		    else if(tempR < 1.0E30 && tempR >= 1.0E27){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-27,2)+"x 10 27");
		    }
		    else if(tempR >= 1.0E30){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-30,2)+"x 10 30");
		    }
		    else if(tempR < 1.0E-3 && tempR >= 1.0E-6){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E6,2)+"x 10 -6");
		    }
		    else if(tempR < 1.0E-6 && tempR >= 1.0E-9){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E9,2)+"x 10 -9");
		    }
		    else if(tempR < 1.0E-9 && tempR >= 1.0E-12){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E12,2)+"x 10 -12");
		    }
		    else if(tempR < 1.0E-12 && tempR >= 1.0E-15){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E15,2)+"x 10 -15");
		    }
		    else if(tempR < 1.0E-15 && tempR >= 1.0E-18){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E18,2)+"x 10 -18");
		    }
		    else if(tempR < 1.0E-18 && tempR >= 1.0E-21){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E21,2)+"x 10 -21");
		    }
		    else if(tempR < 1.0E-21 && tempR >= 1.0E-24){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E24,2)+"x 10 -24");
		    }
                    else if(tempR < 1.0E-24 && tempR >= 1.0E-27){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E27,2)+"x 10 -27");
		    }
                    else if(tempR < 1.0E-27 && tempR >= 1.0E-30){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E30,2)+"x 10 -30");
		    }
                    else if(tempR < 1.0E-30 && tempR != 0.0){
			MaestroG.superscripter("= 0.0","","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= 0.0");
		    }
		    
		    xinit3 = xinit2+stepx;
		    
		    if(tempX < 1.0E3 && tempX >= 1.0E-3){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX,6),"","",g,state.font11,xinit3,y);
		    }
		    else if(tempX == 0.0){
			MaestroG.superscripter(" + j 0.0","","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E6 && tempX >= 1.0E3){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-3,2)+" x 10","3","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E9 && tempX >= 1.0E6){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-6,2)+" x 10","6","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E12 && tempX >= 1.0E9){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-9,2)+" x 10","9","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E15 && tempX >= 1.0E12){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-12,2)+" x 10","12","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E18 && tempX >= 1.0E15){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-15,2)+" x 10","15","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E21 && tempX >= 1.0E18){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-18,2)+" x 10","18","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E24 && tempX >= 1.0E21){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-21,2)+" x 10","21","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E27 && tempX >= 1.0E24){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-24,2)+" x 10","24","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E30 && tempX >= 1.0E27){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-27,2)+" x 10","27","",g,state.font11,xinit3,y);
		    }
		    else if(tempX >= 1.0E30){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-30,2)+" x 10","30","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-3 && tempX >= 1.0E-6){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E6,2)+" x 10","-6","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-6 && tempX >= 1.0E-9){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E9,2)+" x 10","-9","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-9 && tempX >= 1.0E-12){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E12,2)+" x 10","-12","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-12 && tempX >= 1.0E-15){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E15,2)+" x 10","-15","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-15 && tempX >= 1.0E-18){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E18,2)+" x 10","-18","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-18 && tempX >= 1.0E-21){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E21,2)+" x 10","-21","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-21 && tempX >= 1.0E-24){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E24,2)+" x 10","-24","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-24 && tempX >= 1.0E-27){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E27,2)+" x 10","-27","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-27 && tempX >= 1.0E-30){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E30,2)+" x 10","-30","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-30 && tempX != 0.0){
			MaestroG.superscripter(sign+" 0.0","","",g,state.font11,xinit3,y);
		    }
		//}
                
                ///-----------------------------------------------------------------------       
                
                y += dy;
           	    
		    tempR = Complex.Magnitude(state.Iin);
                        
                    if(tempR == 0.0){dtmp2 = 0.0;}
                    else{dtmp2=MaestroA.rounder(state.Iin.Arg2(),4);}
                
                    		    
		    if(tempR < 1.0E3 && tempR >= 1.0E-3){
                        //MaestroG.SansMiditalic("= "+MaestroA.rounder(tempR,6),"  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= "+MaestroA.rounder(tempR,6),angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR == 0.0){
			//MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= 0.0",angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E6 && tempR >= 1.0E3){
                        //MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E9 && tempR >= 1.0E6){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E12 && tempR >= 1.0E9){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E15 && tempR >= 1.0E12){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E18 && tempR >= 1.0E15){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E21 && tempR >= 1.0E18){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E24 && tempR >= 1.0E21){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E27 && tempR >= 1.0E24){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E30 && tempR >= 1.0E27){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR >= 1.0E30){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-3 && tempR >= 1.0E-6){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-6 && tempR >= 1.0E-9){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-9 && tempR >= 1.0E-12){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-12 && tempR >= 1.0E-15){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-15 && tempR >= 1.0E-18){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-18 && tempR >= 1.0E-21){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-21 && tempR >= 1.0E-24){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-24 && tempR >= 1.0E-27){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-27 && tempR >= 1.0E-30){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-30 && tempR != 0.0){
			//MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= 0.0",angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
            
            
            
	    g.setColor(new Color(120,120,120));
	    g.drawLine(state.s5,y+dyy/5,getSize().width-state.s5,y+dyy/4);
	    y += dyy;
	    
            g.setColor(Color.black);
            //g.drawString("<P(d)>",x+dx-8,y-1);
            MaestroG.subscripter("P","av","",g,state.font11,x+dx,y-state.s1);
	    g.setColor(Color.red);
	    g.drawString("Power Flow",x,y-state.s1);

	    if(state.Power_flow<=1.0E-30){
		g.drawString("  [ W ]",x,y+dy-state.s3);
		g.setColor(Color.black);
		g.drawString("= "+MaestroA.rounder(state.Power_flow,6)+"",xinit2,y-state.s1);
	    }
	    else if(state.Power_flow>=1.0 && state.Power_flow <1.0E3 ){
		g.drawString("  [ W ]",x,y+dy-state.s3);
		g.setColor(Color.black);
		g.drawString("= "+MaestroA.rounder(state.Power_flow,6)+"",xinit2,y-state.s1);
	    }
	    else if(state.Power_flow<1.0E6 && state.Power_flow>=1.0E3){
		g.drawString("  [ k W ]",x,y+dy-state.s3);
		g.setColor(Color.black);
		temp = state.Power_flow*1.0E-3;
		g.drawString("= "+MaestroA.rounder(temp,4)+"",xinit2,y-state.s1);
	    }
	    else if(state.Power_flow>=1.0E6){
		g.drawString("  [ M W ]",x,y+dy-state.s3);
		g.setColor(Color.black);
		temp = state.Power_flow*1.0E-6;
		g.drawString("= "+MaestroA.rounder(temp,2)+"",xinit2,y-state.s1);
	    }
	    else if(state.Power_flow<1.0 && state.Power_flow>=0.001){
		g.drawString("  [ m W ]",x,y+dy-state.s3);
		g.setColor(Color.black);
		temp = state.Power_flow*1.0E3;
		g.drawString("= "+MaestroA.rounder(temp,6)+"",xinit2,y-state.s1);
	    }
	    else if(state.Power_flow<1.0E-3 && state.Power_flow>=1.0E-6){
		g.drawString("  [ \u00b5 W ]",x,y+dy-state.s3);
		g.setColor(Color.black);
		temp = state.Power_flow*1.0E6;
		g.drawString("= "+MaestroA.rounder(temp,6)+"",xinit2,y-state.s1);
	    }
	    else if(state.Power_flow<1.0E-6 && state.Power_flow>=1.0E-9){
		g.drawString("  [ n W ]",x,y+dy-state.s3);
		g.setColor(Color.black);
		temp = state.Power_flow*1.0E9;
		g.drawString("= "+MaestroA.rounder(temp,6)+"",xinit2,y-state.s1);
	    }
	    else if(state.Power_flow<1.0E-9 && state.Power_flow>=1.0E-12){
		g.drawString("  [ p W ]",x,y+dy-state.s3);
		g.setColor(Color.black);
		temp = state.Power_flow*1.0E12;
		g.drawString("= "+MaestroA.rounder(temp,6)+"",xinit2,y-state.s1);
	    }
	    else if(state.Power_flow<1.0E-12 && state.Power_flow>=1.0E-15){
		g.drawString("  [ f W ]",x,y+dy-state.s3);
		g.setColor(Color.black);
		temp = state.Power_flow*1.0E15;
		g.drawString("= "+MaestroA.rounder(temp,6)+"",xinit2,y-state.s1);
	    }
	    else if(state.Power_flow<1.0E-15){
		g.drawString("  [ a W ]",x,y+dy-state.s3);
		g.setColor(Color.black);
		temp = state.Power_flow*1.0E18;
		g.drawString("= "+MaestroA.rounder(temp,6)+"",xinit2,y-state.s1);
	    }
	}
}

class SpaceIndependentCanvas extends Canvas{
    //private static final Font normalfont = new Font("SanSerif",Font.PLAIN,11);
    //private static final Font symbolfont = new Font("Serif",Font.PLAIN,12);
    public static final Font normalfont = Trans_OutputPanel.normalfont;
    public static final Font symbolfont = Trans_OutputPanel.symbolfont;
	Trans_State state;
        private Image im;
	private Graphics buf;
    
    private BufferedImage angle_img;
        
	public SpaceIndependentCanvas(Trans_State state){
	    super();
	    this.state = state;
	    getImages();
	}

    private void getImages() {
        // read in character images that CHEERPJ will not render
	//   (java to javascript converter)
	double font11_factor = 11.0 * state.sfactor;
	long fontsize = Math.round(font11_factor);
	if (fontsize > 30) fontsize = 30;
	else if (fontsize < 11) fontsize = 11;
	String filename = "angle_"+String.valueOf(fontsize)+".png";
        try {
	    angle_img = ImageIO.read(getClass().getResource(filename));
            //angle_img = ImageIO.read(getClass().getResource("angle.png"));
        } 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){
	    int x, y, dx, dxx, dxxx, dy, dyy;
	    double temp, temp2;
	    Complex tempc;
            Font newfont = new Font("Serif",Font.PLAIN,state.font11);
            Font newfontSS = new Font("SanSerif",Font.PLAIN,state.font11);
	    FontMetrics fm;
            
            String alpha, Ohm, lambda, infinity, Gamma, plusj, minusj, 
                       sign, plusr, minusr, signr;
		alpha="\u03b1";
		lambda="\u03bb";
		Ohm="\u03a9";
		infinity="\u221e";
		Gamma="\u0393";
                plusj =" + j ";
		minusj=" - j ";
                plusr ="";
                minusr =" - ";

	    
		float dmax, dmin;
		if(state.ZL.Imaginary()>0.0f){
		    dmax=(float)((state.GammaL.Arg2())/(4.0*Math.PI));
		    dmin=dmax+0.25f;
		}
		else{
		    dmax=(float)((state.GammaL.Arg2())/(4.0*Math.PI))+0.5f;
		    dmin=(float)((state.GammaL.Arg2())/(4.0*Math.PI))+0.25f;
		}

		while(dmax>0.5f) dmax=dmax-0.5f;
		while(dmin>0.5f) dmin=dmin-0.5f; 
	    
                g.clearRect(0,0,getSize().width-1,getSize().height-1);
                Graphics2D g2d = (Graphics2D)g;
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
                
	    x = state.s10;
	    y = state.s15;
	    dx = state.s80;
	    dxx = state.s15;
            dxxx = state.s80;
            
	    g.setFont(newfontSS);
	    fm = g.getFontMetrics();
	    
            dy = fm.getHeight();
	    //dyy = dy+3;    JAN
	    dyy = dy+state.s8;
            
	    g.setColor(Color.red);
	    //g.drawString("SWR",x+dxx,y); JAN
            g.drawString("SWR",x+dxx,y+state.s15); // JAN
	    //g.drawString("SWR(d)",x+dxx,y+state.s15);  JAN
	    g.setColor(Color.black);
	    if(state.VSWR >= 1.0){
		if(state.VSWR > 1.0e16){
		    
                    MaestroG.subscripterInfinityTwo("= ","","","","            (load)",g,state.font11,x+dx,y+state.s15);// for lossy line
                    MaestroG.subscripterInfinityTwo("= ","","","","            ",g,state.font11,x+dx,y+state.s15);
		}
		else if(state.VSWR >=100.0 && state.VSWR <= 1.0e16){
                    g.drawString("= "+MaestroA.rounder(state.VSWR,2)+"  (load)",x+dx,y+state.s15); // for lossy line
		    g.drawString("= "+MaestroA.rounder(state.VSWR,2)+"  ",x+dx,y+state.s15);
		}
		else{	
		    g.drawString("= "+MaestroA.rounder(state.VSWR,4)+"  (load)",x+dx,y+state.s15);// for lossy line
                    g.drawString("= "+MaestroA.rounder(state.VSWR,4)+"  ",x+dx,y+state.s15);
		}
	    }
	    else{ // for lossy line
		MaestroG.subscripterSymMiddle("= undefined   | ", "", "",Gamma, " | > 1.0",g,state.font11,x+dx,y+state.s15);
                g.setFont(normalfont);
	    }
	    
	    double VSWRin = (1.0+Complex.Magnitude(state.Gammain))/(1-Complex.Magnitude(state.Gammain)); // for lossy line
	    
            /*   JAN // for lossy line
	    if(VSWRin >= 1.0){
		if(VSWRin > 1.0e16){
		    MaestroG.subscripterInfinityTwo("= ","","","","            (cursor)",g,state.font11,x+dx,y+15);
		}
		else if(VSWRin >=100.0 && VSWRin <= 1.0e16){
		    g.drawString("= "+MaestroA.rounder(VSWRin,2)+"  (cursor)",x+dx,y+15);
		}
		else{	
		    g.drawString("= "+MaestroA.rounder(VSWRin,4)+"  (cursor)",x+dx,y+15);
		}
	    }
	    else{
                    MaestroG.subscripterSymMiddle("= undefined   | ", "", "",Gamma, " | > 1.0",g,state.font11,x+dx,y+15);
                    g.setFont(normalfont);
	    }
            */
	    	    
	    g.setColor(Color.white);
            y += state.s3;  // JAN (added)
	    g.drawLine(state.s5,y+dyy/4+state.s15,getSize().width-state.s5,y+dyy/4+state.s15); 
	    
	    y += dyy+state.s15;
	    //-----------------------------------------------------------------
            g.setColor(Color.red);
	    g.drawString("Amplitude of Incident Voltage Wave  [ V ]",x,y);
	    g.setColor(Color.black);
	    
	    y+= dy*15/10;
            
            //-------------------------------------------------------------------------------
            
            MaestroG.subscripterSpecialSubSup("V","o","+","",g,state.font11,x+state.s60,y);
            
            
            double tempR=0.0; double tempX=0.0; double Tolerance = 1.0E-10;
            int stepx = 0;
            int xinit2 = x+dxxx;
            
                    if(Complex.Real(state.VPlus) >= 0.0){signr = plusr;}
		    else{signr = minusr;}
		    if(Complex.Imaginary(state.VPlus) >= 0.0){sign = plusj;}
		    else{sign = minusj;}
		    
		    //if(state.IsLoadImaginary || state.IsLoadOpen || state.IsLoadShort){
			//tempR = 0.0;
		    //}
		    //else if(state.IsLoadRegular){
			tempR = Math.abs(state.VPlus.Real());
		    //}
		    tempX = Math.abs(state.VPlus.Imaginary());
		    
                    if(Math.abs(tempX) < (Math.abs(tempR)*Tolerance)){tempX = 0.0;}
                    if(Math.abs(tempR) < (Math.abs(tempX)*Tolerance)){tempR = 0.0;} 
                     
		    if(tempR < 1.0E3 && tempR >= 1.0E-3){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR,6),"","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR,6));
		    }
		    else if(tempR == 0.0){
			MaestroG.superscripter("= 0.0","","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= 0.0 ");
		    }
		    else if(tempR < 1.0E6 && tempR >= 1.0E3){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-3,2)+"x 10 3");
		    }
		    else if(tempR < 1.0E9 && tempR >= 1.0E6){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-6,2)+"x 10 6");
		    }
		    else if(tempR < 1.0E12 && tempR >= 1.0E9){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-9,2)+"x 10 9");
		    }
		    else if(tempR < 1.0E15 && tempR >= 1.0E12){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-12,2)+"x 10 12");
		    }
		    else if(tempR < 1.0E18 && tempR >= 1.0E15){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-15,2)+"x 10 15");
		    }
		    else if(tempR < 1.0E21 && tempR >= 1.0E18){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-18,2)+"x 10 18");
		    }
		    else if(tempR < 1.0E24 && tempR >= 1.0E21){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-21,2)+"x 10 21");
		    }
		    else if(tempR < 1.0E27 && tempR >= 1.0E24){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-24,2)+"x 10 24");
		    }
		    else if(tempR < 1.0E30 && tempR >= 1.0E27){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-27,2)+"x 10 27");
		    }
		    else if(tempR >= 1.0E30){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E-30,2)+"x 10 30");
		    }
		    else if(tempR < 1.0E-3 && tempR >= 1.0E-6){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E6,2)+"x 10 -6");
		    }
		    else if(tempR < 1.0E-6 && tempR >= 1.0E-9){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E9,2)+"x 10 -9");
		    }
		    else if(tempR < 1.0E-9 && tempR >= 1.0E-12){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E12,2)+"x 10 -12");
		    }
		    else if(tempR < 1.0E-12 && tempR >= 1.0E-15){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E15,2)+"x 10 -15");
		    }
		    else if(tempR < 1.0E-15 && tempR >= 1.0E-18){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E18,2)+"x 10 -18");
		    }
		    else if(tempR < 1.0E-18 && tempR >= 1.0E-21){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E21,2)+"x 10 -21");
		    }
		    else if(tempR < 1.0E-21 && tempR >= 1.0E-24){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E24,2)+"x 10 -24");
		    }
                    else if(tempR < 1.0E-24 && tempR >= 1.0E-27){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E27,2)+"x 10 -27");
		    }
                    else if(tempR < 1.0E-27 && tempR >= 1.0E-30){
			MaestroG.superscripter("= "+signr+""+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= "+signr+""+MaestroA.rounder(tempR*1.0E30,2)+"x 10 -30");
		    }
                    else if(tempR < 1.0E-30 && tempR != 0.0){
			MaestroG.superscripter("= 0.0","","",g,state.font11,xinit2,y);
			stepx = fm.stringWidth("= 0.0");
		    }
		    
		    int xinit3 = xinit2+stepx;
		    
		    if(tempX < 1.0E3 && tempX >= 1.0E-3){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX,6),"","",g,state.font11,xinit3,y);
		    }
		    else if(tempX == 0.0){
			MaestroG.superscripter(" + j 0.0","","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E6 && tempX >= 1.0E3){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-3,2)+" x 10","3","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E9 && tempX >= 1.0E6){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-6,2)+" x 10","6","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E12 && tempX >= 1.0E9){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-9,2)+" x 10","9","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E15 && tempX >= 1.0E12){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-12,2)+" x 10","12","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E18 && tempX >= 1.0E15){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-15,2)+" x 10","15","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E21 && tempX >= 1.0E18){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-18,2)+" x 10","18","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E24 && tempX >= 1.0E21){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-21,2)+" x 10","21","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E27 && tempX >= 1.0E24){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-24,2)+" x 10","24","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E30 && tempX >= 1.0E27){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-27,2)+" x 10","27","",g,state.font11,xinit3,y);
		    }
		    else if(tempX >= 1.0E30){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E-30,2)+" x 10","30","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-3 && tempX >= 1.0E-6){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E6,2)+" x 10","-6","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-6 && tempX >= 1.0E-9){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E9,2)+" x 10","-9","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-9 && tempX >= 1.0E-12){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E12,2)+" x 10","-12","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-12 && tempX >= 1.0E-15){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E15,2)+" x 10","-15","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-15 && tempX >= 1.0E-18){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E18,2)+" x 10","-18","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-18 && tempX >= 1.0E-21){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E21,2)+" x 10","-21","",g,state.font11,xinit3,y);
		    }
		    else if(tempX < 1.0E-21 && tempX >= 1.0E-24){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E24,2)+" x 10","-24","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-24 && tempX >= 1.0E-27){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E27,2)+" x 10","-27","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-27 && tempX >= 1.0E-30){
			MaestroG.superscripter(sign+""+MaestroA.rounder(tempX*1.0E30,2)+" x 10","-30","",g,state.font11,xinit3,y);
		    }
                    else if(tempX < 1.0E-30 && tempX != 0.0){
			MaestroG.superscripter(sign+" 0.0","","",g,state.font11,xinit3,y);
		    }
		//}
                
                ///-----------------------------------------------------------------------       
                
                y += dy;
           	    
		    tempR = Complex.Magnitude(state.VPlus);
                    double dtmp2;
     
                    if(tempR == 0.0){dtmp2 = 0.0;}
                    else{dtmp2=MaestroA.rounder(state.VPlus.Arg2(),4);}
                
                    		    
		    if(tempR < 1.0E3 && tempR >= 1.0E-3){
                        //MaestroG.SansMiditalic("= "+MaestroA.rounder(tempR,6),"  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= "+MaestroA.rounder(tempR,6),angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR == 0.0){
			//MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= 0.0",angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E6 && tempR >= 1.0E3){
                        //MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-3,2)+" x 10","3",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E9 && tempR >= 1.0E6){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-6,2)+" x 10","6",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E12 && tempR >= 1.0E9){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-9,2)+" x 10","9",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E15 && tempR >= 1.0E12){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-12,2)+" x 10","12",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E18 && tempR >= 1.0E15){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-15,2)+" x 10","15",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E21 && tempR >= 1.0E18){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-18,2)+" x 10","18",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E24 && tempR >= 1.0E21){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-21,2)+" x 10","21",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E27 && tempR >= 1.0E24){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-24,2)+" x 10","24",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E30 && tempR >= 1.0E27){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-27,2)+" x 10","27",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR >= 1.0E30){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E-30,2)+" x 10","30",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-3 && tempR >= 1.0E-6){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E6,2)+" x 10","-6",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-6 && tempR >= 1.0E-9){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E9,2)+" x 10","-9",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-9 && tempR >= 1.0E-12){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E12,2)+" x 10","-12",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-12 && tempR >= 1.0E-15){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E15,2)+" x 10","-15",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-15 && tempR >= 1.0E-18){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E18,2)+" x 10","-18",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-18 && tempR >= 1.0E-21){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E21,2)+" x 10","-21",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
		    else if(tempR < 1.0E-21 && tempR >= 1.0E-24){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E24,2)+" x 10","-24",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-24 && tempR >= 1.0E-27){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E27,2)+" x 10","-27",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-27 && tempR >= 1.0E-30){
			//MaestroG.SansMiditalicSuper("= "+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtSuperImgTxt("= "+MaestroA.rounder(tempR*1.0E30,2)+" x 10","-30",angle_img,
						""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }
                    else if(tempR < 1.0E-30 && tempR != 0.0){
			//MaestroG.SansMiditalic("= 0.0","  \u2220 ",""+dtmp2+" rad",g,state.font11,xinit2,y);
			MaestroG.TxtImgTxt("= 0.0",angle_img,""+dtmp2+" rad",g,state.font11,xinit2,y,this);
		    }        
      
            y+=state.s3;  // JAN
	    g.setColor(new Color(120,120,120));
	    g.drawLine(state.s5,y+dyy/5,getSize().width-state.s5,y+dyy/4);  
	    y+= dyy;
	    
	    g.setColor(Color.red);
	    g.drawString("Location of First Voltage Maximum & Minimum",x,y);
	    y+= dy*15/10;
            
            g.setColor(Color.black);
            
            // print dmax and dmin in wavelength units
            
            g.drawString("d (max)",x+dxx+state.s25,y);
            MaestroG.SansNosansSymb2("= "+MaestroA.rounder(dmax,5)+" ","",""+lambda,g,state.font11,xinit2,y);
	    y+=dy;
	    
	    g.drawString("d (min)",x+dxx+state.s25,y);
            MaestroG.SansNosansSymb2("= "+MaestroA.rounder(dmin,5)+" ","",""+lambda,g,state.font11,xinit2,y);
	    
            // print zmax and zmin in meter units
            int xmax, xmin, xgood;
            
            xmax = fm.stringWidth("d(max) = "+MaestroA.rounder(dmax,5));
            xmin = fm.stringWidth("d(min) = "+MaestroA.rounder(dmin,5));
            xgood = Math.max(xmax,xmin);
                  
            double testmax = dmax * state.wavelength;
            double testmin = dmin * state.wavelength;
            int rangemax = 7;
            int rangemin = 7;
            int dxmax = xgood - state.s5; int dystep = state.s20;
                        
            if(testmax < 1.0E-9 && testmax > 0.0){
		g.drawString("= "+MaestroA.rounder(testmax*1.0e9,8)+" nm",xinit2+dxmax,y-dy);	
	    }
	    else if(testmax < 1.0E-6 && testmax >= 1.0E-9){
		g.drawString("= "+MaestroA.rounder(testmax*1.0e9,4)+" nm",xinit2+dxmax,y-dy);	
	    }
	    else if(testmax < 1.0E-3 && testmax >= 1.0E-6){
		g.drawString("= "+MaestroA.rounder(testmax*1.0e6,4)+" \u00b5m",xinit2+dxmax,y-dy);	
	    }
	    else if(testmax <= 1.0 && testmax >= 1.0E-3){
		g.drawString("= "+MaestroA.rounder(testmax*1000,4)+" mm",xinit2+dxmax,y-dy);	
	    }
            else if((testmax < 1000.0 && testmax >= 1.0 ) || testmax == 0.0){
		g.drawString("= "+MaestroA.rounder(testmax,6)+" m",xinit2+dxmax,y-dy);	
	    }
	    else if(testmax >= 1000.0 && testmax < 1.0E6){
		g.drawString("= "+MaestroA.rounder(testmax/1000.0,4)+" km",xinit2+dxmax,y-dy);	
	    }
	    else if(testmax >= 1.0E6 && testmax < 1.0E9){
		//g.drawString("= "+MaestroA.rounder(testmax/1.0E6,4)+" Mm",xinit2+dxmax,y-dy);
                MaestroG.superscripter("= "+MaestroA.rounder(testmax/1.0E6,4)+" x 10","3"," km",g,state.font11,xinit2+dxmax,y-dy);
	    }
	    else if(testmax >= 1.0E9){
		//g.drawString("= "+MaestroA.rounder(testmax/1.0E9,4)+" Gm",xinit2+dxmax,y);
                MaestroG.superscripter("= "+MaestroA.rounder(testmax/1.0E9,4)+" x 10","6"," km",g,state.font11,xinit2+dxmax,y-dy);
	    }
            
            if(testmin < 1.0E-9 && testmin > 0.0){
		g.drawString("= "+MaestroA.rounder(testmin*1.0e9,8)+" nm",xinit2+dxmax,y);	
	    }
	    else if(testmin < 1.0E-6 && testmin >= 1.0E-9){
		g.drawString("= "+MaestroA.rounder(testmin*1.0e9,4)+" nm",xinit2+dxmax,y);	
	    }
	    else if(testmin < 1.0E-3 && testmin >= 1.0E-6){
		g.drawString("= "+MaestroA.rounder(testmin*1.0e6,4)+" \u00b5m",xinit2+dxmax,y);	
	    }
	    else if(testmin <= 1.0 && testmin >= 1.0E-3){
		g.drawString("= "+MaestroA.rounder(testmin*1000,4)+" mm",xinit2+dxmax,y);	
	    }
            else if((testmin < 1000.0 && testmin >= 1.0 ) || testmin == 0.0){
		g.drawString("= "+MaestroA.rounder(testmin,6)+" m",xinit2+dxmax,y);	
	    }
	    else if(testmin >= 1000.0 && testmin < 1.0E6){
		g.drawString("= "+MaestroA.rounder(testmin/1000.0,4)+" km",xinit2+dxmax,y);	
	    }
	    else if(testmin >= 1.0E6 && testmin < 1.0E9){
		//g.drawString("= "+MaestroA.rounder(testmin/1.0E6,4)+" Mm",xinit2+dxmax,y);
                MaestroG.superscripter("= "+MaestroA.rounder(testmin/1.0E6,4)+" x 10","3"," km",g,state.font11,xinit2+dxmax,y);
	    }
	    else if(testmin >= 1.0E9){
		//g.drawString("= "+MaestroA.rounder(testmin/1.0E9,4)+" Gm",xinit2+dxmax,y);
                MaestroG.superscripter("= "+MaestroA.rounder(testmin/1.0E9,4)+" x 10","6"," km",g,state.font11,xinit2+dxmax,y);
	    }
            
            
	    g.setColor(Color.white);	
            y += state.s3;  // JAN (added)
    	    g.drawLine(state.s5,y+dyy/5,getSize().width-state.s5,y+dyy/4); 
	    
	    g.setColor(Color.red);
	    y += dyy+state.s1;
	    g.drawString("TIME-AVERAGE POWER", x, y);
            
            int dx1 = state.s40;

            /* JAN
	    y+= dy;

	    g.setColor(Color.blue);
	    g.drawString("Absorbed by input",x+dx+dx+17,y);
	    g.setColor(Color.black);
            
            g.drawString("P( in )",x,y);
	    if(state.Power_input>=1.0 && state.Power_input<=1.0E3 || state.Power_input==0.0){
		g.drawString("= "+MaestroA.rounder(state.Power_input,6)+" [ W ]",x+dx1,y);
	    }
	    else if(state.Power_input<1.0E6 && state.Power_input>=1.0E3){
		temp = state.Power_input*1.0E-3;
		g.drawString("= "+MaestroA.rounder(temp,4)+" [ k W ]",x+dx1,y);
	    }
	    else if(state.Power_input>=1.0E6){
		temp = state.Power_input*1.0E-6;
		g.drawString("= "+MaestroA.rounder(temp,2)+" [ M W ]",x+dx1,y);
	    }
	    else if(state.Power_input<1.0 && state.Power_input>=0.001){
		temp = state.Power_input*1000;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ m W ]",x+dx1,y);
	    }
	    else if(state.Power_input<0.001 && state.Power_input>=1.0E-6){
		temp = state.Power_input*1.0E6;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ \u00b5 W ]",x+dx1,y);
	    }
	    else if(state.Power_input<1.0E-6 && state.Power_input>=1.0E-9){
		temp = state.Power_input*1.0E9;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ n W ]",x+dx1,y);
	    }
	    else if(state.Power_input<1.0E-9 && state.Power_input>=1.0E-12){
		temp = state.Power_input*1.0E12;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ p W ]",x+dx1,y);
	    }
	    else if(state.Power_input<1.0E-12 && state.Power_input>=1.0E-15){
		temp = state.Power_input*1.0E15;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ f W ]",x+dx1,y);
	    }
	    else if(state.Power_input<1.0E-15 && state.Power_input>=1.0E-18){
		temp = state.Power_input*1.0E18;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ a W ]",x+dx1,y);
	    }
	    else if(state.Power_input<1.0E-18){
		temp = 0.0;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ W ]",x+dx1,y);
	    }
            */
            
	    g.setColor(Color.blue);
	    y+= dy*15/10;
            
	    g.drawString("Absorbed by load",x+dx+dx+state.s17,y);
	
	    g.setColor(Color.black);
            
            g.drawString("P(abs)",x,y);
	    if((state.Power_load>=1.0 && state.Power_load<=1.0E3) || state.Power_load==0.0){
		g.drawString("= "+MaestroA.rounder(state.Power_load,6)+" [ W ]",x+dx1,y);
	    }
	    else if(state.Power_load<1.0E6 && state.Power_load>=1.0E3){
		temp = state.Power_load*1.0E-3;
		g.drawString("= "+MaestroA.rounder(temp,4)+" [ k W ]",x+dx1,y);
	    }
	    else if(state.Power_load>=1.0E6){
		temp = state.Power_load*1.0E-6;
		g.drawString("= "+MaestroA.rounder(temp,2)+" [ M W ]",x+dx1,y);
	    }
	    else if(state.Power_load<1.0 && state.Power_load>=0.001){
		temp = state.Power_load*1000;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ m W ]",x+dx1,y);
	    }
	    else if(state.Power_load<0.001 && state.Power_load>=1.0E-6){
		temp = state.Power_load*1.0E6;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ \u00b5 W ]",x+dx1,y);
	    }
	    else if(state.Power_load<1.0E-6 && state.Power_load>=1.0E-9){
		temp = state.Power_load*1.0E9;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ n W ]",x+dx1,y);
	    }
	    else if(state.Power_load<1.0E-9 && state.Power_load>=1.0E-12){
		temp = state.Power_load*1.0E12;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ p W ]",x+dx1,y);
	    }
	    else if(state.Power_load<1.0E-12 && state.Power_load>=1.0E-15){
		temp = state.Power_load*1.0E15;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ f W ]",x+dx1,y);
	    }
	    else if(state.Power_load<1.0E-15 && state.Power_load>=1.0E-18){
		temp = state.Power_load*1.0E18;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ a W ]",x+dx1,y);
	    }
	    else if(state.Power_load<1.0E-18){
		temp = 0.0;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ W ]",x+dx1,y);
	    }
            
	    /* JAN

	    y += dy;
	    g.setColor(Color.blue);
	    g.drawString("Absorbed by Line",x+dx+dx+17,y);
	    if(state.alpha==0.0){
		temp2 =0;
	    }
	    else{
		temp2 = state.Power_input - state.Power_load;
	    }
	    g.setColor(Color.black);
            
            g.drawString("P( line )",x,y);
	    if((temp2>=1.0 && temp2 <1.0E3) || temp2<=1.0E-30){
		g.drawString("= "+MaestroA.rounder(temp2,6)+" [ W ]",x+dx1,y);
	    }
	    else if(temp2<1.0E6 && temp2>=1.0E3){
		temp = temp2*1.0E-3;
		g.drawString("= "+MaestroA.rounder(temp,4)+" [ k W ]",x+dx1,y);
	    }
	    else if(temp2>=1.0E6){
		temp = temp2*1.0E-6;
		g.drawString("= "+MaestroA.rounder(temp,2)+" [ M W ]",x+dx1,y);
	    }
	    else if(temp2<1.0 && temp2>=0.001){
		temp = temp2*1000;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ m W ]",x+dx1,y);
	    }
	    else if(temp2<0.001 && temp2>=1.0E-6){
		temp = temp2*1.0E6;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ \u00b5 W ]",x+dx1,y);
	    }
	    else if(temp2<1.0E-6 && temp2>=1.0E-9){
		temp = temp2*1.0E9;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ n W ]",x+dx1,y);
	    }
	    else if(temp2<1.0E-9 && temp2>=1.0E-12){
		temp = temp2*1.0E12;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ p W ]",x+dx1,y);
	    }
	    else if(temp2<1.0E-12 && temp2>=1.0E-15){
		temp = temp2*1.0E15;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ f W ]",x+dx1,y);
	    }
	    else if(temp2<1.0E-15){
		temp = temp2*1.0E18;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ a W ]",x+dx1,y);
	    }

            */
    	   
	    y += dy;
	    g.setColor(Color.blue);
	    g.drawString("Absorbed by Zg",x+dx+dx+state.s17,y);
	    
	    
	    g.setColor(Color.black);
            g.drawString("P(Zg)",x,y);
            
	    if((state.Power_Zg>=1.0 && state.Power_Zg<1.0E3) || state.Power_Zg<=1.0E-30){
		g.drawString("= "+MaestroA.rounder(state.Power_Zg,6)+" [ W ]",x+dx1,y);
	    }
	    else if(state.Power_Zg<1.0E6 && state.Power_Zg>=1.0E3){
		temp = state.Power_Zg*1.0E-3;
		g.drawString("= "+MaestroA.rounder(temp,4)+" [ k W ]",x+dx1,y);
	    }
	    else if(state.Power_Zg>=1.0E6){
		temp = state.Power_Zg*1.0E-6;
		g.drawString("= "+MaestroA.rounder(temp,2)+" [ M W ]",x+dx1,y);
	    }
	    else if(state.Power_Zg<1.0 && state.Power_Zg>=0.001){
		temp = state.Power_Zg*1000;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ m W ]",x+dx1,y);
	    }
	    else if(state.Power_Zg<0.001 && state.Power_Zg>=1.0E-6){
		temp = state.Power_Zg*1.0E6;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ \u00b5 W ]",x+dx1,y);
	    }
	    else if(state.Power_Zg<1.0E-6 && state.Power_Zg>=1.0E-9){
		temp = state.Power_Zg*1.0E9;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ n W ]",x+dx1,y);
	    }
	    else if(state.Power_Zg<1.0E-9 && state.Power_Zg>=1.0E-12){
		temp = state.Power_Zg*1.0E12;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ p W ]",x+dx1,y);
	    }
	    else if(state.Power_Zg<1.0E-12 && state.Power_Zg>=1.0E-15){
		temp = state.Power_Zg*1.0E15;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ f W ]",x+dx1,y);
	    }
	    else if(state.Power_Zg<1.0E-15){
		temp = state.Power_Zg*1.0E18;
		g.drawString("= "+MaestroA.rounder(temp,6)+" [ a W ]",x+dx1,y);
	    }
	    
	    /* JAN
	    y += dyy;
	    g.setColor(Color.red);
	    g.drawString("Total time-average power from the generator",x,y);
	    y += dy;
	    g.setColor(Color.black);
	    if((state.Power_generator>=1.0 && state.Power_generator<1.0E3)|| state.Power_generator<=1.0E-30){
		g.drawString("P( tot ) = P( in ) + P( Zg ) = "+MaestroA.rounder(state.Power_generator,6)+" [ W ]",x+dxx,y);
	    }
	    else if(state.Power_generator<1.0E6 && state.Power_generator>=1.0E3){
		temp = state.Power_generator*1.0E-3;
		g.drawString("P( tot ) = P( in ) + P( Zg ) = "+MaestroA.rounder(temp,4)+" [ k W ]",x+dxx,y);
	    }
	    else if(state.Power_generator>=1.0E6){
		temp = state.Power_generator*1.0E-6;
		g.drawString("P( tot ) = P( in ) + P( Zg ) = "+MaestroA.rounder(temp,2)+" [ M W ]",x+dxx,y);
	    }
	    else if(state.Power_generator<1.0 && state.Power_generator>=0.001){
		temp = state.Power_generator*1000;
		g.drawString("P( tot ) = P( in ) + P( Zg ) = "+MaestroA.rounder(temp,6)+" [ m W ]",x+dxx,y);
	    }
	    else if(state.Power_generator<0.001 && state.Power_generator >=1.0E-6){
		temp = state.Power_generator*1.0E6;
		g.drawString("P( tot ) = P( in ) + P( Zg ) = "+MaestroA.rounder(temp,6)+" [ \u00b5 W ]",x+dxx,y);
	    }
	    else if(state.Power_generator<1.0E-6 && state.Power_generator >=1.0E-9){
		temp = state.Power_generator*1.0E9;
		g.drawString("P( tot ) = P( in ) + P( Zg ) = "+MaestroA.rounder(temp,6)+" [ n W ]",x+dxx,y);
	    }
	    else if(state.Power_generator<1.0E-9 && state.Power_generator >=1.0E-12){
		temp = state.Power_generator*1.0E12;
		g.drawString("P( tot ) = P( in ) + P( Zg ) = "+MaestroA.rounder(temp,6)+" [ p W ]",x+dxx,y);
	    }
	    else if(state.Power_generator<1.0E-12 && state.Power_generator>=1.0E-15){
		temp = state.Power_generator*1.0E15;
		g.drawString("P( tot ) = P( in ) + P( Zg ) = "+MaestroA.rounder(temp,6)+" [ f W ]",x+dxx,y);
	    }
	    else if(state.Power_generator<1.0E-15){
		temp = state.Power_generator*1.0E18;
		g.drawString("P( tot ) = P( in ) + P( Zg ) = "+MaestroA.rounder(temp,6)+" [ a W ]",x+dxx,y);
	    }
            */
	}
}

