//ObliqueInputPanel.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

public class ObliqueInputPanel extends Panel implements ChangeListener, ActionListener, ItemListener{
    private static final Color bgcolor = new Color(236,236,236);
    private Font labfont, labfontB, labfontB2;
    private Font labfontS;
    private Font labfontbig;
    private Font labfontbigI;
    private Font titlefont;
    private static final int SCROLLMIN = 0;
    private static final int SCROLLMAX = 9001;
    Label titlelabel;	
    Label lab1, lab2, lab3, lab3b, lab4, lab5, lab6, lab7, lab8, lab9, lab10,
          labm1, labm2, labpa, labpb, labpc, labpd, labpe, labpf, 
          labr1, labr2, labr3, labr4, labHz, 
          labeqa, labeqb, labeqc, labeqd, labeqe;
    Label vlab1;
    TextField text1, text2, text3, text4, text5, text6, text7;
    Button b1;
    public Button button1, button2, button3, button4;
    public Panel pbut1, pbut2, pbut3, pbut4, pbut5, pbut6, pbut7, pbut8, pbut9;
    
    
    public Label labscale;
    public Panel scale1, scale2;
    
    public Checkbox c1, c2, c3, c4, c5, c6, c7, c8, c9;
    public CheckboxGroup cgrp, cgrp2, cgrp3, cgfield;
    public JSlider slider, slider2, slider_scale;
    private Oblique_State state;
    public TitleCanvas title;
    
