//-----------------------------------------------------------------------------
//
// $Id: SliderAddon.java 8 2006-02-01 16:58:12Z jnross $
// $HeadURL: svn+ssh://wopr.csl.mtu.edu/major/jnross/svn_repos/cs4760/TdaSimulator/app-src/SliderAddon.java $
//
//-----------------------------------------------------------------------------

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

public class SliderAddon extends SimulatorAddon implements ChangeListener{

	private SliderHandler app;
	public Class addonInterface() {
		return SliderHandler.class;
	}

	public void setupAddon(TdaApp app) {
		
		this.app = (SliderHandler)app;
		setSize(200, 50);
		JSlider slider = new JSlider(0, 255, 0);
		add(slider);
		slider.addChangeListener(this);
		slider.addKeyListener(this.getKeyListeners()[0]);
	}
	
	public void stateChanged(ChangeEvent e)
	{
		JSlider slider = (JSlider)e.getSource();
		double value = ((double)slider.getValue())/slider.getMaximum();
		app.sliderChanged(value);
	}
}
