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

// $Id: SimQuadRecognizer.java,v 1.6 2003/03/06 00:40:41 moltmans Exp $
// Time-stamp: <2000-03-11 18:59:37 moltmans>
package rec.simulate.recognizers;


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

public class SimQuadRecognizer extends Recognizer
{
  public SimQuadRecognizer()
  {
  }

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

  public boolean recognize( Surface s, Widget w )
  {
   
    WQuadrilateral q = (WQuadrilateral)w;
    
    // we have the surface create the new object, since it knows what 
    // specific type of simulatable object we are dealing with.
    // that way this function doesn't change no matter how we are simulating
    WSimQuadrilateral q_sim = ((SimulateSurface)s).makeSimQuad( q );
    s.replaceWidget( q, q_sim );
    // simulate is called after every recognition.  
    // ***  this will need to change soon.  ***
    // this now occurs in the simulate button
    //((SimulateSurface)s).simulate();
    
    return ( true );
   
  }

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

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

    return( v.iterator() );
  }

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

    v.addElement( "rec.simulate.widgets.WSimQuadrilateral" );

    return( v.iterator() );
  }
}
