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

////////////////////////////////////////////////////////////////////////////////
//
// FILE:	GShape.java
//
// AUTHOR:	Manoj D. Muzumdar
//		archon@ai.mit.edu
//
// DATE:	06-XX-98
//
// COPYRIGHT:	Massachusetts Institute of Technology
//		All rights reserved.
//
// PURPOSE:	Geometric modeling
//
// HISTORY:     11-06-98 archon
//              Made mutable
//
////////////////////////////////////////////////////////////////////////////////

package rec.geo;

import java.awt.*;
import rec.util.*;
import java.io.*;

/**
 * A GShape is an mutable representation of a geometric shape.
 */
public abstract class GShape implements Cloneable, Displayable, Serializable
{
  public abstract GShape copy();
  public abstract void reflect();
  public abstract void translate( double dx, double dy );

  /**
   * @param gp     The point of rotation.
   * @param angle  The angle in radians.
   */
  public abstract void rotate( GPoint gp, double angle );

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

  public abstract double size();
  public abstract void resize( double scaleFactor );

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

  public abstract Rectangle getBounds();

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

  /**
   * Translate by the vector defined by gp2 - gp1
   */
  public final void translate( GPoint gp1, GPoint gp2 )
  {
    translate( gp2.x - gp1.x, gp2.y - gp1.y );
  }

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

  /**
   * Is gp on the shape, as opposed to contained within the region
   * defined by shape.
   **/
  public abstract boolean includes( GPoint gp );
  /**
   * Is gp on the border of shape, as opposed to contained within the
   * region defined by shape.
   **/
  public abstract boolean includes( GPoint gp, double offset );

  /**
   * Is gp contained in the region of the shape?
   **/
  public abstract boolean contains( GPoint gp );

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

  public final Object clone()
  {
    return( copy() );
  }

  public boolean equals( Object o )
  {
    throw new RuntimeException( "equals not defined" );
  }

  public int hashCode( )
  {
    throw new RuntimeException( "hashcode not been overridden" );
  }
}

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