From: Niki Roo Date: Sat, 25 Apr 2020 23:23:11 +0000 (+0200) Subject: DataNode, DataTree fixes X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=commitdiff_plain;h=2da37d38f809da144338309b478f3b2e3287e4f8 DataNode, DataTree fixes --- diff --git a/ui/DataNode.java b/ui/DataNode.java index 2d3ac26..b4dbe7b 100644 --- a/ui/DataNode.java +++ b/ui/DataNode.java @@ -78,8 +78,14 @@ public class DataNode { return userData; } - protected int count() { - int s = 0; + /** + * The total number of nodes present in this {@link DataNode} (including + * itself and descendants). + * + * @return the number + */ + public int count() { + int s = 1; for (DataNode child : children) { s += child.count(); } diff --git a/ui/DataTree.java b/ui/DataTree.java index e941a71..108476e 100644 --- a/ui/DataTree.java +++ b/ui/DataTree.java @@ -65,24 +65,4 @@ public abstract class DataTree { return new DataNode(children, source.getUserData()); } - - // TODO: not in this class: - - public void loadInto(DefaultMutableTreeNode root, String filter) { - DataNode filtered = getRoot(filter); - for (DataNode child : filtered.getChildren()) { - root.add(nodeToNode(child)); - } - } - - private MutableTreeNode nodeToNode(DataNode node) { - // TODO: node.toString - DefaultMutableTreeNode otherNode = new DefaultMutableTreeNode( - node.toString()); - for (DataNode child : node.getChildren()) { - otherNode.add(nodeToNode(child)); - } - - return otherNode; - } }