/**
 * 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.io.*;
import java.awt.font.*;
import java.net.URL;
import java.text.*;
import java.util.Map;
import java.util.Hashtable;
import java.util.jar.Attributes;


public class LossyWide extends Frame implements AdjustmentListener, ActionListener, ItemListener, MouseListener, WindowListener{
    Instructions instructions;
    //About about;
    TitlePanel titlepanel;
    CircuitCanvas ccan;
    Position position;
    ChoicePanel cp;
    TransSlidePanel slidepanel;
    Trans_OutputPanel outputpanel;
    //Trans_Data outputdata;
    Trans_State state;
    LossyLinePanel linepanel;
    TransLoadPanel loadpanel;
    TransGeneratorPanel generatorpanel;
    TimeChoicePanel tcp;
    
    StartStopClock ssc;
    
    Trans_MultiGraphPanelA mgpa;
    Trans_MultiGraphPanelB mgpb;
    //Image image;
    //private Graphics buf;
    
    Font ttfFont, phiFont, italicFont;
    
    // CHANGE ==================================================================
    public int xmove = 10;
    public int ymove = 34;
    //==========================================================================
    
    private static final boolean useOldFonts = true;    

    public static void main(String[] args){
        LossyWide f = new LossyWide();
        int xxmove = 20;
        int yymove = 41;
        f.setSize(920+xxmove,548+yymove);
        f.setVisible(true);
        f.setLayout(null);
    }

  public LossyWide(){
    setLayout(null);
   // image = getImage(getDocumentBase(),"copyright.gif");
    
    // CHANGE ==================================================================
    //int xmove = 10;
    //int ymove = 34;
    //==========================================================================
    
    String lcOSName = System.getProperty("os.name").toLowerCase();
    boolean MAC_OS_X = lcOSName.startsWith("mac os x");
    //System.out.println(lcOSName);
    
    if (!useOldFonts) {
        //getUlabyFonts();
        state = new Trans_State();
        state.ttfFont = ttfFont;
        state.sanSerifFont = ttfFont;
        state.serifFont = ttfFont;
        state.symbolFont = phiFont;
        state.italicFont = italicFont;
        MaestroG.serifFont = ttfFont;
        MaestroG.sanSerifFont = ttfFont;
        MaestroG.symbolFont = phiFont;
        MaestroG.italicFont = italicFont;        
        MaestroG.useBiggerFont = true;
        
        TransSlidePanel.labelfont = ttfFont.deriveFont(14f);
        TransSlidePanel.labelfont2 = ttfFont.deriveFont(14f);
        ChoicePanel.labelfont = ttfFont.deriveFont(Font.BOLD,16f);
        ChoicePanel.normalfont = ttfFont.deriveFont(16f);
        CircuitCanvas.normalfont = ttfFont.deriveFont(14f);
        CircuitCanvas.normalfont11 = ttfFont.deriveFont(13f);
        CircuitCanvas.subfont = ttfFont.deriveFont(12f);
        CircuitCanvas.symbolfont = ttfFont.deriveFont(16f);
        LossyLinePanel.labfont = ttfFont.deriveFont(14f);
        LossyLinePanel.titlefont = ttfFont.deriveFont(Font.BOLD,18f);
        StartStopClock.buttonFont = ttfFont.deriveFont(Font.BOLD,13f);
        TimeChoicePanel.labfont = ttfFont.deriveFont(12f);
        TransGraphCanvas2.TitleFontSe = ttfFont.deriveFont(15f);
        TransGraphCanvas2.LabelFont = ttfFont.deriveFont(13f);
        TransGraphCanvas2.LabelFontIT2 = italicFont.deriveFont(18f);
        TransGraphCanvas2.LabelFontITsmall = italicFont.deriveFont(15f);
        TransGraphCanvas3.TitleFontSe = ttfFont.deriveFont(15f);
        TransGraphCanvas3.LabelFont = ttfFont.deriveFont(13f);
        TransGraphCanvas3.LabelFontIT2 = italicFont.deriveFont(18f);
        Trans_OutputPanel.symbolfont = ttfFont.deriveFont(14f);
        Trans_OutputPanel.titlefont = ttfFont.deriveFont(Font.BOLD,18f);
        Trans_OutputPanel.normalfont = ttfFont.deriveFont(13f);
        Trans_OutputPanel.normalfontSerif = ttfFont.deriveFont(13f);
        Trans_MultiGraphPanelB.labfont = ttfFont.deriveFont(13f);
        Trans_MultiGraphPanelB.titlefont = ttfFont.deriveFont(Font.BOLD,18f);
        Trans_MultiGraphPanelB.symbolfont = ttfFont.deriveFont(14f);
        Trans_MultiGraphPanelB.normalfont = ttfFont.deriveFont(16f);
        Trans_MultiGraphPanelA.labfont = ttfFont.deriveFont(13f);
        Trans_MultiGraphPanelA.titlefont = ttfFont.deriveFont(Font.BOLD,18f);
        Trans_MultiGraphPanelA.symbolfont = ttfFont.deriveFont(14f);
        Trans_MultiGraphPanelA.normalfont = ttfFont.deriveFont(16f);
        PR2.labfont = ttfFont.deriveFont(14f);
        PR2.titlefont = ttfFont.deriveFont(Font.BOLD,18f);
        PR2.symbolfont = ttfFont.deriveFont(14f);
        PR2.normalfont = ttfFont.deriveFont(14f);
        PR2.smallfont = ttfFont.deriveFont(12f);
        PR.labfont = PR2.labfont;
        PR.titlefont = PR2.titlefont;
        PR.symbolfont = PR2.symbolfont;
        PR.normalfont = PR2.normalfont;
        PR.smallfont = PR2.smallfont;
        PC.labfont = PR.labfont;
        PC.titlefont = PR.titlefont;
        PlotSizeControl.labelfont = ttfFont.deriveFont(13f);
        Position.normalfont = ttfFont.deriveFont(14f);
        StubPanel.labfont = ttfFont.deriveFont(14f);
        StubPanel.titlefont = ttfFont.deriveFont(Font.BOLD,18f);
       
    } else {
        state = new Trans_State();
        state.ttfFont = new Font("SanSerif",Font.PLAIN,12);
        state.sanSerifFont = new Font("SanSerif",Font.PLAIN,12);
        state.serifFont = new Font("Serif",Font.PLAIN,12);
        state.symbolFont = new Font("Symbol",Font.PLAIN,12);
        //state.italicFont = new Font("SanSerif",Font.ITALIC,12);
        state.italicFont = new Font("Serif",Font.ITALIC,12); // ????!!!!!!
        MaestroG.serifFont = state.serifFont;
        MaestroG.sanSerifFont = state.sanSerifFont;
        MaestroG.symbolFont = state.symbolFont;
        MaestroG.italicFont = state.italicFont;        
        MaestroG.useBiggerFont = false;
        
        TransSlidePanel.labelfont=new Font("Sanserif",Font.PLAIN,12);
        TransSlidePanel.labelfont2=new Font("Serif",Font.PLAIN,12);
        ChoicePanel.labelfont = new Font("Sanserif",Font.BOLD,14);
        ChoicePanel.normalfont = new Font("Sanserif",Font.PLAIN,14);
        CircuitCanvas.normalfont = new Font("SanSerif",Font.PLAIN,12);
        CircuitCanvas.normalfont11 = new Font("SanSerif",Font.PLAIN,11);
        CircuitCanvas.subfont = new Font("SanSerif",Font.PLAIN,10);
        CircuitCanvas.symbolfont = new Font("Serif",Font.PLAIN,14);
        LossyLinePanel.labfont=new Font("SanSerif",Font.PLAIN,12);
        LossyLinePanel.titlefont=new Font("SanSerif",Font.BOLD,16);
        StartStopClock.buttonFont = new Font("SanSerif",Font.BOLD,11);
        TimeChoicePanel.labfont = new Font("Sanserif",Font.PLAIN,10);
        TransGraphCanvas2.TitleFontSe = new Font("Serif",Font.PLAIN,13);
        TransGraphCanvas2.LabelFont = new Font("SanSerif",Font.PLAIN,11);
        TransGraphCanvas2.LabelFontIT2 = new Font("Serif",Font.ITALIC,16);
        TransGraphCanvas2.LabelFontITsmall = new Font("Serif",Font.ITALIC,13);
        TransGraphCanvas3.TitleFontSe = new Font("Serif",Font.PLAIN,13);
        TransGraphCanvas3.LabelFont = new Font("SanSerif",Font.PLAIN,11);
        TransGraphCanvas3.LabelFontIT2 = new Font("Serif",Font.ITALIC,16);
        Trans_OutputPanel.symbolfont = new Font("Serif",Font.PLAIN,12);
        Trans_OutputPanel.titlefont = new Font("SanSerif",Font.BOLD,16);
        Trans_OutputPanel.normalfont = new Font("SanSerif",Font.PLAIN,11);
        Trans_OutputPanel.normalfontSerif = new Font("Serif",Font.PLAIN,13);
        Trans_MultiGraphPanelB.labfont = new Font("SanSerif",Font.PLAIN,11);
        Trans_MultiGraphPanelB.titlefont = new Font("SanSerif",Font.BOLD,16);
        Trans_MultiGraphPanelB.symbolfont = new Font("Symbol",Font.PLAIN,12);
        Trans_MultiGraphPanelB.normalfont = new Font("SanSerif",Font.PLAIN,14);
        Trans_MultiGraphPanelA.labfont = new Font("SanSerif",Font.PLAIN,11);
        Trans_MultiGraphPanelA.titlefont = new Font("SanSerif",Font.BOLD,16);
        Trans_MultiGraphPanelA.symbolfont = new Font("Symbol",Font.PLAIN,12);
        Trans_MultiGraphPanelA.normalfont = new Font("SanSerif",Font.PLAIN,14);
        //PR2.labfont = new Font("SanSerif",Font.PLAIN,12);
        PR2.labfont = new Font("Serif",Font.PLAIN,12);
        PR2.titlefont = new Font("SanSerif",Font.BOLD,16);
        PR2.symbolfont = new Font("Symbol",Font.PLAIN,12);
        PR2.normalfont = new Font("SanSerif",Font.PLAIN,12);
        PR2.smallfont = new Font("SanSerif",Font.PLAIN,10);
        PR.labfont = PR2.labfont;
        PR.titlefont = PR2.titlefont;
        PR.symbolfont = PR2.symbolfont;
        PR.normalfont = PR2.normalfont;
        PR.smallfont = PR2.smallfont;
        PC.labfont = PR.labfont;
        PC.titlefont = PR.titlefont;
        PlotSizeControl.labelfont = new Font("SanSerif",Font.PLAIN,11);
        Position.normalfont = new Font("SanSerif",Font.PLAIN,12);
        StubPanel.labfont = new Font("SanSerif",Font.PLAIN,12);
        StubPanel.titlefont = new Font("SanSerif",Font.BOLD,16);
    }
    
    setFont(state.ttfFont.deriveFont(Font.PLAIN,12f));

    //about = new About();
    //add(about);
    //about.setBounds(9,9,902,527);
	
    instructions = new Instructions(state);
    //instructions.setBounds(12,262,902,286);
    instructions.setBounds(12+xmove,245+ymove,896,286);
    instructions.setVisible(true);

    //titlepanel = new TitlePanel(subtitleFont,"Module 2.4","Transmission Line Simulator");
    titlepanel = new TitlePanel(state.ttfFont.deriveFont(Font.BOLD,15f),
                                "Module 2.4","Transmission Line Simulator");
    titlepanel.setBounds(10+xmove,9+ymove,585,41);

    ccan = new CircuitCanvas(state);
    ccan.setBounds(10+xmove,99+ymove,900,140);
    
    position = new Position(state);
    position.setBounds(444+xmove,106+ymove,250,14);
    position.setVisible(false);
    
    //String arg1[] = {"Options:"," Set Input / Output"," View Plots (phasors)"," View Plots (time)"," About"};
    //String arg2[] = {"Options:"," Set Input / Output"," View Plots (phasors)"," View Plots (time)"," About"};
    String arg1[] = {"Options:"," Set Input / Output"," View Plots (phasors)"," View Plots (time)"};
    String arg2[] = {"Options:"," Set Input / Output"," View Plots (phasors)"," View Plots (time)"};
    
    cp = new ChoicePanel(arg1,arg2);
    //cp.setBounds(309,11,286,38);
    cp.setBounds(601+xmove,11+ymove,308,38);
    
    tcp = new TimeChoicePanel();
    tcp.setBounds(404+xmove,466+ymove,70,60);
    tcp.setVisible(false);
    
    slidepanel = new TransSlidePanel();
    slidepanel.setBounds(11+xmove,55+ymove,898,39);
    slidepanel.setLineLength(state.lineLength, state.lineLength_part1, state.lineLength_part2, state.linecounter1, state.linecounter2);
    
    {
      linepanel = new LossyLinePanel(state);
      //add(linepanel);
      linepanel.setBounds(11+xmove,245+ymove,296,286);
    }
    {
      String[] str1 =  {"Z"};
      String[] str2 =  {"\u03a9"};
      loadpanel = new TransLoadPanel("Set Load",str1,str2,state);
      //add(loadpanel);
      loadpanel.setValue(state.ZL,0);
      loadpanel.setBounds(307+xmove,245+ymove,292,143);
    }
    
    {
      String[] str1 =  {"Vg =","Zg ="};
      String[] str2 =  {"V","\u03a9"};
      generatorpanel = new TransGeneratorPanel("Set Generator",str1,str2,state);
      //add(generatorpanel);
      generatorpanel.setValue(state.generator.getVg(),0);
      generatorpanel.setValue(state.generator.getZg(),1);
      generatorpanel.setBounds(307+xmove,388+ymove,292,143);
    }

    mgpa = new Trans_MultiGraphPanelA("Plots (phasors)");
    //add(mgpa);
    //mgpa.setBounds(11,236,308,288);
    
    // CHANGE ==================================================================
    // MOVE AWAY UNTIL CALLED EXPLICITLY DUE TO MAC PROBLEM - MAC SUCKS
    // setVisible() DOES NOT WORK TOO WELL - WORKS FUNE IN WINDOWS
    //
    //mgpa.setBounds(10+xmove,99+ymove,900,434);
    mgpa.setBounds(10+xmove,99+ymove+10000,900,434);
    //==========================================================================
    
    
    mgpb = new Trans_MultiGraphPanelB("Plots (time)");
    //add(mgpb);
    //mgpb.setBounds(11,236,308,288);
    
    // CHANGE ==================================================================
    // MOVE AWAY UNTIL CALLED EXPLICITLY DUE TO MAC PROBLEM - MAC SUCKS
    // setVisible() DOES NOT WORK TOO WELL - WORKS FINE IN WINDOWS
    //
    //mgpb.setBounds(10+xmove,99+ymove,900,434);
    mgpb.setBounds(10+xmove,99+ymove+10000,900,434);
    //==========================================================================
    
    //hide and show panels
    {
	loadpanel.setVisible(true);
	linepanel.setVisible(true);
	
	generatorpanel.setVisible(true);
	mgpa.setVisible(false);
	mgpb.setVisible(false);
        //about.setVisible(false);
        instructions.setVisible(true);
    }
    
    outputpanel = new Trans_OutputPanel(state);
    outputpanel.setVisible(true);
    //add(outputpanel);
    outputpanel.setBounds(599+xmove,245+ymove,310,286);
    
    //outputdata = new Trans_Data(state);
    //outputdata.setVisible(true);
    //outputdata.setBounds(601,11,308,38);
	    
    Panel pgraph = new Panel();
	    pgraph.setBackground(Color.black);
	    //add(pgraph);
	    pgraph.setBounds(10+xmove,244+ymove,900,288);
    
    Panel pslide = new Panel();
	    pslide.setBackground(Color.black);
	    //add(pslide);
	    pslide.setBounds(10+xmove,54+ymove,900,41);
	    
    Panel pchoice = new Panel();
	    pchoice.setBackground(Color.black);
	    //add(pchoice);
	    pchoice.setBounds(308+xmove,10+ymove,288,40);
    
    Panel pdata = new Panel();
	    pdata.setBackground(Color.black);
	    //add(pchoice);
	    pdata.setBounds(600+xmove,10+ymove,310,40);
	    
    /*Panel ptitle = new Panel();
	    ptitle.setBackground(Color.black);
	    //add(ptitle);
	    ptitle.setBounds(9,9,310,40);
    */
    
    Panel p0 = new Panel();
	    p0.setBackground(Color.cyan);
	    //p0.setBackground(tinta);
	    //add(p0);
	    p0.setBounds(3+xmove,3+ymove,914,539);
	    
    Panel p00 = new Panel();
	    p00.setBackground(Color.black);
	    //add(p00);
	    p00.setBounds(xmove,ymove,920,545);
	    
    Panel p000 = new Panel(); // NOT USED
	    p000.setBackground(Color.white);
	    ////add(p000);
	    p000.setBounds(0,0,920,566);
	    
            //if(state.this_year > line.magicyear || (state.this_year == line.magicyear && state.this_month > line.magicmonth)){
            //    state.LicenseExpired = true;
            //}
            //else{ 
            add(instructions);
            //add(about);
            add(titlepanel); 	    
            add(position);
	    add(ccan);
	     	    
            add(cp); 	
            add(tcp);

            add(slidepanel);
	    add(linepanel);
	    add(loadpanel);
	    add(generatorpanel);
	    add(outputpanel);
	    //add(outputdata);
	    
	    add(mgpa);
	    add(mgpb);
	    add(pgraph);
	    
	    add(pslide);
	    add(pchoice);
	    add(pdata);	    
            add(p0); 	    
            add(p00);
	    
	    state.LicenseExpired = false; 	
            //}
    
    //Listeners
    this.addWindowListener(this);
    loadpanel.bupdate.addActionListener(this);
    instructions.bupdate.addActionListener(this);
    slidepanel.slider.addAdjustmentListener(this);
    slidepanel.slider2.addAdjustmentListener(this);
    
    slidepanel.b2a.addActionListener(this);
    slidepanel.b2b.addActionListener(this);
    slidepanel.b3a.addActionListener(this);
    slidepanel.b3b.addActionListener(this);
    
    linepanel.lowpanel.b1.addActionListener(this);
    linepanel.highpanel.b1.addActionListener(this);
    
    loadpanel.b1.addActionListener(this);
    loadpanel.c1.addItemListener(this);
    loadpanel.c2.addItemListener(this);
    
    tcp.button1.addActionListener(this);
    tcp.button2.addActionListener(this);
    tcp.button3.addActionListener(this);
    
    generatorpanel.b1.addActionListener(this);
    
    cp.c1.addItemListener(this);
    cp.c2.addItemListener(this);
    mgpa.c1.addItemListener(this);
    mgpb.c1.addItemListener(this);
    mgpb.cbx1.addItemListener(this);
    mgpb.cbx2.addItemListener(this);
    mgpb.ssc.button1.addMouseListener(this);
    mgpb.ssc.button2.addMouseListener(this);
}

    public void windowClosing(WindowEvent e) {
        dispose();
        System.exit(0);
    }
    
    public void windowOpened(WindowEvent evt){}
    
    public void windowIconified(WindowEvent evt){}
    
    public void windowClosed(WindowEvent evt){}
    
    public void windowDeiconified(WindowEvent evt){}
    
    public void windowActivated(WindowEvent evt){}
    
    public void windowDeactivated(WindowEvent evt){}


    public void mouseClicked(MouseEvent evt){mouseHandler(evt);}
    public void mouseEntered(MouseEvent evt){;}
    public void mouseExited(MouseEvent evt){;}
    public void mousePressed(MouseEvent evt){;}
    public void mouseReleased(MouseEvent evt){;}
    
    private synchronized void mouseHandler(MouseEvent evt){
	if(evt.getSource() == mgpb.ssc.button1){
            if(mgpb.DynamicRunType==3)
            {
                tcp.button1.setEnabled(false);
                tcp.button2.setEnabled(false);
                tcp.button3.setEnabled(false);
            }
            mgpb.c1.setEnabled(false);
            state.IsTronRunning = true;
            slidepanel.slider.setEnabled(false);
	    slidepanel.slider2.setEnabled(false);
            cp.c1.setEnabled(false);
            mgpb.ssc.IsStop = false;
            mgpb.ssc.repaint();
	}
	if(evt.getSource() == mgpb.ssc.button2){
	    tcp.button1.setEnabled(true);
            tcp.button2.setEnabled(true);
            tcp.button3.setEnabled(true);
            mgpb.c1.setEnabled(true);
            
            state.IsTronRunning = false;
            slidepanel.slider.setEnabled(true);
	    slidepanel.slider2.setEnabled(true);
            cp.c1.setEnabled(true);
            mgpb.ssc.IsStop = true;
            mgpb.ssc.repaint();
	}
    }
 
  public void paint(Graphics g){
    
    Font licensefont = new Font("SanSerif",Font.BOLD,18); 
    Font fonto = new Font("SanSerif",Font.PLAIN,12);
    Font fontc = new Font("SanSerif",Font.BOLD,16);
    
	Graphics2D g2d = (Graphics2D)g;
        //g.setColor(Color.white);	
	//g.fillRect(0,0,920,545);  	
	/*	
	if(state.LicenseExpired){
	    g.setFont(licensefont);
	
	    g.setColor(Color.red);
	    g.drawString("The software license has expired.", 50, 200);
	    g.setColor(Color.black);
	    g.drawString("Obtain updated files from www.amanogawa.com", 50, 230);
	} 
        
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        int annonuovo = 2006;
        int anno = 2006;
        
        if(anno > state.this_year){
            annonuovo = anno;
        }
        else{
            annonuovo = state.this_year;
        }
        //g.setColor(Color.red.darker());
        //g.setFont(fontc);
        //g.drawString("\u00a9",10,552);
        //g.setFont(fonto);
        //g.drawString("Amanogawa, "+annonuovo+" - All Rights Reserved",30,550);
        */
    }

