The Dendrogrammer Code Documentation

dendrogrammer  Dendrogrammer version 1.0.3

The Dendrogrammer > dendrogrammer > ClusterNode

Class ClusterNode

The ClusterTree is made up of ClusterNodes. See description of ClusterTree class for further details. A ClusterTree is a tree structure of these ClusterNodes.

The constructor does the following:
If this node is a leaf
then it sets the child nodes to null and set default leaf descriptions and that is the end of that.
else it calls grow(), causing recursive calls on the new Cluster Node constructor to spawn its childA and its childB child nodes. (and also sets default cluster descriptions)

Important ClusterNode attributes used by other classes:

parent - ancestor node or null for root. Used in traversing the ClusterTree data structure as are childA and B
childA - descendant node or null for leaf
childB - as childA
xHt - used when drawing elements on the graph (i.e. its xPos)
yPos - graph position on the vertical axis
element - the drawn object represented on the graph
label - graphical Raphael label drawn to left of the y axis
bBox - the bounding box for event sensing
longDescription - not used but set to mimic the short description
shortDescription - used to label the node. (Read from leaf data or created from the cluster ID)

Constructor

ClusterNode ( cTableIn , idNoIn , parentNodeIn , nTypeIn , stylesIn )
Parameters:
cTableIn <ClusterTable>
idNoIn <number>
parentNodeIn <ClusterNode>
nTypeIn <number>
stylesIn <the Styles object>

Methods

appendDescendants

array of leaf nodes appendDescendants ( nodeIn , arrayIn )
Called by the ClusterNode_getDescendants method. It does this by calling itself recursively on the node's two children until it comes to a leaf, then pushing the leaf onto the array.
Parameters:
nodeIn <a ClusterNode> the node for which the list is sought.
arrayIn <array> the array to which any leaves are to be appended (an array of ClusterNodes all members of which will be type leaf)
Returns: array of leaf nodes
an array of leaf nodes descended from the given node.

displayDescendants

displayDescendants ( nodeIn , guiIn )
Outputs a string listing the descendant leaf nodes of the given node Calls the node's getDescendants() method to make an array of descendant leaves from which it compiles the string. If the node is a leaf it outputs the leaf's short and long description It also includes a search link in the dialog to send the descendant list to a search engine.
Parameters:
nodeIn <a ClusterNode> the node for which the list is sought
guiIn <a Gui> the gui

drawBoundingBox

void drawBoundingBox ( paperIn )
Draws a transparent rectangular bounding box around the node element This will be used as a larger area to be sensitive for interacting with the cluster.
Parameters:
paperIn <Raphael canvas>
Returns: void

getDescendants

array getDescendants ( the )
Given a cluster node this returns an array of the leaces descended from that cluster node. Calls the appendDescendants method to fill the array.
Parameters:
the <node> cluster node for which we want to list the descendant leaves
Returns: array
An array of descendant leaves OR if the node itself is a leaf then it will return the node itself.

grow

boolean grow ( nodeIn )
Grows the tree by calling itself recursively. The recursion is via the ClusterNode constructor which calls this grow() method. First grow down the childA branch. Then grow down the childB branch.
Parameters:
nodeIn <ClusterNode Object> the current node whose children are to be grown.
Returns: boolean
value not used.

isLeaf

boolean isLeaf ( )
Returns: boolean
true if the node is a leaf

isRoot

boolean isRoot ( )
Returns: boolean
true if the node is the root

showBranch

void showBranch ( nodeIn , on , isSummaryIn )
Turns on or off the highlighting of a tree branch

The reason that "this" is not used in this block is due to it being involved in event handling. When an event fires "this" becomes the object associated with the event rather than the current in scope class object.

Uses a recursive call to highlight itself and all its children.
Parameters:
nodeIn <a ClusterNode> the node at the base of the branch
on <boolean> True indicates turn on highlight. False is off.
isSummaryIn <object> (boolean) True indicates this is a summary dendrogram.
Returns: void


The Dendrogrammer © 2011 D.Robb (See Readme for MIT licence). These pages were created with YUIDoc Copyright © 2011 Yahoo! Inc. All rights reserved.