Example usage for javax.swing.tree TreePath isDescendant

List of usage examples for javax.swing.tree TreePath isDescendant

Introduction

In this page you can find the example usage for javax.swing.tree TreePath isDescendant.

Prototype

public boolean isDescendant(TreePath aTreePath) 

Source Link

Document

Returns true if aTreePath is a descendant of this TreePath .

Usage

From source file:mobac.gui.components.JMapSourceTree.java

/**
 * Check if the mouse cursor was over a clickable node
 * /* w  w  w. j a v  a2  s. c o m*/
 * @param eventPoint
 *            - a mouse position coordinates
 * @return true if a node was clickable, false otherwise
 */
public boolean isLocationClickable(Point eventPoint) {
    int x = (int) eventPoint.getX();
    int y = (int) eventPoint.getY();
    TreePath treePathForXY = getPathForLocation(x, y);

    // If a node is an ancestor of a currently selected node - it can't be closed, so it is unclickable.
    if (treePathForXY != null && treePathForXY.isDescendant(findTreePathOfMapSource(selectedMapSource))) {
        return false;
    }

    boolean isInside = false;
    if (treePathForXY != null) {
        Rectangle pathBounds = this.getPathBounds(treePathForXY);
        isInside = pathBounds.contains(eventPoint);
    }
    return isInside;
}