import java.awt.*;
import java.awt.event.*;

public class DipoleRadiation extends Frame implements AdjustmentListener, ActionListener, ItemListener, MouseListener, WindowListener{
    
    //About about;
    Instructions instructions;
    Panel instrFrame; Panel instrFrame2;
    ChoicePanel cp;
    ChoiceInput chinp;
    ChoiceInput2 chinp2;
    ChoiceInput3 chinp3;
    
    TitlePanel titlepanel;
    
    DrawCurrent draw_current;
    DrawCurrent2 draw_current2;
    
    TransSlidePanel slidepanel;
    NewGuideCanvas2 dipolecanvas;
    Trans_State state;
    
    Trans_MultiGraphPanelC mgpc;
    
    Draw2DCanvas draw2D;
    Draw2DCanvasB draw2DB;
    DrawPalette drawpalette;
    
    public Label labella1, labella2;
    // New 8/9/14:
    public Label labella3;

    final Font labfonte = new Font("Sanserif",Font.BOLD,12);
    
    int start1 = 7;
    int start2 = 287;
    int start3 = 700;
   
public static void main(String[] args){
        DipoleRadiation f = new DipoleRadiation();
        int xmove = 20;
        int ymove = 41;
        f.setSize(759+xmove,573+ymove);
        f.setVisible(true);
        f.setLayout(null);
}
   
public DipoleRadiation(){
    
    setLayout(null);
    state = new Trans_State();
    
    int xmove = 10;
    int ymove = 34;
    
    //labella1 = new Label("This module simulates how a short dipole radiates an EM wave into",Label.LEFT);  8/9/14
    labella1 = new Label("This module simulates how a short dipole radiates an EM wave",Label.LEFT);
        labella1.setFont(labfonte);
	labella1.setForeground(Color.black);
        labella1.setBackground(new Color(255,255,250));
        labella1.setBounds(305+xmove,10+ymove,430,20);
        labella1.setVisible(true);
        
    //labella2 = new Label("its surrounding space.  The dipole is oriented along the z-axis.",Label.LEFT);
    labella2 = new Label("into its surrounding space.  The dipole is oriented along",Label.LEFT);
        labella2.setFont(labfonte);
	labella2.setForeground(Color.black);
        labella2.setBackground(new Color(255,255,250));
        labella2.setBounds(305+xmove,30+ymove,430,20);
        labella2.setVisible(true);

        // NEW 8/9/14:
    labella3 = new Label("the z-axis.",Label.LEFT);
        labella3.setFont(labfonte);
	labella3.setForeground(Color.black);
        labella3.setBackground(new Color(255,255,250));
        labella3.setBounds(305+xmove,50+ymove,430,20);
        labella3.setVisible(true);


    instructions = new Instructions();
    instructions.setBounds(8+xmove,58+ymove,743,503);
    instructions.setBackground(new Color(255,255,250));

    instrFrame = new Panel();
    instrFrame.setBackground(Color.black);
    instrFrame.setBounds(7+xmove,57+ymove,745,505);

    instrFrame2 = new Panel();
    instrFrame2.setBackground(new Color(255,255,250));
    instrFrame2.setBounds(288+xmove,8+ymove,463,90);
        
    titlepanel = new TitlePanel("Module 9.1",""); //must customize special
    titlepanel.setBounds(start1+xmove,7+ymove,275,45);
	
    cp = new ChoicePanel();
    cp.setBounds(start2+xmove,462+ymove,465,100);
    
    chinp = new ChoiceInput();
    //add(chinp);
    chinp.setBounds(7+xmove,7+ymove,625,30+615);
    chinp.setVisible(false);
    
    chinp2 = new ChoiceInput2();
    //add(chinp2);
    chinp2.setBounds(start2+xmove,7+ymove,465,450);
    chinp2.setVisible(true);
    
    chinp3 = new ChoiceInput3();
    //add(chinp3);
    chinp3.setBounds(7+xmove,7+ymove,625,30+615);
    chinp3.setVisible(false);
    
    dipolecanvas = new NewGuideCanvas2();
    dipolecanvas.setBounds(start1+xmove,57+ymove,275,250);
    
    slidepanel = new TransSlidePanel(state);
    //add(slidepanel);
    slidepanel.setBounds(start1+xmove,462+ymove,275,100);
    slidepanel.setVisible(true);
        
    draw_current = new DrawCurrent(state);
    draw_current.setBounds(start1+1+xmove,58+ymove,273,248);
    draw_current.setVisible(true);
    
    draw_current2 = new DrawCurrent2(state);
    draw_current2.setBounds(15+xmove,15+ymove,600,600);
    draw_current2.setVisible(false);
    
    mgpc = new Trans_MultiGraphPanelC("Transient 1",state,draw_current);
    mgpc.setBounds(start1+xmove,312+ymove,275,145);
        
    draw2D = new Draw2DCanvas(state);
    draw2D.setBounds(start2+xmove,7+ymove,616,616);
    
    draw2DB = new Draw2DCanvasB(state);
    draw2DB.setBounds(start2+2+xmove,9+ymove,410,410);
    
    drawpalette = new DrawPalette(state);
    drawpalette.setBounds(start3+xmove,9+ymove,50,410);
        
    Panel p000 = new Panel();
	    p000.setBackground(Color.black);
	    //add(p000);
	    p000.setBounds(start1+xmove,57+ymove,275,250); 
    
    Panel p0 = new Panel();
	    p0.setBackground(Color.cyan);
            //add(p0);
	    p0.setBounds(2+xmove,2+ymove,755,566);
	    
    Panel p00 = new Panel();
	    p00.setBackground(Color.black);
	    //add(p00);
	    p00.setBounds(xmove,ymove,759,570);

   //hide and show panels
    {
	
	mgpc.setVisible(true);
        draw2DB.setVisible(true);
        dipolecanvas.setVisible(true);
        draw_current.setVisible(false);
    }    
        
    //if(state.this_year > line.magicyear || (state.this_year == line.magicyear && state.this_month > line.magicmonth)){
    //	    state.LicenseExpired = true;
    //	}
    //	else
    //  {   
             //add(about); 
            add(labella1); add(labella2);  add(labella3);  // 8/9/14 (3rd add)
            add(instructions);
            add(instrFrame2);
            add(instrFrame);
            add(titlepanel);
            add(cp); 	
	    add(draw_current);
            //add(draw_current2);
            add(slidepanel); 
            add(dipolecanvas);
	    add(mgpc); 
            //add(draw2D);
            add(draw2DB);
            add(drawpalette);
            //add(chinp);
            add(chinp2);
            //add(chinp3);
            
            add(p000);
            add(p0); 	    
	    add(p00);
	    state.LicenseExpired = false; 	
            //}
              
    //Listeners
    this.addWindowListener(this);
    instructions.bupdate.addActionListener(this);
    slidepanel.slider3.addAdjustmentListener(this);
    slidepanel.trace.addItemListener(this);
    slidepanel.ch1.addItemListener(this);
    slidepanel.ch2.addItemListener(this);
    slidepanel.ch3.addItemListener(this);
    slidepanel.ch4.addItemListener(this);
    slidepanel.ch5.addItemListener(this);
    slidepanel.ch6.addItemListener(this);
    
    cp.c1.addItemListener(this);
    cp.c2.addItemListener(this);
    cp.c3.addItemListener(this);
    cp.c4.addItemListener(this);
    cp.c5.addItemListener(this);
    cp.c6.addItemListener(this);
    
    cp.f1.addItemListener(this);
    cp.f2.addItemListener(this);
    
    mgpc.ssc.button1.addMouseListener(this);
    mgpc.ssc.button2.addMouseListener(this);
    mgpc.ssc.button3.addMouseListener(this);
    
    mgpc.slider1.addAdjustmentListener(this);
    mgpc.sliderzoom.addAdjustmentListener(this);
    
    state.RestartPlot = true;
    
    mgpc.ssc.setEnabled(true);
    mgpc.plotTransientVoltage(state);
    mgpc.watch1.setText("0\u00b0");
    mgpc.ssc.clockcanvas.setStatus(0,state.NTime,state.dtime);
    mgpc.ssc.clockcanvas.reset();
    mgpc.ssc.button2.setEnabled(false);
    
    cp.information.addActionListener(this);	
    chinp2.about.addActionListener(this);
    mgpc.ssc.button3.addActionListener(this);
    cp.setDeltaLambda(state.delta_lambda*state.Nx);
}

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,985,700);  	
		
	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,677);
        //g.setFont(fonto);
        //g.drawString("Amanogawa, "+annonuovo+" - All Rights Reserved",30,675);
	 
}


