From 2da37d38f809da144338309b478f3b2e3287e4f8 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sun, 26 Apr 2020 01:23:11 +0200 Subject: [PATCH] DataNode, DataTree fixes --- ui/DataNode.java | 10 ++++++++-- ui/DataTree.java | 20 -------------------- 2 files changed, 8 insertions(+), 22 deletions(-) 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; - } } -- 2.27.0