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

package rec.simulate.recognizers;

// -*-Mode: Java-*- 
// ForceRecognizer.java -- 
// Author: Christine Alvarado <calvarad@ai.mit.edu> 
// Maintainer: Christine Alvarado <calvarad@ai.mit.edu> 
// Version: 
// Created: <Thu May 20 13:29:19 1999> 
// Time-stamp: <> 
// Keywords: 

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

import rec.simulate.widgets.*;
import rec.simulate.*;
import rec.meche.WMForce;

/**
 * This recognizes forces from Arrowheads.
 */
public class SimForce2Recognizer extends Recognizer
{
  public SimForce2Recognizer()
  {
  }

  public boolean recognize( Surface s, Widget w )
  {
    Arrowhead ah = (Arrowhead)w;
    
    GSegment wl = ah.getLine().getLine();
    WMForce wmf =  new WMForce( wl.getMidpoint(),
				Geometry.angle( wl.getTailPoint(),
						wl.getHeadPoint() ),
				wl.size(),
				null );

    HashSet st = new HashSet();
    st.add( ah );
    st.add( ah.getLine() );
    s.replaceWidget( st, wmf, true );

    return true;
  }

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

    v.addElement( "rec.simulate.recognizers.Arrowhead" );

    return( v.iterator() );
  }

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

    v.addElement( "rec.meche.WMForce" );

    return( v.iterator() );
  }

}
