예제 #1
0
  /**
   * Searches this Figure's children for the deepest descendant for which {@link
   * #isMouseEventTarget()} returns <code>true</code> and returns that descendant or <code>null
   * </code> if none found.
   *
   * @see #findMouseEventTargetAt(int, int)
   * @param x The X coordinate
   * @param y The Y coordinate
   * @return The deepest descendant for which isMouseEventTarget() returns true
   */
  protected IFigure findMouseEventTargetInDescendantsAt(int x, int y) {
    PRIVATE_POINT.setLocation(x, y);
    translateFromParent(PRIVATE_POINT);

    if (!getClientArea(Rectangle.SINGLETON).contains(PRIVATE_POINT)) return null;

    IFigure fig;
    for (int i = children.size(); i > 0; ) {
      i--;
      fig = (IFigure) children.get(i);
      if (fig.isVisible() && fig.isEnabled()) {
        if (fig.containsPoint(PRIVATE_POINT.x, PRIVATE_POINT.y)) {
          fig = fig.findMouseEventTargetAt(PRIVATE_POINT.x, PRIVATE_POINT.y);
          return fig;
        }
      }
    }
    return null;
  }