//NewGuideInputPanel.java
/* A Java class for
 * Coaxial.java
 * Electromagnetic Transmission Line Applet
 * Applet without Smith Chart - Prepared by Umberto Ravaioli 
 * for 6th edition of Fundamentals of Applied Electromagnetics Book
 * May 2009 - All Rights Reserved
 */   

import java.awt.*;
import java.awt.event.*;
import java.text.*;

public class NewGuideInputPanel extends Panel implements ActionListener, AdjustmentListener{
    private NewGuide_State state;
    
    private static final Color bgcolor = new Color(236,236,236);
    //private static final Font labfont=new Font("SanSerif",Font.PLAIN,12);
    //private static final Font normalfont = new Font("SanSerif",Font.PLAIN,14);
    //private static final Font smallfont = new Font("SanSerif",Font.PLAIN,12);
    private static Font labfont;
    private static Font normalfont;
    private static Font smallfont;

    public int ScrollMax = 10000;
    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 CheckboxGroup cgrp;
    public  Button b1, b2, b3, b5;
    public  Button bupdate, binstr;
  
    public NewGuideInputPanel(NewGuide_State state){
	super();
	setLayout(null);
	setBackground(bgcolor);
	this.state = state;

        if (MaestroG.useBiggerFont) {
            labfont = state.sanSerifFont.deriveFont(14F);
            //normalfont = state.sanSerifFont.deriveFont(16F);
            //smallfont = state.sanSerifFont.deriveFont(14F);
            normalfont = state.sanSerifFont.deriveFont(14F);
            smallfont = state.sanSerifFont.deriveFont(12F);
        } else {
            labfont = state.sanSerifFont.deriveFont(12F);
            //normalfont = state.sanSerifFont.deriveFont(14F);
            //smallfont = state.sanSerifFont.deriveFont(12F);
            normalfont = state.sanSerifFont.deriveFont(12F);
            smallfont = state.sanSerifFont.deriveFont(10F);
        }

        setFont(normalfont);

	titlelabel = new Label("Input",Label.CENTER);
	//titlelabel.setFont(new Font("SanSerif",Font.BOLD,16));

        if (MaestroG.useBiggerFont) {
            titlelabel.setFont(state.sanSerifFont.deriveFont(Font.BOLD,18F));
        } else {
            titlelabel.setFont(state.sanSerifFont.deriveFont(Font.BOLD,16F));
        }
		
	lab1 = new Label("Shield radius b =  ",Label.RIGHT);
	lab2 = new Label("Insulator ",Label.LEFT);
	lab2.setFont(labfont);
	lab3 = new Label("Relative \u03bc = ",Label.RIGHT);
	lab3.setFont(labfont);
	lab4 = new Label("Frequency   f  =  ",Label.RIGHT);
	lab5 = new Label("Strip thickness t  =  ",Label.RIGHT);
	lab6 = new Label("Inner radius a  =  ",Label.RIGHT);
	lab7 = new Label("Metal",Label.RIGHT);
		
	text1 = new TextField(""+state.a,8);
	text3 = new TextField(""+state.epsilon_r,8);
	text4 = new TextField(""+state.frequency,8);
	text5 = new TextField(""+state.b,8);
	text6 = new TextField(""+state.w,8);
	text7 = new TextField(""+state.sigma2,8);
	//text7 = new TextField(""+state.loss_tangent,8);
	//text8 = new TextField(""+state.rho_metal);
        DecimalFormat dec = new DecimalFormat("0.###E0");
        // NOTE: sigma_metal is 1/rho_metal
	text8 = new TextField(""+dec.format(state.sigma_metal),8);
        text1.setFont(labfont);
        text3.setFont(labfont);
        text4.setFont(labfont);
        text5.setFont(labfont);
        text6.setFont(labfont);
        text7.setFont(labfont);
        text8.setFont(labfont);
	
	ulab1 = new Label(" [ mm ]",Label.LEFT);
	ulab2 = new Label(" [ mm ]",Label.LEFT);
	ulab3 = new Label(" [ mm ]",Label.LEFT);
	ulab4 = new Label(" [ Hz ]",Label.LEFT);
	ulab5 = new Label(" [ S/m ]",Label.LEFT);
	//ulab6 = new Label(" [ \u03a9 m ]",Label.LEFT);
	ulab6 = new Label(" [ S/m ]",Label.LEFT);
	//ulab6.setFont(labfont);
	
	slider1 = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,ScrollMax+1);//changes a
	slider2 = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,ScrollMax+1);//changes frequency
	slider3 = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,ScrollMax+1);//changes w
	slider5 = new Scrollbar(Scrollbar.HORIZONTAL,0,1,0,ScrollMax+1);//changes t
        slider1.setBackground(Color.white);
        slider2.setBackground(Color.white);
        slider3.setBackground(Color.white);
        slider5.setBackground(Color.white);
	
	slider1.setValue((int)((state.a-state.a_minimum)*ScrollMax/(state.a_maximum-state.a_minimum)));
	slider2.setValue((int)((state.frequency-state.frequency_minimum)*ScrollMax/(state.frequency_maximum-state.frequency_minimum)));
	slider3.setValue((int)((state.w-state.w_minimum)*ScrollMax/(state.w_maximum-state.w_minimum)));
	slider5.setValue((int)((state.b-state.b_minimum)*ScrollMax/(state.b_maximum-state.b_minimum)));
	
        FontMetrics fmSmall = getFontMetrics(smallfont);
        int buttonWidth = fmSmall.stringWidth("XRangeX");
	b1 = new Button("Range");
        //b1.setFont(smallfont);

	b2 = new Button("Range");
        //b2.setFont(smallfont);

	b3 = new Button("Range");
        //b3.setFont(smallfont);

	b5 = new Button("Range");
        //b5.setFont(smallfont);

	bupdate = new Button("Update");
        //bupdate.setFont(smallfont);
        
        b1.setBackground(Color.white);
        b2.setBackground(Color.white);
        b3.setBackground(Color.white);
        b5.setBackground(Color.white);
	bupdate.setBackground(Color.white);
        
        // update button
	binstr = new Button("Instructions");
        binstr.setBackground(Color.white);
	add(binstr);
        int buttonx = 175;
        int buttony = 10;
        int buttonwide = 100;
        int buttonheight = 22;
	 
        binstr.setBounds(buttonx,buttony,buttonwide,buttonheight);	
        Panel pin = new Panel();
	    pin.setBackground(Color.black);
	    add(pin);
	    pin.setBounds(buttonx-1,buttony-1,buttonwide+2,buttonheight+2);
    
	add(titlelabel);
	add(lab1);
	//add(lab2);
	add(lab3);
	add(lab4);
	//add(lab5);
	add(lab6);
	add(lab7);
	add(text1);
	//add(text2);
	add(text3);
	add(text4);
	//add(text5);
	add(text6);
	add(text7);
	add(text8);
	//add(ulab1);
	//add(ulab2);
	//add(ulab3);
	add(ulab4);
	add(ulab5);
	add(ulab6);
	add(slider1);
	add(slider2);
	add(slider3);
	//add(slider5);
	add(b1);
	add(b2);
	add(b3);
	//add(b5);
	add(bupdate);
	
	titlelabel.setBounds(15,10,50,18);
	
	int vPosInit = 50, vPos, dvPos = 7, vHeight = 15; 
	vPos = vPosInit;
        
	// band I
	int y_wide = 68; 
	lab6.setBounds(20,y_wide-25,150,vHeight);
	text6.setBounds(170,y_wide-25,80,vHeight+3);
	//ulab3.setBounds(250,y_wide-25,40,vHeight);
	    
	slider3.setBounds(80,y_wide,196,vHeight);
	Panel ps1 = new Panel();
	    ps1.setBackground(Color.cyan);
	    add(ps1);
	    ps1.setBounds(79,y_wide-1,198,vHeight+2);
	    
	Panel ps2 = new Panel();
	    ps2.setBackground(Color.black);
	    add(ps2);
	    ps2.setBounds(78,y_wide-2,200,vHeight+4);
	
        //b3.setBounds(20,y_wide-2,45,20);
        b3.setBounds(15,y_wide-2,buttonWidth,20);
        Panel p3 = new Panel();
	    p3.setBackground(Color.black);
	    add(p3);
	    p3.setBounds(14,y_wide-3,buttonWidth+2,22);
	
	// band III
	int y_sub = 124;   
	lab1.setBounds(20,y_sub-25,150,vHeight);    
	text1.setBounds(170,y_sub-25,80,vHeight+3);
	//ulab1.setBounds(250,y_sub-25,40,vHeight);  
	  
	slider1.setBounds(80,y_sub,196,vHeight);
	Panel ps9 = new Panel();
	    ps9.setBackground(Color.cyan);
	    add(ps9);
	    ps9.setBounds(79,y_sub-1,198,vHeight+2);
	    
	Panel ps10 = new Panel();
	    ps10.setBackground(Color.black);
	    add(ps10);
	    ps10.setBounds(78,y_sub-2,200,vHeight+4);
	
        //b1.setBounds(20,y_sub-2,45,20); 
	b1.setBounds(15,y_sub-2,buttonWidth,20); 
	Panel p1 = new Panel();
	    p1.setBackground(Color.black);
	    add(p1);
	    p1.setBounds(14,y_sub-3,buttonWidth+2,22);
            
	// band IV
	int y_frequency = 180;
	lab4.setBounds(20,y_frequency-25,150,vHeight);
	text4.setBounds(170,y_frequency-25,80,vHeight+3);
	ulab4.setBounds(247,y_frequency-25,40,vHeight);   
	    
	slider2.setBounds(80,y_frequency,196,vHeight);
	Panel ps5 = new Panel();
	    ps5.setBackground(Color.cyan);
	    add(ps5);
	    ps5.setBounds(79,y_frequency-1,198,vHeight+2);
	    
	Panel ps6 = new Panel();
	    ps6.setBackground(Color.black);
	    add(ps6);
	    ps6.setBounds(78,y_frequency-2,200,vHeight+4);
	
        //b2.setBounds(20,y_frequency-2,45,20); // range button
	b2.setBounds(15,y_frequency-2,buttonWidth,20); // range button
	Panel p2 = new Panel();
	    p2.setBackground(Color.black);
	    add(p2);
	    p2.setBounds(14,y_frequency-3,buttonWidth+2,22);
            
	// band V
	int y_material = 224;
        text3.setBounds(20,y_material,70,vHeight+3);
	text7.setBounds(105,y_material,80,vHeight+3);
	text8.setBounds(200,y_material,80,vHeight+3);
	
	ulab5.setBounds(133,y_material-18,50,vHeight);
	ulab6.setBounds(230,y_material-18,50,vHeight);
		    
        //  band VI
	int y_update =255;
	bupdate.setBounds(20,y_update,260,20);	
	Panel ps7 = new Panel();
	    ps7.setBackground(Color.cyan);
	    add(ps7);
	    ps7.setBounds(19,y_update-1,262,22);
	    
	Panel ps8 = new Panel();
	    ps8.setBackground(Color.black);
	    add(ps8);
	    ps8.setBounds(18,y_update-2,264,24);
	
	//Listeners
	bupdate.addActionListener(this);
	
	slider1.addAdjustmentListener(this);
	slider2.addAdjustmentListener(this);
	slider3.addAdjustmentListener(this);
	
    }
    
    public void paint(Graphics g){
	Graphics2D g2d = (Graphics2D)g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
        g.clearRect(0,0,getSize().width-1,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);
	int vPosInit = 30, vPos, dvPos = 2, vHeight = 20; 
	vPos = vPosInit+9*vHeight+8*dvPos;
	g.setColor(Color.red);    
	
        if (MaestroG.useBiggerFont) {
            g.setFont(state.serifFont.deriveFont(16f));
        } else {
            g.setFont(state.serifFont.deriveFont(14f));
        }
	g.drawString("\u03b5",32,vPos-10);
	g.drawString("\u03c3",115,vPos-10);
	//g.drawString("\u03c1",202,vPos-10);
	g.drawString("\u03c3",202,vPos-10);
	
        if (MaestroG.useBiggerFont) {
            g.setFont(state.sanSerifFont.deriveFont(16f));
        } else {
            g.setFont(state.sanSerifFont.deriveFont(14f));
        }
	MaestroG.subscripter("","r","",g,14,40,vPos-10);	
	//MaestroG.subscripter("","s","",g,14,210,vPos-10);
	MaestroG.subscripter("","c","",g,14,210,vPos-10);
	
        if (MaestroG.useBiggerFont) {
            g.setFont(state.sanSerifFont.deriveFont(14f));
        } else {
            g.setFont(state.sanSerifFont.deriveFont(12f));
        }
	g.setColor(Color.black);    
	if(state.IsMilsOn){
	    g.drawString("[mils]",252,54);
	    g.drawString("[mils]",252,110);
	}
	else{
	    g.drawString("[mm]",252,54);
	    g.drawString("[mm]",252,110);
	}
	
    }
    
    public void actionPerformed(ActionEvent evt){
     //***********
     if(evt.getSource()==bupdate){
	//*********
	  if(!state.IsMilsOn){
	    try{ if(Double.valueOf(text1.getText()).doubleValue()<=state.a_maximum &&
		    Double.valueOf(text1.getText()).doubleValue()>=state.a_minimum){
		    state.a=Double.valueOf(text1.getText()).doubleValue();
		    slider1.setValue((int)(ScrollMax*(state.a-state.a_minimum)
						    /(state.a_maximum-state.a_minimum)));
		 }
		 else if(Double.valueOf(text1.getText()).doubleValue()>state.a_maximum){
		    state.a = state.a_maximum;
		    text1.setText(""+state.a_maximum);
		    slider1.setValue(ScrollMax);
		 }
		 else if(Double.valueOf(text1.getText()).doubleValue()<state.a_minimum){
		    state.a = state.a_minimum;
		    text1.setText(""+state.a_minimum);
		    slider1.setValue(0);
		 }
		 else if(Double.valueOf(text1.getText()).doubleValue()<state.w){
		    state.a =state.w;
		    text1.setText(""+state.a);
		    slider1.setValue((int)(ScrollMax*(state.a-state.a_minimum)
						    /(state.a_maximum-state.a_minimum)));
		 }
	    }
	     catch(NumberFormatException e){
		  state.a =  0.0;
	    } 
		 
	    try{if(Double.valueOf(text6.getText()).doubleValue()<=state.w_maximum &&
		    Double.valueOf(text6.getText()).doubleValue()>=state.w_minimum){
		    state.w=Double.valueOf(text6.getText()).doubleValue();
		     slider3.setValue((int)(ScrollMax*(state.w-state.w_minimum)/
					(state.w_maximum-state.w_minimum)));
		}
		else if(Double.valueOf(text6.getText()).doubleValue()>state.w_maximum){
		    state.w = state.w_maximum;
		    text6.setText(""+state.w_maximum);
		    slider3.setValue(ScrollMax);
		}
		else if(Double.valueOf(text6.getText()).doubleValue()<state.w_minimum){
		    state.w = state.w_minimum;
		    text6.setText(""+state.w_minimum);
		    slider3.setValue(0);
		}
		
	    }
	    catch(NumberFormatException e){
		state.w = 0.0;
	    		 
	    }
	   
	  }//***********
	  else{
	    try{ if(Double.valueOf(text1.getText()).doubleValue()<=state.a_mil_maximum &&
		    Double.valueOf(text1.getText()).doubleValue()>=state.a_mil_minimum){
		    state.a_mil=Double.valueOf(text1.getText()).doubleValue();
		    slider1.setValue((int)(ScrollMax*(state.a_mil-state.a_mil_minimum)
						    /(state.a_mil_maximum-state.a_mil_minimum)));
		 }
		 else if(Double.valueOf(text1.getText()).doubleValue()>state.a_mil_maximum){
		    state.a_mil = state.a_mil_maximum;
		    text1.setText(""+state.a_mil_maximum);
		    slider1.setValue(ScrollMax);
		 }
		 else if(Double.valueOf(text1.getText()).doubleValue()<state.a_mil_minimum){
		    state.a_mil = state.a_mil_minimum;
		    text1.setText(""+state.a_mil_minimum);
		    slider1.setValue(0);
		 }
		 else if(Double.valueOf(text1.getText()).doubleValue()<state.w_mil){
		    state.a_mil =state.w_mil;
		    text1.setText(""+state.a_mil);
		    slider1.setValue((int)(ScrollMax*(state.a_mil-state.a_mil_minimum)
						    /(state.a_mil_maximum-state.a_mil_minimum)));
		 }
	    }
	    catch(NumberFormatException e){
		  state.a_mil =  0.0;
	    }
	    
	    try{if(Double.valueOf(text6.getText()).doubleValue()<=state.w_mil_maximum &&
		    Double.valueOf(text6.getText()).doubleValue()>=state.w_mil_minimum){
		    state.w_mil=Double.valueOf(text6.getText()).doubleValue();
		     slider3.setValue((int)(ScrollMax*(state.w_mil-state.w_mil_minimum)/
					(state.w_mil_maximum-state.w_mil_minimum)));
		}
		else if(Double.valueOf(text6.getText()).doubleValue()>state.w_mil_maximum){
		    state.w_mil = state.w_mil_maximum;
		    text6.setText(""+state.w_mil_maximum);
		    slider3.setValue(ScrollMax);
		}
		else if(Double.valueOf(text6.getText()).doubleValue()<state.w_mil_minimum){
		    state.w_mil = state.w_mil_minimum;
		    text6.setText(""+state.w_mil_minimum);
		    slider3.setValue(0);
		}
		
	    }
	    catch(NumberFormatException e){
		state.w_mil = 0.0;
	    } 
		 
	}
	  
	    
	    try{if(Double.valueOf(text3.getText()).doubleValue()>=1.0){
		    state.epsilon_r=Double.valueOf(text3.getText()).doubleValue();
		}
		else{
		    state.epsilon_r=1.0;
		    text3.setText(""+state.epsilon_r);
		}
	    }
	    catch(NumberFormatException e){
		  state.epsilon_r = 1.0;
	    }  
	    
	    
	    try{if(Double.valueOf(text7.getText()).doubleValue()>=0.0){
		    state.sigma2=Double.valueOf(text7.getText()).doubleValue();
		    //state.loss_tangent=Double.valueOf(text7.getText()).doubleValue();
		}
		else{
		    state.sigma2=0.0;
		    text7.setText(""+state.sigma2);
		    //state.loss_tangent=0.0;
		    //text7.setText(""+state.loss_tangent);
		}
	    }
	    catch(NumberFormatException e){
		  state.sigma2 = 0.0;
		  //state.loss_tangent = 0.0;
	    }  
	    try{if(Double.valueOf(text8.getText()).doubleValue()>=0.0){
		    //state.rho_metal=Double.valueOf(text8.getText()).doubleValue();
		    state.sigma_metal=Double.valueOf(text8.getText()).doubleValue();
                    state.rho_metal = 1.0/state.sigma_metal;
		    
		}
		else{
		    //state.rho_metal=0.0;
		    //text8.setText(""+state.rho_metal);
		    state.sigma_metal=1.0E-99;
                    state.rho_metal=1.0/state.sigma_metal;
		    
		}
	    }
	    catch(NumberFormatException e){
		  state.rho_metal = 0.0;
	    }

	    try{if(Double.valueOf(text4.getText()).doubleValue()<=state.frequency_maximum &&
		    Double.valueOf(text4.getText()).doubleValue()>=state.frequency_minimum){
		    state.frequency=Double.valueOf(text4.getText()).doubleValue();
		    slider2.setValue((int)(ScrollMax*(state.frequency-state.frequency_minimum)/
					    (state.frequency_maximum-state.frequency_minimum)));
		}
		else if(Double.valueOf(text4.getText()).doubleValue()>state.frequency_maximum){
		    state.frequency = state.frequency_maximum;
		    text4.setText(""+state.frequency_maximum);
		    slider2.setValue(ScrollMax);
		}
		else if(Double.valueOf(text4.getText()).doubleValue()<state.frequency_minimum){
		    state.frequency = state.frequency_minimum;
		    text4.setText(""+state.frequency_minimum);
		    slider2.setValue(0);
		}
	    }
	    catch(NumberFormatException e){
		  state.frequency = 0.0; 
	    }
	  
	    
	  }
	  //************************
	    state.ignition();
	    
	
    }//End of actionPerformed()
    
    public void adjustmentValueChanged(AdjustmentEvent evt){//NEED HERE
	if(evt.getSource()==slider2){
	    if(slider2.getValue()>=ScrollMax){
		state.frequency=state.frequency_maximum;
		slider2.setValue((int)(ScrollMax*(state.frequency-state.frequency_minimum)
						    /(state.frequency_maximum-state.frequency_minimum)));
	    }
	    else{
		state.frequency = state.frequency_minimum + 
		    (state.frequency_maximum-state.frequency_minimum)*slider2.getValue()/ScrollMax;
	    }
	    
	    text4.setText(""+state.frequency);
	    state.ignition();
	    
	}
	//-----------------------------------------
	else if(evt.getSource()==slider1){
	  if(!state.IsMilsOn){
	    if(slider1.getValue()>=ScrollMax){
		    state.a=state.a_maximum;
		    slider1.setValue((int)(ScrollMax*(state.a-state.a_minimum)
						    /(state.a_maximum-state.a_minimum)));
	    }
	    else{
	    state.a  = state.a_minimum + 
		(state.a_maximum-state.a_minimum)*slider1.getValue()/ScrollMax;
	    }
	    text1.setText(""+MaestroA.rounder(state.a,7));
	    state.ignition();
	    
	    
	    if(state.a <= state.w){
		    state.a =state.w;
		    
		    slider1.setValue((int)(ScrollMax*(state.a-state.a_minimum)
						    /(state.a_maximum-state.a_minimum)));
		    text1.setText(""+MaestroA.rounder(state.a,7));
		    state.ignition();
		    
	    }
	
	    
	  }
	  else{
	    if(slider1.getValue()>=ScrollMax){
		    state.a_mil=state.a_mil_maximum;
		    slider1.setValue((int)(ScrollMax*(state.a_mil-state.a_mil_minimum)
						    /(state.a_mil_maximum-state.a_mil_minimum)));
	    }
	    else{
	    state.a_mil  = state.a_mil_minimum + 
		(state.a_mil_maximum-state.a_mil_minimum)*slider1.getValue()/ScrollMax;
	    }
	    text1.setText(""+MaestroA.rounder(state.a_mil,7));
	    state.ignition();
	    
	    
	    if(state.a_mil<=state.w_mil){
		    state.a_mil =state.w_mil;
		    
		    slider1.setValue((int)(ScrollMax*(state.a_mil-state.a_mil_minimum)
						    /(state.a_mil_maximum-state.a_mil_minimum)));
		    text1.setText(""+MaestroA.rounder(state.a_mil,7));
		    state.ignition();
		    
	    }
	  }
	}
	//----------------------------------------------------------------------
	
	else if(evt.getSource()==slider3){
	  if(!state.IsMilsOn){
	    if(slider3.getValue()>=ScrollMax){
		    state.w=state.w_maximum;
		    slider3.setValue((int)(ScrollMax*(state.w-state.w_minimum)
						    /(state.w_maximum-state.w_minimum)));
	    }
	    else{
		state.w = state.w_minimum + 
		    (state.w_maximum-state.w_minimum)*slider3.getValue()/ScrollMax;
	    }
	
	    text6.setText(""+MaestroA.rounder(state.w,7));
	    state.ignition();
	    
	    if(state.w > state.a){
		    state.w =state.a;
		    
		    slider3.setValue((int)(ScrollMax*(state.w-state.w_minimum)
						    /(state.w_maximum-state.w_minimum)));
		    text6.setText(""+MaestroA.rounder(state.w,7));
		    state.ignition();
		    
	    }
	    
	  }
	  else{
	    if(slider3.getValue()>=ScrollMax){
		    state.w_mil=state.w_mil_maximum;
		    slider3.setValue((int)(ScrollMax*(state.w_mil-state.w_mil_minimum)
						    /(state.w_mil_maximum-state.w_mil_minimum)));
	    }
	    else{
		state.w_mil = state.w_mil_minimum + 
		    (state.w_mil_maximum-state.w_mil_minimum)*slider3.getValue()/ScrollMax;
	    }
	
	    text6.setText(""+MaestroA.rounder(state.w_mil,7));
	    state.ignition();
	    
	    if(state.w_mil > state.a_mil){
		    state.w_mil =state.a_mil;
		    
		    slider3.setValue((int)(ScrollMax*(state.w_mil-state.w_mil_minimum)
						    /(state.w_mil_maximum-state.w_mil_minimum)));
		    text6.setText(""+MaestroA.rounder(state.w_mil,7));
		    state.ignition();
		    
	    }
	  }
	}
    }
    
}


