本文整理匯總了Java中javax.swing.tree.TreePath.getPathCount方法的典型用法代碼示例。如果您正苦於以下問題:Java TreePath.getPathCount方法的具體用法?Java TreePath.getPathCount怎麽用?Java TreePath.getPathCount使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.tree.TreePath的用法示例。
在下文中一共展示了TreePath.getPathCount方法的19個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。
示例1: hasAsParent
點讚 3
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,
示例2: hasAsParent
點讚 3
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,
示例3: actionProduced
點讚 3
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,
示例4: collapseAll
點讚 3
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,
示例5: keyPressed
點讚 3
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,
示例6: removeSelectionPaths
點讚 2
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,
示例7: expandSelection
點讚 2
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 al = new ArrayList ();
while (tn != null) {
al.add(tn);
tn = tn.getParent();
}
Collections.reverse(al);
TreePath tp = new TreePath(al.toArray());
Deque pathsStack = new ArrayDeque(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,
示例8: isEditEvent
點讚 2
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,
示例9: convertPath
點讚 2
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,
示例10: getRowPathStr
點讚 2
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,
示例11: getMaxValue
點讚 2
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,
示例12: getSimilarPath
點讚 2
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,
示例13: actionPerformed
點讚 2
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,
示例14: getRowPathStr
點讚 2
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,
示例15: isRootSelected
點讚 2
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,
示例16: removeSelectionPaths
點讚 2
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:transwarpio,項目名稱:rapidminer,代碼行數:12,
示例17: compare
點讚 2
import javax.swing.tree.TreePath; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public int compare(RowMapping rm1, RowMapping rm2) {
int index1 = rm1.getModelRowIndex();
int index2 = rm2.getModelRowIndex();
if (index1 == index2) {
return 0;
}
TreePath tp1 = getLayoutCache().getPathForRow(index1);
TreePath tp2 = getLayoutCache().getPathForRow(index2);
if (tp1 == null) {
if (tp2 == null) {
return 0;
} else {
return -1;
}
} else if (tp2 == null) {
return 1;
}
if (tp1.isDescendant(tp2)) {
return -1;
}
if (tp2.isDescendant(tp1)) {
return 1;
}
boolean tp1Changed = false;
boolean tp2Changed = false;
TreePath parent1 = tp1.getParentPath();
TreePath parent2 = tp2.getParentPath();
if (parent1 != null && parent2 != null && parent1.equals(parent2) &&
getOutlineModel().isLeaf(tp1.getLastPathComponent()) &&
getOutlineModel().isLeaf(tp2.getLastPathComponent())) {
return ascending ? super.compare(rm1, rm2) : - super.compare(rm1, rm2);
}
while (tp1.getPathCount() < tp2.getPathCount()) {
tp2 = tp2.getParentPath();
tp2Changed = true;
}
while (tp1.getPathCount() > tp2.getPathCount()) {
tp1 = tp1.getParentPath();
tp1Changed = true;
}
parent1 = tp1.getParentPath();
parent2 = tp2.getParentPath();
while (parent1 != null && parent2 != null && !parent1.equals(parent2)) {
tp1 = parent1;
tp2 = parent2;
parent1 = tp1.getParentPath();
parent2 = tp2.getParentPath();
tp1Changed = true;
tp2Changed = true;
}
if (tp1Changed || tp2Changed) {
return compare(tempSortMap.get(tp1), tempSortMap.get(tp2));
} else {
return ascending ? super.compare(rm1, rm2) : - super.compare(rm1, rm2);
}
}
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:59,
示例18: checkAt
點讚 2
import javax.swing.tree.TreePath; //導入方法依賴的package包/類
/**
* Perform a selection/deselection of a check box on the given row and column,
* if a check box exists on the given position.
* @param row The row of the check box
* @param column The column of the check box
* @param me The mouse event that performs the check, or null
.
* @return true
if a {@link CheckRenderDataProvider} is found
* on the given row and column, is checkable and enabled and the
* mouse event is either null
or upon the check-box
* location. Returns false
otherwise.
* @since 1.25
*/
protected final boolean checkAt(int row, int column, MouseEvent me) {
RenderDataProvider render = getRenderDataProvider();
TableCellRenderer tcr = getDefaultRenderer(Object.class);
if (render instanceof CheckRenderDataProvider && tcr instanceof DefaultOutlineCellRenderer) {
CheckRenderDataProvider crender = (CheckRenderDataProvider) render;
DefaultOutlineCellRenderer ocr = (DefaultOutlineCellRenderer) tcr;
Object value = getValueAt(row, column);
if (value != null && crender.isCheckable(value) && crender.isCheckEnabled(value)) {
boolean chBoxPosition;
if (me == null) {
chBoxPosition = true;
} else {
int handleWidth = DefaultOutlineCellRenderer.getExpansionHandleWidth();
int chWidth = ocr.getTheCheckBoxWidth();
Insets ins = getInsets();
TreePath path = getLayoutCache().getPathForRow(convertRowIndexToModel(row));
int nd = path.getPathCount() - (isRootVisible() ? 1 : 2);
if (nd < 0) {
nd = 0;
}
int chStart = ins.left + (nd * DefaultOutlineCellRenderer.getNestingWidth()) + handleWidth;
int chEnd = chStart + chWidth;
//TODO: Translate x/y to position of column if non-0
chBoxPosition = (me.getX() > ins.left && me.getX() >= chStart && me.getX() <= chEnd);
}
if (chBoxPosition) {
Boolean selected = crender.isSelected(value);
if (selected == null || Boolean.TRUE.equals(selected)) {
crender.setSelected(value, Boolean.FALSE);
} else {
crender.setSelected(value, Boolean.TRUE);
}
Rectangle r = getCellRect(row, column, true);
repaint (r.x, r.y, r.width, r.height);
return true;
}
}
}
return false;
}
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:54,
示例19: checkPath
點讚 1
import javax.swing.tree.TreePath; //導入方法依賴的package包/類
/**
* implementation of JTreeOperator.TreePathChooser
*
* @param path TreePath
* @param indexInParent int
* @return boolean
*/
@Override
public boolean checkPath(TreePath path, int indexInParent) {
return (path.getPathCount() == arr.length + parentPathCount
&& hasAsParent(path, indexInParent));
}
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,
注:本文中的javax.swing.tree.TreePath.getPathCount方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。