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

package rec.fsm;


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

public class EdgeNamer extends Recognizer
{
  int cur_name = 0;

  public EdgeNamer()
  {
  }
  
  /**
   * Each new stroke generated gets put into the pipe here.  It will
   * remove and add objects to the 'out' target as it deems fit.
   *
   * @return true if changes were made
   */
  public boolean recognize( Surface s, Widget w )
  {
    /****** NOTE-- this is a bad thing since it changes an object
     without saving a copy.  This will clobber (possibly) the
     various undo features.
     */
    final Edge n = (Edge)w;

    if ( n.name == null )
      {
	final String the_name = "" + ( cur_name++ % 3 );
	
	//Console.writeln( "Naming Edge " + the_name );

	n.setName( the_name );

	return false; // we are not wanting to rerecognize anything.
      }
    else
      return false;
  }
  
  public Iterator getInputTypes()
  {
    Vector v = new Vector();
    
    v.addElement( "rec.fsm.Edge" );
    
    return v.iterator();
  }

  public Iterator getOutputTypes() 
  {
    return getInputTypes();
  }


}
