Package com.macrofocus.hierarchy
Interface Hierarchy<T>
-
- All Superinterfaces:
java.io.Serializable
- All Known Subinterfaces:
MutableHierarchy<T>
- All Known Implementing Classes:
AbstractHierarchy,SimpleHierarchy
public interface Hierarchy<T> extends java.io.Serializable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddHierarchyListener(HierarchyListener<T> listener)voidaddWeakHierarchyListener(HierarchyListener<T> listener)java.lang.Iterable<T>breadthFirstIterator()java.lang.Iterable<T>breadthFirstIterator(T parent)Creates and returns an iterable that traverses the subhierarchy rooted at the give node in breadth-first order.booleancontainsChild(T child)booleancontainsChild(T parent, T child)java.lang.Iterable<T>depthFirstIterator()java.lang.Iterable<T>depthFirstIterator(T parent)Creates and returns an iterable that traverses the subhierarchy rooted at the give node in depth-first order.TgetChild(T parent, int index)intgetChildCount(T parent)java.util.List<T>getChildList(T parent)java.lang.Iterable<T>getChildren(T parent)intgetDepth()TgetFirstLeaf(T node)intgetIndexOfChild(T parent, T child)TgetLastLeaf(T node)intgetLeafCount(T node)intgetLevel(T node)java.lang.Iterable<HierarchyListener<T>>getListeners()TgetNextLeaf(T node)TgetParent(T child)java.util.List<T>getPath(T node)Returns the path from the root, to get to this node.java.lang.Object[]getPathToRoot(T child)TgetPreviousLeaf(T node)TgetRoot()booleanhasChild(T parent)booleanisLeaf(T node)booleanisRoot(T node)java.lang.Iterable<T>leavesIterator()java.lang.Iterable<T>leavesIterator(T parent)voidnotifyHierarchyNodeChanged(T child, T parent, int index, boolean isAdjusting)java.lang.Iterable<T>preorderIterator()java.lang.Iterable<T>preorderIterator(T parent)Creates and returns an iterable that traverses the subhierarchy rooted at the give node in preorder.voidremoveHierarchyListener(HierarchyListener<T> listener)voidremoveHierarchyListeners()voidsetNotifyListeners(boolean enable)
-
-
-
Method Detail
-
getRoot
T getRoot()
-
isRoot
boolean isRoot(T node)
-
hasChild
boolean hasChild(T parent)
-
getChildCount
int getChildCount(T parent)
-
containsChild
boolean containsChild(T child)
-
preorderIterator
java.lang.Iterable<T> preorderIterator()
-
breadthFirstIterator
java.lang.Iterable<T> breadthFirstIterator()
-
depthFirstIterator
java.lang.Iterable<T> depthFirstIterator()
-
leavesIterator
java.lang.Iterable<T> leavesIterator()
-
preorderIterator
java.lang.Iterable<T> preorderIterator(T parent)
Creates and returns an iterable that traverses the subhierarchy rooted at the give node in preorder. The first node returned by the iterator's next() method is the given node.- Parameters:
parent- the root of the hierarchy to traverse- Returns:
- an iterable that traverses the subtree rooted at this node in preorder.
-
breadthFirstIterator
java.lang.Iterable<T> breadthFirstIterator(T parent)
Creates and returns an iterable that traverses the subhierarchy rooted at the give node in breadth-first order. The first node returned by the iterator's next() method is the given node.- Parameters:
parent- the root of the hierarchy to traverse- Returns:
- an iterable that traverses the subtree rooted at this node in breadth-first order.
-
depthFirstIterator
java.lang.Iterable<T> depthFirstIterator(T parent)
Creates and returns an iterable that traverses the subhierarchy rooted at the give node in depth-first order. The first node returned by the iterator's next() method is the leftmost leaf.- Parameters:
parent- the root of the hierarchy to traverse- Returns:
- an iterable that traverses the subtree rooted at this node in depth-first order.
-
addHierarchyListener
void addHierarchyListener(HierarchyListener<T> listener)
-
addWeakHierarchyListener
void addWeakHierarchyListener(HierarchyListener<T> listener)
-
removeHierarchyListener
void removeHierarchyListener(HierarchyListener<T> listener)
-
removeHierarchyListeners
void removeHierarchyListeners()
-
setNotifyListeners
void setNotifyListeners(boolean enable)
-
getListeners
java.lang.Iterable<HierarchyListener<T>> getListeners()
-
getPath
java.util.List<T> getPath(T node)
Returns the path from the root, to get to this node. The last element in the path is this node.- Returns:
- an array of objects giving the path, where the first element in the path is the root and the last element is this node.
-
getPathToRoot
java.lang.Object[] getPathToRoot(T child)
-
notifyHierarchyNodeChanged
void notifyHierarchyNodeChanged(T child, T parent, int index, boolean isAdjusting)
-
getDepth
int getDepth()
-
getLevel
int getLevel(T node)
-
isLeaf
boolean isLeaf(T node)
-
getLeafCount
int getLeafCount(T node)
-
-