Packagecom.yworks.graph.model
Classpublic class DefaultNodeHierarchy
InheritanceDefaultNodeHierarchy Inheritance flash.events.EventDispatcher
Implements INodeHierarchy, Iterable

A basic implementation of the INodeHierarchy interface.



Public Properties
 PropertyDefined By
  root : INode
[read-only] Gets the root node of the hierarchy.
DefaultNodeHierarchy
Public Methods
 MethodDefined By
  
DefaultNodeHierarchy(rootValue:INode = null, mapper:IMapper = null)
Creates a new instance using the provided parameter as the root element and the given mapper to do the mapping.
DefaultNodeHierarchy
  
addChild(parent:INode, child:INode):void
Modifies the hierarchy by adding another child to the given parent.
DefaultNodeHierarchy
  
contains(item:INode):Boolean
Determines whether the given node is part of this hierarchy.
DefaultNodeHierarchy
  
getChildCount(parent:INode):int
Returns the number of children for the given parent item.
DefaultNodeHierarchy
  
Returns an iterable over the children of the provided item.
DefaultNodeHierarchy
  
Returns the parent item of the item or root if child is a top-level item.
DefaultNodeHierarchy
  
isLeaf(item:INode):Boolean
Returns whether the given item is considered a leaf item.
DefaultNodeHierarchy
  
Returns an iterator over a set of elements.
DefaultNodeHierarchy
  
lookup(type:Class):Object
Returns an instance that implements the given type or null.
DefaultNodeHierarchy
  
Triggers the firing of an itemChanged event for the given node.
DefaultNodeHierarchy
  
remove(child:INode):void
Removes the given item from its parent and this hierarchy.
DefaultNodeHierarchy
  
setLeaf(item:INode, leaf:Boolean):void
Determines whether the given item should be considered a leaf.
DefaultNodeHierarchy
  
setParent(child:INode, parent:INode):void
Reparents a child item that already belongs to this hierarchy instance to a new parent.
DefaultNodeHierarchy
Protected Methods
 MethodDefined By
  
onItemAdded(item:INode, parent:INode):void
Dispatches the itemAdded event.
DefaultNodeHierarchy
  
onItemChanged(item:INode, parent:INode):void
Dispatches the itemChanged event.
DefaultNodeHierarchy
  
onItemMoved(item:INode, oldParent:INode, newParent:INode):void
Dispatches the itemMoved event.
DefaultNodeHierarchy
  
onItemRemoved(item:INode, oldParent:INode):void
Dispatches the itemRemoved event.
DefaultNodeHierarchy
Property Detail
rootproperty
root:INode  [read-only]

Gets the root node of the hierarchy.


Implementation
    public function get root():INode
Constructor Detail
DefaultNodeHierarchy()Constructor
public function DefaultNodeHierarchy(rootValue:INode = null, mapper:IMapper = null)

Creates a new instance using the provided parameter as the root element and the given mapper to do the mapping.

Parameters
rootValue:INode (default = null) — The value for the root element, or null.
 
mapper:IMapper (default = null) — The instance to do the mapping of the items in the hierarchy to the internally used data structure. If no mapper is passed, a DictionaryMapper is used.

See also

Method Detail
addChild()method
public function addChild(parent:INode, child:INode):void

Modifies the hierarchy by adding another child to the given parent.

child may not be part of the hierarchy prior to this call. This triggers the itemAdded event.

Parameters

parent:INode — The parent to add the child to.
 
child:INode — The child to add to the parent.

contains()method 
public function contains(item:INode):Boolean

Determines whether the given node is part of this hierarchy.

Parameters

item:INode — The node to check

Returns
Boolean — Whether the node is contained in the hierarchy.
getChildCount()method 
public function getChildCount(parent:INode):int

Returns the number of children for the given parent item.

Parameters

parent:INode — The parent to get the number of child items for.

Returns
int — The number of children.
getChildren()method 
public function getChildren(item:INode):Iterable

Returns an iterable over the children of the provided item.

Parameters

item:INode — The item for which to return the children.

Returns
Iterable — All items that have item as their parent.
getHierarchyItem()method 
yworks_internal function getHierarchyItem(item:INode):MyNodeHierarchyItem

Parameters

item:INode

Returns
MyNodeHierarchyItem
getParent()method 
public function getParent(child:INode):INode

Returns the parent item of the item or root if child is a top-level item.

Parameters

child:INode — The item to retrieve the parent item for.

Returns
INode — The parent item in this hierarchy or root.
isLeaf()method 
public function isLeaf(item:INode):Boolean

Returns whether the given item is considered a leaf item.

Leaves may not have children. However, a non-leaf item does not necessarily need to have children.

Parameters

item:INode — The item to check.

Returns
Boolean — Whether the item is considered a leaf.
iterator()method 
public function iterator():Iterator

Returns an iterator over a set of elements.

Returns
Iterator — an Iterator.
lookup()method 
public function lookup(type:Class):Object

Returns an instance that implements the given type or null.

Typically, this method will be called in order to obtain a different view or aspect of the current instance. This is quite similar to casting or using a super type or interface of this instance, but is not limited to inheritance or compile time constraints. An instance implementing this method is not required to return non-null implementations for the types, nor does it have to return the same instance any time. Also it depends on the type and context whether the instance returned stays up to date or needs to be reobtained for subsequent use.

Parameters

type:Class — the type for which an instance shall be returned

Returns
Object — an instance that is assignable to type or null
onItemAdded()method 
protected function onItemAdded(item:INode, parent:INode):void

Dispatches the itemAdded event.

Parameters

item:INode — The item that is added.
 
parent:INode — The parent of the item.

onItemChanged()method 
protected function onItemChanged(item:INode, parent:INode):void

Dispatches the itemChanged event.

Parameters

item:INode — The item that is changed.
 
parent:INode — The parent of the item.

onItemMoved()method 
protected function onItemMoved(item:INode, oldParent:INode, newParent:INode):void

Dispatches the itemMoved event.

Parameters

item:INode — he item that is reparented.
 
oldParent:INode — The old parent of the item.
 
newParent:INode — The new parent of the item.

onItemRemoved()method 
protected function onItemRemoved(item:INode, oldParent:INode):void

Dispatches the itemRemoved event.

Parameters

item:INode — The item that is removed.
 
oldParent:INode — The parent of the item.

publishItemChanged()method 
public function publishItemChanged(item:INode):void

Triggers the firing of an itemChanged event for the given node.

Parameters

item:INode — The item that has changed.

remove()method 
public function remove(child:INode):void

Removes the given item from its parent and this hierarchy.

This will trigger the itemRemoved event.

Parameters

child:INode — The child to remove from this hierarchy.

setLeaf()method 
public function setLeaf(item:INode, leaf:Boolean):void

Determines whether the given item should be considered a leaf.

Leaves may not have children. However, a non-leaf item does not necessarily need to have children.

Parameters

item:INode — The item to set.
 
leaf:Boolean — Whether to make the item a leaf.

setParent()method 
public function setParent(child:INode, parent:INode):void

Reparents a child item that already belongs to this hierarchy instance to a new parent.

This will trigger the itemMoved event. Note that child may not be an ancestor of parent.

Parameters

child:INode — The child to reparent.
 
parent:INode — The new parent.