當前位置: 首頁>>代碼示例>>Java>>正文


Java TreePath.getPathCount方法代碼示例

本文整理匯總了Java中javax.swing.tree.TreePath.getPathCount方法的典型用法代碼示例。如果您正苦於以下問題:Java TreePath.getPathCount方法的具體用法?Java TreePath.getPathCount怎麽用?Java TreePath.getPathCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.tree.TreePath的用法示例。


在下文中一共展示了TreePath.getPathCount方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: hasAsParent

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
@Override
public boolean hasAsParent(TreePath path, int indexInParent) {
    Object[] comps = path.getPath();
    Object node;
    for (int i = 1; i < comps.length; i++) {
        if (arr.length < path.getPathCount() - 1) {
            return false;
        }
        /*
        if(!comparator.equals(comps[i].toString(), arr[i - 1])) {
            return false;
        }
         */
        if (indices.length >= path.getPathCount() - 1) {
            node = chooseSubnode(comps[i - 1], arr[i - 1], indices[i - 1], comparator);
        } else {
            node = chooseSubnode(comps[i - 1], arr[i - 1], comparator);
        }
        if (node != comps[i]) {
            return false;
        }
    }
    return true;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:JTreeOperator.java

示例2: hasAsParent

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
/**
 * implementation of JTreeOperator.TreePathChooser
 *
 * @param path TreePath
 * @param indexInParent int
 * @return boolean
 */
@Override
public boolean hasAsParent(TreePath path, int indexInParent) {
    if (path.getPathCount() <= parentPathCount) {
        return path.isDescendant(parentPath);
    }
    if (arr.length + parentPathCount < path.getPathCount()) {
        return (false);
    }
    if (indices.length >= path.getPathCount() - parentPathCount
            && indices[path.getPathCount() - parentPathCount - 1] != indexInParent) {
        return (false);
    }
    Object[] comps = path.getPath();
    for (int i = parentPathCount; i < comps.length; i++) {
        if (!comparator.equals(comps[i].toString(), arr[i - parentPathCount])) {
            return (false);
        }
    }
    return (true);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:Node.java

示例3: actionProduced

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
@Override
public Object actionProduced(Object anObject) {
    TreePath lrPath;

    Point lrFindPoint = findCell(name, getRowsToSearch(), new int[]{getTreeColumnIndex()}, index);

    //no cell found
    if (lrFindPoint.equals(new Point(-1, -1))) {
        return null;
    }

    //y is row, x is not important since we're asking for a row in the tree
    lrPath = getOutline().getLayoutCache().getPathForRow(lrFindPoint.y);

    //path for the specified row not found or it is not visible
    if (lrPath == null) {
        return null;
    }

    //found a cell that is a not a direct child of the parent path
    if (lrPath.getPathCount() != parentPath.getPathCount() + 1) {
        return null;
    }

    return lrPath;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:OutlineOperator.java

示例4: collapseAll

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
public void collapseAll() {
    if (tree != null) try {
        markExpansionTransaction();
        
        TreePath selected = tree.getSelectionPath();
        if (selected != null && selected.getPathCount() > 2) {
            tree.setSelectionPath(new TreePath(new Object[] {
                selected.getPathComponent(0), selected.getPathComponent(1)
            }));
        }
        
        TreeModel tmodel = tree.getModel();
        Object root = tmodel.getRoot();
        
        int nchildren = tmodel.getChildCount(root);
        for (int i = 0; i < nchildren; i++)
            tree.collapsePath(new TreePath(new Object[] {
                root, tmodel.getChild(root, i)
            }));
        
        tree.resetExpandedNodes();
    
    } finally {
        clearExpansionTransaction();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:ProfilerTreeTable.java

示例5: keyPressed

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {
        TreePath[] paths = getSelectionPaths();

        if ((paths != null) && (paths.length > 0)) {
            Collection changedNodes = new ArrayList();

            for (int i = 0; i < paths.length; i++) {
                TreePath path = paths[i];

                if ((path != null) && (path.getPathCount() > 0) && path.getLastPathComponent() instanceof CheckTreeNode
                        && (((CheckTreeNode) path.getLastPathComponent()).isLeaf() || (i == (paths.length - 1)))) {
                    fireNodeToggled(path, true);
                }

                changedNodes.addAll(togglePathState(path));
                fireNodeToggled(path, false);
            }

            treeDidChange();
            fireCheckTreeChanged(changedNodes);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:JCheckTree.java

示例6: removeSelectionPaths

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
@Override
public void removeSelectionPaths(TreePath[] paths) {
    for (int i = 0; i < paths.length; i++) {
        TreePath path = paths[i];
        if (path.getPathCount() == 1) {
            super.removeSelectionPaths(new TreePath[]{path});
        } else {
            toggleRemoveSelection(path);
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:12,代碼來源:CheckTreeSelectionModel.java

示例7: expandSelection

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
/**
 * Tries to expand nodes selected in the explorer manager.
 */
private void expandSelection() {
    Node[] arr = manager.getSelectedNodes ();
    for (int i = 0; i < arr.length; i++) {
        if ( (arr[i].getParentNode() == null) && (! outline.isRootVisible())) {
            // don't try to show root if it is invisible
            continue;
        }
        TreeNode tn = Visualizer.findVisualizer(arr[i]);
        if (tn != null) {
            ArrayList<TreeNode> al = new ArrayList<TreeNode> ();
            while (tn != null) {
                al.add(tn);
                tn = tn.getParent();
            }
            Collections.reverse(al);
            TreePath tp = new TreePath(al.toArray());
            Deque<TreePath> pathsStack = new ArrayDeque<TreePath>(al.size());
            while ((tp != null) && (tp.getPathCount() > 0)) {
                tp = tp.getParentPath();
                if (tp != null) {
                    pathsStack.addFirst(tp);
                }
            }
            for (TreePath etp : pathsStack) {
                outline.expandPath(etp);
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:OutlineView.java

示例8: isEditEvent

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
private boolean isEditEvent(int row, int column, MouseEvent me) {
    if (me.getClickCount() > 1) {
        return true;
    }
    boolean noModifiers = me.getModifiersEx() == MouseEvent.BUTTON1_DOWN_MASK;
    if (lastEditPosition != null && selectedRow == row && noModifiers &&
        lastEditPosition[0] == row && lastEditPosition[1] == column) {

        int handleWidth = DefaultOutlineCellRenderer.getExpansionHandleWidth();
        Insets ins = getInsets();
        TreePath path = getLayoutCache().getPathForRow(convertRowIndexToModel(row));
        int nd = path.getPathCount() - (isRootVisible() ? 1 : 2);
        if (nd < 0) {
            nd = 0;
        }
        int handleStart = ins.left + (nd * DefaultOutlineCellRenderer.getNestingWidth());
        int handleEnd = ins.left + handleStart + handleWidth;
        // Translate 'x' to position of column if non-0:
        int columnStart = getCellRect(row, column, false).x;
        handleStart += columnStart;
        handleEnd += columnStart;
        if (me.getX() >= handleEnd) {
            lastEditPosition = null;
            return true;
        }
    }
    lastEditPosition = new int[] { row, column };
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:Outline.java

示例9: convertPath

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
private static String convertPath(TreePath path) {
    if (path == null) {
        return null;
    }
    int pathCount = path.getPathCount();
    if (pathCount < 2) {
        return "";
    }
    StringBuilder bufResult = new StringBuilder(path.getPathComponent(1).toString());
    for (int i = 2; i < pathCount; i++) {
        bufResult.append("|").append(path.getPathComponent(i).toString());
    }
    return bufResult.toString();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:Node.java

示例10: getRowPathStr

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
private String getRowPathStr(TreePath trp) {
	String pathStr = "";
	if (trp.getPathCount() > 1) {
		for (int i = 1; i < trp.getPathCount(); i++) {
			DefaultMutableTreeNode node = (DefaultMutableTreeNode) trp.getPathComponent(i);
			TreeNodeUserObject userObject = (TreeNodeUserObject) node.getUserObject();
			pathStr = pathStr + userObject.getOriginalName() + "/";
		}
	}
	return pathStr;
}
 
開發者ID:KevinPriv,項目名稱:Luyten4Forge,代碼行數:12,代碼來源:TreeUtil.java

示例11: getMaxValue

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
private long getMaxValue(int row, int val) {
    TreePath path = treeTable.getPathForRow(row);
    if (path == null) return Long.MIN_VALUE; // TODO: prevents NPE from export but doesn't provide the actual value!
    if (path.getPathCount() < 2) return 1;
    
    PrestimeCPUCCTNode node = (PrestimeCPUCCTNode)path.getPathComponent(1);
    if (val == 0) return Math.abs(node.getTotalTime0());
    else if (val == 1) return Math.abs(node.getTotalTime1());
    else return Math.abs(node.getNCalls());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:CPUTreeTableView.java

示例12: getSimilarPath

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
private TreePath getSimilarPath(TreePath oldPath) {
    if (oldPath == null || oldPath.getPathCount() < 1) return null;

    TreeModel currentModel = getModel();
    Object currentRoot = currentModel.getRoot();
    if (!currentRoot.equals(oldPath.getPathComponent(0))) return null;

    TreePath p = new TreePath(currentRoot);
    Object[] op = oldPath.getPath();
    Object n = currentRoot;

    for (int i = 1; i < op.length; i++) {
        Object nn = null;

        for (int ii = 0; ii < currentModel.getChildCount(n); ii++) {
            Object c = currentModel.getChild(n, ii);
            if (c.equals(op[i])) {
                nn = c;
                break;
            }
        }

        if (nn == null) return null;

        n = nn;
        p = p.pathByAddingChild(n);
    }

    return p;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:ProfilerTreeTable.java

示例13: actionPerformed

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent event) {
	TreePath path = getSelectionPath();
	if (listener != null && path != null && path.getPathCount() == 2) {
		listener.deleteRequested(new Event(path));
	}
	ProjectExplorer.this.requestFocus();
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:9,代碼來源:ProjectExplorer.java

示例14: getRowPathStr

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
private String getRowPathStr(TreePath trp) {
    String pathStr = "";
    if (trp.getPathCount() > 1) {
        for (int i = 1; i < trp.getPathCount(); i++) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) trp.getPathComponent(i);
            TreeNodeUserObject userObject = (TreeNodeUserObject) node.getUserObject();
            pathStr = pathStr + userObject.getOriginalName() + "/";
        }
    }
    return pathStr;
}
 
開發者ID:hsswx7,項目名稱:CS4500GroupProject,代碼行數:12,代碼來源:TreeUtil.java

示例15: isRootSelected

import javax.swing.tree.TreePath; //導入方法依賴的package包/類
public Boolean isRootSelected() {
    TreePath path = tree.getSelectionPath();
    if (path != null) {
        return path.getPathCount() == 1;
    }
    return true;
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:8,代碼來源:ObjectTree.java


注:本文中的javax.swing.tree.TreePath.getPathCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。