本文整理汇总了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);
}
}