package com.troi.balloon;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import util.panelDimension;

public class Button {

	panelDimension dimension;
	BufferedImage button;
	Panel panel;
	String state;
	public Button(panelDimension panelDimension){
		try{
			button = ImageIO.read(new File("resources/gray-fade.png"));
		}catch(IOException e){
			button = null;
		}
	}
	
	public Button(panelDimension panelDimension, Panel p){
		try{
			button = ImageIO.read(new File("resources/gray-fade.png"));
		}catch(IOException e){
			button = null;
		}
		panel = p;
	}
	
	public Button(panelDimension panelDimension, Panel p, String s, String size){
		try{
			button = ImageIO.read(new File("resources/gray-fade.png"));
		}catch(IOException e){
			button = null;
		}
		panel = p;
		state = s;
		setSize(size);
		}
	
	public Button(Panel p,String size)
	{
		try{
			button = ImageIO.read(new File("resources/gray-fade.png"));
		}catch(IOException e){
			button = null;
		}
		setSize(size);
		panel = p;
	}
	
	public void setSize(String size) {
		// TODO Auto-generated method stub
		if(size.equals("Small")){
			setDimension(new panelDimension(100, 10, 10, 10));
		}
	}

	public Panel getContainer(){
		return panel;
	}
	
	public void paint(Graphics2D render) {
		render.drawImage(button.getScaledInstance(dimension.getWidth(), dimension.getHeight(), Image.SCALE_FAST), dimension.getX(), dimension.getY(), null);
		render.fillRect(10,10,10,10);
	}
	
	public panelDimension getSize()
	{
		return dimension;
	}
	
	//check in use -- checks to see if the button currently being dragged
	
	//toggle draggable
	
	//
	
	public void setDimension(panelDimension dimension)
	{
		this.dimension = dimension;
	}
}
@@ -296,23 +296,20 @@
 n;%0A%09
-BufferedImage b
+Image imageB
 utto
@@ -393,514 +393,193 @@
 %7B%0A%09%09
-try%7B%0A%09%09%09button = ImageIO.read(new File(%22resources/gray-fade.png%22));%0A%09%09%7Dcatch(IOException e)%7B%0A%09%09%09button = null;%0A%09%09%7D%0A%09%7D%0A%09%0A%09public Button(panelDimension panelDimension, Panel p)%7B%0A%09%09try%7B%0A%09%09%09button = ImageIO.read(new File(%22resources/gray-fade.png%22));%0A%09%09%7Dcatch(IOException e)%7B%0A%09%09%09button = null;%0A%09%09%7D%0A%09%09panel = p;%0A%09%7D%0A%09%0A%09public Button(panelDimension panelDimension, Panel p, String s, String size)%7B%0A%09%09try%7B%0A%09%09%09button = ImageIO.read(new File(%22resources/gray-fade.png%22));%0A%09%09%7Dcatch(IOException e)%7B%0A%09%09%09button = null;%0A%09%09%7D
+initImage();%0A%09%7D%0A%09%0A%09public Button(panelDimension panelDimension, Panel p)%7B%0A%09%09panel = p;%0A%09%09initImage();%0A%09%7D%0A%09%0A%09public Button(panelDimension panelDimension, Panel p, String s, String size)%7B
 %0A%09%09p
@@ -615,24 +615,38 @@
 ize(size);%0A%09
+%09initImage();%0A
 %09%7D%0A%09%0A%09public
@@ -677,16 +677,94 @@
 ize)%0A%09%7B%0A
+%09%09setSize(size);%0A%09%09panel = p;%0A%09%09initImage();%0A%09%7D%0A%09%0A%09private void initImage() %7B%0A
 %09%09try%7B%0A%09
@@ -761,25 +761,30 @@
 %7B%0A%09%09try%7B%0A%09%09%09
-b
+imageB
 utton = Imag
@@ -828,16 +828,97 @@
 e.png%22))
+.getScaledInstance(dimension.getWidth(), dimension.getHeight(), Image.SCALE_FAST)
 ;%0A%09%09%7Dcat
@@ -939,17 +939,22 @@
  e)%7B%0A%09%09%09
-b
+imageB
 utton = 
@@ -967,38 +967,8 @@
 %09%09%7D%0A
-%09%09setSize(size);%0A%09%09panel = p;%0A
 %09%7D%0A%09
@@ -1245,95 +1245,19 @@
 age(
-button.getScaledInstance(dimension.getWidth(), dimension.getHeight(), Image.SCALE_FAST)
+imageButton
 , di

minimized math