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

package rec.simulate.recognizers;

// -*-Mode: Java-*- 
// SimRectRecognizer.java -- 
// Author: Christine Alvarado <calvarad@ai.mit.edu> 
// Maintainer: Christine Alvarado <calvarad@ai.mit.edu> 
// Version: 
// Created: <Mon Mar 29 16:58:39 1999> 
// Time-stamp: <> 
// Keywords: 

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 SimRectRecognizer extends Recognizer
{
  public SimRectRecognizer()
  {
  }

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

  public boolean recognize( Surface s, Widget w )
  {
   
    WRectangle r = (WRectangle)w;
    
    // rectangles become simulatable automatically
    // this does not involve replacing anything on the surface, however.
    // although in the future, we may want to take it out of the widget
    // registry and control it from the simulate registry

    Console.writeln( "simulatable rectangle detected" );
    
    // 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

    WSimRectangle r_sim = ((SimulateSurface)s).makeSimRect( r );
    s.replaceWidget( r, r_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.WRectangle" );
    v.addElement( "rec.core.widgets.WSquare" );
    
    return( v.iterator() );
  }

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

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

    return( v.iterator() );
  }
}