    public ObliqueInputPanel(Oblique_State state){
	super();
	this.state = state;
        
        labfont=new Font("SanSerif",Font.PLAIN,state.font12);
        labfontB2 = new Font("SanSerif",Font.BOLD,state.font12);
        labfontB = new Font("SanSerif",Font.BOLD,state.font14);
        labfontS=new Font("Serif",Font.PLAIN,state.font13);
        labfontbig=new Font("SanSerif",Font.PLAIN,state.font14);
        labfontbigI=new Font("Serif",Font.ITALIC,state.font14);
        titlefont=new Font("SanSerif",Font.BOLD,state.font12);

	setBackground(bgcolor);
	setLayout(null);
	titlelabel = new Label("Input",Label.CENTER);
	titlelabel.setFont(titlefont);
	
	title = new TitleCanvas(state);
	add(title);
	title.setBounds(state.s2,state.s2,state.s75,state.s25);
	
	labm1 = new Label("Medium 1",Label.RIGHT);
	labm1.setFont(labfont);
	labm1.setForeground(Color.red.darker());
        
        labm2 = new Label("Medium 2",Label.RIGHT);
	labm2.setFont(labfont);
	labm2.setForeground(Color.blue.darker());
        
	lab1 = new Label("\u03b5",Label.RIGHT);
	lab1.setFont(labfontbig);
	
	lab2 = new Label("\u03bc",Label.RIGHT);
	lab2.setFont(labfontbig);
        
        labr1 = new Label("r",Label.LEFT);
	labr1.setFont(labfont);
        labr2 = new Label("r",Label.LEFT);
	labr2.setFont(labfont);
        labr3 = new Label("r",Label.LEFT);
	labr3.setFont(labfont);
        labr4 = new Label("r",Label.LEFT);
	labr4.setFont(labfont);
        
        labeqa = new Label("=",Label.LEFT);
	labeqa.setFont(labfontbig);
	labeqb = new Label("=",Label.LEFT);
	labeqb.setFont(labfontbig);
        labeqc = new Label("=",Label.LEFT);
	labeqc.setFont(labfontbig);
        labeqd = new Label("=",Label.LEFT);
	labeqd.setFont(labfontbig);
	labeqe = new Label("=",Label.LEFT);
	labeqe.setFont(labfontbig);
        labHz = new Label("Hz",Label.LEFT);
	labHz.setFont(labfontbig);
        
	lab3 = new Label("Incident Transverse Field",Label.CENTER);
	lab3.setFont(labfont);
	
        lab3b = new Label("Component",Label.CENTER);
	lab3b.setFont(labfont);
        
        labpa = new Label("| \u0393 | , | \u03c4 |",Label.CENTER);
	labpa.setFont(labfontS);
        labpb = new Label("|t|",Label.CENTER);
	labpb.setFont(labfontS);
        
        labpc = new Label("\u0393 , \u03c4",Label.CENTER);
	labpc.setFont(labfontS);
        labpd = new Label("tS",Label.CENTER);
	labpd.setFont(labfont);
        
        labpe = new Label("R , T",Label.CENTER);
	labpe.setFont(labfontS);
        labpf = new Label("T",Label.CENTER);
	labpf.setFont(labfontS);
        
	labscale = new Label("plot-zoom",Label.RIGHT);
	labscale.setFont(labfont);
        
        text1 = new TextField("1.0");
	text1.setFont(labfont);
	
	text2 = new TextField("1.0");
	text2.setFont(labfont);
	
	text3 = new TextField("0.0");
	text3.setFont(labfont);
	
	lab4 = new Label("\u03b5",Label.RIGHT);
	lab4.setFont(labfontbig);
	
	lab5 = new Label("\u03bc",Label.RIGHT);
	lab5.setFont(labfontbig);
	
	lab6 = new Label("Conductivity  \u03c3  = ",Label.RIGHT);
	lab6.setFont(labfont);
	
        lab10 = new Label("Field:",Label.RIGHT);
	lab10.setFont(labfont);
	
        text4 = new TextField("2.55");
	text4.setFont(labfont);
	
	text5 = new TextField("1.0");
	text5.setFont(labfont);
	
	text6 = new TextField("0.0");
	text6.setFont(labfont);
	
	lab7 = new Label("f",Label.RIGHT);
	lab7.setFont(labfont);
	
	text7 = new TextField("1.0E9");
	text7.setFont(labfont);
	
	b1 = new Button("UPDATE");
	
	cgrp = new CheckboxGroup();
	c1 = new Checkbox("//",cgrp,true);
	c1.setFont(labfont);
	c2 = new Checkbox("\u22a5",cgrp,false);
	c2.setFont(labfont);
	
        cgrp2 = new CheckboxGroup();
        c3 = new Checkbox("In",cgrp2,true);
	c3.setFont(labfont);
	c4 = new Checkbox("Out",cgrp2,false);
	c4.setFont(labfont);
        
        button2 = new Button("//");
	button2.setFont(labfontB);
	button1 = new Button("\u22a5");
	button1.setFont(labfontB);
	
        button3 = new Button(" In ");
	button3.setFont(labfontB2);
	button4 = new Button("Out");
	button4.setFont(labfontB2);
	
        cgrp3 = new CheckboxGroup();
	//c5 = new Checkbox("plot",cgrp3,true);
	//c5.setFont(labfont);
	//c6 = new Checkbox("plot",cgrp3,false);
	//c6.setFont(labfont);
	//c7 = new Checkbox("plot",cgrp3,false);
	//c7.setFont(labfont);
        
        cgfield = new CheckboxGroup();
	c8 = new Checkbox("Electric",cgfield,true);
	c8.setFont(labfont);
	c9 = new Checkbox("Magnetic",cgfield,false);
	c9.setFont(labfont);
        
	lab8 = new Label("Angle of Incidence: ",Label.LEFT);
	lab8.setFont(labfont);
	
	lab9 = new Label("Polarization: ",Label.LEFT);
	lab9.setFont(labfont);
	
	slider = new JSlider(SCROLLMIN,901);
	slider2 = new JSlider(SCROLLMIN,1000);
	slider2.setValue(5);
        slider_scale = new JSlider(1,9);
	//slider = new Scrollbar(Scrollbar.HORIZONTAL,0,1,SCROLLMIN,901);
	//slider2 = new Scrollbar(Scrollbar.HORIZONTAL,0,5,SCROLLMIN,1000);
        //slider_scale = new Scrollbar(Scrollbar.HORIZONTAL,0,1,1,9);
	
        slider.setBackground(bgcolor);
        slider2.setBackground(bgcolor);
        slider_scale.setBackground(bgcolor);
        slider_scale.setValue(0);
        slider.setValue(0);
	vlab1 = new Label("0 \u00ba",Label.LEFT);
	
	//add(titlelabel);
	add(labm1);
        //add(labm2);
        add(lab1);
	add(text1);
	add(lab2);
	add(text2);
	add(lab3);
        add(lab3b);
        add(labr1); add(labr2); //add(labr3); add(labr4);
        add(labeqa); add(labeqb); //add(labeqc); add(labeqd); 
        add(labeqe);
        add(labHz);
        //add(labpa); add(labpb); add(labpc); add(labpd); add(labpe); add(labpf);
        
	//add(text3);
	//add(lab4);
	//add(text4);
	//add(lab5);
	//add(text5);
	
        //add(lab10);
        
        //add(lab6);
	//add(text6);
	add(lab7);
	add(text7);
	add(b1);
        add(button1);
        add(button2);
        add(button3);
        add(button4);
        
	//add(c1);
	//add(c2);
        //add(c3);
        //add(c4);
        //add(c5);
        //add(c6);
        //add(c7);
        
        //add(c8);
        //add(c9);
	add(lab8);
	add(lab9);
	add(slider);
        add(slider2);
        add(slider_scale);
	add(vlab1);
           
        //Draw the lines as panels - To avoid flickering on MAC even with double buffering --- MAC sucks!!!
        Panel back1 = new Panel();
	    back1.setBackground(Color.gray);
	    add(back1);
	    back1.setBounds(state.s15,state.s150,state.s200+state.s70,1);
        
        Panel back2 = new Panel();
	    back2.setBackground(Color.gray);
	    //add(back2);
	    back2.setBounds(state.s15,state.s169,state.s200+state.s70,1);
       
        Panel back3 = new Panel();
	    back3.setBackground(Color.gray);
	    add(back3);
	    back3.setBounds(state.s15,state.s200+state.s15,state.s200+state.s70,1);
	
	int ypos_block1 = state.s50;   
	text7.setBounds(state.s55,ypos_block1 + state.s2,state.s75,state.s20);
	
        lab7.setBounds(state.s10,ypos_block1 + state.s2,state.s20,state.s20);
        lab7.setFont(labfontbigI);
        labeqe.setBounds(state.s40,ypos_block1 + state.s2,state.s15,state.s20);
        labHz.setBounds(state.s132,ypos_block1 + state.s2,state.s25,state.s20);
        lab7.setForeground(Color.black);
        labeqe.setForeground(Color.black);
        labHz.setForeground(Color.black);
        
        b1.setBounds(state.s195,ypos_block1+state.s50,state.s75,state.s20);
        b1.setBackground(new Color(250,250,250));
        
        Panel pb1 = new Panel();
	    pb1.setBackground(Color.cyan);
	    add(pb1);
	    pb1.setBounds(state.s195-1,ypos_block1+state.s50-1,state.s75+2,state.s20+2);
	    
	Panel pb2 = new Panel();
	    pb2.setBackground(Color.black);
	    add(pb2);
	    pb2.setBounds(state.s195-2,ypos_block1+state.s50-2,state.s75+4,state.s20+4);
        //-----------------------------------------
        int ypos_block2 = state.s80;
        lab1.setBounds(state.s10,ypos_block2,state.s20,state.s20);
        labr1.setBounds(state.s30,ypos_block2+state.s5,state.s10,state.s20);
        labeqa.setBounds(state.s40,ypos_block2,state.s15,state.s20);
        lab1.setForeground(Color.red.darker());
        labr1.setForeground(Color.red.darker());
        labeqa.setForeground(Color.red.darker());
        
	text1.setBounds(state.s55,ypos_block2,state.s75,state.s20);
        text1.setForeground(Color.red.darker());
	lab2.setBounds(state.s10,ypos_block2+state.s22,state.s20,state.s20);
        labr2.setBounds(state.s30,ypos_block2+state.s28,state.s10,state.s20);
        labeqb.setBounds(state.s40,ypos_block2+state.s22,state.s15,state.s20);
        lab2.setForeground(Color.red.darker());
        labr2.setForeground(Color.red.darker());
        labeqb.setForeground(Color.red.darker());
        text2.setBounds(state.s55,ypos_block2+state.s22,state.s75,state.s20);
        text2.setForeground(Color.red.darker());
        
        labm1.setBounds(state.s55,ypos_block2+state.s44,state.s65,state.s15);
        labm2.setBounds(state.s195,ypos_block2+state.s44,state.s65,state.s15);
        lab4.setBounds(state.s150,ypos_block2,state.s20,state.s20);
        labr3.setBounds(state.s170,ypos_block2+state.s5,state.s10,state.s20);
        labeqc.setBounds(state.s180,ypos_block2,state.s15,state.s20);
        lab4.setForeground(Color.blue.darker());
        labr3.setForeground(Color.blue.darker());
        labeqc.setForeground(Color.blue.darker());
        
	text4.setBounds(state.s195,ypos_block2,state.s75,state.s20); 
	text4.setForeground(Color.blue.darker());
        lab5.setBounds(state.s150,ypos_block2+state.s22,state.s20,state.s20);
        labr4.setBounds(state.s170,ypos_block2+state.s28,state.s10,state.s20);
        labeqd.setBounds(state.s180,ypos_block2+state.s22,state.s15,state.s20);
	lab5.setForeground(Color.blue.darker());
        labr4.setForeground(Color.blue.darker());
        labeqd.setForeground(Color.blue.darker());
        text5.setBounds(state.s195,ypos_block2+state.s22,state.s75,state.s20);
        text5.setForeground(Color.blue.darker());
	//---------------------------------------------
	int ypos_block3 = state.s165;
	lab9.setBounds(state.s20,ypos_block3,state.s80,state.s15);
        lab3.setBounds(state.s130,ypos_block3,state.s160,state.s15);
        
        button2.setBounds(state.s65,ypos_block3+state.s20,state.s40,state.s20);
	button1.setBounds(state.s15,ypos_block3+state.s20,state.s40,state.s20);
        pbut2 = new Panel();
	    pbut2.setBackground(Color.black);
	    pbut2.setBounds(state.s65-1,ypos_block3+state.s20-1,state.s40+2,state.s20+2);
	pbut1 = new Panel();
	    pbut1.setBackground(Color.black);
	    pbut1.setBounds(state.s15-1,ypos_block3+state.s20-1,state.s40+2,state.s20+2);
	add(pbut2); add(pbut1);
        
	button2.setBackground(Color.white);
	button1.setBackground(Color.white);
        button2.setForeground(Color.red);
	button1.setForeground(Color.gray.brighter());
        //----------------------------------------------------------------------        
        //c3.setBounds(state.s120,ypos_block3+state.s17,state.s52,state.s25);
	//c3.setBackground(bgcolor);
	//c4.setBounds(state.s200+state.s15,ypos_block3+state.s17,state.s52,state.s25);
	//c4.setBackground(bgcolor);
        
        button3.setBounds(state.s125,ypos_block3+state.s20,state.s50,state.s20);
	button3.setBackground(Color.white);
        button3.setForeground(Color.red);
	button4.setBounds(state.s200+state.s15,ypos_block3+state.s20,state.s50,state.s20);
	button4.setBackground(Color.white);
        button4.setForeground(Color.gray.brighter());
        
        pbut3 = new Panel();
	    pbut3.setBackground(Color.black);
	    pbut3.setBounds(state.s125-1,ypos_block3+state.s20-1,state.s50+2,state.s20+2);
	pbut4 = new Panel();
	    pbut4.setBackground(Color.black);
	    pbut4.setBounds(state.s200+state.s15-1,ypos_block3+state.s20-1,state.s50+2,state.s20+2);
	add(pbut3); add(pbut4);
        
        //c1.setBounds(state.s65,ypos_block3+state.s17,state.s45,state.s25);
	//c2.setBounds(state.s15,ypos_block3+state.s17,state.s45,state.s25);
	//c1.setBackground(bgcolor);
	//c2.setBackground(bgcolor);
	
        //c3.setBounds(state.s135,ypos_block3+state.s17,state.s50,state.s25);
	//c3.setBackground(bgcolor);
	//c4.setBounds(state.s200+state.s15,ypos_block3+state.s17,state.s55,state.s25);
	//c4.setBackground(bgcolor);
	//-------------------------------------------------------------------
	int ypos_block4 = state.s192;
        //c5.setBounds(state.s110,ypos_block4,state.s60,state.s25);
	//c5.setBackground(bgcolor);
        //c6.setBounds(state.s200+state.s10,ypos_block4,state.s60,state.s25);
	//c6.setBackground(bgcolor);
        //c7.setBounds(state.s30,ypos_block4,state.s60,state.s25);
	//c7.setBackground(bgcolor);
        labpa.setBounds(state.s152,ypos_block4+state.s5,state.s55,state.s15); 
        labpc.setBounds(state.s200+state.s52,ypos_block4+state.s5,state.s30,state.s15); 
        labpe.setBounds(state.s72,ypos_block4+state.s5,state.s30,state.s15); 
        //------------------------------------------------------------------
        lab8.setBounds(state.s50,state.s200+state.s22,state.s120,state.s15);
	
	if(state.IsMac){
            slider.setBounds(state.s20+state.s14,state.s200+state.s42,state.s200+state.s60-state.s28,state.s15);
            slider2.setBounds(state.s20+state.s14,state.s200+state.s63,state.s200+state.s60-state.s28,state.s15);
        }
        else{
            slider.setBounds(state.s20,state.s200+state.s42,state.s200+state.s60,state.s15);
            slider2.setBounds(state.s20,state.s200+state.s63,state.s200+state.s60,state.s15);
        }
        slider_scale.setBounds(state.s195,state.s57,state.s75,state.s15);
	/*
	scale2 = new Panel();
	    scale2.setBackground(Color.cyan);
	    add(scale2);
	    scale2.setBounds(state.s195-1,state.s57-1,state.s75+2,state.s15+2);
	scale1 = new Panel();
	    scale1.setBackground(Color.black);
	    add(scale1);
	    scale1.setBounds(state.s195-2,state.s57-2,state.s75+4,state.s15+4);
	add(scale2); add(scale1);
        scale1.setVisible(true);
        scale2.setVisible(true);
	*/
        labscale.setVisible(true);
        slider_scale.setVisible(true);
        
        labscale.setBounds(state.s180,state.s35,state.s80,state.s15);
        add(labscale);
        
        vlab1.setBounds(state.s180,state.s200+state.s22,state.s80,state.s15);
	vlab1.setFont(labfont);
        /*
	Panel pslider2 = new Panel();
	    pslider2.setBackground(Color.cyan);
	    add(pslider2);
	    pslider2.setBounds(state.s20-1,state.s200+state.s42-1,state.s200+state.s60+2,state.s15+2);
	    
	Panel pslider1 = new Panel();
	    pslider1.setBackground(Color.black);
	    add(pslider1);
	    pslider1.setBounds(state.s20-2,state.s200+state.s42-2,state.s200+state.s60+4,state.s15+4);
	
        Panel pslider4 = new Panel();
	    pslider4.setBackground(Color.cyan);
	    add(pslider4);
	    pslider4.setBounds(state.s20-1,state.s200+state.s63-1,state.s200+state.s60+2,state.s15+2);
	    
	Panel pslider3 = new Panel();
	    pslider3.setBackground(Color.black);
	    add(pslider3);
	    pslider3.setBounds(state.s20-2,state.s200+state.s63-2,state.s200+state.s60+4,state.s15+4);
	*/
	//Listeners 
	slider.addChangeListener(this);	
        slider2.addChangeListener(this);
        slider_scale.addChangeListener(this);
                
        b1.addActionListener(this);
        button1.addActionListener(this);
        button2.addActionListener(this);
        button3.addActionListener(this);
        button4.addActionListener(this);
	c1.addItemListener(this);
	c2.addItemListener(this);
        c3.addItemListener(this);
        c4.addItemListener(this);
   }
   
