//NewGuideInputPanel2.java
import java.awt.*;
import java.awt.event.*;
//import maestro.lib.math.*;

public class NewGuideInputPanel2 extends Panel implements ActionListener, AdjustmentListener, ItemListener{
    private NewGuide_State state;
    //private NewModeControlPanel pwmc;
    //private static final Color bgcolor = new Color(160,200,200);
    private static final Color bgcolor = new Color(236,236,221);
    private static final Font labfont=new Font("SanSerif",Font.PLAIN,12);
    private static final Font normalfont = new Font("SanSerif",Font.PLAIN,14);
    private static final Font labelfont = new Font("Serif",Font.PLAIN,14);
    
    public int offset = 20;
    private Label lab1, lab3, lab3b, lab3c, lab4, lab2;
    private Label ulab1, ulab2, ulab3, ulab4;
    public TextField text1, text2, text4;
    public Scrollbar slider1, slider2, slider3;
    public Scrollbar slider10, slider30;
   
    public  Button ground1, ground2, ground3, ground4, ground5, ground6;
    public  Button bupdate;
  
    public NewGuideInputPanel2(NewGuide_State state){
	super();
	setLayout(null);
	setBackground(bgcolor);
	this.state = state;
        
        ground1 = new Button("Perfect Conductor");
        ground2 = new Button("Dry Poor Ground");
        ground3 = new Button("Average Ground");
        ground4 = new Button("Wet Good Ground");
        ground5 = new Button("Fresh Water");
        ground6 = new Button("Sea Water");
        
        add(ground1);
        add(ground2);
        add(ground3);
        add(ground4);
        add(ground5);
        add(ground6);
        
        // CHANGE ==============================================================
        //ground1.setBounds(15, 50, 130, 30);
        //ground2.setBounds(15, 90, 130, 30);
        //ground3.setBounds(15, 130, 130, 30);
        //ground4.setBounds(15, 170, 130, 30);
        //ground5.setBounds(15, 210, 130, 30);
        //ground6.setBounds(15, 250, 130, 30);
        
        ground1.setBounds(5, 50, 140, 30);
        ground2.setBounds(5, 90, 140, 30);
        ground3.setBounds(5, 130, 140, 30);
        ground4.setBounds(5, 170, 140, 30);
        ground5.setBounds(5, 210, 140, 30);
        ground6.setBounds(5, 250, 140, 30);
        //======================================================================
        ground1.setBackground(Color.white);
        ground2.setBackground(Color.white);
        ground3.setBackground(Color.white);
        ground4.setBackground(Color.white);
        ground5.setBackground(Color.white);
        ground6.setBackground(Color.white);
        
        Panel g1 = new Panel();
	    g1.setBackground(Color.black);
	    add(g1);
	    // CHANGE ==========================================================
            //g1.setBounds(14,49,132,32);
            g1.setBounds(4,49,142,32);
            //==================================================================
        Panel g2 = new Panel();
	    g2.setBackground(Color.black);
	    add(g2);
	    // CHANGE ==========================================================
            //g2.setBounds(14,89,132,32);
            g2.setBounds(4,89,142,32);
            //==================================================================
        Panel g3 = new Panel();
	    g3.setBackground(Color.black);
	    add(g3);
	    // CHANGE ==========================================================
            //g3.setBounds(14,129,132,32);
            g3.setBounds(4,129,142,32);
            //==================================================================
        Panel g4 = new Panel();
	    g4.setBackground(Color.black);
	    add(g4);
	    // CHANGE ==========================================================
            //g4.setBounds(14,169,132,32);
            g4.setBounds(4,169,142,32);
            //==================================================================
        Panel g5 = new Panel();
	    g5.setBackground(Color.black);
	    add(g5);
	    // CHANGE ==========================================================
            //g5.setBounds(14,209,132,32);
            g5.setBounds(4,209,142,32);
            //==================================================================
        Panel g6 = new Panel();
	    g6.setBackground(Color.black);
	    add(g6);
	    // CHANGE ==========================================================
            //g6.setBounds(14,249,132,32);
            g6.setBounds(4,249,142,32);
            //==================================================================
        
            ground1.addActionListener(this);
            ground2.addActionListener(this);
            ground3.addActionListener(this);
            ground4.addActionListener(this);
            ground5.addActionListener(this);
            ground6.addActionListener(this);
    }
    
