List of utility methods to do JTree Node
void | insertNodeInAlphabeticalOrder(DefaultMutableTreeNode childNode, DefaultMutableTreeNode parentNode, DefaultTreeModel model) insert Node In Alphabetical Order Enumeration<DefaultMutableTreeNode> children = parentNode.children(); String nodeName = childNode.toString(); int index = 0; if (children.hasMoreElements()) { while (children.hasMoreElements()) { String displayString = children.nextElement().toString(); if (nodeName.compareToIgnoreCase(displayString) < 1) { break; ... |
void | insertStrAsNodeLexi(DefaultTreeModel treeModel, String child, DefaultMutableTreeNode parent, Boolean childIsFile) insert Str As Node Lexi DefaultMutableTreeNode currNode; DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(child); if (childIsFile) childNode.setAllowsChildren(false); else childNode.setAllowsChildren(true); Boolean parentIsFile; boolean inserted = false; ... |
boolean | isAncestor(final TreeNode node, final TreeNode parent) Tests whether a given node is an ancestor node of another node. if (parent == node) { return true; for (int i = 0; i < parent.getChildCount(); i++) { if (isAncestor(node, parent.getChildAt(i))) { return true; return false; |
boolean | isChildNode(DefaultMutableTreeNode parent, DefaultMutableTreeNode child) is Child Node if (parent == child) return false; DefaultMutableTreeNode node = child; while ((node = (DefaultMutableTreeNode) node.getParent()) != null) { if (node.getUserObject() == parent.getUserObject()) return true; return false; ... |
boolean | isMovingUp(DefaultMutableTreeNode ntarget, DefaultMutableTreeNode nsource) Verifica se si sta spostando il nodo source verso l'alto boolean areSiblings; DefaultMutableTreeNode targetParent = (DefaultMutableTreeNode) ntarget.getParent(); DefaultMutableTreeNode sourceParent = (DefaultMutableTreeNode) nsource.getParent(); areSiblings = (sourceParent.getUserObject().equals(targetParent.getUserObject())); if (areSiblings) { int targetIndex = targetParent.getIndex(ntarget); int sourceIndex = sourceParent.getIndex(nsource); if (sourceIndex > targetIndex) { ... |
boolean | isNodeAsStrChild(DefaultMutableTreeNode parent, String child) is Node As Str Child for (int i = 0; i < parent.getChildCount(); i++) { if (((DefaultMutableTreeNode) parent.getChildAt(i)).getUserObject().toString().equals(child)) { return true; return false; |
boolean | isNodeOrChildSelected(JTree tree, DefaultMutableTreeNode node) is Node Or Child Selected TreePath[] selectionPaths = tree.getSelectionPaths(); if (selectionPaths == null || selectionPaths.length == 0) return false; TreePath path = new TreePath(node.getPath()); for (TreePath selectionPath : selectionPaths) { if (path.isDescendant(selectionPath)) return true; return false; |
boolean | isReflectanceType(TreeNode productTypeNode, String type) is Reflectance Type for (int i = 0; i < productTypeNode.getChildCount(); i++) { final TreeNode productTypeChildNode = productTypeNode.getChildAt(i); final String productTypeChildNodeName = productTypeChildNode.toString(); if (productTypeChildNodeName.equals("RADIOMETRY")) { final TreeNode radiometryChildNode = productTypeChildNode.getChildAt(0); return radiometryChildNode.getChildAt(0).toString().equals(type); return false; |
String | listTree(TreeNode node, String prefix, String lineSeparator) list Tree String result = prefix + ((node.toString() != null) ? node.toString() : "") + lineSeparator; if (!node.isLeaf()) { for (int i = 0; i < node.getChildCount(); i++) { result += listTree(node.getChildAt(i), prefix + LEVEL_SEPARATOR, lineSeparator); return result; |
void | printTree(final DefaultMutableTreeNode tree, final String indent) print Tree debug("LOG: \n", treetoString(tree, indent));
|