//ControlPanel3D.java
import java.awt.*;
import java.awt.event.*;

public class ControlPanel3D extends Panel implements ActionListener, AdjustmentListener, ItemListener{
    private NewGuide_State state;
    
    private static final Color bgcolor = new Color(236,236,221);
    private static final Color circolor = Color.black;
    //private static final Color bgcolor = new Color(255,255,255);
    private static final Font labfont=new Font("SanSerif",Font.PLAIN,12);
    private static final Font labfont2=new Font("Serif",Font.PLAIN,12);
    private static final Font normalfont = new Font("SanSerif",Font.PLAIN,14);
    public int ScrollMax = 360; 
    public int offset = 20;
    private Label titlelabel;
    private Label lab1, lab2, lab3, lab4, lab5, lab6, lab7;
    private Label ulab1, ulab2, ulab3, ulab4, ulab5, ulab6;
    public TextField text1, text2, text3, text4, text5, text6, text7, text8;
    public Scrollbar slider1, slider2, slider3, slider5;
    public Checkbox ch1, ch2, ch3, cg1, cg2, cg3, cg4, cg5, cg6;
    public Checkbox cplot1, cplot2, cplot3;
    public CheckboxGroup cplot;
    public  Button b1, b2, b3, b5;
    public  Button bupdate;
    public Panel ps1, ps2;
  
    public ControlPanel3D(NewGuide_State state){
	super();
	setLayout(null);
	setBackground(bgcolor);
	this.state = state;
	
	titlelabel = new Label("Radiation Plots",Label.CENTER);
	titlelabel.setFont(new Font("SanSerif",Font.BOLD,16));
	add(titlelabel);
	titlelabel.setBounds(10,2,280,18);
	titlelabel.setForeground(Color.blue);
	
	CheckboxGroup chgroup1 = new CheckboxGroup();
	ch1 = new Checkbox("",true,chgroup1);
        ch2 = new Checkbox("",false,chgroup1);
	ch3 = new Checkbox("",false,chgroup1);
	cg1 = new Checkbox("",false,chgroup1);
        cg2 = new Checkbox("",false,chgroup1);
	cg3 = new Checkbox("",false,chgroup1);
	cg4 = new Checkbox("",false,chgroup1);
        cg5 = new Checkbox("",false,chgroup1);
	
	CheckboxGroup cplot = new CheckboxGroup();
	cplot1 = new Checkbox("2D plots",true,cplot);
        cplot2 = new Checkbox("Polar plots",false,cplot);
	cplot3 = new Checkbox("Data",false,cplot);
	
	slider1 = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,ScrollMax+1);//changes phi
	slider1.setValue(45);
	add(slider1);
	
	slider1.setBounds(84,165,198,15);
	Panel ps9 = new Panel();
	    ps9.setBackground(Color.cyan);
	    add(ps9);
	    ps9.setBounds(83,164,200,17);
	    
	Panel ps10 = new Panel();
	    ps10.setBackground(Color.black);
	    add(ps10);
	    ps10.setBounds(82,163,202,19);
	
	ch1.setBackground(bgcolor);
	ch2.setBackground(bgcolor);
	ch2.setBackground(bgcolor);
	cg1.setBackground(bgcolor);
	cg2.setBackground(bgcolor);
	cg3.setBackground(bgcolor);
	cg4.setBackground(bgcolor);
	cg5.setBackground(bgcolor);
	
	ch1.setFont(labfont2);
	ch2.setFont(labfont2);
	ch2.setFont(labfont2);
	cg1.setFont(labfont2);
	cg2.setFont(labfont2);
	cg3.setFont(labfont2);
	cg4.setFont(labfont2);
	cg5.setFont(labfont2);
	
	//add(ch1);
	//add(ch2);
	//add(ch3);
	//add(cg1);
	//add(cg2);
	//add(cg3);
	//add(cg4);
	//add(cg5);
	add(cplot1);
	add(cplot2);
	add(cplot3);
	
	ch1.setBounds(20,66,20,20);
	ch2.setBounds(70,66,20,20);
	ch3.setBounds(180,66,20,20);
	cg1.setBounds(20,106,20,20);
	cg2.setBounds(70,106,20,20);
	cg3.setBounds(120,106,20,20);
	cg4.setBounds(180,106,20,20);
	cg5.setBounds(230,106,20,20);
	
	cplot1.setBounds(30,20,75,20);
	cplot2.setBounds(120,20,90,20);
	cplot3.setBounds(220,20,60,20);
	Panel pplot1 = new Panel();
	    pplot1.setBackground(bgcolor);
	    //add(pplot1);
	    pplot1.setBounds(8,29,282,22);
	    
	Panel pplot2 = new Panel();
	    pplot2.setBackground(Color.black);
	    //add(pplot2);
	    pplot2.setBounds(7,28,284,24);
	
	lab1 = new Label("Spherical",Label.LEFT);
	lab2 = new Label("Cartesian",Label.LEFT);
	lab1.setFont(labfont);
	lab2.setFont(labfont);
	lab1.setForeground(Color.black);
	lab2.setForeground(Color.black);
	lab1.setBounds(10,46,150,14); 
	lab2.setBounds(10,86,150,14); 
	
	lab3 = new Label("Distance R = ",Label.LEFT);
	lab3.setFont(labfont);
	lab3.setForeground(Color.blue);
	text3 = new TextField(""+state.point_distance,8);
	ulab3 = new Label(" [  ]",Label.LEFT);
	ulab3.setForeground(Color.blue);
	
	lab3.setBounds(20,140,65,20);
	text3.setBounds(90,137,90,20);
	ulab3.setBounds(180,140,30,20);   
	
	add(lab1);
	add(lab2);
	add(lab3);	
	add(text3);
	//add(ulab3);
	/*
	Panel pplot3 = new Panel();
	    pplot3.setBackground(bgcolor);
	    add(pplot3);
	    pplot3.setBounds(8,57,282,70);
	    
	Panel pplot4 = new Panel();
	    pplot4.setBackground(Color.red);
	    add(pplot4);
	    pplot4.setBounds(7,56,284,72);
	*/
	
	// update
	bupdate = new Button("Update");
	add(bupdate);
	bupdate.setBounds(220,139,62,16);	
	Panel pupdate = new Panel();
	    pupdate.setBackground(Color.cyan);
	    add(pupdate);
	    pupdate.setBounds(219,138,64,18);
	    
	Panel pupdate2 = new Panel();
	    pupdate2.setBackground(Color.black);
	    add(pupdate2);
	    pupdate2.setBounds(218,137,66,20);
	   	
	//Listeners
	slider1.addAdjustmentListener(this);
	//ch1.addItemListener(this);
	//ch2.addItemListener(this);
	//ch3.addItemListener(this);
	//cg1.addItemListener(this);
	//cg2.addItemListener(this);
	//cg3.addItemListener(this);
	//cg4.addItemListener(this);
	//cg5.addItemListener(this);
	cplot1.addItemListener(this);
	cplot2.addItemListener(this);
	bupdate.addActionListener(this);
    }
    
    @Override
    public void paint(Graphics g){
	Graphics2D g2d = (Graphics2D)g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
                
	g.setColor(bgcolor);
	g.fillRect(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.blue);
	g.setFont(new Font("Serif",Font.PLAIN,14)); 
	g.drawString("\u03c6",15,177);
	g.setFont(new Font("Serif",Font.PLAIN,13)); 
	g.drawString("= "+slider1.getValue()+".0\u00b0",28,177);
	
        g.setColor(Color.blue);
	g.drawRect(7,132,283,58);
	
        g.setColor(Color.red);
	//g.drawRect(7,57,283,71);
        g.drawLine(7,43,getSize().width-7,43);
        /*
	g.setColor(Color.red);
	MaestroG.subscripterSymbol("| E","\u03b8"," |",g,12,40,79);
	MaestroG.subscripter2("| E","R"," |",g,12,90,79);
	g.setColor(Color.blue);
	MaestroG.subscripterSymbol("| H","\u03c6"," |",g,12,200,79);
	
        g.setColor(Color.red);
	MaestroG.subscripter2("| E","x"," |",g,12,40,119);
	MaestroG.subscripter2("| E","y"," |",g,12,90,119);
	MaestroG.subscripter2("| E","z"," |",g,12,140,119);
	g.setColor(Color.blue);
	MaestroG.subscripter2("| H","x"," |",g,12,200,119);
	MaestroG.subscripter2("| H","y"," |",g,12,250,119);
	*/
	g.setColor(Color.blue); 
	   
	g.setFont(new Font("Serif",Font.PLAIN,14));
	g.drawString("\u03bb",185,153);
	g.setFont(new Font("Serif",Font.PLAIN,14));
	//drawCircle(80,80,10,circolor,g);
    }
    
    public void drawCircle(int x, int y, int radius, Color c, Graphics g){
		g.setColor(c);
		g.drawOval(x-radius,y-radius,2*radius,2*radius);
    }
    
    public void fillCircle(int x, int y, int radius, Color c, Graphics g){
		g.setColor(c);
		g.fillOval(x-radius,y-radius,2*radius,2*radius);
    }
    
    public void actionPerformed(ActionEvent evt){
     
	
    }//End of actionPerformed()
    
    public void adjustmentValueChanged(AdjustmentEvent evt){
	
    }
    public void itemStateChanged(ItemEvent evt){
	
	   if(evt.getSource() == ch1){
	         
	   }
	   if(evt.getSource() == ch2){
	       
	   }  
    }
}


