本文整理匯總了Java中javax.swing.tree.TreePath.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java TreePath.equals方法的具體用法?Java TreePath.equals怎麽用?Java TreePath.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.tree.TreePath
的用法示例。
在下文中一共展示了TreePath.equals方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: configure
import javax.swing.tree.TreePath; //導入方法依賴的package包/類
/** Configures a tree cell renderer and sets up sizing and the
* backing image from it */
public boolean configure (Object nd, JScrollPane tv, JTree tree, TreePath path, int row) {
boolean sameVn = setLastRendereredObject(nd);
boolean sameComp = setLastRenderedScrollPane (tv);
Component renderer = null;
bg = tree.getBackground();
boolean sel = tree.isSelectionEmpty() ? false :
tree.getSelectionModel().isPathSelected(path);
boolean exp = tree.isExpanded(path);
boolean leaf = !exp && tree.getModel().isLeaf(nd);
boolean lead = path.equals(tree.getSelectionModel().getLeadSelectionPath());
renderer = tree.getCellRenderer().getTreeCellRendererComponent(tree, nd, sel, exp, leaf, row, lead);
if (renderer != null) {
setComponent (renderer, tree);
}
return true;
}
示例2: isSelectionKept
import javax.swing.tree.TreePath; //導入方法依賴的package包/類
private boolean isSelectionKept (TreePath selPath) {
if (curSelPath != null) {
TreePath oldSel = curSelPath.get();
if (oldSel != null && oldSel.equals(selPath)) {
return true;
}
}
return false;
}
示例3: findString
import javax.swing.tree.TreePath; //導入方法依賴的package包/類
public static boolean findString(ProfilerTreeTable treeTable, String text, boolean matchCase, boolean next, TreeHelper helper) {
treeTable.putClientProperty(LAST_FIND_TEXT, text);
treeTable.putClientProperty(LAST_FIND_MATCH_CASE, matchCase);
if (!matchCase) text = text.toLowerCase();
int mainColumn = treeTable.convertColumnIndexToView(treeTable.getMainColumn());
TreePath selectedPath = treeTable.getSelectionPath();
if (selectedPath == null) selectedPath = treeTable.getRootPath();
boolean firstPath = true;
TreePath startPath = null;
int nodeType = helper == null ? TreeHelper.NODE_SEARCH_DOWN : helper.getNodeType(selectedPath);
do {
selectedPath = next ? treeTable.getNextPath(selectedPath, TreeHelper.isDown(nodeType)) :
treeTable.getPreviousPath(selectedPath, TreeHelper.isDown(nodeType));
TreeNode node = (TreeNode)selectedPath.getLastPathComponent();
if (helper != null) nodeType = helper.getNodeType(node);
if (TreeHelper.isSearch(nodeType)) {
String nodeValue = treeTable.getStringValue(node, mainColumn);
if (!matchCase) nodeValue = nodeValue.toLowerCase();
if (nodeValue.contains(text)) {
treeTable.selectPath(selectedPath, true);
return true;
}
}
if (startPath == null) startPath = selectedPath;
else if (firstPath) firstPath = false;
} while (firstPath || !selectedPath.equals(startPath));
ProfilerDialogs.displayInfo(MSG_NOTFOUND, ACTION_FIND, null);
return false;
}
示例4: compare
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);
}
}