当前位置: 首页>>代码示例>>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;未经允许,请勿转载。