public void start(){}


public void stop(){}

public void adjustmentValueChanged(AdjustmentEvent evt){
    
    if(evt.getSource()==mgpc.sliderzoom){// varies time step
	
        //if(mgpc.sliderzoom.getValue()>0){
          //  state.dtime = mgpc.sliderzoom.getValue()*2;
        //}
        //else
        //{
            //state.dtime = mgpc.sliderzoom.getValue();//+1;
        //}
        
        if(mgpc.sliderzoom.getValue()<7){
            state.dtime = mgpc.sliderzoom.getValue();
        }
        else{
            state.dtime = mgpc.sliderzoom.getValue()+1;
        }
        
        cp.information.setEnabled(true);
                //slidepanel2.slider.setEnabled(true);
                //slidepanel2.slider2.setEnabled(true);
                //slidepanel2B.slider.setEnabled(true);
                //slidepanel2B.slider2.setEnabled(true);
                //slidepanel2C.slider.setEnabled(true);
                //slidepanel2C.slider2.setEnabled(true);
                //chinp.setVisible(true);
                
                state.ctime = 0;    
                
                    state.RestartPlot = true;
                    //state.ignition();
                    mgpc.ssc.setEnabled(true);
		    //mgpc.plotTransientVoltage(state);
		    mgpc.watch1.setText("0\u00b0");
		    mgpc.ssc.clockcanvas.setStatus(0,state.NTime,state.dtime);
		    mgpc.ssc.clockcanvas.reset();
		    
                    mgpc.ssc.IsStart = false;
                    mgpc.ssc.IsStop = false;
                    mgpc.ssc.IsReset = false;
                    mgpc.ssc.IsStepNew = true;
                
                    mgpc.ssc.button1.setEnabled(false);
                    mgpc.ssc.button2.setEnabled(false);
                    mgpc.ssc.button3.setEnabled(true);
                    mgpc.ssc.repaint();
                    
    }
        
    if(evt.getSource()==slidepanel.slider){// varies opening of slit
	
        state.RestartPlot = true;
        state.delta_y = slidepanel.slider.getValue()*1.0e-9;
        state.ignition();
	draw2D.repaint();
        draw2DB.repaint();
        draw_current.repaint();
        draw_current2.repaint();
        
    }

    if(evt.getSource()==slidepanel.slider2){// vary wavelength - frequency
	
        state.RestartPlot = true;
        state.lambda = slidepanel.slider2.getValue()*1.0e-9;
        state.ignition();
	draw2D.repaint();
        draw2DB.repaint();
        draw_current.repaint();
        draw_current2.repaint();
        
    }

    if(evt.getSource()==slidepanel.slider3){
	
        state.RestartPlot = true;
        state.delta_lambda = slidepanel.slider3.getValue()*0.000666666;
        cp.setDeltaLambda(state.delta_lambda*state.Nx);
        mgpc.ssc.clockcanvas.setStatus(0,state.NTime,state.dtime);
		    
        state.ignition();
        
        draw2D.repaint();
        draw2DB.repaint();
        draw_current.repaint();
        draw_current2.repaint();
        
        slidepanel.repaint();
    }
}