    public void stateChanged(ChangeEvent evt){
	if(evt.getSource()==slider){
	    if(slider.getValue()==900){
		state.theta1 = Math.PI/2;
		vlab1.setText("90.0 \u00ba ");
		slider.setValue(900);
                slider2.setValue(0);
                slider2.setEnabled(false);
                state.ignition();
            }
	    else{
		//state.theta1 = slider.getValue()*Math.PI/1800.0;
		//vlab1.setText(""+slider.getValue()/10.0+" \u00ba ");
                state.theta1 = MaestroA.rounder(Math.PI/180.0*(slider.getValue()/10.0+MaestroA.rounder(slider2.getValue()*0.0001,4)),6);
                vlab1.setText(""+(MaestroA.rounder(slider.getValue()/10.0+MaestroA.rounder(slider2.getValue()*0.0001,4),6))+" \u00ba ");
                slider2.setEnabled(true);
                //slider2.setValue(0);
                //System.out.println("slider 1 "+MaestroA.rounder((180.0*state.theta1/Math.PI),5));
                state.ignition();
            }
	}
        if(evt.getSource()==slider2){
	    
		//state.theta1 = slider.getValue()*Math.PI/1800.0 +MaestroA.rounder(slider2.getValue()*Math.PI/180.0*0.0001,4);
		
                state.theta1 = MaestroA.rounder(Math.PI/180.0*(slider.getValue()/10.0+MaestroA.rounder(slider2.getValue()*0.0001,4)),6);
                vlab1.setText(""+(MaestroA.rounder(slider.getValue()/10.0+MaestroA.rounder(slider2.getValue()*0.0001,4),6))+" \u00ba ");
                //System.out.println("slider 2 "+MaestroA.rounder((180.0*state.theta1/Math.PI),5));
                state.ignition();
	}
	//state.ignition();
    }

    
    public void actionPerformed(ActionEvent evt){
                // CHANGE - ADD THIS CODE ======================================
                if(evt.getSource() == button2){
                    //button2.setBackground(Color.white);
                    //button1.setBackground(Color.white);
                    button2.setForeground(Color.red);
                    button1.setForeground(Color.gray.brighter());
                    
                    state.isPolarizationParallel=true;
                    state.ignition();
                    state.scan_coefficients();
                }
                else if(evt.getSource() == button1){
                    //button1.setBackground(Color.white);
                    //button2.setBackground(Color.white);
                    button1.setForeground(Color.red);
                    button2.setForeground(Color.gray.brighter());
                    
                    state.isPolarizationParallel=false;
                    state.ignition();
                    state.scan_coefficients();
                }
                if(evt.getSource() == button3){
                    //button3.setBackground(Color.red);
                    //button4.setBackground(Color.white);
                    button3.setForeground(Color.red);
                    button4.setForeground(Color.gray.brighter());
                    state.ignition();
                    state.scan_coefficients();
                }
                else if(evt.getSource() == button4){
                    //button4.setBackground(Color.red);
                    //button3.setBackground(Color.white);
                    button4.setForeground(Color.red);
                    button3.setForeground(Color.gray.brighter());
                    
                    state.ignition();
                    state.scan_coefficients();
                }
                
                
                if(evt.getSource() == b1){
                  
                  if(Double.valueOf(text1.getText()).doubleValue() < 1.0){
                     text1.setText("1.0");
                  }
                  
                  
                  if(Double.valueOf(text2.getText()).doubleValue() < 1.0){
                     text2.setText("1.0");
                  }
                  
                  if(Double.valueOf(text4.getText()).doubleValue() < 1.0){
                     text4.setText("1.0");
                  }
                  
                  if(Double.valueOf(text5.getText()).doubleValue() < 1.0){
                     text5.setText("1.0");
                  }
                  
                    
		  state.epsilon_r1=Double.valueOf(text1.getText()).doubleValue();
		  state.mu_r1=Double.valueOf(text2.getText()).doubleValue();
		  state.conductivity1=Double.valueOf(text3.getText()).doubleValue();
		  state.epsilon_r2=Double.valueOf(text4.getText()).doubleValue();
		  state.mu_r2=Double.valueOf(text5.getText()).doubleValue();
		  state.conductivity2=Double.valueOf(text6.getText()).doubleValue();
		  state.frequency=Double.valueOf(text7.getText()).doubleValue();
		}
		state.ignition();
		state.scan_coefficients();
    }
    
