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

package rec.core.recognizers;

import edu.mit.sketch.geom.Ellipse;
import edu.mit.sketch.geom.Point;
import edu.mit.sketch.geom.Polygon;
import edu.mit.sketch.toolkit.SimpleClassifier;
import edu.mit.sketch.toolkit.SimpleClassifier2;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Vector;
import rec.core.widgets.WCircle;
import rec.core.widgets.WLine;
import rec.core.widgets.WToolkitArc;
import rec.geo.GPoint;
import rec.sys.Recognizer;
import rec.sys.Squiggle;
import rec.sys.Surface;
import rec.sys.Widget;


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

    public boolean recognize( Surface s, Widget w )
    {
	Squiggle squiggle = (Squiggle)w;
	
	SimpleClassifier2 c = (SimpleClassifier2) squiggle.getClassifier();
	
	// the classifier may be null if there was not enough data for it to operate
	if( c == null ) {
	    return false;
	}
	
	if( c.isArc() ) {
	    WToolkitArc arc = new WToolkitArc(c.getArcApproximation() );
	    s.replaceWidget( squiggle, arc );
	    return true;
	}
	
	return false;
    }
    
    public Iterator getInputTypes()
    {
	Vector v = new Vector();
	
	v.addElement( "rec.sys.Squiggle" );
	
	return( v.iterator() );
    }
    
    public Iterator getOutputTypes()
    {
	Vector v = new Vector();
	
	v.addElement( "rec.core.widgets.WArc" );
	
	return( v.iterator() );
    }
    
}

