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

// $Id: DeleteTargetRecognizer.java,v 1.6 2003/03/06 00:40:48 moltmans Exp $
// Time-stamp: <2000-03-16 20:24:57 moltmans>
package rec.core.recognizers;



////////////////////////////////////////////////////////////////////////////////
//
// FILE:	DeleteTargetRecognizer.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.*;
import rec.core.widgets.*;


public class DeleteTargetRecognizer extends TargetRecognizer
{
  public DeleteTargetRecognizer( )
  {
  }

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

  public boolean recognize( Surface s, Widget w )
  {
    Console.writeln( "Checking for deletion.");

    final WClick click = (WClick)w;

    WGroup group = (WGroup)((WSelection)getTarget()).getWidget();
    
    if ( group.includes( click.getLocation().getCenter(), 5 ) ) {
      WDeletion dl = new WDeletion( group );
      s.replaceWidget( w, dl );
      return true;
    }
    return false;
  }

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

    v.addElement( "rec.core.widgets.WClick" );

    return( v.iterator() );
  }

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

    v.addElement( "rec.core.widgets.WDeletion" );

    return( v.iterator() );
  }
}

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