//MultiStubPanel.java

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

public class Trans_MultiStubPanel 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);
    public StubPanel stp1, stp2, stp3, stp4, stp5, stp6, stp7, stp8, stp9, stp10;
    public StubPanelNew stpnew2;
    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);
    protected static final Font buttonfont = new Font("SanSerif",Font.PLAIN,11);
    private Label titlelabel;
    private Trans_State state;
    public Button SetLoad;
    public Trans_MultiStubPanel(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 StubPanel("Section 1",state.stub[0],state,color1);
	stp2 = new StubPanel("Section 2",state.stub[1],state,color2);
	stp3 = new StubPanel("Section 3",state.stub[2],state,color3);
	stp4 = new StubPanel("Section 4",state.stub[3],state,color1);
	stp5 = new StubPanel("Section 5",state.stub[4],state,color2);
	stp6 = new StubPanel("Section 6",state.stub[5],state,color3);
        stp7 = new StubPanel("Section 7",state.stub[6],state,color1);
	stp8 = new StubPanel("Section 8",state.stub[7],state,color2);
	stp9 = new StubPanel("Section 9",state.stub[8],state,color3);
        stp10 = new StubPanel("Section 10",state.stub[9],state,color1);
	
        stpnew2 = new StubPanelNew("Section 2",state.stub[1],state,color2);
        
        //setLayout(gb);
        setLayout(null);
        
        titlelabel = new Label(titulo,Label.LEFT);
	titlelabel.setFont(titlefont);
	
        // CHANGE #1   9/26/2017  ===== MODIFY AS TYPED BELOW ==================
        titlelabel.setBounds(10,5,180,20);
        //======================================================================
        
        titlelabel.setForeground(Color.red.darker());
        add(titlelabel);
        
	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,5,100,25);
        
        //add(c1);
        
        stp1.setBounds(5,29,300,98);
        add(stp1);
        
        stp2.setBounds(5,124,300,100);
        //add(stp2);
        
        stpnew2.setBounds(5,126,300,98);
        add(stpnew2);
        
        stp3.setBounds(5,40,300,93);
        add(stp3);
        
        stp4.setBounds(5,40,300,93);
        add(stp4);
        
        stp5.setBounds(5,40,300,93);
        add(stp5);
        
        stp6.setBounds(5,40,300,93);
        add(stp6);
        
        stp7.setBounds(5,40,300,93);
        add(stp7);
        
        stp8.setBounds(5,40,300,93);
        add(stp8);
        
        stp9.setBounds(5,40,300,93);
        add(stp9);
        
        stp10.setBounds(5,40,300,93);
        add(stp10);
        
        //SetLoad = new Button("\u21aa Set  Load"); // this unicode character does not work in label environment, only in canvas.  Why?
        SetLoad = new Button(">>  Set  Load");
        SetLoad.setBounds(200,5,105,18);
        SetLoad.setBackground(Color.white);
        SetLoad.setFont(buttonfont);
        add(SetLoad);
        Panel load1 = new Panel();
		    load1.setBackground(Color.black);
		    add(load1);
		    load1.setBounds(199,4,107,20);
        
	//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);
    }
    
    public void itemStateChanged(ItemEvent evt){
	ItemSelectable ie = evt.getItemSelectable();
	    if(evt.getSource()==c1){
		/*
                if(ie.getSelectedObjects()[0]=="Section 10"){
		    stp1.setVisible(true);
		    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 9"){
		    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 8"){
		    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 7"){
		    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 6"){
		    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 5"){
		    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 4"){
		    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 3"){
		    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 2"){
		    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 1"){
		    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);   
		}
                */
	    }
    }
    
}