public void actionPerformed(ActionEvent evt){
    //if(evt.getSource()==about.bupdate){
    //        about.setVisible(false);
    //}
    
    if (evt.getSource()==mgpc.ssc.button3){
          state.RestartPlot = true;
          state.ignition();
          draw_current.repaint();
    }
    if (evt.getSource()==instructions.bupdate){
            instructions.setVisible(false);
            instrFrame.setVisible(false);
            instrFrame2.setVisible(false);
            labella1.setVisible(false);
            labella2.setVisible(false);
            labella3.setVisible(false);
    }
        
        if(evt.getSource()==chinp2.about){
            //about.setVisible(true); 
            instructions.setVisible(true);
            instrFrame.setVisible(true);
            instrFrame2.setVisible(true);
            labella1.setVisible(true);
            labella2.setVisible(true);
            labella3.setVisible(true);
        }
        
        if(evt.getSource()==chinp.outgo){
                //slidepanel.setVisible(false);
                chinp.outgo.setVisible(false);
                chinp.outgo.setEnabled(false);
                chinp.ingo.setVisible(true);
                chinp.ingo.setEnabled(true);
        }
        if(evt.getSource()==chinp.ingo){
                //slidepanel.setVisible(true);
                chinp.outgo.setVisible(true);
                chinp.outgo.setEnabled(true);
                chinp.ingo.setVisible(false);
                chinp.ingo.setEnabled(false);
        }
}

