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

package rec.geo;

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

public class GToolkitSpiral extends GShape
{
    public GToolkitSpiral(Spiral spiral)
    {
	m_spiral = spiral;

    }

    public GToolkitSpiral( GToolkitSpiral gs )
    {
	m_spiral = (Spiral)gs.m_spiral.copy();
    }
    
    public Spiral getToolkitSpiral(){
	return (Spiral)m_spiral.copy();
    }

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

    public void reflect()
    {
	//not implemented
    }
    
    public void translate( double dx, double dy )
    {
	m_spiral.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_spiral.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_spiral.paint( g );
    }

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

    public boolean includes( GPoint gp )
    {
	return m_spiral.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_spiral.pointIsOn(new Point((int)gp.x, 
					(int)gp.y), 
			      (int)offset));
  }

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

  public double getRotations()
  {
      return m_spiral.getRotations();
  }

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

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

    private Spiral m_spiral; 
}

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

