//PlotSizeControl.java
/* A Java class for
 * LossyWide.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.applet.*;
import java.lang.*;  


public class PlotSizeControl extends Panel implements AdjustmentListener{
	public Scrollbar slider;
	private double lineLength = 1.0, lineLength_part1 = 1.0, lineLength_part2 = 0.0, linecounter1 = 1000, linecounter2 = 0;
    //private final Font labelfont=new Font("Sanserif",Font.PLAIN,11);
    public static  Font labelfont;
	private static final Color bgcolor = new Color(255,255,255);//white
	//private static final Color bgcolor = new Color(236,236,221);
	
	public int SCROLLMIN=0, SCROLLMAX=49;
	public PlotSizeControl(){
		super();	
		setLayout(null);
		setBackground(bgcolor);
				
		
		slider = new Scrollbar(Scrollbar.HORIZONTAL,0,1,SCROLLMIN,SCROLLMAX);	
                //slider = new Scrollbar(Scrollbar.VERTICAL,8,1,SCROLLMIN,SCROLLMAX);
		slider.addAdjustmentListener(this);
		
		add(slider);
		
		//slider.setBounds(1,1,8,98);	
                slider.setBounds(1,21,98,8);	
                
                Panel slide1 = new Panel();
		    slide1.setBackground(Color.black);
		    //add(slide1);
		    //slide1.setBounds(0,0,10,100);
                    slide1.setBounds(0,20,100,10);
		//Listeners
		//slider.addAdjustmentListener(this);	
	}
	
	public void paint(Graphics g){
		//g.setColor(bgcolor);
		//g.fill3DRect(0,0,getSize().width-1,getSize().height-1,true);
                g.setFont(labelfont);
                g.setColor(Color.blue);
                g.drawString("plot scale",25,17);
	}
	
    	public void adjustmentValueChanged(AdjustmentEvent evt){
	  if(evt.getSource()==slider){
		SCROLLMAX = slider.getMaximum();
		SCROLLMIN = slider.getMinimum();
	  }
	}
	
	public double getValue(){
		SCROLLMAX = slider.getMaximum();
		SCROLLMIN = slider.getMinimum();
		return (slider.getValue());
	}
	
	public synchronized void setValue(double x){
	    slider.setValue((int)(x));
	}
	
	
}