public void start(){}


public void stop(){}

public void adjustmentValueChanged(AdjustmentEvent evt){
	Font symbolfont  = new Font("Symbol",Font.PLAIN,12);
	Font labfont     = new Font("SanSerif",Font.PLAIN,12);
	
	String alpha, Ohm, lambda, infinity, Gamma;
	    setFont(symbolfont);
	    alpha="\u03b1";
	    lambda="\u03bb";
	    Ohm="\u03a9";
	    infinity="\u221e";
	    Gamma="\uu0393";
	    setFont(labfont);

    if(evt.getSource()==slidepanel.slider){
	slidepanel.slider2.setValue(slidepanel.slider2.getMaximum());
	state.xpos = slidepanel.getValue();
	
	if(state.xpos == state.lineLength){
	    slidepanel.slider2.setEnabled(false);  
	}
	else{
	    slidepanel.slider2.setEnabled(true);
	}
	
	send_shock_wave();
	mgpa.tgc1.setXpos(state.xpos);
	mgpa.tgc2.setXpos(state.xpos);
	mgpa.tgc3.setXpos(state.xpos);
	mgpa.tgc4.setXpos(state.xpos);
	mgpb.tgc3.setXpos(state.xpos);
	mgpb.tgc3.setDynamics(false);
	
	//------------------  reference values on plots  ---------------------
	double tempvalue;
	
      // Time Dependent Voltage
      
      if(state.IsTimePlot == 1){
        tempvalue = 0.0;
       
	if(state.IsTotal){
            tempvalue = Complex.Magnitude(state.Vin);
        }
        else if(state.IsIncident){
            tempvalue = Complex.Magnitude(state.VPlus);
        }
        else if(state.IsReflected){
            tempvalue = Complex.Magnitude(Complex.Multiply(state.VPlus,state.GammaL));
        }
        
	//tempvalue = Complex.Magnitude(state.Vin);
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue,3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k V ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpb.tgc3.setValue(" Vmax  = 0.0  [ V ]");   
	}
      }
      
      // Time Dependent Current
      if(state.IsTimePlot == 2){
      
	//tempvalue = Complex.Magnitude(state.Iin);
	
        tempvalue = 0.0;
       
	if(state.IsTotal){
            tempvalue = Complex.Magnitude(state.Iin);
        }
        else if(state.IsIncident){
            tempvalue = Complex.Magnitude(Complex.Divide(state.VPlus,state.Z0));
        }
        else if(state.IsReflected){
            tempvalue = Complex.Magnitude(Complex.Multiply(Complex.Divide(state.VPlus,state.Z0),state.GammaL));
        }
          
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue,3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k A ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpb.tgc3.setValue(" Imax  = 0.0  [ A ]");   
	}
      }
      
      // Time Dependent Power
      if(state.IsTimePlot == 3){
        tempvalue = 0.0; 
        
        if(state.IsTotal){
            ///HERE
            //tempvalue = Complex.Magnitude(Complex.Multiply(state.Vin,state.Iin));
            state.ignition();
            tempvalue = state.Power_X;
        }
        else if(state.IsIncident){
            tempvalue = Complex.Magnitude(Complex.Divide(Complex.Multiply(state.VPlus,state.VPlus),state.Z0));
        }
        else if(state.IsReflected){
            tempvalue = Complex.Magnitude(Complex.Multiply(
                                                            Complex.Multiply(state.VPlus,state.GammaL),
                                                            Complex.Multiply(Complex.Divide(state.VPlus,state.Z0),state.GammaL))
                                                            );
        }
      
	//tempvalue = Complex.Magnitude(state.Vin)*Complex.Magnitude(state.Iin);
        
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue,3)+"  [ W ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k W ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M W ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m W ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 W ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n W ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p W ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f W ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpb.tgc3.setValue(" Pmax  = 0.0  [ W ]");   
	}
      }
      
      
      // Standing Wave Patterns
      if(state.IsPhasorPlot == 1){
	tempvalue = Complex.Magnitude(state.Vin);
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue,3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k V ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("| V | = 0.0  [ V ]");   
	}
	
	tempvalue = Complex.Magnitude(state.Iin);
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue,3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k A ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc4.setValue("| I | = 0.0  [ A ]");   
	}
      
      }
      // Voltage phasor
      if(state.IsPhasorPlot == 2){
	tempvalue = Math.abs(state.Vin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real(),3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()/1.0E3,3)+"  [ kV ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("Re{V} = 0.0  [ V ]");   
	}
	
	
	tempvalue = Math.abs(state.Vin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary(),3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()/1.0E3,3)+"  [ kV ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc4.setValue("Im{V} = 0.0  [ V ]");   
	}
	
      }
      
      // Current phasor
      if(state.IsPhasorPlot == 3){
      
	tempvalue = Math.abs(state.Iin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real(),3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()/1.0E3,3)+"  [ kA ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("Re{I} = 0.0  [ A ]");   
	}
	
	tempvalue = Math.abs(state.Iin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary(),3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()/1.0E3,3)+"  [ kA ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc4.setValue("Im{I} = 0.0  [ A ]");   
	}
      
      }
      
      // Impedance
      if(state.IsPhasorPlot == 4){
	
	tempvalue = Math.abs(state.Zin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real(),3)+"  [ "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()/1.0E3,3)+"  [ k "+Ohm+" ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()/1.0E6,3)+"  [ M "+Ohm+" ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E3,3)+"  [ m "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E6,3)+"  [ \u00b5 "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E9,3)+"  [ n "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E12,3)+"  [ p "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E15,3)+"  [ f "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc1.setValue("Re{Z} = 0.0  [ "+Ohm+" ]");   
	}
	
	tempvalue = Math.abs(state.Zin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary(),3)+"  [ "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()/1.0E3,3)+"  [ k "+Ohm+" ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()/1.0E6,3)+"  [ M "+Ohm+" ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E3,3)+"  [ m "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E6,3)+"  [ \u00b5 "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E9,3)+"  [ n "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E12,3)+"  [ p "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E15,3)+"  [ f "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc2.setValue("Im{Z} = 0.0  [ "+Ohm+" ]");   
	}
      
      }
      
      // Admittance
      if(state.IsPhasorPlot == 5){
	
	tempvalue = Math.abs(state.Yin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real(),3)+"  [ S ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()/1.0E3,3)+"  [ k S ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()/1.0E6,3)+"  [ M S ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E3,3)+"  [ m S ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E6,3)+"  [ \u00b5 S ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E9,3)+"  [ n S ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E12,3)+"  [ p S ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E15,3)+"  [ f S ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc1.setValue("Re{Y} = 0.0  [ S ]");   
	}
	
	tempvalue = Math.abs(state.Yin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary(),3)+"  [ S ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()/1.0E3,3)+"  [ k S ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()/1.0E6,3)+"  [ M S ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E3,3)+"  [ m S ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E6,3)+"  [ \u00b5 S ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E9,3)+"  [ n S ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E12,3)+"  [ p S ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E15,3)+"  [ f S ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc2.setValue("Im{Y} = 0.0  [ S ]");   
	}
      }
      
      // Reflection Coefficient
      if(state.IsPhasorPlot == 6){
      
	mgpa.tgc1.setValue("Re{"+Gamma+"} = "+MaestroA.rounder(state.Gammain.Real(),6));
	mgpa.tgc2.setValue("Im{"+Gamma+"} = "+MaestroA.rounder(state.Gammain.Imaginary(),6));
      }
      
      // Time-average Power
      if(state.IsPhasorPlot == 7){
      
      tempvalue = state.Power_flow;
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue,3)+"  [ W ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k W ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M W ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m W ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 W ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n W ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p W ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f W ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("< P > = 0.0  [ W ]");   
	}
      
      mgpa.tgc2.setValue("| "+Gamma+" | = "+MaestroA.rounder(Complex.Magnitude(state.Gammain),6));
      }
	
	//--------------------------------------------------------------------
	
	mgpa.tgc1.repaint();
	mgpa.tgc2.repaint();
	mgpa.tgc3.repaint();
	mgpa.tgc4.repaint();
	
        mgpb.tgc3.cleanUp();
        mgpb.tgc3.repaint();
	
	
    }
    
    
    if(evt.getSource()==slidepanel.slider2){
	
	if(slidepanel.slider.getValue() == 0){
	    if(slidepanel.slider2.getValue() < (slidepanel.SCROLLMAX2 - state.linecounter2)){
		slidepanel.slider2.setValue(slidepanel.SCROLLMAX2 - state.linecounter2-1);
	    }
	}
	state.xpos = slidepanel.getValue()+slidepanel.getValue2();
	send_shock_wave();
	mgpa.tgc1.setXpos(state.xpos);
	mgpa.tgc2.setXpos(state.xpos);
	mgpa.tgc3.setXpos(state.xpos);
	mgpa.tgc4.setXpos(state.xpos);
	mgpb.tgc3.setXpos(state.xpos);
	mgpb.tgc3.setDynamics(false);
	
	//------------------  reference values on plots  ---------------------
	double tempvalue;
      // Time Dependent Voltage
      
      if(state.IsTimePlot == 1){
	tempvalue = 0.0;
       
	if(state.IsTotal){
            tempvalue = Complex.Magnitude(state.Vin);
        }
        else if(state.IsIncident){
            tempvalue = Complex.Magnitude(state.VPlus);
        }
        else if(state.IsReflected){
            tempvalue = Complex.Magnitude(Complex.Multiply(state.VPlus,state.GammaL));
        }
        
        //tempvalue = Complex.Magnitude(state.Vin);
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue,3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k V ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpb.tgc3.setValue(" Vmax  = 0.0  [ V ]");   
	}
      }
      
      // Time Dependent Current
      if(state.IsTimePlot == 2){
      
	//tempvalue = Complex.Magnitude(state.Iin);
	
        tempvalue = 0.0;
       
	if(state.IsTotal){
            tempvalue = Complex.Magnitude(state.Iin);
        }
        else if(state.IsIncident){
            tempvalue = Complex.Magnitude(Complex.Divide(state.VPlus,state.Z0));
        }
        else if(state.IsReflected){
            tempvalue = Complex.Magnitude(Complex.Multiply(Complex.Divide(state.VPlus,state.Z0),state.GammaL));
        }
          
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue,3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k A ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpb.tgc3.setValue(" Imax  = 0.0  [ A ]");   
	}
      }
      
      // Time Dependent Power
      if(state.IsTimePlot == 3){
      
	tempvalue = 0.0; 
        
        if(state.IsTotal){
            //tempvalue = Complex.Magnitude(state.Vin)*Complex.Magnitude(state.Iin);
            tempvalue = Complex.Magnitude(Complex.Multiply(state.Vin,state.Iin));
        }
        else if(state.IsIncident){
            tempvalue = Complex.Magnitude(Complex.Divide(Complex.Multiply(state.VPlus,state.VPlus),state.Z0));
        }
        else if(state.IsReflected){
            tempvalue = Complex.Magnitude(Complex.Multiply(
                                                            Complex.Multiply(state.VPlus,state.GammaL),
                                                            Complex.Multiply(Complex.Divide(state.VPlus,state.Z0),state.GammaL))
                                                            );
        }
      
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue,3)+"  [ W ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k W ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M W ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m W ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 W ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n W ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p W ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f W ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpb.tgc3.setValue(" Pmax  = 0.0  [ W ]");   
	}
      }
	
      // Standing Wave Patterns
      if(state.IsPhasorPlot == 1){
	tempvalue = Complex.Magnitude(state.Vin);
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue,3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k V ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("| V | = 0.0  [ V ]");   
	}
	
	tempvalue = Complex.Magnitude(state.Iin);
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue,3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k A ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc4.setValue("| I | = 0.0  [ A ]");   
	}
      
      }
      // Voltage phasor
      if(state.IsPhasorPlot == 2){
	tempvalue = Math.abs(state.Vin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real(),3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()/1.0E3,3)+"  [ kV ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("Re{V} = 0.0  [ V ]");   
	}
	
	
	tempvalue = Math.abs(state.Vin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary(),3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()/1.0E3,3)+"  [ kV ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc4.setValue("Im{V} = 0.0  [ V ]");   
	}
	
      }
      
      // Current phasor
      if(state.IsPhasorPlot == 3){
      
	tempvalue = Math.abs(state.Iin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real(),3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()/1.0E3,3)+"  [ kA ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("Re{I} = 0.0  [ A ]");   
	}
	
	tempvalue = Math.abs(state.Iin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary(),3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()/1.0E3,3)+"  [ kA ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc4.setValue("Im{I} = 0.0  [ A ]");   
	}
      
      }
      
      // Impedance
      if(state.IsPhasorPlot == 4){
	
	tempvalue = Math.abs(state.Zin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real(),3)+"  [ "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()/1.0E3,3)+"  [ k "+Ohm+" ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()/1.0E6,3)+"  [ M "+Ohm+" ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E3,3)+"  [ m "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E6,3)+"  [ \u00b5 "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E9,3)+"  [ n "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E12,3)+"  [ p "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E15,3)+"  [ f "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc1.setValue("Re{Z} = 0.0  [ "+Ohm+" ]");   
	}
	
	tempvalue = Math.abs(state.Zin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary(),3)+"  [ "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()/1.0E3,3)+"  [ k "+Ohm+" ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()/1.0E6,3)+"  [ M "+Ohm+" ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E3,3)+"  [ m "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E6,3)+"  [ \u00b5 "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E9,3)+"  [ n "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E12,3)+"  [ p "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E15,3)+"  [ f "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc2.setValue("Im{Z} = 0.0  [ "+Ohm+" ]");   
	}
      
      }
      
      // Admittance
      if(state.IsPhasorPlot == 5){
	
	tempvalue = Math.abs(state.Yin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real(),3)+"  [ S ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()/1.0E3,3)+"  [ k S ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()/1.0E6,3)+"  [ M S ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E3,3)+"  [ m S ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E6,3)+"  [ \u00b5 S ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E9,3)+"  [ n S ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E12,3)+"  [ p S ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E15,3)+"  [ f S ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc1.setValue("Re{Y} = 0.0  [ S ]");   
	}
	
	tempvalue = Math.abs(state.Yin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary(),3)+"  [ S ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()/1.0E3,3)+"  [ k S ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()/1.0E6,3)+"  [ M S ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E3,3)+"  [ m S ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E6,3)+"  [ \u00b5 S ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E9,3)+"  [ n S ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E12,3)+"  [ p S ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E15,3)+"  [ f S ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc2.setValue("Im{Y} = 0.0  [ S ]");   
	}
      }
      
      // Reflection Coefficient
      if(state.IsPhasorPlot == 6){
      
	mgpa.tgc1.setValue("Re{"+Gamma+"} = "+MaestroA.rounder(state.Gammain.Real(),6));
	mgpa.tgc2.setValue("Im{"+Gamma+"} = "+MaestroA.rounder(state.Gammain.Imaginary(),6));
      }
      
      // Time-average Power
      if(state.IsPhasorPlot == 7){
      
      tempvalue = state.Power_flow;
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue,3)+"  [ W ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k W ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M W ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m W ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 W ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n W ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p W ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f W ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("< P > = 0.0  [ W ]");   
	}
      
      mgpa.tgc2.setValue("| "+Gamma+" | = "+MaestroA.rounder(Complex.Magnitude(state.Gammain),6));
      }
	//--------------------------------------------------------------------
	mgpa.tgc1.repaint();
	mgpa.tgc2.repaint();
	mgpa.tgc3.repaint();
	mgpa.tgc4.repaint();
        
        mgpb.tgc3.cleanUp();
	mgpb.tgc3.repaint();
    }
    
}

