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

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

public class SimpleApp extends JPanel implements TdaApp, SliderHandler {

	private Color background = Color.WHITE;
	
	private JPanel one = new JPanel();
	private JPanel two = new JPanel();
	private JPanel three = new JPanel();
	private JPanel four = new JPanel();
	
	private boolean isDown[] = {false, false, false, false};
	
	
	public SimpleApp()
	{
		setLayout(new GridLayout(2,2));
		add(one);
		add(two);
		add(three);
		add(four);
		
	}
	
	public boolean isWide() {return true;}
	
	public void buttonOneDown(InputEvent event){
		one.setBackground(Color.red);
		isDown[0] = true;
	}
	public void buttonOneUp(InputEvent event){
		one.setBackground(background);
		isDown[0] = false;
	}
	public void buttonTwoDown(InputEvent event){
		two.setBackground(Color.green);
		isDown[1] = true;
	}
	public void buttonTwoUp(InputEvent event){
		two.setBackground(background);
		isDown[1] = false;
	}
	public void buttonThreeDown(InputEvent event){
		three.setBackground(Color.yellow);
		isDown[2] = true;
	}
	public void buttonThreeUp(InputEvent event){
		three.setBackground(background);
		isDown[2] = false;
	}
	public void buttonFourDown(InputEvent event){
		four.setBackground(Color.blue);
		isDown[3] = true;
	}
	public void buttonFourUp(InputEvent event){
		four.setBackground(background);
		isDown[3] = false;
	}
	
	public void sliderChanged(double ratio)
	{
		background = new Color((float)ratio, (float)ratio, (float)ratio);
		if (!isDown[0]) one.setBackground(background);
		if (!isDown[1]) two.setBackground(background);
		if (!isDown[2]) three.setBackground(background);
		if (!isDown[3]) four.setBackground(background);
		
	}
}
