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

// $Id: SetFilter.java,v 1.3 2003/03/06 00:40:39 moltmans Exp $
// Time-stamp: <2000-03-11 18:59:37 moltmans>
package rec.sys;


import java.util.*;

/**
 * This is used by the GeometryCalculator and is applied to the
 *   list of visible widgets to grab a useful widget as defined by
 *   this function.
 *
 */
public class SetFilter implements GeoFunction
{
  HashSet set;

  public SetFilter()
  {
    this( null, null );
  }

  public SetFilter( GeoFunction f1 )
  {
    this( f1, null );
  }

  public SetFilter( GeoFunction f1, GeoFunction f2 )
  {
    set = new HashSet();
    if ( f1 != null )
      set.add( f1 );
    if ( f2 != null )
      set.add( f2 );
  }

  /**
   * Return if this widget is not the me wid.
   */
  public boolean check( VisibleWidget w )
  {
    Iterator it = set.iterator();
    while( it.hasNext() )
      {
	if ( ! ((GeoFunction)it.next()).check( w ) )
	  return false;
      }

    return true;
  }



}

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