Package cz.vutbr.fit.layout.impl
Class DefaultTreeNode<T extends GenericTreeNode<T>>
- java.lang.Object
-
- cz.vutbr.fit.layout.impl.DefaultTreeNode<T>
-
- All Implemented Interfaces:
GenericTreeNode<T>
- Direct Known Subclasses:
DefaultLogicalArea,DefaultTreeContentRect
public class DefaultTreeNode<T extends GenericTreeNode<T>> extends Object implements GenericTreeNode<T>
A generic tree node used as a base for the Box and Area implementation.- Author:
- burgetr
-
-
Constructor Summary
Constructors Constructor Description DefaultTreeNode(Class<T> myType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddUserAttribute(String name, Object value)Sets a user-defined attribute for the tree node.voidappendChild(T child)voidappendChildren(List<T> list)intgetDepth()TgetChildAt(int index)intgetChildCount()List<T>getChildren()intgetIndex(T child)intgetLeafCount()TgetNextSibling()TgetParent()TgetPreviousSibling()TgetRoot()<P> PgetUserAttribute(String name, Class<P> clazz)Obtains the user-defined attribute value assigned to the node.voidchildrenChanged()This method is called after some child nodes have been added or removed.voidinsertChild(T child, int index)booleanisLeaf()booleanisRoot()voidremoveAllChildren()voidremoveChild(int index)voidremoveChild(T child)voidsetParent(T parent)voidsetRoot(T root)
-
-
-
Method Detail
-
getParent
public T getParent()
- Specified by:
getParentin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
setParent
public void setParent(T parent)
- Specified by:
setParentin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
getRoot
public T getRoot()
- Specified by:
getRootin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
setRoot
public void setRoot(T root)
- Specified by:
setRootin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
isRoot
public boolean isRoot()
- Specified by:
isRootin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
getUserAttribute
public <P> P getUserAttribute(String name, Class<P> clazz)
Description copied from interface:GenericTreeNodeObtains the user-defined attribute value assigned to the node.- Specified by:
getUserAttributein interfaceGenericTreeNode<T extends GenericTreeNode<T>>- Parameters:
name- the attribute nameclazz- the class of the required attribute- Returns:
- an object of the given class representing the value of the attribute (application-specific)
or
nullwhen no such attribute is present.
-
addUserAttribute
public void addUserAttribute(String name, Object value)
Description copied from interface:GenericTreeNodeSets a user-defined attribute for the tree node. This allows to assign multiple attributes identified by their names.- Specified by:
addUserAttributein interfaceGenericTreeNode<T extends GenericTreeNode<T>>- Parameters:
name- the attribute namevalue- the attribute value
-
getChildren
public List<T> getChildren()
- Specified by:
getChildrenin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
getChildCount
public int getChildCount()
- Specified by:
getChildCountin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
isLeaf
public boolean isLeaf()
- Specified by:
isLeafin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
appendChild
public void appendChild(T child)
- Specified by:
appendChildin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
appendChildren
public void appendChildren(List<T> list)
- Specified by:
appendChildrenin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
insertChild
public void insertChild(T child, int index) throws IndexOutOfBoundsException
- Specified by:
insertChildin interfaceGenericTreeNode<T extends GenericTreeNode<T>>- Throws:
IndexOutOfBoundsException
-
removeAllChildren
public void removeAllChildren()
- Specified by:
removeAllChildrenin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
removeChild
public void removeChild(int index) throws IndexOutOfBoundsException- Specified by:
removeChildin interfaceGenericTreeNode<T extends GenericTreeNode<T>>- Throws:
IndexOutOfBoundsException
-
removeChild
public void removeChild(T child) throws IllegalArgumentException
- Specified by:
removeChildin interfaceGenericTreeNode<T extends GenericTreeNode<T>>- Throws:
IllegalArgumentException
-
getChildAt
public T getChildAt(int index) throws IndexOutOfBoundsException
- Specified by:
getChildAtin interfaceGenericTreeNode<T extends GenericTreeNode<T>>- Throws:
IndexOutOfBoundsException
-
getIndex
public int getIndex(T child)
- Specified by:
getIndexin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
getPreviousSibling
public T getPreviousSibling()
- Specified by:
getPreviousSiblingin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
getNextSibling
public T getNextSibling()
- Specified by:
getNextSiblingin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
getDepth
public int getDepth()
- Specified by:
getDepthin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
getLeafCount
public int getLeafCount()
- Specified by:
getLeafCountin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
childrenChanged
public void childrenChanged()
This method is called after some child nodes have been added or removed. Subclasses may override this method in order to update their own internal structures.- Specified by:
childrenChangedin interfaceGenericTreeNode<T extends GenericTreeNode<T>>
-
-