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

package rec.core;


////////////////////////////////////////////////////////////////////////////////
//
// FILE:        CopyTargetRecognizer.java
//
// AUTHOR:	Manoj D. Muzumdar
//		archon@ai.mit.edu
//
// DATE:	October, 1998
//
// COPYRIGHT:	Massachusetts Institute of Technology
//		All rights reserved.
//
// PURPOSE:	Drawing recognition
//
// HISTORY:     October, 1998
//              MDM
//              adapted from ModifyModeRecognizer
//
////////////////////////////////////////////////////////////////////////////////


import java.util.*;
import rec.sys.*;
import rec.util.*;

public class CopyTargetRecognizer extends TargetRecognizer
{

  public boolean recognize( Surface s, Widget w )
  {
    if( w instanceof rec.sys.Squiggle ) {

      rec.sys.Squiggle st = (rec.sys.Squiggle)w;

      if( VeryLooseCircleRecognizer.isCircle( st ) ) {

	s.removeWidget( st );

	WCircle c = new WCircle( st.getBounds() );

	VisibleWidget pw = (VisibleWidget)getTarget();
	
	//Console.writeln( "Going to clone: " + pw );
	VisibleWidget cw = (VisibleWidget)pw.clone();
	//Console.writeln( "done cloning, now have: " + cw );

	cw.move( c.getCenter() );
	s.addWidget( cw );

	return( true );
      }
    }

    return( false );
  }

  public Iterator getInputTypes()
  {
    Vector v = new Vector();

    v.addElement( "rec.sys.Squiggle" );

    return( v.iterator() );
  }

  public Iterator getOutputTypes()
  {
    Vector v = new Vector();

    v.addElement( "rec.sys.Widget" );

    return( v.iterator() );
  }
}

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