diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/console/TreeNode.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/console/TreeNode.java')
| -rw-r--r-- | NET/worlds/console/TreeNode.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/NET/worlds/console/TreeNode.java b/NET/worlds/console/TreeNode.java new file mode 100644 index 0000000..f424f12 --- /dev/null +++ b/NET/worlds/console/TreeNode.java @@ -0,0 +1,64 @@ +package NET.worlds.console; + +import java.util.Vector; + +public abstract class TreeNode { + private int level; + private TreeNode parent; + private boolean isOpen; + + protected TreeNode(TreeNode parent) { + this.parent = parent; + if (parent != null) { + this.level = parent.getLevel() + 1; + } + } + + public int getLevel() { + return this.level; + } + + public TreeNode getParent() { + return this.parent; + } + + public boolean isDescendant(TreeNode e) { + while (e != null) { + if ((e = e.getParent()) == this) { + return true; + } + } + + return false; + } + + public boolean isOpen() { + return this.isOpen; + } + + public void setOpen(boolean isOpen) { + this.isOpen = isOpen; + } + + public boolean displayAsTitle() { + return false; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof TreeNode && this.getObject().equals(((TreeNode)obj).getObject()); + } + + @Override + public int hashCode() { + return this.getObject().hashCode(); + } + + public abstract Vector<?> getChildren(); + + public boolean shouldSort() { + return true; + } + + public abstract Object getObject(); +} |