Packageflare.vis.data
Classpublic class Tree
InheritanceTree Inheritance Data Inheritance flash.events.EventDispatcher

Data structure for managing a collection of visual data objects in a tree (hierarchy) structure. This class extends the functionality of the Data class to model a hierarchy. The class can be used as an alternative to the Data class when the data forms a strict tree, or to model a spanning tree over a general graph.



Public Properties
 PropertyDefined by
 InheriteddirectedEdges : Boolean
The default directedness of new edges.
Data
 Inheritededges : DataList
The collection of EdgeSprites.
Data
 Inheritedlength : int
The total number of items (nodes and edges) in the data.
Data
 Inheritednodes : DataList
The collection of NodeSprites.
Data
  root : NodeSprite
[write-only] Sets the root node of this tree.
Tree
  tree : Tree
This property simply points back to this object.
Tree
 InheritedtreeEdgeWeight : Function
The edge weight function for computing a minimum spanning tree.
Data
 InheritedtreePolicy : String
The spanning tree creation policy.
Data
Protected Properties
 PropertyDefined by
 Inherited_edges : DataList
Internal list of EdgeSprites.
Data
 Inherited_groups : Object
Internal set of data groups.
Data
 Inherited_nodes : DataList
Internal list of NodeSprites.
Data
 Inherited_root : NodeSprite = null
The root node of the spanning tree.
Data
 Inherited_span : TreeBuilder
The spanning tree constructor class.
Data
 Inherited_tree : Tree = null
The the spanning tree.
Data
Public Methods
 MethodDefined by
  
Add a node to the tree.
Tree
  
Adds the given edge as a child edge between a node already in the tree and another node not yet in the tree.
Tree
 Inherited
Add an edge to this data set.
Data
 Inherited
addEdgeFor(source:NodeSprite, target:NodeSprite, directed:Object = null, data:Object = null):EdgeSprite
Creates a new edge between the given nodes and adds it to the data collection.
Data
 Inherited
addGroup(name:String, group:DataList = null):DataList
Adds a new data group.
Data
 Inherited
addNode(d:Object = null):NodeSprite
Adds a node to this data collection.
Data
  
Creates and returns a new root NodeSprite for the tree.
Tree
  
clear():void
Clears the tree, removing all nodes and edges.
Tree
 Inherited
contains(d:DataSprite):Boolean
Indicates if this Data object contains the input DataSprite.
Data
  
Counts the number of leaf nodes in the tree.
Tree
 Inherited
createEdges(sortBy:* = null, groupBy:Boolean = null, ignoreExistingEdges:* = false):void
Generates edges for this data collection that connect the nodes according to the input properties.
Data
 Inherited
fromArray(a:Array):Data
[static] Creates a new Data instance from an array of tuples.
Data
 Inherited
[static] Creates a new Data instance from a data set.
Data
 Inherited
group(name:String):DataList
Retrieves the data group with the given name.
Data
 Inherited
remove(d:DataSprite):Boolean
Removes a DataSprite (node or edge) from this data collection.
Data
  
Removes an edge from tree tree, removing the entire subtree rooted at the child node adjacent to the edge.
Tree
 Inherited
removeGroup(name:String):DataList
Removes a data group.
Data
  
Removes a node from the tree, removing the entire subtree rooted at that node.
Tree
  
Continuously swaps the given node with its parent node until it is the root.
Tree
  
Swaps the given node with its parent node.
Tree
 Inherited
visit(v:Function, group:String = null, filter:Boolean = null, reverse:* = false):Boolean
Visit items, invoking a function on all visited elements.
Data
Protected Methods
 MethodDefined by
  
Registers all tree descendants with this Tree instance.
Tree
 Inherited
newEdge(s:NodeSprite, t:NodeSprite, d:Boolean, data:Object):EdgeSprite
Internal function for creating a new edge.
Data
 Inherited
newNode(data:Object):NodeSprite
Internal function for creating a new node.
Data
Events
 EventSummaryDefined by
 Inherited
add
 Data
 Inherited  Data
Public Constants
 ConstantDefined by
 InheritedEDGES : String = "edges"
[static] Constant indicating the edges in a Data object.
Data
 InheritedNODES : String = "nodes"
[static] Constant indicating the nodes in a Data object.
Data
Property detail
rootproperty
root:NodeSprite  [write-only]

Sets the root node of this tree. This property can only be set when the tree does not yet have a root node.

Implementation
    public function set root(value:NodeSprite):void
treeproperty 
tree:Tree  [read-write]

This property simply points back to this object.

Implementation
    public function get tree():Tree
    public function set tree(value:Tree):void
Method detail
addChild()method
public function addChild(p:NodeSprite, c:NodeSprite = null):NodeSprite

Add a node to the tree. If the child node argument is null, a new NodeSprite will be created. A new EdgeSprite connecting the nodes will be created. Returns the new child node.

Parameters
p:NodeSprite — the parent node
 
c:NodeSprite (default = null) — the child node. If null, a new child node is created.

Returns
NodeSprite — the new child node
addChildEdge()method 
public function addChildEdge(e:EdgeSprite):EdgeSprite

Adds the given edge as a child edge between a node already in the tree and another node not yet in the tree.

Parameters
e:EdgeSprite — the edge to add to the tree

Returns
EdgeSprite — the newly added edge
addDescendants()method 
protected function addDescendants(n:NodeSprite):void

Registers all tree descendants with this Tree instance.

Parameters
n:NodeSprite — a sub-tree root that has already been added to this Tree
addRoot()method 
public function addRoot():NodeSprite

Creates and returns a new root NodeSprite for the tree. If the tree already has a root, this method throws an error.

Returns
NodeSprite — the newly added root
clear()method 
public override function clear():void

Clears the tree, removing all nodes and edges.

countLeaves()method 
public function countLeaves():int

Counts the number of leaf nodes in the tree.

Returns
int — the number of leaf nodes
removeEdge()method 
public override function removeEdge(e:EdgeSprite):Boolean

Removes an edge from tree tree, removing the entire subtree rooted at the child node adjacent to the edge.

Parameters
e:EdgeSprite — the edge to remove from the tree

Returns
Boolean — true if the edge was successfully removed, false otherwise
removeNode()method 
public override function removeNode(n:NodeSprite):Boolean

Removes a node from the tree, removing the entire subtree rooted at that node.

Parameters
n:NodeSprite — the node to remove

Returns
Boolean — true if the node was successfully removed, false otherwise
swapToRoot()method 
public function swapToRoot(n:NodeSprite):void

Continuously swaps the given node with its parent node until it is the root.

WARNING: this method causes connecting edges to be reconfigured. If this tree is a spanning tree, this can cause havoc.

Parameters
n:NodeSprite — the node to swap with its parent until it becomes the root
swapWithParent()method 
public function swapWithParent(n:NodeSprite):void

Swaps the given node with its parent node.

WARNING: this method causes connecting edges to be reconfigured. If this tree is a spanning tree, this can cause havoc.

Parameters
n:NodeSprite — the node to swap with its parent