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

////////////////////////////////////////////////////////////////////////////////
//
// FILE:	HexagonRecognizer.java
//
// AUTHOR:	Manoj D. Muzumdar
//		archon@ai.mit.edu
//
// DATE:	Apr 99
//
// COPYRIGHT:	Massachusetts Institute of Technology
//		All rights reserved.
//
// PURPOSE:     Hexagon recognition
//
// HISTORY:     Apr 99  archon  created
//
////////////////////////////////////////////////////////////////////////////////

package rec.core.recognizers;

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


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

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

  public boolean recognize( Surface s, Widget w )
  {
    WLine l = (WLine)w;

    PolygonInfo pi = null;

    if( (pi = PolygonParser.parse( 6, s, l )) != null ) {

      WHexagon t = new WHexagon( pi );

      for( int i = 0; i < 6; ++i )
	s.removeWidget( pi.getLineAt( i ) );
      s.addWidget( t );

      return( true );
    }

    return( false );
  }

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

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

    return( v.iterator() );
  }

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

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

    return( v.iterator() );
  }
}

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