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

package rec.simulate.recognizers;

import rec.geo.*;
import java.util.*;
import java.awt.*;
import rec.util.*;
import rec.sys.*;
import rec.core.widgets.*;
import rec.meche.Estimator;
import rec.meche.WMSpring;
import rec.simulate.widgets.*;
import rec.simulate.*;

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

    public boolean recognize(Surface s, Widget w)
    {

	if (w instanceof WToolkitSpiral){
	    
	    WToolkitSpiral spiral = (WToolkitSpiral) w;
	    GToolkitSpiral gSpiral = spiral.getSpiral();
	    	    
	    SimulateSurface SimS = (SimulateSurface) s;
	    
	    WSimRotationalSpring rotationalSpring = 
		SimS.makeRotationalSpring(gSpiral);
	
	    HashSet set = new HashSet();
	    
	    set.add(spiral);
	    
	    s.replaceWidget(set, rotationalSpring, true);
	    
	    return true;
	}

	//shouldn't happen
	return false;
	
    }

    public Iterator getInputTypes()
    {
	Vector v = new Vector();
	
	v.addElement("rec.core.widgets.WToolkitSpiral");

	return(v.iterator());
    }

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

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

	return(v.iterator());
    }
}
