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

// $Id: QuadFromPolyRecognizer.java,v 1.5 2003/03/06 00:40:47 moltmans Exp $
// Time-stamp: <2000-03-11 18:54:46 moltmans>
package rec.core.recognizers;



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

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


  public boolean recognize( Surface s, Widget w )
  {
    WPolygon pl = (WPolygon)w;

    if ( pl.numSides() == 4 )
      {
	WQuadrilateral q = new WQuadrilateral( (WPolygon)pl );

	s.replaceWidget( w, q );
	
	return true;
      }

    return( false );
  }

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

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

    return( v.iterator() );
  }

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

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

    return( v.iterator() );
  }
}

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