import y.layout.NodeLayout;

/**
 * Interface implemented by classes responsible for calculating an inclusion
 * test for the visual representation of an associated node.
 * This interface is especially useful in conjunction with the
 * {@link demo.view.layout.PortCalculator2} {@link y.layout.LayoutStage}.
 *
 * @see demo.view.layout.PortCalculator2
 * @author Thomas Behr
 */
public interface ContainsTest {
  /**
   * Key to be used when registering a DataProvider to a graph instance that
   * provides for each Node object in a graph an <code>ContainsTest</code>
   * instance that is configured to calculate the appropriate inclusion test.
   */
  public static final Object CONTAINS_TEST_DPKEY =
          "ContainsTest.CONTAINS_TEST_DPKEY";

  /**
   * Determines whether the visual representation of the associated node would
   * contain the point <code>(x, y)</code> if the node's bounding box
   * corresponds to the given <code>NodeLayout</code> instance.
   *
   * @param nl   the associated node's current bounding box
   * @param x    the x-coordinate of the point to be tested for inclusion
   * @param y    the y-coordinate of the point to be tested for inclusion
   * @return <code>true</code> iff the visual representation of the associated
   * node contains the point <code>(x,y)</code>; <code>false</code> otherwise.
   */
  public boolean contains( NodeLayout nl, double x, double y );
}
