API Reference 0.7.1rikulo_modelTreeNode<T>

TreeNode<T> abstract class

Represents a tree node that can be used with DefaultTreeModel. DefaultTreeModel assumes each node is an instance of TreeNode.

abstract class TreeNode<T> {
 /** Returns the tree model this node belongs to.
  */
 DefaultTreeModel<T> get model;
 /** Sets the tree model it belongs to.
  * This method is invoked automatically by [DefaultTreeModel],
  * so you don't have to invoke it.
  *
  * It can be called only if this node is a root. If a node has a parent,
  * its model shall be the same as its parent.
  */
 void set model(DefaultTreeModel<T> model);

 /** Returns the application-specific data held in this node.
  */
 T get data;
 /** Sets the application-specific data held in this node.
  */
 void set data(T data);

 /** Returns true if this node is a leaf.
  */
 bool get isLeaf;

 /**
  * Returns the child ([TreeNode]) at the given index.
  */
 TreeNode<T> operator[](int index);
 /**
  * Returns the number of children [TreeNode]s this node contains.
  */
 int get length;
 /**
  * Returns the parent [TreeNode] of this node.
  */
 TreeNode<T> get parent;
 /**
  * Returns the index of this node.
  * If this node does not have any parent, 0 will be returned.
  */
 int get index;

 /** Adds child to this node.
  *
  * + [index] the index that [child] will be added at.
  * If null, [child] will be added to the end.
  */
 void add(TreeNode<T> child, [int index]);
 /** Adds a collection of children nodes.
  *
  * Each element of the given [nodes] can be an instance of [TreeNode]
  * or the data. For example,
  *
  *     node.addAll(["apple", "orange"]);
  *     node.addAll([new DefaultTreeNode("group", ["item1", "item2"])]);
  *
  * + [nodes] is a collection of nodes to add. Any element of it can
  * be [TreeNode] or the data.
  * + [index] is the index that nodes will be added at.
  * If null, nodes will be added to the end.
  */
 void addAll(Iterable nodes, [int index]);
 /** Removes the child at index from this node.
  *
  * This method returns the tree node being removed.
  */
 TreeNode<T> remove(int index);
 /** Removes all children nodes.
  */
 void clear();
}

Subclasses

DefaultTreeNode<T>

Properties

abstract T get data #

Returns the application-specific data held in this node.

abstract void set data(T data) #

Sets the application-specific data held in this node.

final int index #

Returns the index of this node. If this node does not have any parent, 0 will be returned.

int get index;

final bool isLeaf #

Returns true if this node is a leaf.

bool get isLeaf;

final int length #

Returns the number of children TreeNodes this node contains.

int get length;

abstract DefaultTreeModel<T> get model #

Returns the tree model this node belongs to.

abstract void set model(DefaultTreeModel<T> model) #

Sets the tree model it belongs to. This method is invoked automatically by DefaultTreeModel, so you don't have to invoke it.

It can be called only if this node is a root. If a node has a parent, its model shall be the same as its parent.

final TreeNode<T> parent #

Returns the parent TreeNode of this node.

TreeNode<T> get parent;

Operators

abstract TreeNode<T> operator [](int index) #

Returns the child (TreeNode) at the given index.

Methods

abstract void add(TreeNode<T> child, [int index]) #

Adds child to this node.

  • index the index that child will be added at. If null, child will be added to the end.

abstract void addAll(Iterable nodes, [int index]) #

Adds a collection of children nodes.

Each element of the given nodes can be an instance of TreeNode or the data. For example,

node.addAll(["apple", "orange"]);
node.addAll([new DefaultTreeNode("group", ["item1", "item2"])]);
  • nodes is a collection of nodes to add. Any element of it can be TreeNode or the data.

  • index is the index that nodes will be added at. If null, nodes will be added to the end.

abstract void clear() #

Removes all children nodes.

abstract TreeNode<T> remove(int index) #

Removes the child at index from this node.

This method returns the tree node being removed.