//MultiStubPanelLarge.java

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

public class Trans_MultiStubPanelLarge extends Panel implements ItemListener{
    //public static final Color bgcolor = new Color(180,147,112);
    //public static final Color bgcolor = new Color(200,200,200);
    private static final Color bgcolor = new Color(236,236,236); 
    private static final Color bgcolor2 = new Color(250,250,250);
    public StubPanel2 stp1, stp2, stp3, stp4, stp5, stp6, stp7, stp8, stp9, stp10;
    public Choice c1;
    //GridBagLayout gb = new GridBagLayout();
    //GridBagConstraints gbc = new GridBagConstraints();
    private String titulo = "Unknown Title";
    private static final Font titlefont = new Font("SanSerif",Font.PLAIN,14);
    private static final Font textfont = new Font("SanSerif",Font.PLAIN,12);
    private static final Font textfontI = new Font("Serif",Font.ITALIC,14);
    private static final Font labelfont = new Font("SanSerif",Font.PLAIN,11);
    private Label titlelabel;
    private Label order1, order2, order3, order4, order5, order6, order7, order8, order9, order10;
    private Label line1, line2, line3, line4, line5, line5b, line5c, line6, line7, line8, line9, line10;
    private Trans_State state;
    public Trans_MultiStubPanelLarge(String titulo, Trans_State state){
	super();
	this.state = state;
	setBackground(bgcolor);
	this.titulo=titulo;
        
        Color color1 = Color.blue;
        Color color2 = Color.black;
        Color color3 = Color.red;

	stp1 = new StubPanel2("Section 1",state.stub[0],state,color1);
	stp2 = new StubPanel2("Section 2",state.stub[1],state,color2);
	stp3 = new StubPanel2("Section 3",state.stub[2],state,color3);
	stp4 = new StubPanel2("Section 4",state.stub[3],state,color1);
	stp5 = new StubPanel2("Section 5",state.stub[4],state,color2);
	stp6 = new StubPanel2("Section 6",state.stub[5],state,color3);
        stp7 = new StubPanel2("Section 7",state.stub[6],state,color1);
	stp8 = new StubPanel2("Section 8",state.stub[7],state,color2);
	stp9 = new StubPanel2("Section 9",state.stub[8],state,color3);
        stp10 = new StubPanel2("Section 10",state.stub[9],state,color1);
	
        //setLayout(gb);
        setLayout(null);
        
        titlelabel = new Label(titulo,Label.LEFT);
	titlelabel.setFont(titlefont);
	titlelabel.setBounds(10,10,115,25);
        titlelabel.setForeground(Color.red.darker());
        //add(titlelabel);
        
        order1 = new Label("1",Label.LEFT);
        order1.setFont(labelfont);
        order1.setBounds(6,195,10,12);
        order1.setForeground(Color.black);
        order1.setBackground(bgcolor2);
        add(order1);

        order2 = new Label("2",Label.LEFT);
        order2.setFont(labelfont);
        order2.setBounds(6,290,10,12);
        order2.setForeground(Color.black);
        order2.setBackground(bgcolor2);
        add(order2);
        
        order3 = new Label("3",Label.LEFT);
        order3.setFont(labelfont);
        order3.setBounds(272,5,10,12);
        order3.setForeground(Color.black);
        order3.setBackground(bgcolor2);
        add(order3);
        
        order4 = new Label("4",Label.LEFT);
        order4.setFont(labelfont);
        order4.setBounds(272,100,10,12);
        order4.setForeground(Color.black);
        order4.setBackground(bgcolor2);
        add(order4);
        
        order5 = new Label("5",Label.LEFT);
        order5.setFont(labelfont);
        order5.setBounds(272,195,10,12);
        order5.setForeground(Color.black);
        order5.setBackground(bgcolor2);
        add(order5);
        
	order6 = new Label("6",Label.LEFT);
        order6.setFont(labelfont);
        order6.setBounds(272,290,10,12);
        order6.setForeground(Color.black);
        order6.setBackground(bgcolor2);
        add(order6);
        
        order7 = new Label("7",Label.LEFT);
        order7.setFont(labelfont);
        order7.setBounds(538,5,10,12);
        order7.setForeground(Color.black);
        order7.setBackground(bgcolor2);
        add(order7);
        
        order8 = new Label("8",Label.LEFT);
        order8.setFont(labelfont);
        order8.setBounds(538,100,10,12);
        order8.setForeground(Color.black);
        order8.setBackground(bgcolor2);
        add(order8);
        
        order9 = new Label("9",Label.LEFT);
        order9.setFont(labelfont);
        order9.setBounds(538,195,10,12);
        order9.setForeground(Color.black);
        order9.setBackground(bgcolor2);
        add(order9);
        
	order10 = new Label("10",Label.LEFT);
        order10.setFont(labelfont);
        order10.setBounds(538,290,15,12);
        order10.setForeground(Color.black);
        order10.setBackground(bgcolor2);
        add(order10);
        
        line1 = new Label("In this panel,  one can select the length and",Label.LEFT);
        line2 = new Label("the  characteristic impedance  of  up  to  ten",Label.LEFT);
        line3 = new Label("transmission line sections.  The selectable",Label.LEFT);
        line4 = new Label("lengths are in the range of  0 to 0.5 \u03bb  at the",Label.LEFT);
        line5 = new Label("reference frequency         .",Label.LEFT);
        line5b = new Label("f",Label.RIGHT);
        line5c = new Label("o",Label.LEFT);
        
        line6 = new Label("While  displaying plots,  the properties of an",Label.LEFT);
        line7 = new Label("individual  line section  can  be  modified by",Label.LEFT);
        line8 = new Label("selecting the '' Set: Line Sections '' option.",Label.LEFT);
        line9 = new Label("To add a shunt impedance, '' Set: Shunt ''",Label.LEFT);
        
        line1.setFont(textfont); line2.setFont(textfont); 
        line3.setFont(textfont); line4.setFont(textfont); 
        line5.setFont(textfont); line5b.setFont(textfontI); line5c.setFont(textfontI);
        line6.setFont(textfont); 
        line7.setFont(textfont); line8.setFont(textfont);
        line9.setFont(textfont);
        
        line1.setBounds(15,15,250,15); line2.setBounds(15,32,250,15); 
        line3.setBounds(15,49,250,15); line4.setBounds(15,66,250,15);
        line5.setBounds(15,83,164,15); line5b.setBounds(128,83,12,17); line5c.setBounds(138,88,12,11); 
        line6.setBounds(15,105,250,15); 
        line7.setBounds(15,122,250,15); line8.setBounds(15,139,250,15);
        line9.setBounds(15,162,250,15);
        
        Color textcolor1 = Color.blue.darker();
        Color textcolor2 = Color.red.darker();
        
        line1.setForeground(textcolor1); line2.setForeground(textcolor1); 
        line3.setForeground(textcolor1); line4.setForeground(textcolor1); 
        line5.setForeground(textcolor1); line5b.setForeground(textcolor1); line5c.setForeground(textcolor1);
        line6.setForeground(textcolor2); 
        line7.setForeground(textcolor2); line8.setForeground(textcolor2); 
        line9.setForeground(textcolor1);
        
        line1.setBackground(bgcolor2); line2.setBackground(bgcolor2);
        line3.setBackground(bgcolor2); line4.setBackground(bgcolor2);
        line5.setBackground(bgcolor2); line5b.setBackground(bgcolor2); 
        line5c.setBackground(bgcolor2);line6.setBackground(bgcolor2);
        line7.setBackground(bgcolor2); line8.setBackground(bgcolor2);
        line9.setBackground(bgcolor2);
        
        add(line1); add(line2); add(line3); add(line4);
        add(line5c); add(line5b); add(line5); add(line6); 
        add(line7); add(line8); add(line9);
        
        
        c1 = new Choice();
	c1.addItem("Section 1");
	c1.addItem("Section 2");
	c1.addItem("Section 3");
        c1.addItem("Section 4");
	c1.addItem("Section 5");
	c1.addItem("Section 6");
        c1.addItem("Section 7");
	c1.addItem("Section 8");
	c1.addItem("Section 9");
        c1.addItem("Section 10");
	
        c1.setBackground(bgcolor.brighter());
        //c1.setBounds(150,10,100,25);
        c1.setBounds(200,10,100,25);
        
        //add(c1);
        
        stp1.setBounds(537,288,263,93);
        add(stp1);
        
        stp2.setBounds(537,193,263,93);
        add(stp2);
        
        stp3.setBounds(537,98,263,93);
        add(stp3);
        
        stp4.setBounds(537,3,263,93);
        add(stp4);
        
        stp5.setBounds(271,288,263,93);
        add(stp5);
        
        stp6.setBounds(271,193,263,93);
        add(stp6);
        
        stp7.setBounds(271,98,263,93);
        add(stp7);
        
        stp8.setBounds(271,3,263,93);
        add(stp8);
        
        stp9.setBounds(5,288,263,93);
        add(stp9);
        
        stp10.setBounds(5,193,263,93);
        add(stp10);
        
        
        //  Explanation Panel
        Panel pexp = new Panel();
	    pexp.setBackground(new Color(250,250,250));
	    add(pexp);
	    pexp.setBounds(6,4,261,186);
        Panel pexp2 = new Panel();
	    pexp2.setBackground(Color.black);
	    add(pexp2);
	    pexp2.setBounds(5,3,263,188);
    
        //Listeners
	c1.addItemListener(this);
    }
    
