|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.zaval.data.Tree
This class is implementation of TreeModel
interface and it is used to organize
tree-like structures basing on Item
class. The class provides methods to bound
items with each other The class supports listener interface that allows to listen when
the structure has been modified.
Constructor Summary | |
Tree()
Constructs a new tree class. |
|
Tree(Item r)
Constructs a new tree with the given item as a root of the hierarchy. |
Method Summary | |
void |
add(Item to,
Item item)
Adds the item into the tree as a child of the parent item. |
void |
addTreeListener(TreeListener l)
Adds the specified tree listener to receive the tree events. |
Tree |
clone(Item item)
Creates a subtree for the specified item of this tree. |
boolean |
contains(Item item)
Tests if the specified item is contained with this tree model. |
Item |
getChildAt(Item item,
int index)
Returns a child item for the given parent item at the specified index. |
int |
getChildIndex(Item item)
Searches for the first occurence of the given item in the parent items vector, testing for equality using the equals method and returns the child index. |
Item[] |
getChildren()
Gets all child items for the root item of the tree. |
Item[] |
getChildren(Item item)
Gets all child items for the specified item. |
int |
getChildrenCount(Item item)
Returns a number of child items for the given parent item. |
int |
getItemsCount()
Gets the total items number that are contained by the tree. |
Item |
getParent(Item item)
Returns a parent for the given item. |
Item |
getRoot()
Gets the root item of the tree model. |
boolean |
hasChildren(Item item)
Tests if the item has one or more child items. |
void |
insert(Item to,
Item item,
int index)
Inserts the specified item into the tree as a child of the parent item, at the specified index. |
protected void |
perform(TreeEvent e)
Fires the specified tree event to the tree model listeners. |
protected void |
regItem(Item item,
Item parent,
java.util.Vector v)
The method is used to register the specified item as a member of the tree model. |
void |
remove(Item item)
Removes the specified item from the tree. |
void |
removeChild(Item parent,
int index)
Deletes a child item from the specified parent item at the specified index. |
void |
removeKids(Item item)
Deletes all child items for the specified parent item. |
void |
removeTreeListener(TreeListener l)
Removes the specified tree listener so that it no longer receives tree events from this tree model. |
void |
set(Item item,
java.lang.Object o)
Sets the specified value for the given tree item. |
void |
setRoot(Item r)
|
protected void |
unregItem(Item item)
The method is used to unregister the specified item as a member of the tree model. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Tree()
public Tree(Item r)
r
- the initial value of the container root. The root item
will be used as root of the hierarchy. Use null
value to postpone
the root item definition.Method Detail |
public void setRoot(Item r)
public Item getRoot()
TreeModel
getRoot
in interface TreeModel
org.zaval.data.TreeModel
public int getItemsCount()
TreeModel
getItemsCount
in interface TreeModel
org.zaval.data.TreeModel
public Item[] getChildren()
public Item[] getChildren(Item item)
item
- the item that is used as a root to get a child items array.public Item getChildAt(Item item, int index)
TreeModel
getChildAt
in interface TreeModel
org.zaval.data.TreeModel
item
- the item that is used as a parent to get a child item by the index.index
- the index into this parent child items vector.public int getChildIndex(Item item)
TreeModel
equals
method and returns the child index.getChildIndex
in interface TreeModel
org.zaval.data.TreeModel
item
- the specified item to define it index.-1
if the item is not member of the model.public Item getParent(Item item)
TreeModel
getParent
in interface TreeModel
org.zaval.data.TreeModel
item
- the specified item to define it parent.public int getChildrenCount(Item item)
TreeModel
getChildrenCount
in interface TreeModel
org.zaval.data.TreeModel
item
- the parent item to define a number of child items.public boolean hasChildren(Item item)
TreeModel
hasChildren
in interface TreeModel
org.zaval.data.TreeModel
item
- the item to test.true
if the item has one or more child items; false
otherwisepublic boolean contains(Item item)
item
- the specified item to be tested.true
if the specified item contained with this tree model;
false
otherwise.public void add(Item to, Item item)
TreeModel
add
in interface TreeModel
org.zaval.data.TreeModel
to
- the parent item.item
- the child item that has to be added.public void insert(Item to, Item item, int index)
TreeModel
insert
in interface TreeModel
org.zaval.data.TreeModel
to
- the specified parent item.item
- the specified child item that has to be added.index
- the specified index where the child has to be inserted.public void remove(Item item)
TreeModel
remove
in interface TreeModel
org.zaval.data.TreeModel
item
- the item that has to be removed.public void removeChild(Item parent, int index)
parent
- the parent item for what the child item will be removed.index
- the index of the child item to be removed.public void removeKids(Item item)
item
- the parent item for what all child items will be removed.public Tree clone(Item item)
item
- the specified item.public void addTreeListener(TreeListener l)
TreeModel
addTreeListener
in interface TreeModel
org.zaval.data.TreeModel
l
- the tree listener.public void removeTreeListener(TreeListener l)
TreeModel
removeTreeListener
in interface TreeModel
org.zaval.data.TreeModel
l
- the tree listener.public void set(Item item, java.lang.Object o)
set
in interface TreeModel
item
- the item.o
- the specified value.protected void regItem(Item item, Item parent, java.util.Vector v)
item
- the item that has to be registered as a member of the tree.parent
- the parent of the registered item.v
- the vector of child items for the given parent item.protected void unregItem(Item item)
item
- the item that has to be unregistered as a member of this tree.protected void perform(TreeEvent e)
e
- the tree event.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |