//TransLoadPanel

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.lang.*;
import java.awt.font.*;


public class TransLoadPanel extends PC implements ItemListener{
    public Checkbox c1, c2;
    protected CheckboxGroup cgrp;
    private Trans_State state;
    //private static final Color bgcolor = new Color(216,216,191);
    private static final Color tinta = new Color(236,236,236);
    private static final Color bgcolor = new Color(236,236,236);
    protected static final Font titfont = new Font("SanSerif",Font.PLAIN,14);
    protected static final Font buttonfont = new Font("SanSerif",Font.PLAIN,11);
    public Button SetTr;
    //CHANGE #3 ADD LINE  9/26/2017 ============================================
    private boolean ShowZ = true;
    //==========================================================================
    //private static final Color bgcolor = new Color(200,200,200);
    
    public TransLoadPanel(String titulo, String[] nome, String[] unidade, Trans_State state){
	super(titulo,nome,unidade);
	setLayout(null);
	setBackground(bgcolor);
	this.state = state;
	cgrp = new CheckboxGroup();
	c1 = new Checkbox("Impedance",cgrp,true);
	c2 = new Checkbox("Admittance",cgrp,false);
	//======================================================================
        //add(c1);
	//add(c2);
        //======================================================================
	//titlelabel.setBounds(5,15,280,30);
        //titlelabel.setForeground(Color.black);
        
        titlelabel.setBounds(15,5,80,20);
        titlelabel.setForeground(Color.red.darker());
        titlelabel.setFont(titfont);
        
        // CHANGE #1  COMMENT LINE BELOW 9/25/2017  ============================
	//lab1[0].setBounds(25,63,10,12);
        //======================================================================
        
	text1[0].setBounds(55,60,80,20);
	
	lab2[0].setBounds(145,60,20,20);
	text2[0].setBounds(170,60,80,20);
	
	lab3[0].setBounds(255,60,45,20);
	c1.setBounds(55,90,100,20);
	c1.setBackground(bgcolor);
	//======================================================================
        //c2.setBounds(170,90,100,20);
        //c2.setBounds(170,90,130,20);
        //======================================================================
	c2.setBackground(bgcolor);
	b1.setBounds(120,120,70,20);
        b1.setBackground(bgcolor);
	
	text1[0].setText(""+state.ZL.Real());
	text2[0].setText(""+state.ZL.Imaginary());
	
	//Listeners
	//c1.addItemListener(this);
	//c2.addItemListener(this);
        
        SetTr = new Button(">>  Set  Line / Stub");
        SetTr.setBounds(150,5,155,18);
        SetTr.setBackground(Color.white);
        SetTr.setFont(buttonfont);
        add(SetTr);
        Panel but1 = new Panel();
		    but1.setBackground(Color.black);
		    add(but1);
		    but1.setBounds(149,4,157,20);
    }
    
    public void paint(Graphics g){
	    g.clearRect(0,0,getSize().width,getSize().height);
	    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.black);	
	    
            //  CHANGE #2   9/25/2017 ==========================================
	    //MaestroG.subscripter("    ","L","=",g,12,25,75);
            //MaestroG.subscripter("  Z","L","=",g,14,12,75);
            if(ShowZ){
                  MaestroG.subscripter("Z","L","=",g,14,20,75);
            }
            else{
                  MaestroG.subscripter("Y","L","=",g,14,20,75);
            }
            //==================================================================
            
            g.setColor(Color.red.darker());
            g.drawRect(52,57,84,24);
            g.drawRect(167,57,84,24);
            g.drawRect(117,117,74,24);
    }
    
    public void itemStateChanged(ItemEvent evt){
	if(evt.getSource()==c1){
            
	    lab1[0].setText("Z");
	    lab3[0].setText("[ \u03a9 ]");
	    // CHANGE #6 CHANGE LINES BELOW  9/26/2017 =========================
            //text1[0].setText(""+state.ZL.Real());
	    //text2[0].setText(""+state.ZL.Imaginary());
            text1[0].setText(""+MaestroA.rounder(state.ZL.Real(),6));
	    text2[0].setText(""+MaestroA.rounder(state.ZL.Imaginary(),6));
	    state.is_Load_Ztype = true;
            ShowZ = true;
            repaint();
            //==================================================================
	}
	
	else if(evt.getSource()==c2){
            
	    lab1[0].setText("Y");
	    lab3[0].setText("[ S ]");
	    // CHANGE #7 CHANGE LINES BELOW  9/26/2017 =========================
            //text1[0].setText(""+state.YL.Real());
	    //text2[0].setText(""+state.YL.Imaginary());
            text1[0].setText(""+MaestroA.rounder(state.YL.Real(),6));
	    text2[0].setText(""+MaestroA.rounder(state.YL.Imaginary(),6));
	    state.is_Load_Ztype = false;
            ShowZ = false;
            repaint();
            //==================================================================
	}
    }

}


