Packagecom.yworks.ui.tree
Classpublic class HierarchyTreeView
InheritanceHierarchyTreeView Inheritance mx.collections.ArrayCollection

Utility class that helps in visualizing an INodeHierarchy in a mx.controls.Tree.

Instances of this class can be installed as a dataProvider which represents a given INodeHierarchy to a Tree.

Actionscript:
     var htv:HierarchyTreeView = new HierarchyTreeView();
     htv.graphCanvasComponent = graphCanvasComponent;
     tree.dataProvider = htv;
     
MXML:
     <mx:Tree>
       <mx:dataProvider>
         <tree:HierarchyTreeView id="htv" graphCanvasComponent="graphCanvas"/>
       </mx:dataProvider>
     </mx:Tree>
     

If the HierarchyTreeView is intended to display flat graphs, DefaultGraph's groupingSupported property must be set to true, anyhow, otherwise there will be no INodeHierarchy available.

The HierarchyTreeView can also serve as data provider for mx.contrlos.Lists. Note, that in this case only the nodes in the root will be displayed.

Default MXML Propertysource



Public Properties
 PropertyDefined By
  graphCanvas : GraphCanvasComponent
[write-only] The GraphCanvasComponent whose graph is this instance's model.
HierarchyTreeView
  labelFunction : Function
A user-supplied function to run on each item to determine its label.
HierarchyTreeView
  model : INodeHierarchy
The model to be used with this instance.
HierarchyTreeView
Public Methods
 MethodDefined By
  
HierarchyTreeView(tree:Tree = null, model:INodeHierarchy = null)
Creates a new instance.
HierarchyTreeView
  
Returns the TreeNode representation of a given node.
HierarchyTreeView
  
publishItemChanged(kind:String = null, location:int = -1, oldLocation:int = -1, items:Array = null):void
Forces a repaint.
HierarchyTreeView
Protected Methods
 MethodDefined By
  
onGraphChanged(oldGraph:IGraph, newGraph:IGraph):void
Callback when the graph property of the graphCanvasComponent changed.
HierarchyTreeView
  
treeLabelFunction(item:Object):String
Delegate function which is returns a String representation of the given item to be displayed in the tree view.
HierarchyTreeView
Property Detail
graphCanvasproperty
graphCanvas:GraphCanvasComponent  [write-only]

The GraphCanvasComponent whose graph is this instance's model.


Implementation
    public function set graphCanvas(value:GraphCanvasComponent):void
labelFunctionproperty 
labelFunction:Function

A user-supplied function to run on each item to determine its label.

The label function takes a single argument which is the item, represented by a TreeNode, and returns a String:

		 myLabelFunction(item:Object):String
		 
The actual node can be found in the TreeNode's item property.

After setting this property to a new value, publishItemChanged() will be called in order to redraw the tree.

The default value is this.treeLabelFunction.


Implementation
    public function get labelFunction():Function
    public function set labelFunction(value:Function):void

See also

modelproperty 
model:INodeHierarchy

The model to be used with this instance. Usually the INodeHierarchy of the current grouped graph.

Setting the graphCanvasComponent property will automatically set this property, too.


Implementation
    public function get model():INodeHierarchy
    public function set model(value:INodeHierarchy):void
Constructor Detail
HierarchyTreeView()Constructor
public function HierarchyTreeView(tree:Tree = null, model:INodeHierarchy = null)

Creates a new instance.

The recommended use is to use the standard constructor and set the created instance as dataProvider to the tree and the graphCanvasComponent property to the current GraphCanvasComponent.

For backward compatibility, it is possible to pass a Tree. The new instance will install itself to that tree as dataProvider representing the given INodeHierarchy.

Parameters
tree:Tree (default = null) — The tree to initialize.
 
model:INodeHierarchy (default = null) — The INodeHierarchy to represent. Usually the INodeHierarchy of the current grouped graph.
Method Detail
findNode()method
public function findNode(node:INode):TreeNode

Returns the TreeNode representation of a given node.

Parameters

node:INode — The node to search the TreeNode representation for.

Returns
TreeNode — The TreeNode which represents the given node or null.
onGraphChanged()method 
protected function onGraphChanged(oldGraph:IGraph, newGraph:IGraph):void

Callback when the graph property of the graphCanvasComponent changed.

Parameters

oldGraph:IGraph — The graph before the change.
 
newGraph:IGraph — The current graph.

publishItemChanged()method 
public function publishItemChanged(kind:String = null, location:int = -1, oldLocation:int = -1, items:Array = null):void

Forces a repaint.

Parameters

kind:String (default = null)
 
location:int (default = -1)
 
oldLocation:int (default = -1)
 
items:Array (default = null)

treeLabelFunction()method 
protected function treeLabelFunction(item:Object):String

Delegate function which is returns a String representation of the given item to be displayed in the tree view.

This implementation returns the text of the first label of the node if there is one. Otherwise it returns an empty String.

Parameters

item:Object — A TreeNode with the item to get the text for.

Returns
String — A String representation of the given item.

See also

mx.controls.Tree.labelFunction
TreeNode