X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fui%2FDataNode.java;h=b4dbe7bb04130bf69e4e67ca12ea330b812544ef;hb=9e7330d793887fe9ee378ca1413141d7761e76ca;hp=2d3ac267842325333484b68886998471981d8135;hpb=bc4db23ff5c21d7d4716f9b7f97de73b15a6fc21;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/ui/DataNode.java b/src/be/nikiroo/utils/ui/DataNode.java deleted file mode 100644 index 2d3ac26..0000000 --- a/src/be/nikiroo/utils/ui/DataNode.java +++ /dev/null @@ -1,98 +0,0 @@ -package be.nikiroo.utils.ui; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import javax.swing.Icon; - -public class DataNode { - private DataNode parent; - private List> children; - private T userData; - - public DataNode(List> children, T userData) { - if (children == null) { - children = new ArrayList>(); - } - - this.children = children; - this.userData = userData; - - for (DataNode child : children) { - child.parent = this; - } - } - - public DataNode getRoot() { - DataNode root = this; - while (root.parent != null) { - root = root.parent; - } - - return root; - } - - public DataNode getParent() { - return parent; - } - - public List> getChildren() { - return children; - } - - public int size() { - return children.size(); - } - - public boolean isRoot() { - return this == getRoot(); - } - - public boolean isSiblingOf(DataNode node) { - if (this == node) { - return true; - } - - return node != null && parent != null && parent.children.contains(node); - } - - public boolean isParentOf(DataNode node) { - if (node == null || node.parent == null) - return false; - - if (this == node.parent) - return true; - - return isParentOf(node.parent); - } - - public boolean isChildOf(DataNode node) { - if (node == null || node.size() == 0) - return false; - - return node.isParentOf(this); - } - - public T getUserData() { - return userData; - } - - protected int count() { - int s = 0; - for (DataNode child : children) { - s += child.count(); - } - - return s; - } - - @Override - public String toString() { - if (userData == null) { - return ""; - } - - return userData.toString(); - } -} \ No newline at end of file