/**
*Programme cree par The Clusters
*Classe RoundButton du jeu "Chkoba"
*Cree les boutons rond sur l'index
*@author The Clusters
*@version 1.0
**/

package chkoba;

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

/**
*	Classe RoundButton
*/

public class RoundButton extends JButton 
{
 
	public RoundButton(String text) 
	{
		super(text);
		setBorderPainted(false);
		setFocusPainted(false);
		setContentAreaFilled(false);
	}
	
	public RoundButton(Icon icon) 
	{
		super(icon);
		setBorderPainted(false);
		setFocusPainted(false);
		setContentAreaFilled(false);
	}
 
  /**
   * determine si le point (x, y) est a l'interieur de l'icone circulaire
   */
	public boolean contains(int x, int y) 
	{
		Dimension size = getSize();
		float x0 = size.width / 2F;
		
		float y0 = size.height / 2F;
		
	 
		Icon icon = getIcon();
		float w = icon.getIconWidth() / 2F;
		float h = icon.getIconHeight() / 2F;
	 
		return (x - x0) * (x - x0) + (y - y0) * (y - y0) <= w * h;
	}
}