    public void paint(Graphics g){
		/*
                g.setColor(Color.black);
                g.drawLine(0,getSize().height-1,getSize().width-1,getSize().height-1);
                g.drawLine(getSize().width-1,0,getSize().width-1,getSize().height-1);
                g.setColor(Color.white);
                g.drawLine(0,0,getSize().width-1,0);
                g.drawLine(0,0,0,getSize().height-1);
                */
        
                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);
                //g.fillRect(5,3,263,188);
                
                //g.drawString("1",2,203);
                //g.drawString("2",2,298);
    }
    
    public void itemStateChanged(ItemEvent evt){
	ItemSelectable ie = evt.getItemSelectable();
	    if(evt.getSource()==c1){
		if(ie.getSelectedObjects()[0]=="Section 1"){
		    stp1.setVisible(true);
		    stp2.setVisible(false);
		    stp3.setVisible(false);
                    stp4.setVisible(false);
		    stp5.setVisible(false);
                    stp6.setVisible(false);
		    stp7.setVisible(false);
                    stp8.setVisible(false);
		    stp9.setVisible(false);
                    stp10.setVisible(false);
                }
		else if(ie.getSelectedObjects()[0]=="Section 2"){
		    stp1.setVisible(false);
		    stp2.setVisible(true);
		    stp3.setVisible(false);
                    stp4.setVisible(false);
		    stp5.setVisible(false);
                    stp6.setVisible(false);
		    stp7.setVisible(false);
                    stp8.setVisible(false);
		    stp9.setVisible(false);
                    stp10.setVisible(false);
		}
		else if(ie.getSelectedObjects()[0]=="Section 3"){
		    stp1.setVisible(false);
		    stp2.setVisible(false);
		    stp3.setVisible(true);
		    stp4.setVisible(false);
		    stp5.setVisible(false);
                    stp6.setVisible(false);
		    stp7.setVisible(false);
                    stp8.setVisible(false);
		    stp9.setVisible(false);
                    stp10.setVisible(false);
		}
                else if(ie.getSelectedObjects()[0]=="Section 4"){
		    stp1.setVisible(false);
		    stp2.setVisible(false);
		    stp3.setVisible(false);
                    stp4.setVisible(true);
		    stp5.setVisible(false);
                    stp6.setVisible(false);
		    stp7.setVisible(false);
                    stp8.setVisible(false);
		    stp9.setVisible(false);
                    stp10.setVisible(false);
		}
		else if(ie.getSelectedObjects()[0]=="Section 5"){
		    stp1.setVisible(false);
		    stp2.setVisible(false);
		    stp3.setVisible(false);
                    stp4.setVisible(false);
		    stp5.setVisible(true);
                    stp6.setVisible(false);
		    stp7.setVisible(false);
                    stp8.setVisible(false);
		    stp9.setVisible(false);
                    stp10.setVisible(false);
		}
		else if(ie.getSelectedObjects()[0]=="Section 6"){
		    stp1.setVisible(false);
		    stp2.setVisible(false);
		    stp3.setVisible(false);
                    stp4.setVisible(false);
		    stp5.setVisible(false);
                    stp6.setVisible(true);
		    stp7.setVisible(false);
                    stp8.setVisible(false);
		    stp9.setVisible(false);
                    stp10.setVisible(false);
		}
                else if(ie.getSelectedObjects()[0]=="Section 7"){
		    stp1.setVisible(false);
		    stp2.setVisible(false);
		    stp3.setVisible(false);
                    stp4.setVisible(false);
		    stp5.setVisible(false);
                    stp6.setVisible(false);
		    stp7.setVisible(true);
                    stp8.setVisible(false);
		    stp9.setVisible(false);
                    stp10.setVisible(false);
		}
		else if(ie.getSelectedObjects()[0]=="Section 8"){
		    stp1.setVisible(false);
		    stp2.setVisible(false);
		    stp3.setVisible(false);
                    stp4.setVisible(false);
		    stp5.setVisible(false);
                    stp6.setVisible(false);
		    stp7.setVisible(false);
                    stp8.setVisible(true);
		    stp9.setVisible(false);
                    stp10.setVisible(false);
		}
		else if(ie.getSelectedObjects()[0]=="Section 9"){
		    stp1.setVisible(false);
		    stp2.setVisible(false);
		    stp3.setVisible(false);
                    stp4.setVisible(false);
		    stp5.setVisible(false);
                    stp6.setVisible(false);
		    stp7.setVisible(false);
                    stp8.setVisible(false);
		    stp9.setVisible(true);
                    stp10.setVisible(false);
		}
                else if(ie.getSelectedObjects()[0]=="Section 10"){
		    stp1.setVisible(false);
		    stp2.setVisible(false);
		    stp3.setVisible(false);
                    stp4.setVisible(false);
		    stp5.setVisible(false);
                    stp6.setVisible(false);
		    stp7.setVisible(false);
                    stp8.setVisible(false);
		    stp9.setVisible(false);
                    stp10.setVisible(true);   
		}
	    }
    }
    
}