    @Override
    public void paint(Graphics g){
	
	g.setColor(bgcolor.darker());
	g.fillRect(0,getSize().height-2,getSize().width,2);
	g.fillRect(getSize().width-2,0,2,getSize().height);
	g.setColor(bgcolor.brighter());
	g.fillRect(0,0,2,getSize().height-1);
	g.fillRect(0,0,getSize().width-2,2);
        
        g.setColor(Color.yellow);
        if(state.GroundChoose == 1){
            g.fillRect(155, 43, 130, 40);  
        }
        else if(state.GroundChoose == 2){
            g.fillRect(155, 83, 130, 40);  
        }
        else if(state.GroundChoose == 3){
            g.fillRect(155, 123, 130, 40);  
        }
        else if(state.GroundChoose == 4){
            g.fillRect(155, 163, 130, 40);  
        }
        else if(state.GroundChoose == 5){
            g.fillRect(155, 203, 130, 40);  
        }
        else if(state.GroundChoose == 6){
            g.fillRect(155, 243, 130, 40);  
        }
        
        g.setColor(Color.red.darker());
        MaestroG.superscripter("\u03c3 \u2192 ","","\u221e  [S/m]", g, 13, 160, 60);
        //MaestroG.subscripter("\u03b5","r"," = 1.0", g, 14, 200, 65);     
        g.setColor(Color.blue.darker());
        MaestroG.superscripter("\u03c3 = 10","-3","  [S/m]", g, 13, 160, 100);
        MaestroG.subscripter("\u03b5","r"," = 5.0", g, 14, 160, 115);
        g.setColor(Color.red.darker());
        MaestroG.superscripter("\u03c3 = 5 \u00b7 10","-3","  [S/m]", g, 13, 160, 140);
        MaestroG.subscripter("\u03b5","r"," = 15.0", g, 14, 160, 155);
        g.setColor(Color.blue.darker());
        MaestroG.superscripter("\u03c3 = 2 \u00b7 10","-2","  [S/m]", g, 13, 160, 180);
        MaestroG.subscripter("\u03b5","r"," = 30.0", g, 14, 160, 195);
        g.setColor(Color.red.darker());
        MaestroG.superscripter("\u03c3 = 10","-2","  [S/m]", g, 13, 160, 220);
        MaestroG.subscripter("\u03b5","r"," = 81.0", g, 14, 160, 235);
        g.setColor(Color.blue.darker());
        MaestroG.superscripter("\u03c3 = 5.0","","  [S/m]", g, 13, 160, 260);
        MaestroG.subscripter("\u03b5","r"," = 81.0", g, 14, 160, 275);
    }
    
    public void actionPerformed(ActionEvent evt){
        if(evt.getSource()==ground1){
            state.sigma = 1.0E130;
            state.epsilon_r = 1.0;
            state.GroundChoose = 1;
        }
        if(evt.getSource()==ground2){
            state.sigma = 1.0E-3;
            state.epsilon_r = 5.0;
            state.GroundChoose = 2;
        }
        if(evt.getSource()==ground3){
            state.sigma = 5.0E-3;
            state.epsilon_r = 15.0;
            state.GroundChoose = 3;
        }
        if(evt.getSource()==ground4){
            state.sigma = 2.0E-2;
            state.epsilon_r = 30.0;
            state.GroundChoose = 4;
        }
        if(evt.getSource()==ground5){
            state.sigma = 1.0E-2;
            state.epsilon_r = 81.0;
            state.GroundChoose = 5;
        }
        if(evt.getSource()==ground6){
            state.sigma = 5.0;
            state.epsilon_r = 81.0;
            state.GroundChoose = 6;
        }
	state.ignition();
        repaint();
    }    
    public void adjustmentValueChanged(AdjustmentEvent evt){
	
    }
    
    public void itemStateChanged(ItemEvent evt){
	   
    }
    
}