/*
//TransLoadPanel

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.lang.*;
import java.awt.font.*;


public class TransLoadPanel extends PC implements ItemListener{
    public Checkbox c1, c2;
    protected CheckboxGroup cgrp;
    private Trans_State state;
    //private static final Color bgcolor = new Color(216,216,191);
    private static final Color tinta = new Color(236,236,236);
    private static final Color bgcolor = new Color(236,236,236);
    protected static final Font titfont = new Font("SanSerif",Font.PLAIN,14);
    protected static final Font buttonfont = new Font("SanSerif",Font.PLAIN,11);
    public Button SetTr;
    //private static final Color bgcolor = new Color(200,200,200);
    
    public TransLoadPanel(String titulo, String[] nome, String[] unidade, Trans_State state){
	super(titulo,nome,unidade);
	setLayout(null);
	setBackground(bgcolor);
	this.state = state;
	cgrp = new CheckboxGroup();
	c1 = new Checkbox("Impedance",cgrp,true);
	c2 = new Checkbox("Admittance",cgrp,false);
	//add(c1);
	//add(c2);
	//titlelabel.setBounds(5,15,280,30);
        //titlelabel.setForeground(Color.black);
        
        titlelabel.setBounds(15,5,80,20);
        titlelabel.setForeground(Color.red.darker());
        titlelabel.setFont(titfont);
        
	lab1[0].setBounds(25,63,10,12);
	text1[0].setBounds(55,60,80,20);
	
	lab2[0].setBounds(145,60,20,20);
	text2[0].setBounds(170,60,80,20);
	
	lab3[0].setBounds(255,60,45,20);
	c1.setBounds(55,90,100,20);
	c1.setBackground(bgcolor);
	c2.setBounds(170,90,100,20);
	c2.setBackground(bgcolor);
	b1.setBounds(120,120,70,20);
        b1.setBackground(bgcolor);
	
	text1[0].setText(""+state.ZL.Real());
	text2[0].setText(""+state.ZL.Imaginary());
	
	//Listeners
	c1.addItemListener(this);
	c2.addItemListener(this);
        
        SetTr = new Button(">>  Set  Line / Stub");
        SetTr.setBounds(150,5,155,18);
        SetTr.setBackground(Color.white);
        SetTr.setFont(buttonfont);
        add(SetTr);
        Panel but1 = new Panel();
		    but1.setBackground(Color.black);
		    add(but1);
		    but1.setBounds(149,4,157,20);
    }
    
    public void paint(Graphics g){
	    g.clearRect(0,0,getSize().width,getSize().height);
	    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.black);	
	      
	    MaestroG.subscripter("   ","L","=",g,12,25,75);
            g.setColor(Color.red.darker());
            g.drawRect(52,57,84,24);
            g.drawRect(167,57,84,24);
            g.drawRect(117,117,74,24);
    }
    
    public void itemStateChanged(ItemEvent evt){
	if(evt.getSource()==c1){
	    lab1[0].setText("Z");
	    lab3[0].setText("[ \u03a9 ]");
	    text1[0].setText(""+state.ZL.Real());
	    text2[0].setText(""+state.ZL.Imaginary());
	    state.is_Load_Ztype = true;
	}
	
	else if(evt.getSource()==c2){
	    lab1[0].setText("Y");
	    lab3[0].setText("[ S ]");
	    text1[0].setText(""+state.YL.Real());
	    text2[0].setText(""+state.YL.Imaginary());
	    state.is_Load_Ztype = false;
	}
    }

}
*/
