예제 #1
0
  /**
   * Returns a descendant of this Figure such that the Figure returned contains the point (x, y),
   * and is accepted by the given TreeSearch. Returns <code>null</code> if none found.
   *
   * @param x The X coordinate
   * @param y The Y coordinate
   * @param search the TreeSearch
   * @return The descendant Figure at (x,y)
   */
  protected IFigure findDescendantAtExcluding(int x, int y, TreeSearch search) {
    PRIVATE_POINT.setLocation(x, y);
    translateFromParent(PRIVATE_POINT);
    if (!getClientArea(Rectangle.SINGLETON).contains(PRIVATE_POINT)) return null;

    x = PRIVATE_POINT.x;
    y = PRIVATE_POINT.y;
    IFigure fig;
    for (int i = children.size(); i > 0; ) {
      i--;
      fig = (IFigure) children.get(i);
      if (fig.isVisible()) {
        fig = fig.findFigureAt(x, y, search);
        if (fig != null) return fig;
      }
    }
    // No descendants were found
    return null;
  }