//Trans_MultiGraphPanelA.java
//This is for frequency plots
import java.net.*;
import java.awt.*;
import java.awt.event.*;

public class Trans_MultiGraphPanelA extends Panel implements ItemListener, AdjustmentListener, ActionListener{
    //private static final Color bgcolor = new Color(216,216,191);
    private  static final Color bgcolor = new Color(255,255,255);
    private static final Color tinta2 = new Color(236,236,236); // gray
    //private  static final Color bgcolor = new Color(161,220,220);
    private static final Color tinta = new Color(236,236,236);
    private static final Font titlefont = TheFonts.bold16;
    private static final Font labfont = TheFonts.sanSerif11;
    private static final Font labfont2 = TheFonts.bold11;
    private static final Font labfont3 = TheFonts.sanSerif16;
    private final Font labelfont=TheFonts.sanSerif12;
    public Label titlelabel, selectlabel, rise3, rise4, rise5;  
    public Label rise1, rise2; 
    private String titulo;
    public Choice c1;
    public boolean IsStepOn;
    private int RampIndex = 0;
    //private int ScrollMax2 = 9993;
    private int ScrollMax2 = 4057;
    public double RiseTime =0.5;
    public Scrollbar slider2;
    public CheckboxGroup cbgroup;
    public Checkbox cb1, cb2;
    public int Flag =1;
    
    public Panel ps3, ps4;
    // CHANGE ==============================================================
        public Button b2a, b2b;
    //======================================================================
	
    TransGraphCanvas tgc1, tgc2;
    //TransGraphCanvas tgc3, tgc4;

    public Trans_MultiGraphPanelA(String titulo){
	super();
        setFont(TheFonts.sanSerif14);
	this.titulo=titulo;
	setLayout(null);
	setBackground(bgcolor);
	 
	c1 = new Choice();
	c1.addItem(" Select a Plot");
	c1.addItem(" Voltage V(t)");
	c1.addItem(" Current I(t)");
	c1.addItem(" Power P(t)");
	
	c1.setBackground(Color.white);
	c1.setForeground(Color.black);
	c1.setFont(TheFonts.sanSerif11);
        //c1.setFont(TheFonts.serif12);
	//titlelabel = new Label(titulo,Label.CENTER);
	titlelabel = new Label("Transient Plots",Label.LEFT);
	titlelabel.setFont(titlefont);
	
	selectlabel = new Label("Click to select a plot",Label.RIGHT);
	selectlabel.setFont(labfont);
	selectlabel.setBackground(bgcolor);
	selectlabel.setForeground(Color.blue);
	
	rise1 = new Label("0.5",Label.RIGHT);
	rise2 = new Label("fs",Label.LEFT);
	rise3 = new Label("Pulse Width",Label.RIGHT);
	rise4 = new Label("r",Label.CENTER);
	rise5 = new Label(" = ",Label.CENTER);
	rise1.setFont(labfont3);
	rise2.setFont(labfont3);
	rise3.setFont(labfont3);
	rise4.setFont(labfont2);
	rise4.setFont(labfont3);
	rise1.setForeground(Color.blue);
	rise2.setForeground(Color.blue);
	rise3.setForeground(Color.blue);
	rise4.setForeground(Color.blue);
	rise5.setForeground(Color.blue);
	
	tgc1 = new TransGraphCanvas();
	tgc2 = new TransGraphCanvas();
	//tgc3 = new TransGraphCanvas2();
	//tgc4 = new TransGraphCanvas2();
	
	cbgroup = new CheckboxGroup();
	cb1 = new Checkbox("Step",cbgroup,true);
	cb2 = new Checkbox("Pulse",cbgroup,false);
	cb1.setForeground(Color.red);
	cb2.setForeground(Color.blue);
        
        // CHANGE  =====================================================
        b2a = new Button("<");
        b2a.setBackground(bgcolor);        
        b2b = new Button(">");
        b2b.setBackground(bgcolor);
        b2a.setFont(labelfont);
        b2b.setFont(labelfont);
                
        add(b2a); add(b2b);
        //==============================================================
	
	slider2 = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,ScrollMax2);//changes pulse time
        slider2.setBackground(Color.white);
	slider2.setValue(RampIndex);
	add(slider2);
	slider2.setBounds(265,33,345,15);
	slider2.setVisible(false);
        
