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

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



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

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


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

    if ( pl.numSides() == 3 )
      {
	WTriangle q = new WTriangle( (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.WTriangle" );

    return( v.iterator() );
  }
}

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