    public void itemStateChanged(ItemEvent evt){
	if(evt.getSource() == c1){
	    state.isPolarizationParallel=true;
	    state.ignition();
	    state.scan_coefficients();
	}
	else if(evt.getSource() == c2){
	    state.isPolarizationParallel=false;
	    state.ignition();
	    state.scan_coefficients();
	}
    }
	
    public void paint(Graphics g){
	//g.setColor(Color.black);
	//g.draw3DRect(0,0,getSize().width-1,getSize().height-1,true);
        
            //g.setColor(Color.gray);
            //g.drawLine(15,123,getSize().width-15,123);
            //g.drawLine(15,169,getSize().width-15,169);
            //g.drawLine(15,220,getSize().width-15,220);
        
        double radiusH = state.s6;
        double xpos = state.s200+state.s80;
        double ypos2 = (double)state.s195;
        double xpos2 = (double)state.s195;;
        double ypos = (double)state.s195;;
        
        //double radiusH = state.s6;
        //double xpos = state.s200+state.s80;
        //double ypos = (double)state.s152;
        //double xpos2 = (double)state.s190;
        //double ypos2 = (double)state.s152;
            
            Color colore;
            if(state.isPolarizationParallel){colore = Color.blue;}
            else{colore = Color.magenta.darker();}
            
            MaestroG.fillCircleThick(g, xpos,ypos,(double)radiusH+state.s1,state.s2,colore);
            MaestroG.fillCircleThick(g, xpos,ypos,(double)(radiusH)-1, state.s2, Color.white);
            MaestroG.fillCircleThick(g, xpos,ypos,(double)state.s1,state.s4,colore);
                        
            //MaestroG.fillCircleThick(g, xpos, ypos, radiusH, 2, Color.white);                        
            //MaestroG.drawCircleThick(g, xpos, ypos, (double)state.s1,2, colore);
            //MaestroG.drawCircleThick(g, xpos, ypos, radiusH, 2, colore);
            
            MaestroG.fillCircleThick(g, xpos2-1,ypos2,(double)radiusH, state.s2, Color.white);
            MaestroG.drawLineThick(g, xpos2-(double)(radiusH/2),ypos2-(double)(radiusH/2),
                                    xpos2 + (double)(radiusH/2),ypos2 + (double)(radiusH/2), state.s1,colore);
            MaestroG.drawLineThick(g, xpos2+(double)(radiusH/2),ypos2-(double)(radiusH/2),
                                    xpos2 - (double)(radiusH/2),ypos2 + (double)(radiusH/2), state.s1,colore);
            MaestroG.drawCircleThick(g, xpos2-1, ypos2, (double)radiusH, 2, colore);
            
            //MaestroG.fillCircleThick(g, xpos2, ypos2, radiusH, 2, Color.white);
            //MaestroG.drawLineThick(g, xpos2-(double)(radiusH/2), ypos2-(double)(radiusH/2),
            //                        xpos2 + (double)(radiusH/2), ypos2 + (double)(radiusH/2), state.s1, colore);
            //MaestroG.drawLineThick(g, xpos2+(double)(radiusH/2), ypos2-(double)(radiusH/2),
            //                        xpos2 - (double)(radiusH/2), ypos2 + (double)(radiusH/2), state.s1,colore);           
            //MaestroG.drawCircleThick(g, xpos2, ypos2, radiusH, 2, colore);
	    slider.requestFocusInWindow();
	    slider2.requestFocusInWindow();
	    slider_scale.requestFocusInWindow();
    }
}

class TitleCanvas extends Canvas{
	
	private static final Font normalfont = new Font("Sanserif",Font.PLAIN,12);
	private static final Font subfont    = new Font("Sanserif",Font.PLAIN,10);
	private Font titlefont = new Font("Sanserif",Font.BOLD,16);
	private Oblique_State state;
        
	public TitleCanvas(Oblique_State state){
	    super();
            this.state = state;
	}
	
	public void paint(Graphics g){
            titlefont = new Font("Sanserif",Font.BOLD,state.font16);
	    int x, y, dx, dxx, dy, dyy;
	    Complex temp1, temp2, ratioZ;
	    double temp3, temp4, temp5, test1, test2, test3, factor1;
	    Graphics2D g2d = (Graphics2D)g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
            FontMetrics fm;
	    x = 10;
	    y = 20;
	    dx = 80;
	    dxx = 15;
	    g.setFont(titlefont);
            g.setColor(Color.red.darker());
	    g.drawString("Input",state.s20,state.s20);
            
            
	}
    }