        // CHANGE  =====================================================
        b2a.setBounds(265,33,14,15);
        b2b.setBounds(596,33,14,15);
        //b2a.setVisible(false);
        //b2b.setVisible(false);
        //==============================================================
        
	ps3 = new Panel();
	    ps3.setBackground(Color.cyan);
	    //add(ps3);
	    ps3.setBounds(264,32,347,22);
	
        ps4 = new Panel();
	    ps4.setBackground(Color.black);
	    add(ps4);
	    ps4.setBounds(264,32,347,17);	
	
                   
        ps3.setVisible(false);
        ps4.setVisible(false);
        
        rise1.setVisible(false);
        rise2.setVisible(false);
        rise3.setVisible(false);
        rise5.setVisible(false);   
            
	add(titlelabel);
	//add(selectlabel);
	add(rise1);
	add(rise2);
	add(rise3);
	//add(rise4);
	//add(rise5);

	add(c1);
	add(tgc1);
	add(tgc2);
	//add(tgc3);
	//add(tgc4);
	
	add(cb1);
	add(cb2);

	titlelabel.setBounds(15,5,150,25);
	
	c1.setBounds(15,30,150,25);
	
	tgc2.setBounds(6,61,605,223);
	
	rise1.setBounds(470,10,50,20);
	rise2.setBounds(530,10,30,20);
	//rise3.setBounds(320,10,90,20);
	rise3.setBounds(320,10,110,20);
	rise4.setBounds(440,15,10,15);
	rise5.setBounds(460,10,10,15);
	
	cb1.setBounds(185,7,70,20);
	cb2.setBounds(185,33,70,20);

	Panel pgraph1 = new Panel();
	    pgraph1.setBackground(tinta2);
	    //pgraph1.setBackground(bgcolor);
	    add(pgraph1);
	    pgraph1.setBounds(6,61,605,223);
	    
	Panel pgraph2 = new Panel();
	    pgraph2.setBackground(Color.black);
	    add(pgraph2);
	    pgraph2.setBounds(5,60,607,225);
        
        //Listeners
	
	cb1.addItemListener(this);
	cb2.addItemListener(this);
	
