Package | com.yworks.ui.tree |
Class | public class HierarchyTreeView |
Inheritance | HierarchyTreeView mx.collections.ArrayCollection |
INodeHierarchy
in a
mx.controls.Tree
.
Instances of this class can be installed as a dataProvider
which represents
a given INodeHierarchy
to a Tree
.
var htv:HierarchyTreeView = new HierarchyTreeView(); htv.graphCanvasComponent = graphCanvasComponent; tree.dataProvider = htv;
<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.List
s. Note, that in this case only the nodes in the root
will be displayed.
Default MXML Propertysource
Property | Defined 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 |
Method | Defined 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 |
Method | Defined By | ||
---|---|---|---|
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 |
graphCanvas | property |
graphCanvas:GraphCanvasComponent
[write-only]
The GraphCanvasComponent
whose graph
is
this instance's model.
public function set graphCanvas(value:GraphCanvasComponent):void
labelFunction | property |
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):StringThe 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
.
public function get labelFunction():Function
public function set labelFunction(value:Function):void
See also
model | property |
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.
public function get model():INodeHierarchy
public function set model(value:INodeHierarchy):void
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
.
tree:Tree (default = null ) — The tree to initialize.
| |
model:INodeHierarchy (default = null ) — The INodeHierarchy to represent. Usually the
INodeHierarchy of the current grouped graph.
|
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.
|
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.
|
String — A String representation of the given item.
|
See also