//TransLoadPanel
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.lang.*;


public class TransLoadPanel extends PR implements ItemListener{
    public Checkbox c1, c2;
    protected CheckboxGroup cgrp;
    private Trans_State state;
    
    private static final Color bgcolor = new Color(236,236,236);
    private static final Color tinta = new Color(236,236,236);
    
    public boolean IsResistance;
    
    public TransLoadPanel(String titulo, String[] nome, String[] unidade,Trans_State state){
	super(titulo,nome,unidade);
	setLayout(null);
	this.state = state;
        
        IsResistance = true;
        
	cgrp = new CheckboxGroup();
	c1 = new Checkbox("Resistance",cgrp,true);
	c2 = new Checkbox("Conductance",cgrp,false);
	add(c1);
	add(c2);
	
	titlelabel.setBounds(100,15,100,25);
	//lab1[0].setBounds(70,40,45,25);
	text1[0].setBounds(100,40,80,25);
		
	lab2[0].setBounds(180,40,40,25);
	
	c1.setBounds(55,70,100,25);
	c1.setBackground(bgcolor);
	c2.setBounds(170,70,120,25);
	c2.setBackground(bgcolor);
	b1.setBounds(220,39,75,25);
	
	//Listeners
	c1.addItemListener(this);
	c2.addItemListener(this);
    }
    
    public void paint(Graphics g){
            Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
	    
            g.clearRect(0,0,getSize().width,getSize().height);
	    g.setColor(bgcolor.darker());
	    g.fillRect(getSize().width-2,0,2,getSize().height);
	    g.setColor(bgcolor.brighter());
	    g.fillRect(0,0,2,getSize().height);
	    g.fillRect(0,0,getSize().width-2,2);
	                
            g.setColor(Color.black);
            if(IsResistance){
                MaestroG.subscripter("R","L"," =",g,12,60,55);
            }
            else{
                MaestroG.subscripter("G","L"," =",g,12,60,55);
            }
	}
    
    public void itemStateChanged(ItemEvent evt){
	if(evt.getSource()==c1){
	    lab1[0].setText("");
	    lab2[0].setText("  [ \u03a9 ]");
	    text1[0].setText(""+state.Resistance);
            IsResistance = true;
            repaint();
	    
	}
	
	else if(evt.getSource()==c2){
	    lab1[0].setText("");
	    lab2[0].setText("  [ S ]");
	    text1[0].setText(""+state.Conductance);
            IsResistance = false;
            repaint();
	    
	}
    }
}