	slider2.addAdjustmentListener(this);
	// CHANGE ======================================================
        b2a.addActionListener(this);
        b2b.addActionListener(this);
        //==============================================================
	IsStepOn = true;
	    
    }			
    
    public void actionPerformed(ActionEvent evt){
            if(evt.getSource()==b2a){
                slider2.setValue(slider2.getValue()-1);
                if(IsStepOn){
                        //RiseTime=0.0;
                        //rise1.setText("0.0");
                        //rise2.setText("s");
                        //slider2.setValue(0);
                }
                else{  	    
                    if(slider2.getValue() == 0){
                        RiseTime=0.5e-15;
                        rise1.setText("0.5");
                        rise2.setText("fs");
                    }
                    if(slider2.getValue() < 2000 && slider2.getValue()>0.0){
                        RiseTime=((double)((slider2.getValue())/2.0))*1.0e-15;
                        rise1.setText(""+MaestroA.rounder(RiseTime*1.0e15,2));
                        rise2.setText("fs");
                    }
                    if(slider2.getValue() == 2000){
                        RiseTime=1.0e-12;
                        rise1.setText("1.0");
                        rise2.setText("ps");
                    }
                    if(slider2.getValue() > 2000 && slider2.getValue() < 3998 ){
                        RiseTime=((double)((slider2.getValue()-2000)/2.0)+1)*1.0e-12;
                        rise1.setText(""+MaestroA.rounder(RiseTime*1.0e12,2));
                        rise2.setText("ps");
                    }
                    if(slider2.getValue() == 3998){
                        RiseTime=1.0e-9;
                        rise1.setText("1.0");
                        rise2.setText("ns");
                    }
                    if(slider2.getValue() > 3998 && slider2.getValue() < 5996 ){
                        RiseTime=((double)((slider2.getValue()-3998)/2.0)+1)*1.0e-9;
                        rise1.setText(""+MaestroA.rounder(RiseTime*1.0e9,2));
                        rise2.setText("ns");
                    }
                    if(slider2.getValue() ==5996){
                        RiseTime=1.0e-6;
                        rise1.setText("1.0");
                        rise2.setText("\u00b5s");
                    }
                    if(slider2.getValue() > 5996 && slider2.getValue() < 7994 ){
                        RiseTime=((double)((slider2.getValue()-5996)/2.0)+1)*1.0e-6;
                        rise1.setText(""+MaestroA.rounder(RiseTime*1.0e6,2));
                        rise2.setText("\u00b5s");
                    }
                    if(slider2.getValue() == 7994){
                        RiseTime=1.0e-3;
                        rise1.setText("1.0");
                        rise2.setText("ms");
                    }
                    if(slider2.getValue() > 7994 && slider2.getValue() < 9992 ){
                        RiseTime=((double)((slider2.getValue()-7994)/2.0)+1)*1.0e-3;
                        rise1.setText(""+MaestroA.rounder(RiseTime*1.0e3,2));
                        rise2.setText("ms");
                    }
                    if(slider2.getValue() ==9992 ){
                        RiseTime=1.0;
                        rise1.setText("1.0");
                        rise2.setText("s");
                    }
                }
            }
            else if(evt.getSource()==b2b){
                slider2.setValue(slider2.getValue()+1);
                if(IsStepOn){
                        //RiseTime=0.0;
                        //rise1.setText("0.0");
                        //rise2.setText("s");
                        //slider2.setValue(0);
                }
                else{  	    
                    if(slider2.getValue() == 0){
                        RiseTime=0.5e-15;
                        rise1.setText("0.5");
                        rise2.setText("fs");
                    }
                    if(slider2.getValue() < 2000 && slider2.getValue()>0.0){
                        RiseTime=((double)((slider2.getValue())/2.0))*1.0e-15;
                        rise1.setText(""+MaestroA.rounder(RiseTime*1.0e15,2));
                        rise2.setText("fs");
                    }
                    if(slider2.getValue() == 2000){
                        RiseTime=1.0e-12;
                        rise1.setText("1.0");
                        rise2.setText("ps");
                    }
                    if(slider2.getValue() > 2000 && slider2.getValue() < 3998 ){
                        RiseTime=((double)((slider2.getValue()-2000)/2.0)+1)*1.0e-12;
                        rise1.setText(""+MaestroA.rounder(RiseTime*1.0e12,2));
                        rise2.setText("ps");
                    }
                    if(slider2.getValue() == 3998){
                        RiseTime=1.0e-9;
                        rise1.setText("1.0");
                        rise2.setText("ns");
                    }
                    if(slider2.getValue() > 3998 && slider2.getValue() < 5996 ){
                        RiseTime=((double)((slider2.getValue()-3998)/2.0)+1)*1.0e-9;
                        rise1.setText(""+MaestroA.rounder(RiseTime*1.0e9,2));
                        rise2.setText("ns");
                    }
                    if(slider2.getValue() ==5996){
                        RiseTime=1.0e-6;
                        rise1.setText("1.0");
                        rise2.setText("\u00b5s");
                    }
                    if(slider2.getValue() > 5996 && slider2.getValue() < 7994 ){
                        RiseTime=((double)((slider2.getValue()-5996)/2.0)+1)*1.0e-6;
                        rise1.setText(""+MaestroA.rounder(RiseTime*1.0e6,2));
                        rise2.setText("\u00b5s");
                    }
                    if(slider2.getValue() == 7994){
                        RiseTime=1.0e-3;
                        rise1.setText("1.0");
                        rise2.setText("ms");
                    }
                    if(slider2.getValue() > 7994 && slider2.getValue() < 9992 ){
                        RiseTime=((double)((slider2.getValue()-7994)/2.0)+1)*1.0e-3;
                        rise1.setText(""+MaestroA.rounder(RiseTime*1.0e3,2));
                        rise2.setText("ms");
                    }
                    if(slider2.getValue() ==9992 ){
                        RiseTime=1.0;
                        rise1.setText("1.0");
                        rise2.setText("s");
                    }
                }
            }
    }

    
    public void itemStateChanged(ItemEvent evt){
	
	if(evt.getSource() == cb1){
	    //tgc1.setStep(true);
	    //tgc2.setStep(true);
	    //rise1.setText("0.0");
	    //rise2.setText(" s");
	    IsStepOn = true;
	    //slider2.setValue(0);
            ps4.setVisible(false);
	}
	else if(evt.getSource() == cb2){
	    //tgc1.setStep(false);
	    //tgc2.setStep(false);
	    IsStepOn = false;
            //rise1.setText("0.5");
	    //rise2.setText(" fs");
	    ps4.setVisible(true);
            slider2.setEnabled(true);
    	}
    }

    public synchronized void plotTimeVoltage(Trans_State state){
	state.ScanTimeVoltage();
	
	//tgc1.setTitle("    V (t)        Load Location");    
	
	double test;
	test = state.getYRangeMax(1);
	
	
	if (test>=1.0 && test<1.0E3 || test==0.0){
	    tgc1.setTitle("   V(t)  [ V ]         Load Location");    
	}
	else if(test <1.0E6 && test >=1.0E3  ){
	    tgc1.setTitle("   V(t)  [ k V ]         Load Location"); 
	   
	}
	else if(test>=1.0E6  ){
	    tgc1.setTitle("   V(t)  [ M V ]         Load Location"); 
	   
	}
	else if(test<1.0 && test>=1.0E-3  ){
	    tgc1.setTitle("   V(t)  [ m V ]         Load Location"); 
	   
	}
	else if(test<1.0E-3 && test>=1.0E-6  ){
	    tgc1.setTitle("   V(t)  [ \u00b5 V ]         Load Location"); 
	    
	}
	else if(test<1.0E-6 && test>=1.0E-9  ){
	    tgc1.setTitle("   V(t)  [ n V ]         Load Location"); 
	    
	}
	else if(test<1.0E-9 && test>=1.0E-12  ){
	    tgc1.setTitle("   V(t)  [ p V ]         Load Location"); 
	    
	}
	else if(test<1.0E-12 && test>=1.0E-15 ){
	    tgc1.setTitle("   V(t)  [ f V ]         Load Location"); 
	   
	}
	else if(test<1.0E-15 ){
	    tgc1.setTitle("   V(t)  [ a V ]         Load Location"); 
	   
	}
	
	tgc1.reset();
	tgc1.setDynamics(false);
	
	tgc1.setYRangeMax(state.getYRangeMax(1));
	tgc1.setValueMax(state.getYRangeMax(1));
	tgc1.setYRangeMin(-state.getYRangeMax(1));
	
	if(RiseTime > 0.0){
	    tgc1.setPulse(true);
	}
	else{
	    tgc1.setPulse(false);
	}
	
	tgc1.plot(state.x,state.y1);
	
	//tgc2.setTitle("    V (t)        Cursor Location");    
	
	test = state.getYRangeMax(1);
	
	
	if (test>=1.0 && test<1.0E3 || test==0.0){
	    tgc2.setTitle("   V(t)  [ V ]         Cursor Location");    
	}
	else if(test <1.0E6 && test >=1.0E3  ){
	    tgc2.setTitle("   V(t)  [ k V ]         Cursor Location"); 
	   
	}
	else if(test>=1.0E6  ){
	    tgc2.setTitle("   V(t)  [ M V ]         Cursor Location"); 
	   
	}
	else if(test<1.0 && test>=1.0E-3  ){
	    tgc2.setTitle("   V(t)  [ m V ]         Cursor Location"); 
	   
	}
	else if(test<1.0E-3 && test>=1.0E-6  ){
	    tgc2.setTitle("   V(t)  [ \u00b5 V ]         Cursor Location"); 
	    
	}
	else if(test<1.0E-6 && test>=1.0E-9  ){
	    tgc2.setTitle("   V(t)  [ n V ]         Cursor Location"); 
	    
	}
	else if(test<1.0E-9 && test>=1.0E-12  ){
	    tgc2.setTitle("   V(t)  [ p V ]         Cursor Location"); 
	    
	}
	else if(test<1.0E-12 && test>=1.0E-15 ){
	    tgc2.setTitle("   V(t)  [ f V ]         Cursor Location"); 
	   
	}
	else if(test<1.0E-15 ){
	    tgc2.setTitle("   V(t)  [ a V ]         Cursor Location"); 
	   
	}
	 
	tgc2.reset();
	tgc2.setDynamics(false);
	
	tgc2.setYRangeMax(state.getYRangeMax(1));
	tgc2.setValueMax(state.getYRangeMax(1));
	tgc2.setYRangeMin(-state.getYRangeMax(1));
	
	if(!IsStepOn){
	    tgc2.setPulse(true);
	}
	else{
	    tgc2.setPulse(false);
	}
	
	tgc2.plot(state.x,state.y2);
    }
    

    
    public synchronized void plotTimeCurrent(Trans_State state){
	state.ScanTimeCurrent();
	
	//tgc1.setTitle("    I (t)        Load Location");    
	double test;
	test = state.getYRangeMax(2);
	
	
	if (test>=1.0 && test<1.0E3 || test==0.0){
	    tgc1.setTitle("   I(t)  [ A ]         Load Location");    
	}
	else if(test <1.0E6 && test >=1.0E3  ){
	    tgc1.setTitle("   I(t)  [ k A ]         Load Location"); 
	   
	}
	else if(test>=1.0E6  ){
	    tgc1.setTitle("   I(t)  [ M A ]         Load Location"); 
	   
	}
	else if(test<1.0 && test>=1.0E-3  ){
	    tgc1.setTitle("   I(t)  [ m A ]         Load Location"); 
	   
	}
	else if(test<1.0E-3 && test>=1.0E-6  ){
	    tgc1.setTitle("   I(t)  [ \u00b5 A ]         Load Location"); 
	    
	}
	else if(test<1.0E-6 && test>=1.0E-9  ){
	    tgc1.setTitle("   I(t)  [ n A ]         Load Location"); 
	    
	}
	else if(test<1.0E-9 && test>=1.0E-12  ){
	    tgc1.setTitle("   I(t)  [ p A ]         Load Location"); 
	    
	}
	else if(test<1.0E-12 && test>=1.0E-15 ){
	    tgc1.setTitle("   I(t)  [ f A ]         Load Location"); 
	   
	}
	else if(test<1.0E-15 ){
	    tgc1.setTitle("   I(t)  [ a A ]         Load Location"); 
	   
	} 
	
	tgc1.reset();
	tgc1.setDynamics(false);
	
	tgc1.setYRangeMax(state.getYRangeMax(2));
	tgc1.setValueMax(state.getYRangeMax(2));
	tgc1.setYRangeMin(-state.getYRangeMax(2));
	
	if(!IsStepOn){
	    tgc1.setPulse(true);
	}
	else{
	    tgc1.setPulse(false);
	}
	
	tgc1.plot(state.x,state.y1);
	
	
	//tgc2.setTitle("    I (t)        Cursor Location");    
	test = state.getYRangeMax(2);
	
	
	if (test>=1.0 && test<1.0E3 || test==0.0){
	    tgc2.setTitle("   I(t)  [ A ]         Cursor Location");    
	}
	else if(test <1.0E6 && test >=1.0E3  ){
	    tgc2.setTitle("   I(t)  [ k A ]         Cursor Location"); 
	   
	}
	else if(test>=1.0E6  ){
	    tgc2.setTitle("   I(t)  [ M A ]         Cursor Location"); 
	   
	}
	else if(test<1.0 && test>=1.0E-3  ){
	    tgc2.setTitle("   I(t)  [ m A ]         Cursor Location"); 
	   
	}
	else if(test<1.0E-3 && test>=1.0E-6  ){
	    tgc2.setTitle("   I(t)  [ \u00b5 A ]         Cursor Location"); 
	    
	}
	else if(test<1.0E-6 && test>=1.0E-9  ){
	    tgc2.setTitle("   I(t)  [ n A ]         Cursor Location"); 
	    
	}
	else if(test<1.0E-9 && test>=1.0E-12  ){
	    tgc2.setTitle("   I(t)  [ p A ]         Cursor Location"); 
	    
	}
	else if(test<1.0E-12 && test>=1.0E-15 ){
	    tgc2.setTitle("   I(t)  [ f A ]         Cursor Location"); 
	   
	}
	else if(test<1.0E-15 ){
	    tgc2.setTitle("   I(t)  [ a A ]         Cursor Location"); 
	   
	} 
	
	tgc2.reset();
	tgc2.setDynamics(false);
	
	tgc2.setYRangeMax(state.getYRangeMax(2));
	tgc2.setValueMax(state.getYRangeMax(2));
	tgc2.setYRangeMin(-state.getYRangeMax(2));
	
	if(!IsStepOn){
	    tgc2.setPulse(true);
	}
	else{
	    tgc2.setPulse(false);
	}
	
	tgc2.plot(state.x,state.y2);	
	
    }
    
    public synchronized void plotTimePower(Trans_State state){
	state.ScanTimePower();
	
	//tgc1.setTitle("    P (t)        Load Location");    
	
	double test;
	test = state.getYRangeMax(3);
	
	if (test>=1.0 && test<1.0E3 || test==0.0){
	    tgc1.setTitle("   P(t)  [ W ]         Load Location");    
	}
	else if(test <1.0E6 && test >=1.0E3  ){
	    tgc1.setTitle("   P(t)  [ k W ]         Load Location"); 
	   
	}
	else if(test>=1.0E6  ){
	    tgc1.setTitle("   P(t)  [ M W ]         Load Location"); 
	   
	}
	else if(test<1.0 && test>=1.0E-3  ){
	    tgc1.setTitle("   P(t)  [ m W ]         Load Location"); 
	   
	}
	else if(test<1.0E-3 && test>=1.0E-6  ){
	    tgc1.setTitle("   P(t)  [ \u00b5 W ]         Load Location"); 
	    
	}
	else if(test<1.0E-6 && test>=1.0E-9  ){
	    tgc1.setTitle("   P(t)  [ n W ]         Load Location"); 
	    
	}
	else if(test<1.0E-9 && test>=1.0E-12  ){
	    tgc1.setTitle("   P(t)  [ p W ]         Load Location"); 
	    
	}
	else if(test<1.0E-12 && test>=1.0E-15 ){
	    tgc1.setTitle("   P(t)  [ f W ]         Load Location"); 
	   
	}
	else if(test<1.0E-15 ){
	    tgc1.setTitle("   P(t)  [ a W ] "); 
	   
	}    
		
	tgc1.reset();
	tgc1.setDynamics(false);
	
	tgc1.setYRangeMax(state.getYRangeMax(3));
	tgc1.setValueMax(state.getYRangeMax(3));
	tgc1.setYRangeMin(-state.getYRangeMax(3));
	
	if(!IsStepOn){
	    tgc1.setPulse(true);
	}
	else{
	    tgc1.setPulse(false);
	}
	
	tgc1.plot(state.x,state.y1);
	
	
	
	//tgc2.setTitle("    P (t)        Cursor Location");    
	test = state.getYRangeMax(3);
	
	if (test>=1.0 && test<1.0E3 || test==0.0){
	    tgc2.setTitle("   P(t)  [ W ]         Cursor Location");    
	}
	else if(test <1.0E6 && test >=1.0E3  ){
	    tgc2.setTitle("   P(t)  [ k W ]         Cursor Location"); 
	   
	}
	else if(test>=1.0E6  ){
	    tgc2.setTitle("   P(t)  [ M W ]         Cursor Location"); 
	   
	}
	else if(test<1.0 && test>=1.0E-3  ){
	    tgc2.setTitle("   P(t)  [ m W ]         Cursor Location"); 
	   
	}
	else if(test<1.0E-3 && test>=1.0E-6  ){
	    tgc2.setTitle("   P(t)  [ \u00b5 W ]         Cursor Location"); 
	    
	}
	else if(test<1.0E-6 && test>=1.0E-9  ){
	    tgc2.setTitle("   P(t)  [ n W ]         Cursor Location"); 
	    
	}
	else if(test<1.0E-9 && test>=1.0E-12  ){
	    tgc2.setTitle("   P(t)  [ p W ]         Cursor Location"); 
	    
	}
	else if(test<1.0E-12 && test>=1.0E-15 ){
	    tgc2.setTitle("   P(t)  [ f W ]         Cursor Location"); 
	   
	}
	else if(test<1.0E-15 ){
	    tgc2.setTitle("   P(t)  [ a W ]         Cursor Location"); 
	   
	}    
	
	tgc2.reset();
	tgc2.setDynamics(false);
	
	tgc2.setYRangeMax(state.getYRangeMax(3));
	tgc2.setValueMax(state.getYRangeMax(3));
	tgc2.setYRangeMin(-state.getYRangeMax(3));
	
	if(!IsStepOn){
	    tgc2.setPulse(true);
	}
	else{
	    tgc2.setPulse(false);
	}
	
	tgc2.plot(state.x,state.y2);
	
    }
    
    
    
    public void adjustmentValueChanged(AdjustmentEvent evt){
	
	if(evt.getSource()==slider2){
	  if(IsStepOn){
		//RiseTime=0.0;
		//rise1.setText("0.0");
		//rise2.setText("s");
		//slider2.setValue(0);
	  }
	  else{  	    
	    if(slider2.getValue() == 0){
		RiseTime=0.5e-15;
		rise1.setText("0.5");
		rise2.setText("fs");
	    }
	    if(slider2.getValue() < 2000 && slider2.getValue()>0.0){
		RiseTime=((double)((slider2.getValue())/2.0))*1.0e-15;
		rise1.setText(""+MaestroA.rounder(RiseTime*1.0e15,2));
		rise2.setText("fs");
	    }
	    if(slider2.getValue() == 2000){
		RiseTime=1.0e-12;
		rise1.setText("1.0");
		rise2.setText("ps");
	    }
	    if(slider2.getValue() > 2000 && slider2.getValue() < 3998 ){
		RiseTime=((double)((slider2.getValue()-2000)/2.0)+1)*1.0e-12;
		rise1.setText(""+MaestroA.rounder(RiseTime*1.0e12,2));
		rise2.setText("ps");
	    }
	    if(slider2.getValue() == 3998){
		RiseTime=1.0e-9;
		rise1.setText("1.0");
		rise2.setText("ns");
	    }
	    if(slider2.getValue() > 3998 && slider2.getValue() < 5996 ){
		RiseTime=((double)((slider2.getValue()-3998)/2.0)+1)*1.0e-9;
		rise1.setText(""+MaestroA.rounder(RiseTime*1.0e9,2));
		rise2.setText("ns");
	    }
	    if(slider2.getValue() ==5996){
		RiseTime=1.0e-6;
		rise1.setText("1.0");
		rise2.setText("\u00b5s");
	    }
	    if(slider2.getValue() > 5996 && slider2.getValue() < 7994 ){
		RiseTime=((double)((slider2.getValue()-5996)/2.0)+1)*1.0e-6;
		rise1.setText(""+MaestroA.rounder(RiseTime*1.0e6,2));
		rise2.setText("\u00b5s");
	    }
	    if(slider2.getValue() == 7994){
		RiseTime=1.0e-3;
		rise1.setText("1.0");
		rise2.setText("ms");
	    }
	    if(slider2.getValue() > 7994 && slider2.getValue() < 9992 ){
		RiseTime=((double)((slider2.getValue()-7994)/2.0)+1)*1.0e-3;
		rise1.setText(""+MaestroA.rounder(RiseTime*1.0e3,2));
		rise2.setText("ms");
	    }
	    if(slider2.getValue() ==9992 ){
		RiseTime=1.0;
		rise1.setText("1.0");
		rise2.setText("s");
	    }
	  }
	      
	}
    }
    
    public synchronized void setRiseTime(double RiseTime){
	this.RiseTime = RiseTime;
    }

    
}
