import java.awt.Color;
import java.awt.geom.Point2D;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

public class CircleObj 
{

	int 						x1, y1, x2, y2;
	Color 						color;
	boolean 					selected;
	private int					radius;	
	private int					diametre;
	private int					width;
	private int					height;
	
	public CircleObj()
	{
	}
	
	public CircleObj( int x1, int y1, int x2, int y2, Color c) // Point2D centrePoint
	{
			this.x1 = x1; 
			this.y1 = y1; 
			this.x2 = x2; 
			this.y2 = y2; 
			this.color = c;
			this.selected = false;
/*			
			int xdiff =  x1 - x2;
        	int ydiff =  y1 - y2;
        	int rayon = (int)  Math.sqrt(Math.pow(xdiff, 2)+Math.pow(ydiff, 2));
        	this.diametre = rayon * 2;
        	
        	this.width = rayon * 2;
        	this.height = rayon * 2;
*/		
	         
			//System.out.println("DRAW Circle  stop " + x1 + " " + y1 + " --- " +  diametre );  
			
	}
	
	public void setX1(int x1)
	{
	       this.x1=x1;
    }  
	    
    public int getX1()
    {
        return x1;
    }
		    
    public void setY1(int y1)
    {
        this.y1=y1;
    }   
	    
    public int getY1()
    {
        return y1;
    }
		    
    public void setX2(int x2)
    {
        this.x2=x2;
    }   
	    
    public int getX2()
    {
    	return x2;
    }
		    
    public void setY2(int y2)
    {
        this.y2=y2;
    }   
		 
    public int getY2()
    {
    	return y2;
    }
	
	public void setSelected(boolean select)
	{
		selected = select;
	}

	public void setUnSelected(boolean state) 
	{ 
	   	selected = state; 
  	}
	    
	public boolean getsetSelected()
	{
		return selected;
	}
		
	public void toggleSelected() 
	{ 
		selected = !selected; 
	}
		
	public boolean isSelected() 
	{ 
		return selected; 
	}

	public void set_diametre(int val)
	{
	    diametre = val;
	}
	
	public int get_diametre()
	{
	    return diametre;
	}
	
	public int getWidth()
	{
		return width;
	}
	
	public void setWidth(int val)
	{
		width = val;
	}
		

	public int getHeight()
	{
		return height;
	}
	
	public void setHeight(int val)
	{
		height = val;
	}

	 
    public int CalcWidth()
    {
    	width = Math.abs(x1 - x2);
        return width;
    }
    
    public int CalcHeight()
    {
    	height = Math.abs(y1 - y2 );
        return height;
    }
	
	
	
	public boolean isInside(int circle_x, int circle_y,  int rad, int x, int y) 
	{ 
		// Compare radius of circle with 
		// 	distance of its center from 
		// given point 
		if ((x - circle_x) * (x - circle_x) + (y - circle_y) * (y - circle_y) <= rad * rad) 
			return true; 
		else
			return false; 
	} 
	
	public void saveTo(PrintWriter aFile) 
	{
	        aFile.println( getX1() );
	        aFile.println( getY1() );
	        aFile.println( getX2() );
	        aFile.println( getY2() );
	        aFile.println( get_diametre() );
	        aFile.println( getWidth() );
	        aFile.println( getHeight() );
	        aFile.println(selected);
	}
	
    public static CircleObj loadFrom(BufferedReader aFile) throws IOException 
    {
    	CircleObj   aCircle = new CircleObj();
    	aCircle.setX1( Integer.parseInt(aFile.readLine()) );
    	aCircle.setY1( Integer.parseInt(aFile.readLine()) );
    	aCircle.setX2( Integer.parseInt(aFile.readLine()) );
    	aCircle.setY2( Integer.parseInt(aFile.readLine()) );
    	aCircle.set_diametre( Integer.parseInt(aFile.readLine()) );
    	aCircle.setWidth( Integer.parseInt(aFile.readLine()) );
    	aCircle.setHeight( Integer.parseInt(aFile.readLine()) );
    	aCircle.setSelected(Boolean.valueOf(aFile.readLine()).booleanValue());
        return aCircle;
    }
	
}
