Example usage for javax.swing JTree isVisible

List of usage examples for javax.swing JTree isVisible

Introduction

In this page you can find the example usage for javax.swing JTree isVisible.

Prototype

public boolean isVisible(TreePath path) 

Source Link

Document

Returns true if the value identified by path is currently viewable, which means it is either the root or all of its parents are expanded.

Usage

From source file:Main.java

public static void visitAllExpandedNodes(JTree tree, TreePath parent) {
    if (!tree.isVisible(parent)) {
        return;/*from  ww  w.j  av  a  2  s.c  o  m*/
    }
    TreeNode node = (TreeNode) parent.getLastPathComponent();
    System.out.println(node);

    if (node.getChildCount() >= 0) {
        for (Enumeration e = node.children(); e.hasMoreElements();) {
            TreeNode n = (TreeNode) e.nextElement();
            TreePath path = parent.pathByAddingChild(n);
            visitAllExpandedNodes(tree, path);
        }
    }
}

From source file:Main.java

public void getPaths(JTree tree, TreePath parent, boolean expanded, List<TreePath> list) {
    if (expanded && !tree.isVisible(parent)) {
        return;//from  w w w  .  ja  v  a  2  s  .  c o m
    }
    list.add(parent);
    TreeNode node = (TreeNode) parent.getLastPathComponent();
    if (node.getChildCount() >= 0) {
        for (Enumeration e = node.children(); e.hasMoreElements();) {
            TreeNode n = (TreeNode) e.nextElement();
            TreePath path = parent.pathByAddingChild(n);
            getPaths(tree, path, expanded, list);
        }
    }
}

From source file:it.unibas.spicygui.controllo.datasource.operators.CreaWidgetAlberi.java

private void scansioneAlbero(JTree albero, Component source, Component target, boolean sourceFlag) {
    //VEcchio codice che mette widget solo per le foglie
    //        for (int i = 0; i < listaFoglie.size(); i++) {
    //            int tmp = (Integer) listaFoglie.get(i);
    for (int i = 0; i < albero.getRowCount(); i++) {
        TreePath treePath = albero.getPathForRow(i);
        if (treePath != null && albero.isVisible(treePath)) {
            if (logger.isTraceEnabled()) {
                logger.trace("punto trovato: " + albero.getPathBounds(treePath).getLocation());
            }//from w  w  w.  j a  va2 s. c  om
            Point convertedPoint = SwingUtilities.convertPoint(source,
                    albero.getPathBounds(treePath).getLocation(), target);
            createWidget(convertedPoint, albero, treePath, sourceFlag);
            if (logger.isTraceEnabled()) {
                logger.trace("punto convertito: " + convertedPoint);
            }
        }
    }
    contatore = -1;
    listaFoglie = new ArrayList();
}