public void actionPerformed(ActionEvent evt){
    //if(evt.getSource()==about.bupdate){
    //          about.setVisible(false);
    //          if(state.OptionOne){cp.c1.select(" Set Input / Output");}
    //          else if(state.OptionTwo){cp.c1.select(" View Plots (phasors)");}
    //          else if(state.OptionThree){cp.c1.select(" View Plots (time)");}
    //  }
        
    Font symbolfont  = new Font("Symbol",Font.PLAIN,12);
    Font labfont     = new Font("SanSerif",Font.PLAIN,12);
	
    String alpha, Ohm, lambda, infinity, Gamma;
    setFont(symbolfont);
    alpha="\u03b1";
    lambda="\u03bb";
    Ohm="\u03a9";
    infinity="\u221e";
    Gamma="\uu0393";
    setFont(labfont);
    
    if(evt.getSource()==slidepanel.b2a || evt.getSource()==slidepanel.b2b){
          slidepanel.slider2.setValue(slidepanel.slider2.getMaximum());
	state.xpos = slidepanel.getValue();
	
	if(state.xpos == state.lineLength){
	    slidepanel.slider2.setEnabled(false);  
	}
	else{
	    slidepanel.slider2.setEnabled(true);
	}
	
	send_shock_wave();
	mgpa.tgc1.setXpos(state.xpos);
	mgpa.tgc2.setXpos(state.xpos);
	mgpa.tgc3.setXpos(state.xpos);
	mgpa.tgc4.setXpos(state.xpos);
	mgpb.tgc3.setXpos(state.xpos);
	mgpb.tgc3.setDynamics(false);
	
	//------------------  reference values on plots  ---------------------
	double tempvalue;
	
      // Time Dependent Voltage
      
      if(state.IsTimePlot == 1){
        tempvalue = 0.0;
       
	if(state.IsTotal){
            tempvalue = Complex.Magnitude(state.Vin);
        }
        else if(state.IsIncident){
            tempvalue = Complex.Magnitude(state.VPlus);
        }
        else if(state.IsReflected){
            tempvalue = Complex.Magnitude(Complex.Multiply(state.VPlus,state.GammaL));
        }
        
	//tempvalue = Complex.Magnitude(state.Vin);
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue,3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k V ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpb.tgc3.setValue(" Vmax  = 0.0  [ V ]");   
	}
      }
      
      // Time Dependent Current
      if(state.IsTimePlot == 2){
      
	//tempvalue = Complex.Magnitude(state.Iin);
	
        tempvalue = 0.0;
       
	if(state.IsTotal){
            tempvalue = Complex.Magnitude(state.Iin);
        }
        else if(state.IsIncident){
            tempvalue = Complex.Magnitude(Complex.Divide(state.VPlus,state.Z0));
        }
        else if(state.IsReflected){
            tempvalue = Complex.Magnitude(Complex.Multiply(Complex.Divide(state.VPlus,state.Z0),state.GammaL));
        }
          
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue,3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k A ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpb.tgc3.setValue(" Imax  = 0.0  [ A ]");   
	}
      }
      
      // Time Dependent Power
      if(state.IsTimePlot == 3){
        tempvalue = 0.0; 
        
        if(state.IsTotal){
            ///HERE
            //tempvalue = Complex.Magnitude(Complex.Multiply(state.Vin,state.Iin));
            state.ignition();
            tempvalue = state.Power_X;
        }
        else if(state.IsIncident){
            tempvalue = Complex.Magnitude(Complex.Divide(Complex.Multiply(state.VPlus,state.VPlus),state.Z0));
        }
        else if(state.IsReflected){
            tempvalue = Complex.Magnitude(Complex.Multiply(
                                                            Complex.Multiply(state.VPlus,state.GammaL),
                                                            Complex.Multiply(Complex.Divide(state.VPlus,state.Z0),state.GammaL))
                                                            );
        }
      
	//tempvalue = Complex.Magnitude(state.Vin)*Complex.Magnitude(state.Iin);
        
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue,3)+"  [ W ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k W ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M W ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m W ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 W ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n W ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p W ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f W ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpb.tgc3.setValue(" Pmax  = 0.0  [ W ]");   
	}
      }
      
      
      // Standing Wave Patterns
      if(state.IsPhasorPlot == 1){
	tempvalue = Complex.Magnitude(state.Vin);
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue,3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k V ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("| V | = 0.0  [ V ]");   
	}
	
	tempvalue = Complex.Magnitude(state.Iin);
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue,3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k A ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc4.setValue("| I | = 0.0  [ A ]");   
	}
      
      }
      // Voltage phasor
      if(state.IsPhasorPlot == 2){
	tempvalue = Math.abs(state.Vin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real(),3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()/1.0E3,3)+"  [ kV ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("Re{V} = 0.0  [ V ]");   
	}
	
	
	tempvalue = Math.abs(state.Vin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary(),3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()/1.0E3,3)+"  [ kV ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc4.setValue("Im{V} = 0.0  [ V ]");   
	}
	
      }
      
      // Current phasor
      if(state.IsPhasorPlot == 3){
      
	tempvalue = Math.abs(state.Iin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real(),3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()/1.0E3,3)+"  [ kA ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("Re{I} = 0.0  [ A ]");   
	}
	
	tempvalue = Math.abs(state.Iin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary(),3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()/1.0E3,3)+"  [ kA ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc4.setValue("Im{I} = 0.0  [ A ]");   
	}
      
      }
      
      // Impedance
      if(state.IsPhasorPlot == 4){
	
	tempvalue = Math.abs(state.Zin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real(),3)+"  [ "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()/1.0E3,3)+"  [ k "+Ohm+" ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()/1.0E6,3)+"  [ M "+Ohm+" ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E3,3)+"  [ m "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E6,3)+"  [ \u00b5 "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E9,3)+"  [ n "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E12,3)+"  [ p "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E15,3)+"  [ f "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc1.setValue("Re{Z} = 0.0  [ "+Ohm+" ]");   
	}
	
	tempvalue = Math.abs(state.Zin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary(),3)+"  [ "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()/1.0E3,3)+"  [ k "+Ohm+" ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()/1.0E6,3)+"  [ M "+Ohm+" ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E3,3)+"  [ m "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E6,3)+"  [ \u00b5 "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E9,3)+"  [ n "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E12,3)+"  [ p "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E15,3)+"  [ f "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc2.setValue("Im{Z} = 0.0  [ "+Ohm+" ]");   
	}
      
      }
      
      // Admittance
      if(state.IsPhasorPlot == 5){
	
	tempvalue = Math.abs(state.Yin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real(),3)+"  [ S ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()/1.0E3,3)+"  [ k S ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()/1.0E6,3)+"  [ M S ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E3,3)+"  [ m S ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E6,3)+"  [ \u00b5 S ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E9,3)+"  [ n S ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E12,3)+"  [ p S ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E15,3)+"  [ f S ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc1.setValue("Re{Y} = 0.0  [ S ]");   
	}
	
	tempvalue = Math.abs(state.Yin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary(),3)+"  [ S ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()/1.0E3,3)+"  [ k S ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()/1.0E6,3)+"  [ M S ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E3,3)+"  [ m S ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E6,3)+"  [ \u00b5 S ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E9,3)+"  [ n S ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E12,3)+"  [ p S ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E15,3)+"  [ f S ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc2.setValue("Im{Y} = 0.0  [ S ]");   
	}
      }
      
      // Reflection Coefficient
      if(state.IsPhasorPlot == 6){
      
	mgpa.tgc1.setValue("Re{"+Gamma+"} = "+MaestroA.rounder(state.Gammain.Real(),6));
	mgpa.tgc2.setValue("Im{"+Gamma+"} = "+MaestroA.rounder(state.Gammain.Imaginary(),6));
      }
      
      // Time-average Power
      if(state.IsPhasorPlot == 7){
      
      tempvalue = state.Power_flow;
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue,3)+"  [ W ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k W ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M W ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m W ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 W ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n W ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p W ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f W ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("< P > = 0.0  [ W ]");   
	}
      
      mgpa.tgc2.setValue("| "+Gamma+" | = "+MaestroA.rounder(Complex.Magnitude(state.Gammain),6));
      }
	
	//--------------------------------------------------------------------
	
	
	
	
	mgpa.tgc1.repaint();
	mgpa.tgc2.repaint();
	mgpa.tgc3.repaint();
	mgpa.tgc4.repaint();
	
        mgpb.tgc3.cleanUp();
        mgpb.tgc3.repaint();
	
	  
    }
    if(evt.getSource()==slidepanel.b3a || evt.getSource()==slidepanel.b3b){
        if(slidepanel.slider.getValue() == 0){
	    if(slidepanel.slider2.getValue() < (slidepanel.SCROLLMAX2 - state.linecounter2)){
		slidepanel.slider2.setValue(slidepanel.SCROLLMAX2 - state.linecounter2-1);
	    }
	}
	state.xpos = slidepanel.getValue()+slidepanel.getValue2();
	send_shock_wave();
	mgpa.tgc1.setXpos(state.xpos);
	mgpa.tgc2.setXpos(state.xpos);
	mgpa.tgc3.setXpos(state.xpos);
	mgpa.tgc4.setXpos(state.xpos);
	mgpb.tgc3.setXpos(state.xpos);
	mgpb.tgc3.setDynamics(false);
	
	//------------------  reference values on plots  ---------------------
	double tempvalue;
      // Time Dependent Voltage
      
      if(state.IsTimePlot == 1){
	tempvalue = 0.0;
       
	if(state.IsTotal){
            tempvalue = Complex.Magnitude(state.Vin);
        }
        else if(state.IsIncident){
            tempvalue = Complex.Magnitude(state.VPlus);
        }
        else if(state.IsReflected){
            tempvalue = Complex.Magnitude(Complex.Multiply(state.VPlus,state.GammaL));
        }
        
        //tempvalue = Complex.Magnitude(state.Vin);
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue,3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k V ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpb.tgc3.setValue(" Vmax  = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpb.tgc3.setValue(" Vmax  = 0.0  [ V ]");   
	}
      }
      
      // Time Dependent Current
      if(state.IsTimePlot == 2){
      
	//tempvalue = Complex.Magnitude(state.Iin);
	
        tempvalue = 0.0;
       
	if(state.IsTotal){
            tempvalue = Complex.Magnitude(state.Iin);
        }
        else if(state.IsIncident){
            tempvalue = Complex.Magnitude(Complex.Divide(state.VPlus,state.Z0));
        }
        else if(state.IsReflected){
            tempvalue = Complex.Magnitude(Complex.Multiply(Complex.Divide(state.VPlus,state.Z0),state.GammaL));
        }
          
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue,3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k A ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpb.tgc3.setValue(" Imax  = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpb.tgc3.setValue(" Imax  = 0.0  [ A ]");   
	}
      }
      
      // Time Dependent Power
      if(state.IsTimePlot == 3){
      
	tempvalue = 0.0; 
        
        if(state.IsTotal){
            //tempvalue = Complex.Magnitude(state.Vin)*Complex.Magnitude(state.Iin);
            tempvalue = Complex.Magnitude(Complex.Multiply(state.Vin,state.Iin));
        }
        else if(state.IsIncident){
            tempvalue = Complex.Magnitude(Complex.Divide(Complex.Multiply(state.VPlus,state.VPlus),state.Z0));
        }
        else if(state.IsReflected){
            tempvalue = Complex.Magnitude(Complex.Multiply(
                                                            Complex.Multiply(state.VPlus,state.GammaL),
                                                            Complex.Multiply(Complex.Divide(state.VPlus,state.Z0),state.GammaL))
                                                            );
        }
      
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue,3)+"  [ W ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k W ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M W ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m W ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 W ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n W ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p W ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpb.tgc3.setValue(" Pmax  = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f W ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpb.tgc3.setValue(" Pmax  = 0.0  [ W ]");   
	}
      }
	
      // Standing Wave Patterns
      if(state.IsPhasorPlot == 1){
	tempvalue = Complex.Magnitude(state.Vin);
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue,3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k V ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("| V | = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("| V | = 0.0  [ V ]");   
	}
	
	tempvalue = Complex.Magnitude(state.Iin);
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue,3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k A ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc4.setValue("| I | = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc4.setValue("| I | = 0.0  [ A ]");   
	}
      
      }
      // Voltage phasor
      if(state.IsPhasorPlot == 2){
	tempvalue = Math.abs(state.Vin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real(),3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()/1.0E3,3)+"  [ kV ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("Re{V} = "+MaestroA.rounder(state.Vin.Real()*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("Re{V} = 0.0  [ V ]");   
	}
	
	
	tempvalue = Math.abs(state.Vin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary(),3)+"  [ V ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()/1.0E3,3)+"  [ kV ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()/1.0E6,3)+"  [ M V ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E3,3)+"  [ m V ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E6,3)+"  [ \u00b5 V ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E9,3)+"  [ n V ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E12,3)+"  [ p V ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc4.setValue("Im{V} = "+MaestroA.rounder(state.Vin.Imaginary()*1.0E15,3)+"  [ f V ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc4.setValue("Im{V} = 0.0  [ V ]");   
	}
	
      }
      
      // Current phasor
      if(state.IsPhasorPlot == 3){
      
	tempvalue = Math.abs(state.Iin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real(),3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()/1.0E3,3)+"  [ kA ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("Re{I} = "+MaestroA.rounder(state.Iin.Real()*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("Re{I} = 0.0  [ A ]");   
	}
	
	tempvalue = Math.abs(state.Iin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary(),3)+"  [ A ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()/1.0E3,3)+"  [ kA ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()/1.0E6,3)+"  [ M A ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E3,3)+"  [ m A ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E6,3)+"  [ \u00b5 A ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E9,3)+"  [ n A ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E12,3)+"  [ p A ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc4.setValue("Im{I} = "+MaestroA.rounder(state.Iin.Imaginary()*1.0E15,3)+"  [ f A ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc4.setValue("Im{I} = 0.0  [ A ]");   
	}
      
      }
      
      // Impedance
      if(state.IsPhasorPlot == 4){
	
	tempvalue = Math.abs(state.Zin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real(),3)+"  [ "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()/1.0E3,3)+"  [ k "+Ohm+" ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()/1.0E6,3)+"  [ M "+Ohm+" ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E3,3)+"  [ m "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E6,3)+"  [ \u00b5 "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E9,3)+"  [ n "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E12,3)+"  [ p "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc1.setValue("Re{Z} = "+MaestroA.rounder(state.Zin.Real()*1.0E15,3)+"  [ f "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc1.setValue("Re{Z} = 0.0  [ "+Ohm+" ]");   
	}
	
	tempvalue = Math.abs(state.Zin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary(),3)+"  [ "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()/1.0E3,3)+"  [ k "+Ohm+" ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()/1.0E6,3)+"  [ M "+Ohm+" ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E3,3)+"  [ m "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E6,3)+"  [ \u00b5 "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E9,3)+"  [ n "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E12,3)+"  [ p "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc2.setValue("Im{Z} = "+MaestroA.rounder(state.Zin.Imaginary()*1.0E15,3)+"  [ f "+Ohm+" ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc2.setValue("Im{Z} = 0.0  [ "+Ohm+" ]");   
	}
      
      }
      
      // Admittance
      if(state.IsPhasorPlot == 5){
	
	tempvalue = Math.abs(state.Yin.Real());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real(),3)+"  [ S ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()/1.0E3,3)+"  [ k S ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()/1.0E6,3)+"  [ M S ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E3,3)+"  [ m S ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E6,3)+"  [ \u00b5 S ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E9,3)+"  [ n S ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E12,3)+"  [ p S ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc1.setValue("Re{Y} = "+MaestroA.rounder(state.Yin.Real()*1.0E15,3)+"  [ f S ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc1.setValue("Re{Y} = 0.0  [ S ]");   
	}
	
	tempvalue = Math.abs(state.Yin.Imaginary());
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary(),3)+"  [ S ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()/1.0E3,3)+"  [ k S ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()/1.0E6,3)+"  [ M S ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E3,3)+"  [ m S ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E6,3)+"  [ \u00b5 S ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E9,3)+"  [ n S ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E12,3)+"  [ p S ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc2.setValue("Im{Y} = "+MaestroA.rounder(state.Yin.Imaginary()*1.0E15,3)+"  [ f S ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc2.setValue("Im{Y} = 0.0  [ S ]");   
	}
      }
      
      // Reflection Coefficient
      if(state.IsPhasorPlot == 6){
      
	mgpa.tgc1.setValue("Re{"+Gamma+"} = "+MaestroA.rounder(state.Gammain.Real(),6));
	mgpa.tgc2.setValue("Im{"+Gamma+"} = "+MaestroA.rounder(state.Gammain.Imaginary(),6));
      }
      
      // Time-average Power
      if(state.IsPhasorPlot == 7){
      
      tempvalue = state.Power_flow;
	
	if (tempvalue>=1.0 && tempvalue<1.0E3|| tempvalue==0.0){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue,3)+"  [ W ]");   
	}
	else if(tempvalue<1.0E6 && tempvalue>=1.0E3  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue/1.0E3,3)+"  [ k W ]");   
	}
	else if(tempvalue>=1.0E6  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue/1.0E6,3)+"  [ M W ]");   
	}
	else if(tempvalue<1.0 && tempvalue>=1.0E-3  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E3,3)+"  [ m W ]");   
	}
	else if(tempvalue<1.0E-3 && tempvalue>=1.0E-6  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E6,3)+"  [ \u00b5 W ]");   
	}
	else if(tempvalue<1.0E-6 && tempvalue>=1.0E-9  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E9,3)+"  [ n W ]");   
	}
	else if(tempvalue<1.0E-9 && tempvalue>=1.0E-12  ){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E12,3)+"  [ p W ]");   
	}
	else if(tempvalue<1.0E-12 &&  tempvalue>=1.0E-15){
	    mgpa.tgc3.setValue("< P > = "+MaestroA.rounder(tempvalue*1.0E15,3)+"  [ f W ]");   
	}
	else if(tempvalue<1.0E-15){
	    mgpa.tgc3.setValue("< P > = 0.0  [ W ]");   
	}
      
      mgpa.tgc2.setValue("| "+Gamma+" | = "+MaestroA.rounder(Complex.Magnitude(state.Gammain),6));
      }
	//--------------------------------------------------------------------
	mgpa.tgc1.repaint();
	mgpa.tgc2.repaint();
	mgpa.tgc3.repaint();
	mgpa.tgc4.repaint();
        
        mgpb.tgc3.cleanUp();
	mgpb.tgc3.repaint();
    
    
    }
        
        if(evt.getSource()==instructions.bupdate){ 
                instructions.setVisible(false);
                // CHANGE ======================================================
                instructions.setBounds(12+xmove+10000,245+ymove,896,286);
                //==============================================================
        }
        
        if(evt.getSource()==loadpanel.bupdate){ 
                instructions.setVisible(true);
                // CHANGE ======================================================
                instructions.setBounds(12+xmove,245+ymove,896,286);
                //==============================================================
        }
        
	if(evt.getSource()==linepanel.lowpanel.b1){
	    state.IsLowLoss = true;
	    if(linepanel.lowpanel.getValue(0) < 0.0){
		state.Z0 = new Complex(50.0,0.0);
		linepanel.lowpanel.setValue(50.0,0);
	    }
	    else{
		state.Z0 = new Complex(linepanel.lowpanel.getValue(0),0.0);
	    }

	    if(linepanel.lowpanel.getValue(1) < 0.0){
		state.frequency = 1.0E9;
		linepanel.lowpanel.setValue(1.0E9,1);
		linepanel.highpanel.setValue(1.0E9,4);
	    }
	    else{
		state.frequency = linepanel.lowpanel.getValue(1);
		linepanel.highpanel.setValue(linepanel.lowpanel.getValue(1),4);
	    }
	    
	    if(linepanel.lowpanel.getValue(2) < 1.0){
		state.epsilon_r = 1.0;
		linepanel.lowpanel.setValue(1.0,2);
	    }
	    else{
		state.epsilon_r = linepanel.lowpanel.getValue(2);
	    }
	    
	      
	    state.xpos = 0.0;
	    state.pre_ignition();
	    
	    if(linepanel.Is_Wavelength){
		if(linepanel.lowpanel.getValue(3) < 0.0){
		    state.lineLength = 1.0;
		    linepanel.lowpanel.setValue(1.0,3);
		    linepanel.highpanel.setValue(1.0,5);
		    
		}
		else{
		    state.lineLength = linepanel.lowpanel.getValue(3);
		    linepanel.highpanel.setValue(linepanel.lowpanel.getValue(3),5);
		}
	    }
	    else{
		
		if(linepanel.lowpanel.getValue(3) < 0.0){
		    state.lineLength = 1.0;
		    linepanel.lowpanel.setValue(1.0,3);
		    linepanel.highpanel.setValue(1.0,5);
		}
		else{
		    state.lineLength = linepanel.lowpanel.getValue(3)/state.wavelength;
		    linepanel.highpanel.setValue(linepanel.lowpanel.getValue(3),5);
		    
		}
	    } 
	    
	    
	    /*
	    //Version 1
	    state.ignition();
	    slidepanel.setLineLength(state.lineLength);
	    slidepanel.slider.setMaximum((int)(10001));
	    	    
	    //------------------------------------------------------------------------
	    // Version 2
	    int templine=10000;
	    if(state.lineLength <= 5.0){
		templine = (int)(10000*state.lineLength)+1;
	    }
	    else if(state.lineLength > 5.0 && state.lineLength <= 10.0){
		templine = (int)(5000*state.lineLength)+1;
		slidepanel.slider.setBlockIncrement((int)(state.lineLength)*50);
	    }
	    else{
		templine = (int)(5000*state.lineLength)+1;
		slidepanel.slider.setBlockIncrement((int)(state.lineLength)*50);
	    }
	    state.ignition();
	    slidepanel.setLineLength(state.lineLength);
	    slidepanel.slider.setMaximum(templine);
	    slidepanel.slider.setValues(templine-1,1,0,templine);
	    */
	    //------------------------------------------------------------------------
	    // Version 3
	    int templine = 10000;
	    int templine2 = 1000;
	    
	    if(state.lineLength < 1.0){
		templine = (int)(10000*state.lineLength);
		state.lineLength_part1 = MaestroA.rounder((double)(templine/10000.0),5);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,7);
		templine2 = (int)(10000001*state.lineLength_part2);
		state.lineLength = MaestroA.rounder(state.lineLength_part1 + state.lineLength_part2,8);
	    }
	    else if(state.lineLength >= 1.0 && state.lineLength < 10.0){
		templine = (int)(1000*state.lineLength);
		state.lineLength_part1 = MaestroA.rounder((double)(templine/1000.0),5);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,6);
		templine2 = (int)(1000001*state.lineLength_part2);
		state.lineLength = MaestroA.rounder(state.lineLength_part1 + state.lineLength_part2,7);
	    }
	    else if(state.lineLength >= 10.0 && state.lineLength < 100.0){
		templine = (int)(100*state.lineLength);
		state.lineLength_part1 = MaestroA.rounder((double)(templine/100.0),4);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,5);
		templine2 = (int)(100001*state.lineLength_part2);
		state.lineLength = MaestroA.rounder(state.lineLength_part1 + state.lineLength_part2,6);
	    }
	    else if(state.lineLength >= 100.0 && state.lineLength < 1000.0){
		templine = (int)(10*state.lineLength);
		state.lineLength_part1 = MaestroA.rounder((double)(templine/10.0),3);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,4);
		templine2 = (int)(10001*state.lineLength_part2);
		state.lineLength = MaestroA.rounder(state.lineLength_part1 + state.lineLength_part2,5);
	    }
	    else if(state.lineLength >= 1000.0 && state.lineLength < 10000.0){
		templine = (int)(state.lineLength);
		state.lineLength_part1 = MaestroA.rounder((double)(templine),2);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,3);
		templine2 = (int)(1001*state.lineLength_part2);
		state.lineLength = MaestroA.rounder(state.lineLength_part1 + state.lineLength_part2,4);
	    }
	    else if(state.lineLength >= 10000.0 && state.lineLength <= 100000.0){
		templine = (int)(state.lineLength/10);
		state.lineLength_part1 = MaestroA.rounder((double)(templine)*10,2);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,2);
		templine2 = (int)(100*state.lineLength_part2);
		state.lineLength = MaestroA.rounder(state.lineLength_part1 + state.lineLength_part2,3);
	    }
	    else if(state.lineLength > 100000.0 ){
		state.lineLength = 100000.0;
		templine = (int)(state.lineLength/10);
		state.lineLength_part1 = MaestroA.rounder((double)(templine)*10,2);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,3);
		templine2 = (int)(100*state.lineLength_part2);
	    }
	    state.linecounter1 = templine;
	    state.linecounter2 = templine2;
	    
	    if(linepanel.Is_Wavelength){
		//linepanel.lowpanel.setValue(state.lineLength,4);
		linepanel.lowpanel.setValue(state.lineLength,3);
	    }
            else{
                if(state.lineLength == 100000.0){
                    
                    double testlength=state.lineLength*state.wavelength;
                    double writelength = 0.0;
                 
                    if(testlength < 1.0E-9 && testlength >0.0 ){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength*1.0E9,8)/1000000000;
                    }
                    else if(testlength < 1.0E-6 && testlength >= 1.0E-9 ){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength*1.0E9,4)/1000000000;
                    }
                    else if(testlength < 1.0E-3 && testlength >= 1.0E-6 ){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength*1.0E6,4)/1000000;
                    }
                    else if(testlength < 1.0 && testlength >= 1.0E-3 ){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength*1000,4)/1000;
                    }
                    else if((testlength < 1000.0 && testlength >= 1.0 ) || testlength == 0.0){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength,6);
                    }
                    else if(testlength < 1.0E6 && testlength >=1.0E3){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength/1000,4)*1000;
                    }
                    else if(testlength < 1.0E9 && testlength >=1.0E6){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength/1.0E6,4)*1000000;
                    }
                    else if(testlength >=1.0E9){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength/1.0E9,4)*1000000000;
                    }
                    
                    linepanel.lowpanel.setValue(MaestroA.rounder(writelength,2),3);
                    //linepanel.highpanel.setValue(MaestroA.rounder(writelength,2),5);
                }
            }
	    
	    state.ignition();
	    slidepanel.setLineLength(state.lineLength,state.lineLength_part1,state.lineLength_part2,state.linecounter1,state.linecounter2);
	    slidepanel.slider.setMaximum(templine+1);
	    slidepanel.slider.setValues(templine,1,0,templine+1);
            
	    //------------------------------------------------------------------------   
			    
	    slidepanel.reset();
	    
	    ccan.repaint();
	    position.repaint();
	    outputpanel.canvas1.repaint();
	    outputpanel.canvas2.repaint(); 
	    //outputdata.canvas1.repaint();  
	    //state.ignition();
	    
	    mgpa.tgc1.setXpos(state.xpos);
	    mgpa.tgc2.setXpos(state.xpos);
	    mgpa.tgc3.setXpos(state.xpos);
	    mgpa.tgc4.setXpos(state.xpos);
	    mgpb.tgc3.setXpos(state.xpos);
	    mgpb.tgc3.setDynamics(false);
	
	    mgpa.tgc1.repaint();
	    mgpa.tgc2.repaint();
	    mgpa.tgc3.repaint();
	    mgpa.tgc4.repaint();
	    mgpb.tgc3.repaint();
	}
	else if(evt.getSource()==linepanel.highpanel.b1){
	    
	    state.IsLowLoss = false;
	    
	    if(linepanel.highpanel.getValue(0) < 0.0){
		state.R = 0.0;
		linepanel.highpanel.setValue(0.0,0);
	    }
	    else{
		state.R = linepanel.highpanel.getValue(0);
	    }
	    
	    if(linepanel.highpanel.getValue(1) < 0.0){
		state.L = 0.0;
		linepanel.highpanel.setValue(0.0,1);
	    }
	    else{
		state.L = linepanel.highpanel.getValue(1);
	    }
	    
	    if(linepanel.highpanel.getValue(2) < 0.0){
		state.G = 0.0;
		linepanel.highpanel.setValue(0.0,2);
	    }
	    else{
		state.G = linepanel.highpanel.getValue(2);
	    }
	    
	    if(linepanel.highpanel.getValue(3) < 0.0){
		state.C = 0.0;
		linepanel.highpanel.setValue(0.0,3);
	    }
	    else{
		state.C = linepanel.highpanel.getValue(3);
	    }
	    
	    if(linepanel.highpanel.getValue(4) < 0.0){
		state.frequency = 1.0E9;
		linepanel.lowpanel.setValue(1.0E9,1);
		linepanel.highpanel.setValue(1.0E9,4);
	    }
	    else{
		state.frequency = linepanel.highpanel.getValue(4);
		linepanel.lowpanel.setValue(linepanel.highpanel.getValue(4),1);
	    }
	    
	    state.xpos = 0.0;  
	    state.pre_ignition();
	    
	    if(linepanel.Is_Wavelength){
		if(linepanel.highpanel.getValue(5) < 0.0){
		    state.lineLength = 1.0;
		    linepanel.lowpanel.setValue(1.0,3);
		    linepanel.highpanel.setValue(1.0,5);
		}
		else{
		    state.lineLength = linepanel.highpanel.getValue(5);
		    linepanel.lowpanel.setValue(linepanel.highpanel.getValue(5),3);
		}  	    	    
		//state.lineLength = linepanel.highpanel.getValue(5);
		//linepanel.lowpanel.setValue(state.lineLength,4);
	    }
	    else{
		if(linepanel.highpanel.getValue(5) < 0.0){
		    state.lineLength = 1.0;
		    linepanel.lowpanel.setValue(1.0,3);
		    linepanel.highpanel.setValue(1.0,5);
		}
		else{
		    state.lineLength = linepanel.highpanel.getValue(5)/state.wavelength;
		    linepanel.lowpanel.setValue(linepanel.highpanel.getValue(5),3);
		}	    
		//state.lineLength = linepanel.highpanel.getValue(5)/state.wavelength;
		//linepanel.lowpanel.setValue(state.lineLength/state.wavelength,4);
	    }
	    /*
	    // Versione 2 
	    int templine=10000;
	    if(state.lineLength <= 5.0){
		templine = (int)(10000*state.lineLength)+1;
		slidepanel.slider.setBlockIncrement(10);
	    }
	    else if(state.lineLength > 5.0 && state.lineLength <= 10.0){
		templine = (int)(5000*state.lineLength)+1;
		slidepanel.slider.setBlockIncrement((int)(state.lineLength)*50);
		//slidepanel.slider.setPageIncrement(100);
	    }
	    else{
		templine = (int)(5000*state.lineLength)+1;
		slidepanel.slider.setBlockIncrement((int)(state.lineLength)*50);
	    }
	    state.pre_ignition();
	    state.ignition();
	    sp.setGammaFlag(state.IsLargerThanOne);
	    sp2.setGammaFlag(state.IsLargerThanOne);
	    
	    slidepanel.setLineLength(state.lineLength);
	    slidepanel.slider.setMaximum(templine);
	    slidepanel.slider.setValues(templine-1,1,0,templine);
	    */
	    /*
	    //Versione 1
	    state.ignition();
	    slidepanel.setLineLength(state.lineLength);
	    slidepanel.slider.setMaximum((int)(10001));
	    */
	    
	    //------------------------------------------------------------------------
	    // Version 3
	    int templine = 10000;
	    int templine2 = 1000;
	    
	    if(state.lineLength < 1.0){
		templine = (int)(10000*state.lineLength);
		state.lineLength_part1 = MaestroA.rounder((double)(templine/10000.0),5);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,7);
		templine2 = (int)(10000001*state.lineLength_part2);
		state.lineLength = MaestroA.rounder(state.lineLength_part1 + state.lineLength_part2,8);
	    }
	    else if(state.lineLength >= 1.0 && state.lineLength < 10.0){
		templine = (int)(1000*state.lineLength);
		state.lineLength_part1 = MaestroA.rounder((double)(templine/1000.0),5);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,6);
		templine2 = (int)(1000001*state.lineLength_part2);
		state.lineLength = MaestroA.rounder(state.lineLength_part1 + state.lineLength_part2,7);
	    }
	    else if(state.lineLength >= 10.0 && state.lineLength < 100.0){
		templine = (int)(100*state.lineLength);
		state.lineLength_part1 = MaestroA.rounder((double)(templine/100.0),4);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,5);
		templine2 = (int)(100001*state.lineLength_part2);
		state.lineLength = MaestroA.rounder(state.lineLength_part1 + state.lineLength_part2,6);
	    }
	    else if(state.lineLength >= 100.0 && state.lineLength < 1000.0){
		templine = (int)(10*state.lineLength);
		state.lineLength_part1 = MaestroA.rounder((double)(templine/10.0),3);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,4);
		templine2 = (int)(10001*state.lineLength_part2);
		state.lineLength = MaestroA.rounder(state.lineLength_part1 + state.lineLength_part2,5);
	    }
	    else if(state.lineLength >= 1000.0 && state.lineLength < 10000.0){
		templine = (int)(state.lineLength);
		state.lineLength_part1 = MaestroA.rounder((double)(templine),2);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,3);
		templine2 = (int)(1001*state.lineLength_part2);
		state.lineLength = MaestroA.rounder(state.lineLength_part1 + state.lineLength_part2,4);
	    }
	    else if(state.lineLength >= 10000.0 && state.lineLength <= 100000.0){
		templine = (int)(state.lineLength/10);
		state.lineLength_part1 = MaestroA.rounder((double)(templine)*10,2);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,2);
		templine2 = (int)(100*state.lineLength_part2);
		state.lineLength = MaestroA.rounder(state.lineLength_part1 + state.lineLength_part2,3);
	    }
	    else if(state.lineLength > 100000.0 ){
		state.lineLength = 100000.0;
		templine = (int)(state.lineLength/10);
		state.lineLength_part1 = MaestroA.rounder((double)(templine)*10,2);
		state.lineLength_part2 = MaestroA.rounder(state.lineLength - state.lineLength_part1,3);
		templine2 = (int)(100*state.lineLength_part2);
	    }
	    state.linecounter1 = templine;
	    state.linecounter2 = templine2;
	    
	    if(linepanel.Is_Wavelength){
		linepanel.highpanel.setValue(state.lineLength,5);
	    }
	    else{
                if(state.lineLength == 100000.0){
                    
                    double testlength=state.lineLength*state.wavelength;
                    double writelength = 0.0;
                 
                    if(testlength < 1.0E-9 && testlength >0.0 ){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength*1.0E9,8)/1000000000;
                    }
                    else if(testlength < 1.0E-6 && testlength >= 1.0E-9 ){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength*1.0E9,4)/1000000000;
                    }
                    else if(testlength < 1.0E-3 && testlength >= 1.0E-6 ){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength*1.0E6,4)/1000000;
                    }
                    else if(testlength < 1.0 && testlength >= 1.0E-3 ){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength*1000,4)/1000;
                    }
                    else if((testlength < 1000.0 && testlength >= 1.0 ) || testlength == 0.0){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength,6);
                    }
                    else if(testlength < 1.0E6 && testlength >=1.0E3){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength/1000,4)*1000;
                    }
                    else if(testlength < 1.0E9 && testlength >=1.0E6){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength/1.0E6,4)*1000000;
                    }
                    else if(testlength >=1.0E9){
                        writelength = MaestroA.rounder(state.lineLength*state.wavelength/1.0E9,4)*1000000000;
                    }
                    
                    linepanel.highpanel.setValue(MaestroA.rounder(writelength,2),5);
                    //linepanel.lowpanel.setValue(MaestroA.rounder(writelength,2),4);
                }
            }
	    
	    state.pre_ignition();
	    state.ignition();
	    slidepanel.setLineLength(state.lineLength,state.lineLength_part1,state.lineLength_part2,state.linecounter1,state.linecounter2);
	    slidepanel.slider.setMaximum(templine+1);
	    slidepanel.slider.setValues(templine,1,0,templine+1);
	    //------------------------------------------------------------------------
	    
	    
	    slidepanel.reset();
	    
	    ccan.repaint();
	    position.repaint();
	    outputpanel.canvas1.repaint();
	    outputpanel.canvas2.repaint();   
	    //outputdata.canvas1.repaint();  
	    //state.ignition();
	    
	    mgpa.tgc1.setXpos(state.xpos);
	    mgpa.tgc2.setXpos(state.xpos);
	    mgpa.tgc3.setXpos(state.xpos);
	    mgpa.tgc4.setXpos(state.xpos);
	    mgpb.tgc3.setXpos(state.xpos);
	    mgpb.tgc3.setDynamics(false);
	
	    mgpa.tgc1.repaint();
	    mgpa.tgc2.repaint();
	    mgpa.tgc3.repaint();
	    mgpa.tgc4.repaint();
	    mgpb.tgc3.repaint();
	}
	else if(evt.getSource()==loadpanel.b1){
	
	    if(loadpanel.c1.getState()){//Impedance choice is on
		
		double temp1, temp2;
		temp1 = Complex.Real(loadpanel.getValue(0));
		temp2 = Complex.Imaginary(loadpanel.getValue(0));
		
		if(temp1 < 0.0){
		    state.ZL = new Complex(0.0,temp2);
		    state.YL = new Complex(0.0,-1.0/temp2);
		    loadpanel.setValue(state.ZL,0);
		}
		else{
		state.ZL = loadpanel.getValue(0);
		}
		state.is_Load_Ztype = true;
	    }
	    else{ //Admittance choice is on
		
		double temp1, temp2;
		temp1 = Complex.Real(loadpanel.getValue(0));
		temp2 = Complex.Imaginary(loadpanel.getValue(0));
		
		if(temp1 < 0.0){
		    state.YL = new Complex(0.0,temp2);
		    state.ZL = new Complex(0.0,-1.0/temp2);
		    loadpanel.setValue(state.YL,0);
		}
		else{
		state.YL = loadpanel.getValue(0);
		}
		state.is_Load_Ztype = false;
	    }

	
	    /*
	    if(loadpanel.c1.getState()){//Impedance choice is on
		state.ZL = loadpanel.getValue(0);
		state.is_Load_Ztype = true;
	    }
	    else{ //Admittance choice is on
		state.YL = loadpanel.getValue(0);
		state.is_Load_Ztype = false;
		Complex YOpen = new Complex(0.0,0.0);
		if(state.YL == YOpen){state.ZL = new Complex(0.0,-1.0E135);}
	    }
	    */
	    
	    state.pre_ignition();
	    state.ignition();
	    
	    ccan.repaint();
	    position.repaint();
	    outputpanel.canvas1.repaint();
	    outputpanel.canvas2.repaint();
	}
	else if(evt.getSource()==generatorpanel.b1){
	    state.generator.setVg(generatorpanel.getValue(0));
	    
	    double temp1, temp2;
	    Complex temp3 = new Complex(1.0,1.0);
	    temp1 = Complex.Real(generatorpanel.getValue(1));
	    temp2 = Complex.Imaginary(generatorpanel.getValue(1));
		
	    if(temp1 < 0.0){
	        temp3 = new Complex(100.0,temp2);
		state.generator.setZg(temp3);
		generatorpanel.setValue(temp3,1);
	    }
	    else{	    
	        state.generator.setZg(generatorpanel.getValue(1));
	    }	    
	    
	    //state.generator.setZg(generatorpanel.getValue(1));
	    send_shock_wave();
	}
        
        else if(evt.getSource()==tcp.button1){
	    //state.IsTronRunning = false;
            //mgpb.IsTronRunning = false;
            state.IsIncident = true;
            state.IsReflected = false;
            state.IsTotal = false; 
            mgpb.tgc3.cleanUp();
            
            state.ScanTimePowerBounds();
            mgpb.setPowerEnvelope(state.y5B,state.y6B);
            
            if(mgpb.DynamicRunType == 1){mgpb.plotTimeDependentVoltage(state);}
            else if(mgpb.DynamicRunType == 2){mgpb.plotTimeDependentCurrent(state);}
            else if(mgpb.DynamicRunType == 3){mgpb.plotTimeDependentPower(state);}
            
            if(state.IwantTraceOn){
                //mgpb.cbx1.setState(true);
                mgpb.tgc3.setTrace(true);
            }
            else{
                //mgpb.cbx1.setState(false);
                mgpb.tgc3.setTrace(false);
            }
            
            tcp.IsButtonOne = true;
            tcp.IsButtonTwo = false;
            tcp.IsButtonThree = false;
            tcp.repaint();
            /*
            state.IsTronRunning = true;
            mgpb.IsTronRunning = true;
            if(!mgpb.ThreadStarted){
                mgpb.start();
                mgpb.ThreadStarted = true;
                mgpb.ssc.button1.setEnabled(false);
                mgpb.ssc.button2.setEnabled(true);           
            }
            else{
                mgpb.ssc.button1.setEnabled(false);
                mgpb.ssc.button2.setEnabled(true);
                mgpb.notify();
            }
             */
            mgpb.tgc3.cleanUp();
            //c1.setEnabled(false);
            mgpb.repaint();
            mgpb.tgc3.repaint();
            
            mgpb.tgc3.cleanUp();
            mgpb.repaint();
            mgpb.tgc3.repaint();
      	}
        
        else if(evt.getSource()==tcp.button2){
	    state.IsIncident = false;
            state.IsReflected = true;
            state.IsTotal = false; 
            mgpb.tgc3.cleanUp();
            state.ScanTimePowerBounds();
            mgpb.setPowerEnvelope(state.y5C,state.y6C);
            
            if(mgpb.DynamicRunType == 1){mgpb.plotTimeDependentVoltage(state);}
            else if(mgpb.DynamicRunType == 2){mgpb.plotTimeDependentCurrent(state);}
            else if(mgpb.DynamicRunType == 3){mgpb.plotTimeDependentPower(state);}
            
            if(state.IwantTraceOn){
                //mgpb.cbx1.setState(true);
                mgpb.tgc3.setTrace(true);
            }
            else{
                //mgpb.cbx1.setState(false);
                mgpb.tgc3.setTrace(false);
            }
            
            tcp.IsButtonOne = false;
            tcp.IsButtonTwo = true;
            tcp.IsButtonThree = false;
            tcp.repaint();
            
            mgpb.tgc3.cleanUp();
            mgpb.repaint();
            mgpb.tgc3.repaint();

            mgpb.tgc3.cleanUp();
            mgpb.repaint();
            mgpb.tgc3.repaint();
        }
        
        else if(evt.getSource()==tcp.button3){
	    state.IsIncident = false;
            state.IsReflected = false;
            state.IsTotal = true; 
            mgpb.tgc3.cleanUp();
            state.ScanTimePowerBounds();
            mgpb.setPowerEnvelope(state.y5A,state.y6A);
            
            if(mgpb.DynamicRunType == 1){mgpb.plotTimeDependentVoltage(state);}
            else if(mgpb.DynamicRunType == 2){mgpb.plotTimeDependentCurrent(state);}
            else if(mgpb.DynamicRunType == 3){mgpb.plotTimeDependentPower(state);}
            
            if(state.IwantTraceOn){
                //mgpb.cbx1.setState(true);
                mgpb.tgc3.setTrace(true);
            }
            else{
                //mgpb.cbx1.setState(false);
                mgpb.tgc3.setTrace(false);
            }
            
            tcp.IsButtonOne = false;
            tcp.IsButtonTwo = false;
            tcp.IsButtonThree = true;
            tcp.repaint();
            
            mgpb.tgc3.cleanUp();
            mgpb.tgc3.cleanUp();
            mgpb.tgc3.repaint();
            
            mgpb.tgc3.cleanUp();
            mgpb.repaint();
            mgpb.tgc3.repaint();
	}        

}

