// (c) MIT 2003.  All rights reserved.

package rec.geo;

import java.awt.*;
import java.awt.geom.*;
import rec.util.*;
import edu.mit.sketch.geom.Arc;
import edu.mit.sketch.geom.Point;

public class GToolkitArc extends GShape
{
    public GToolkitArc(Arc arc)
    {
	m_arc = arc;

    }

    public GToolkitArc( GToolkitArc ga )
    {
	m_arc = ga.m_arc;
    }
    
    public Arc getToolkitArc(){
	return m_arc;
    }

    public GShape copy()
    {
	return( new GToolkitArc( this ) );
    }

    public void reflect()
    {
	//not implemented
    }
    
    public void translate( double dx, double dy )
    {
	m_arc.translate( dx, dy );
    }

    public void rotate( GPoint gp, double radians )
    {
	//not implemented

	//m_arc.transform( AffineTransform.getRotateInstance(radians,
	//					   gp.x,
	//					   gp.y));
    }

    public double size()
    {
	//not implemented
	return 0;
    }
    
    public void resize( double scaleFactor )
    { 
	//not implemented
	// m_arc.transform( AffineTransform.getScaleInstance(scaleFactor, 
	//    						  scaleFactor));
    }
    
    public Rectangle getBounds()
    {
	edu.mit.sketch.geom.Rectangle rec = m_arc.getRectangularBounds();
	Point center = rec.getCenter();
	int height = (int) rec.getHeight();
	int width = (int) rec.getWidth();
	Point upperleft = new Point((center.x - width/2), 
				    (center.y - height/2));
	return new Rectangle(upperleft.x, upperleft.y, width, height);

    }

    public void display( Graphics g )
    {
	m_arc.paint( g );
    }

    public GPoint getPoint( double radians )
    {
	//NOT IMPLEMENTED
	return( new GPoint( 0,0));
    }

    public boolean includes( GPoint gp )
    {
	return m_arc.pointIsOn(new Point((int)gp.x, 
					 (int)gp.y), 
			       5);
    }

  public boolean contains( GPoint gp )
  {
    Assert.error( "Not implemented" );
    return false;
  }

  public boolean includes( GPoint gp, double offset )
  {
      
      return( m_arc.pointIsOn(new Point((int)gp.x, 
					(int)gp.y), 
			      (int)offset));
  }

  public GPoint getCenter()
  {
      Point center = m_arc.getCenter();
      return new GPoint (center.x, center.y);
  }

  public GPoint getHead()
  {
      Point point = m_arc.getHeadPoint();
      return new GPoint(point.x, point.y); 
  }

  public GPoint getTail()
  {
      Point point = m_arc.getTailPoint();
      return new GPoint(point.x, point.y); 
  }

  public boolean getClockwise()
  {
      return m_arc.getClockwise();
  }

  public int hashCode()
  {
      return (int) (getHead().x + getHead().y 
		    + getTail().x + getTail().y);
  }

    private Arc m_arc; 
}

////////////////////////////////////////////////////////////////////////////////