public void itemStateChanged(ItemEvent evt){
	    ItemSelectable ie = evt.getItemSelectable();
	    
            if(evt.getSource()==slidepanel.trace){
                if(state.ShowCurrent){
                    state.ShowCurrent = false;
                    draw_current.setVisible(false);
                    dipolecanvas.setVisible(true);
                }
                else{
                    state.ShowCurrent = true;
                    draw_current.setVisible(true);
                    dipolecanvas.setVisible(false);
                }
                
            }
            
            if(evt.getSource()==slidepanel.ch1){
                state.IsHorizon = true;
                dipolecanvas.setPlane(true);
                if(state.ctime==0){
                    state.ignition();
                }
                state.ScanTransientVoltage();
                mgpc.repaint();
                draw2D.repaint();
                draw2DB.repaint();
                draw_current.repaint();
                draw_current2.repaint();
                dipolecanvas.repaint();
            }
            if(evt.getSource()==slidepanel.ch2){
                state.IsHorizon = false;
                if(state.ctime==0){
                    state.ignition();
                }
                state.ScanTransientVoltage();
                mgpc.repaint();
                draw2D.repaint();
                draw2DB.repaint();
                draw_current.repaint();
                draw_current2.repaint();
                dipolecanvas.setPlane(false);
                dipolecanvas.repaint();
            }
            if(evt.getSource()==slidepanel.ch3){
                state.IsThreshold = false;
                if(state.ctime==0){
                    state.ignition();
                }
                state.ScanTransientVoltage();
                mgpc.repaint();
                draw2D.redopalette();
                draw2DB.redopalette();
                draw2D.repaint();
                draw2DB.repaint();
                draw_current.repaint();
                draw_current2.repaint();
                slidepanel.ch5.setVisible(false);
                slidepanel.ch6.setVisible(false);
                slidepanel.repaint();
            }
            if(evt.getSource()==slidepanel.ch4){
                state.IsThreshold = true;
                if(state.ctime==0){
                    state.ignition();
                }
                state.ScanTransientVoltage();
                mgpc.repaint();
                draw2D.redopalette();
                draw2DB.redopalette();
                draw2D.repaint();
                draw2DB.repaint();
                draw_current.repaint();
                draw_current2.repaint();
                slidepanel.ch5.setVisible(true);
                slidepanel.ch6.setVisible(true);
                slidepanel.repaint();
            }
            if(evt.getSource()==slidepanel.ch5){
                state.IsCoarser = false;
                if(state.ctime==0){
                    state.ignition();
                }
                state.ScanTransientVoltage();
                mgpc.repaint();
                draw2D.redopalette();
                draw2DB.redopalette();
                draw2D.repaint();
                draw2DB.repaint();
                draw_current.repaint();
                draw_current2.repaint();
                slidepanel.repaint();
            }
            if(evt.getSource()==slidepanel.ch6){
                state.IsCoarser = true;
                if(state.ctime==0){
                    state.ignition();
                }
                state.ScanTransientVoltage();
                mgpc.repaint();
                draw2D.redopalette();
                draw2DB.redopalette();
                draw2D.repaint();
                draw2DB.repaint();
                draw_current.repaint();
                draw_current2.repaint();
                slidepanel.repaint();
            }
            
            if(evt.getSource()==cp.c1){
                state.Select_far = true;
                state.Select_near = false;
                state.Select_r = false;
                state.Select_dif = false;
                state.Select_dif = false;
                state.Select_wide = false;
                state.IsFormula = false;
                
                //about.setVisible(false);
                instructions.setVisible(false);
                instrFrame.setVisible(false);
                instrFrame2.setVisible(false);
                labella1.setVisible(false);
                labella2.setVisible(false);
                labella3.setVisible(false);
                chinp.setVisible(false);
                chinp2.setVisible(true);
                chinp3.setVisible(false);
                
                if(state.ctime == 0){
                    state.ignition();
                }
                else{
                    state.ScanTransientVoltage();
                }
                
                draw2D.setVisible(false);
                draw2DB.setVisible(true);
                
                draw2DB.repaint();
            }
            if(evt.getSource()==cp.c2){
                state.Select_far = false;
                state.Select_near = true;
                state.Select_r = false;
                state.Select_dif = false;
                state.Select_wide = false;
                state.IsFormula = false;
                
                //about.setVisible(false);
                instructions.setVisible(false);
                instrFrame.setVisible(false);
                instrFrame2.setVisible(false);
                labella1.setVisible(false);
                labella2.setVisible(false);
                labella3.setVisible(false);
                chinp.setVisible(false);
                chinp2.setVisible(true);
                chinp3.setVisible(false);
                
                if(state.ctime == 0){
                    state.ignition();
                }
                else{
                    state.ScanTransientVoltage();
                }
                
                draw2D.setVisible(false);
                draw2DB.setVisible(true);
                
                draw2DB.repaint();
                
            }
            if(evt.getSource()==cp.c3){// select r-component (electric) 
                state.Select_far = false;
                state.Select_near = false;
                state.Select_r = true;
                state.Select_dif = false;
                state.Select_wide = false;
                state.IsFormula = false;
                
                //about.setVisible(false);
                instructions.setVisible(false);
                instrFrame.setVisible(false);
                instrFrame2.setVisible(false);
                labella1.setVisible(false);
                labella2.setVisible(false);
                labella3.setVisible(false);
                draw2D.setVisible(false);
                
                if(state.ctime == 0){
                    state.ignition();
                }
                else{
                    state.ScanTransientVoltage();
                }
                
                if(state.IsMagnetic){
                    draw2DB.setVisible(false);
                    chinp2.setVisible(false);
                    chinp.setVisible(false);
                    chinp3.setVisible(true);
                }
                else{
                    draw2DB.setVisible(true);
                    draw2DB.repaint();
                    chinp2.setVisible(true);
                    chinp.setVisible(false);
                    chinp3.setVisible(false);
                }
                
            }
            
            if(evt.getSource()==cp.c4){// select difference
                state.Select_far = false;
                state.Select_near = false;
                state.Select_r = false;
                state.Select_dif = true;
                state.Select_wide = false;
                state.IsFormula = false;
                
                //about.setVisible(false);
                instructions.setVisible(false);
                instrFrame.setVisible(false);
                instrFrame2.setVisible(false);
                labella1.setVisible(false);
                labella2.setVisible(false);
                labella3.setVisible(false);
                chinp2.setVisible(true);
                chinp.setVisible(false);
                chinp3.setVisible(false);
                if(state.ctime == 0){
                    state.ignition();
                }
                else{
                    state.ScanTransientVoltage();
                }
                
                draw2D.setVisible(false);
                draw2DB.setVisible(true);
                
                draw2DB.repaint();
                
            }
            
            if(evt.getSource()==cp.c5){// show all
                state.Select_far = false;
                state.Select_near = false;
                state.Select_r = false;
                state.Select_dif = false;
                state.Select_wide = true;
                state.IsFormula = false;
                
                draw2D.setVisible(true);
                draw2DB.setVisible(false);
                
                //about.setVisible(false);
                instructions.setVisible(false);
                instrFrame.setVisible(false);
                instrFrame2.setVisible(false);
                labella1.setVisible(false);
                labella2.setVisible(false);
                labella3.setVisible(false);
                chinp.setVisible(true);
                chinp2.setVisible(false);
                chinp3.setVisible(false);
                
                if(state.ctime == 0){
                    state.ignition();
                }
                else{
                    state.ScanTransientVoltage();
                }
                
                
                draw2D.repaint();
                draw_current.repaint();
                draw_current2.repaint();
                
            }
            if(evt.getSource()==cp.c6){// formulas - NOT USED
                state.IsFormula = true;
                
                if(state.IsMagnetic){
                    //about.setVisible(true);
                    instructions.setVisible(true);
                    instrFrame.setVisible(true);
                    labella1.setVisible(false);
                    labella2.setVisible(false);
                    labella3.setVisible(false);
                }
                else{
                    //about.setVisible(false);       // 10-7-09  WAS true
                    instructions.setVisible(false);
                    instrFrame.setVisible(false);
                    labella1.setVisible(false);
                    labella2.setVisible(false);
                    labella3.setVisible(false);
                }
                 
                draw2D.setVisible(false);
                draw2DB.setVisible(false);
                draw_current.setVisible(false);
                draw_current2.setVisible(false);
                chinp2.setVisible(false);
                chinp.setVisible(false);
                chinp3.setVisible(true);
            }
            
            if(evt.getSource()==cp.f1){// select magnetic field
                state.IsMagnetic = true;
                if(cp.c3.getState()){
                    cp.c3.setState(false);
                    cp.c2.setState(true);
                    state.Select_far = false;
                    state.Select_near = true;
                    state.Select_r = false;
                    state.Select_dif = false;
                    state.Select_wide = false;
                    state.IsFormula = false;
                }
                
                if(state.ctime == 0){
                    state.ignition();
                }
                state.ScanTransientVoltage();
                                
                
                {
                    //about.setVisible(false);
                    instructions.setVisible(false);
                    instrFrame.setVisible(false);
                    instrFrame2.setVisible(false);  
                    labella1.setVisible(false);
                    labella2.setVisible(false);
                    labella3.setVisible(false);
                    if(state.Select_wide){
                        draw2D.setVisible(true);
                        draw2DB.setVisible(false);
                        draw2D.repaint();
                        draw_current.repaint();
                    }
                    else{
                        if(state.Select_far || state.Select_near || state.Select_dif){
                            draw2DB.setVisible(true);
                            draw2DB.repaint();
                            draw2D.setVisible(false);
                        }
                        else if(state.Select_r){
                            draw2DB.setVisible(false);
                            draw2D.setVisible(false);
                        }
                    }
                }
            }
            
            if(evt.getSource()==cp.f2){// select electric field
                state.IsMagnetic = false;
                if(state.ctime == 0){
                    state.ignition();
                }
                state.ScanTransientVoltage();
                
                
                if(state.IsFormula){
                    //about.setVisible(true);
                    instructions.setVisible(true);
                    instrFrame.setVisible(true);
                }
                else{
                    //about.setVisible(false);
                    instructions.setVisible(false);
                    instrFrame.setVisible(false);
                 }
                                     
                    if(state.Select_wide){
                        draw2D.setVisible(true);
                        draw2D.repaint();
                        draw_current.repaint();
                        draw_current2.repaint();
                        draw2DB.setVisible(false);
                    }
                    else{
                        draw2DB.setVisible(true);
                        draw2DB.repaint();
                        draw_current.repaint();
                        draw_current2.repaint();
                        draw2D.setVisible(false);
                    }
            }
}

    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){;}
    
    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 synchronized void mouseHandler(MouseEvent evt){
	if(evt.getSource() == mgpc.ssc.button1){
	    
		cp.ps7.setVisible(false);
                cp.ps8.setVisible(false);
                
                mgpc.ssc.IsStart = true;
                mgpc.ssc.IsStop = false;
                mgpc.ssc.IsReset = false;
                mgpc.ssc.IsStepNew = false;
                                
                mgpc.ssc.button1.setEnabled(false);
                mgpc.ssc.button2.setEnabled(true);
                mgpc.ssc.button3.setEnabled(false);

                mgpc.ssc.repaint();
                
                //cp.c1.setEnabled(false);
                //cp.c2.setEnabled(false);
                //cp.c3.setEnabled(false);
	}

        if(evt.getSource() == mgpc.ssc.button2){
	    
		//state.ignition();
		
                cp.ps7.setVisible(true);
                cp.ps8.setVisible(true);
                
                mgpc.ssc.IsStart = false;
                mgpc.ssc.IsStop = true;
                mgpc.ssc.IsReset = false;
                mgpc.ssc.IsStepNew = false;
                
                mgpc.ssc.button1.setEnabled(true);
                mgpc.ssc.button2.setEnabled(false);
                mgpc.ssc.button3.setEnabled(true);
                mgpc.ssc.repaint();
                
	}
        
	if(evt.getSource() == mgpc.ssc.button3){
	    
		cp.ps7.setVisible(true);
                cp.ps8.setVisible(true);
                mgpc.ssc.button1.setEnabled(true);
                mgpc.ssc.button2.setEnabled(false);
                mgpc.ssc.button3.setEnabled(false);
                
                mgpc.ssc.IsStart = false;
                mgpc.ssc.IsStop = false;
                mgpc.ssc.IsReset = true;
                mgpc.ssc.IsStepNew = false;
                
                mgpc.ssc.repaint();
                //cp.c1.setEnabled(true);
                //cp.c2.setEnabled(true);
                //cp.c3.setEnabled(true);

    	}
        
	if(evt.getSource() == mgpc.ssc.button1){
	    
		cp.information.setEnabled(false);
                
                mgpc.sliderzoom.setEnabled(false);
        }

        if(evt.getSource() == mgpc.ssc.button2){
                state.RestartPlot = false;
		
                cp.information.setEnabled(true);
                mgpc.sliderzoom.setEnabled(true);
                
	}
        
	if(evt.getSource() == mgpc.ssc.button3){
                cp.information.setEnabled(true);
                mgpc.sliderzoom.setEnabled(true);
                state.ctime = 0;    
                
                    state.RestartPlot = true;
                    state.ignition();
                    mgpc.ssc.setEnabled(true);
		    mgpc.plotTransientVoltage(state);
		    mgpc.watch1.setText("0\u00b0");
		    mgpc.ssc.clockcanvas.setStatus(0,state.NTime,state.dtime);
		    mgpc.ssc.clockcanvas.reset();
		    mgpc.ssc.button2.setEnabled(false);
                    
	}
    }

    private void send_shock_wave(){
	//state.ignition();
  }    
}