public void itemStateChanged(ItemEvent evt){
	    ItemSelectable ie = evt.getItemSelectable();
	    
	    if(evt.getSource()==loadpanel.c1){
		repaint();
	    }
	    
	    if(evt.getSource()==loadpanel.c2){
		repaint();
	    }
	    
	    if(evt.getSource()==cp.c1){
                tcp.setVisible(false);

                if(ie.getSelectedObjects()[0]==" Instructions"){
                    instructions.setVisible(true);
                    // CHANGE ==================================================
                    instructions.setBounds(12+xmove,245+ymove,896,286);
                    //==========================================================
                }
		if(ie.getSelectedObjects()[0]==" Set Input / Output"){
		    loadpanel.setVisible(true);
		    linepanel.setVisible(true);
		    ccan.setVisible(true);
		    generatorpanel.setVisible(true);
		    mgpa.setVisible(false);
		    mgpb.setVisible(false);
		    state.pre_ignition();
		    state.ignition();
		    outputpanel.repaint();
		    outputpanel.setVisible(true);
                    
                    // CHANGE ==================================================
                    // BRING BACK INITIAL PANELS - MAC SUCKS
                    instructions.setBounds(12+xmove,245+ymove,896,286);
                    outputpanel.setBounds(599+xmove,245+ymove,310,286);
                    ccan.setBounds(10+xmove,99+ymove,900,140);
                    linepanel.setBounds(11+xmove,245+ymove,296,286);
                    loadpanel.setBounds(307+xmove,245+ymove,292,143);
                    generatorpanel.setBounds(307+xmove,388+ymove,292,143);
                    // MOVE AWAY GRAPH PANELS
                    mgpa.setBounds(10+xmove,99+ymove+10000,900,434);
                    mgpb.setBounds(10+xmove,99+ymove+10000,900,434);
                    //==========================================================
                    
		    position.setDark(true);
		    position.setVisible(false);
                    position.repaint();
                    //about.setVisible(false);
                    instructions.setVisible(false);
                    // CHANGE ==================================================
                    instructions.setBounds(12+xmove+10000,245+ymove,896,286);
                    //==========================================================
                    mgpa.c1.select("  Select a Plot");
                    mgpb.c1.select("  Select a Plot");
                    
                    state.OptionOne = true;
                    state.OptionTwo = false;
                    state.OptionThree = false;

		}
		if(ie.getSelectedObjects()[0]==" View Plots (phasors)"){
                    mgpa.c1.select("  Select a Plot"); //*****
                    mgpb.c1.select("  Select a Plot");
		    loadpanel.setVisible(false);
		    linepanel.setVisible(false);
		    generatorpanel.setVisible(false);
		    outputpanel.setVisible(false);
                    ccan.setVisible(false);
		    position.setDark(false);
		    position.setVisible(false);
		    
		    mgpa.setVisible(true);
		    mgpa.tgc1.setVisible(false);
		    mgpa.tgc2.setVisible(false);
		    mgpa.tgc3.setVisible(false);
		    mgpa.tgc4.setVisible(false);
		    mgpb.setVisible(false);
                    
                    // Reset "Total" to make sure one has the total waveform when returning to phasor plots
                    state.IsIncident = false;
                    state.IsReflected = false;
                    state.IsTotal = true; 
           
                    tcp.IsButtonOne = false;
                    tcp.IsButtonTwo = false;
                    tcp.IsButtonThree = true;
                    tcp.repaint();
                    //about.setVisible(false);
                    instructions.setVisible(false);
                    // CHANGE ==================================================
                    instructions.setBounds(12+xmove+10000,245+ymove,896,286);
                    //==========================================================
                
                    // CHANGE ==================================================
                    // MOVE OUT OF THE WAY -  MAC SUCKS
		    instructions.setBounds(12+xmove,245+ymove+10000,896,286);
                    outputpanel.setBounds(599+xmove,245+ymove+10000,310,286);
                    ccan.setBounds(10+xmove,99+ymove+10000,900,140);
                    linepanel.setBounds(11+xmove,245+ymove+10000,296,286);
                    loadpanel.setBounds(307+xmove,245+ymove+10000,292,143);
                    generatorpanel.setBounds(307+xmove,388+ymove+10000,292,143);
                    
                    // MOVE IN AND OUT GRAPH PANELS
                    mgpa.setBounds(10+xmove,99+ymove,900,434);
                    mgpb.setBounds(10+xmove,99+ymove+10000,900,434);
                    //==========================================================
                    
                    state.OptionOne = false;
                    state.OptionTwo = true;
                    state.OptionThree = true;
                    
		 }	
		 if(ie.getSelectedObjects()[0]==" View Plots (time)"){
		    loadpanel.setVisible(false);
		    linepanel.setVisible(false);
		    generatorpanel.setVisible(false);
		    outputpanel.setVisible(false);
		    ccan.setVisible(false);
		    position.setDark(false);
		    position.setVisible(false);
		    tcp.setVisible(false);
		    mgpa.setVisible(false);
		    mgpb.setVisible(true);

                    mgpb.c1.setEnabled(true);//*****
                    mgpb.c1.select("  Select a Plot");//*****
                    mgpa.c1.select("  Select a Plot");
                    mgpb.ssc.setVisible(false);//*****
                    mgpb.ssc.setEnabled(false);
                    mgpb.tgc3.setVisible(false);
                    //about.setVisible(false);
                    instructions.setVisible(false);
                    // CHANGE ==================================================
                    instructions.setBounds(12+xmove+10000,245+ymove,896,286);
                    //==========================================================
                
                    // CHANGE ==================================================
                    // MOVE OUT OF THE WAY -  MAC SUCKS
                    instructions.setBounds(12+xmove,245+ymove+10000,896,286);
		    outputpanel.setBounds(599+xmove,245+ymove+10000,310,286);
                    ccan.setBounds(10+xmove,99+ymove+10000,900,140);
                    linepanel.setBounds(11+xmove,245+ymove+10000,296,286);
                    loadpanel.setBounds(307+xmove,245+ymove+10000,292,143);
                    generatorpanel.setBounds(307+xmove,388+ymove+10000,292,143);
                    // MOVE IN AND OUT GRAPH PANELS
                    mgpa.setBounds(10+xmove,99+ymove+10000,900,434);
                    mgpb.setBounds(10+xmove,99+ymove,900,434);
                    //==========================================================
                    
                    
                    state.OptionOne = false;
                    state.OptionTwo = false;
                    state.OptionThree = true;
                    
		}
                 //if(ie.getSelectedObjects()[0]==" About"){
                 //    
                 //    about.setVisible(true);
                 //}
                
	    }
            
	    //Trans_MultiGraphPanelA Choices
	    else if(evt.getSource()==mgpa.c1){
		if(ie.getSelectedObjects()[0]=="  Impedance"){
		    mgpa.plotImpedance(state);
		    mgpa.tgc1.setVisible(true);
		    mgpa.tgc2.setVisible(true);
		    mgpa.tgc3.setVisible(false);
		    mgpa.tgc4.setVisible(false);
		    mgpa.tgc1.setFlag(1);
		    mgpa.tgc2.setFlag(1);
		    position.setDark(false);
		    position.setVisible(true);
		    position.repaint();
                    tcp.setVisible(false);
		}
		else if(ie.getSelectedObjects()[0]=="  Admittance"){
		    mgpa.plotAdmittance(state);
		    mgpa.tgc1.setVisible(true);
		    mgpa.tgc2.setVisible(true);
		    mgpa.tgc3.setVisible(false);
		    mgpa.tgc4.setVisible(false);
		    mgpa.tgc1.setFlag(0);
		    mgpa.tgc2.setFlag(0);
		    position.setDark(false);
		    position.setVisible(true);
		    position.repaint();
                    tcp.setVisible(false);
		}
		else if(ie.getSelectedObjects()[0]=="  Reflection Coefficient"){
		    mgpa.plotReflectionCoefficient(state);
		    mgpa.tgc1.setVisible(true);
		    mgpa.tgc2.setVisible(true);
		    mgpa.tgc3.setVisible(false);
		    mgpa.tgc4.setVisible(false);
		    mgpa.tgc1.setFlag(2);
		    mgpa.tgc2.setFlag(2);
		    position.setDark(false);
		    position.setVisible(true);
		    position.repaint();
                    tcp.setVisible(false);
		}
		else if(ie.getSelectedObjects()[0]=="  Voltage Phasor"){
		    mgpa.plotVoltagePhasor(state);
		    mgpa.tgc1.setVisible(false);
		    mgpa.tgc2.setVisible(false);
		    mgpa.tgc3.setVisible(true);
		    mgpa.tgc4.setVisible(true);
		    mgpa.tgc3.setFlag(3);
		    mgpa.tgc4.setFlag(3);
		    position.setDark(false);
		    position.setVisible(true);
		    position.repaint();
                    tcp.setVisible(false);
		} 
		else if(ie.getSelectedObjects()[0]=="  Current Phasor"){
		    mgpa.plotCurrentPhasor(state);
		    mgpa.tgc1.setVisible(false);
		    mgpa.tgc2.setVisible(false);
		    mgpa.tgc3.setVisible(true);
		    mgpa.tgc4.setVisible(true);
		    mgpa.tgc3.setFlag(3);
		    mgpa.tgc4.setFlag(3);
		    position.setDark(false);
		    position.setVisible(true);
		    position.repaint();
                    tcp.setVisible(false);
		} 
		else if(ie.getSelectedObjects()[0]=="  Standing Wave Pattern - | V | & | I |"){
		    mgpa.plotVoltageCurrent(state);
		    mgpa.tgc1.setVisible(false);
		    mgpa.tgc2.setVisible(false);
		    mgpa.tgc3.setVisible(true);
		    mgpa.tgc4.setVisible(true);
		    mgpa.tgc3.setFlag(3);
		    mgpa.tgc4.setFlag(3);
		    position.setDark(false);
		    position.setVisible(true);
		    position.repaint();
                    tcp.setVisible(false);
		}
		else if(ie.getSelectedObjects()[0]=="  Time-average Power"){
		    mgpa.plotPower(state);
		    mgpa.tgc1.setVisible(false);
		    mgpa.tgc2.setVisible(true);
		    mgpa.tgc3.setVisible(true);
		    mgpa.tgc4.setVisible(false);
		    mgpa.tgc2.setFlag(2);
		    mgpa.tgc3.setFlag(0);
		    position.setDark(false);
		    position.setVisible(true);
		    position.repaint();
                   tcp.setVisible(false);
		}
                else if(ie.getSelectedObjects()[0]=="  Select a Plot"){//*******
                    mgpa.c1.select("  Select a Plot"); //*****
		    loadpanel.setVisible(false);
		    linepanel.setVisible(false);
		    generatorpanel.setVisible(false);
		    outputpanel.setVisible(false);
		    ccan.setVisible(false);
		    position.setDark(false);
		    position.setVisible(false);
		    
		    mgpa.setVisible(true);
		    mgpa.tgc1.setVisible(false);
		    mgpa.tgc2.setVisible(false);
		    mgpa.tgc3.setVisible(false);
		    mgpa.tgc4.setVisible(false);
		    mgpb.setVisible(false);
                    
                    // Reset "Total" to make sure one has the total waveform when returning to phasor plots
                    state.IsIncident = false;
                    state.IsReflected = false;
                    state.IsTotal = true; 
           
                    tcp.IsButtonOne = false;
                    tcp.IsButtonTwo = false;
                    tcp.IsButtonThree = true;
                    tcp.repaint();
                
                }
		
	    }
	    //Trans_MultiGraphPanelB Choices
	    else if(evt.getSource()==mgpb.c1){
		//mgpb.tgc1.setVisible(false);
		mgpb.tgc3.setVisible(true);
		mgpb.ssc.setEnabled(false);
		if(ie.getSelectedObjects()[0]=="  Time Dependent Voltage"){
                    mgpb.ssc.setVisible(true);//******
		    mgpb.DynamicRunType = 1;
                    mgpb.ssc.setEnabled(true);
		    mgpb.plotTimeDependentVoltage(state);
		    mgpb.tgc3.setFlag(3);
		    position.setDark(false);
		    position.setVisible(true);
		    position.repaint();
                    tcp.setVisible(true);
                    
                    if(state.IwantTraceOn){
			mgpb.tgc3.setTrace(true);
                        mgpb.cbx1.setState(true);
                        //mgpb.cbx2.setState(false);
                    }
                    else{
                        mgpb.tgc3.setTrace(false);
                        //mgpb.cbx2.setState(true);
                        mgpb.cbx1.setState(false);
                    }

		}
		else if(ie.getSelectedObjects()[0]=="  Time Dependent Current"){
                    mgpb.ssc.setVisible(true);//******
		    mgpb.DynamicRunType = 2;
                    mgpb.ssc.setEnabled(true);
		    mgpb.plotTimeDependentCurrent(state);
		    mgpb.tgc3.setFlag(3);
		    position.setDark(false);
		    position.setVisible(true);
		    position.repaint();
                    tcp.setVisible(true);
                    
                    if(state.IwantTraceOn){
			mgpb.tgc3.setTrace(true);
                        mgpb.cbx1.setState(true);
                        //mgpb.cbx2.setState(false);
                    }
                    else{
                        mgpb.tgc3.setTrace(false);
                        //mgpb.cbx2.setState(true);
                        mgpb.cbx1.setState(false);
                    }

		}
		else if(ie.getSelectedObjects()[0]=="  Time Dependent Power"){
                    mgpb.ssc.setVisible(true);//******
                    mgpb.DynamicRunType = 3;
                    state.ScanTimePowerBounds();
                    state.ignition();
                    if(state.IsIncident){
                        mgpb.setPowerEnvelope(state.y5B,state.y6B);
                    }
                    else if(state.IsReflected){
                        mgpb.setPowerEnvelope(state.y5C,state.y6C);
                    }
                    else if(state.IsTotal){
                        mgpb.setPowerEnvelope(state.y5A,state.y6A);
                    }
                    mgpb.ssc.setEnabled(true);
		    mgpb.plotTimeDependentPower(state);
		    mgpb.tgc3.setFlag(3);
		    position.setDark(false);
		    position.setVisible(true);
		    position.repaint();
                    tcp.setVisible(true);
                    
                    if(state.IwantTraceOn){
			mgpb.tgc3.setTrace(true);
                        mgpb.cbx1.setState(true);
                        mgpb.cbx2.setState(false);
                    }
                    else{
                        mgpb.tgc3.setTrace(false);
                        //mgpb.cbx2.setState(true);
                        mgpb.cbx1.setState(false);
                    }
		}
                else if(ie.getSelectedObjects()[0]=="  Select a Plot"){//*****
                    loadpanel.setVisible(false);
		    linepanel.setVisible(false);
		    generatorpanel.setVisible(false);
		    outputpanel.setVisible(false);
		    ccan.setVisible(false);
		    position.setDark(false);
		    position.setVisible(false);
		    
		    mgpa.setVisible(false);
		    mgpb.setVisible(true);

                    mgpb.c1.setEnabled(true);//*****
                    mgpb.c1.select("  Select a Plot");//*****
                    
                    tcp.setVisible(false);
                    mgpb.ssc.setVisible(false);//*****
                    mgpb.ssc.setEnabled(false);
                    mgpb.tgc3.setVisible(false);
                }
	    }
            
            if(evt.getSource() == mgpb.cbx1){
                if(!mgpb.IsTraceON){
                    mgpb.tgc3.setTrace(false);
                    state.IwantTraceOn = false;
                    mgpb.tgc3.cleanUp();
                }
                else{
                    mgpb.tgc3.setTrace(true);
                    state.IwantTraceOn = true;
                    mgpb.tgc3.cleanUp();
                }
            }
            
            //else if(evt.getSource() == mgpb.cbx2){
              //  mgpb.tgc3.setTrace(false);
              //  state.IwantTraceOn = false;
              //   mgpb.tgc3.cleanUp();
            //}
            /*
            if(evt.getSource() == tcp.Envelope){
                mgpb.tgc3.setEnvelope(tcp.IsEnvelope);
                mgpb.tgc3.cleanUp();
                mgpb.tgc3.repaint();
            }
            */
}


private void send_shock_wave(){
	state.ignition();
	ccan.repaint();
	position.repaint();
	
	outputpanel.canvas1.repaint();
	outputpanel.canvas2.repaint();
	state.ignition();
}    
     

}
