echopointng.ui.syncpeer
Class TreeRenderer

java.lang.Object
  extended by echopointng.ui.syncpeer.TreeRenderer

public class TreeRenderer
extends java.lang.Object

TreeRenderer will render a Tree into a list of table elements. This allows the rendering of the individual "tree rows" to be broken out of the main Tree peer.

A Tree is rendered as a series of rows (know here as "tree rows"). The rows are to be line up directly on top of one another. The "TD cells" of the tree rows must line up in order for the Tree to look right. The effect looks something like this :

 |------------|-------------------------------------------------------------
 |            |                                       
 |   folder   |  Root Text                               
 |   icon     |                                          
 |------------|------------|------------|-----------------------------------
 |            |    +/-     |            |               
 |   empty    |  expando   |   folder   |    Child Text
 |            |   icon     |    icon    |             
 |------------|------------|------------|-----------------------------------
 |            |    +/-     |            |               
 |   empty    |  expando   |   folder   |    Child Text
 |            |   icon     |    icon    |             
 |------------|------------|------------|------------|----------------------
 |            |            |   +/-      |            |
 |   empty    |   empty    |   expando  |  folder    |  Grandchild Text
 |            |            |    icon    |   icon     |
 |------------|------------|------------|------------|----------------------
 |            |            |   +/-      |            |
 |   empty    |   empty    |   expando  |  folder    |  Grandchild Text
 |            |            |    icon    |   icon     |
 |------------|------------|------------|------------|----------------------
 

One thing to remember is that the rows are table elements not rows within a single table. This allows the most flexibility for Tree and TreeTables so it really more like this :

 |------------|------------|------------|------------|----------------------
 |            |            |   +/-      |            |
 |   empty    |   empty    |   expando  |  folder    |  Grandchild Text
 |            |            |    icon    |   icon     |
 |------------|------------|------------|------------|----------------------
 
 |------------|------------|------------|------------|----------------------
 |            |            |   +/-      |            |
 |   empty    |   empty    |   expando  |  folder    |  Grandchild Text
 |            |            |    icon    |   icon     |
 |------------|------------|------------|------------|----------------------

 |------------|------------|------------|------------|----------------------
 |            |            |   +/-      |            |
 |   empty    |   empty    |   expando  |  folder    |  Grandchild Text
 |            |            |    icon    |   icon     |
 |------------|------------|------------|------------|----------------------
 


Nested Class Summary
static interface TreeRenderer.EventSupportCallBack
          EventSupportCallBack is a callback that is used to call back to the caller and get it to add "event handling" code to the renderer elements.
 
Constructor Summary
TreeRenderer(RenderingContext rc, TreeRenderer.EventSupportCallBack eventSupportCallBack, Tree tree, Style fallbackStyle, ImageManager imageManager)
          Constructs a TreeRenderer
 
Method Summary
static java.lang.String createPathId(TreePath treeNodePath, TreeModel model)
          This returns a String identifier for a given TreePath.
 void renderTree()
          This is called to render a given Tree as a series of tree rows.
 org.w3c.dom.Element renderTreeRow(java.lang.Object treeNode, TreePath treeNodePath)
          This is called to render a given Tree node as tree row.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeRenderer

public TreeRenderer(RenderingContext rc,
                    TreeRenderer.EventSupportCallBack eventSupportCallBack,
                    Tree tree,
                    Style fallbackStyle,
                    ImageManager imageManager)
Constructs a TreeRenderer

Parameters:
rc - - the RenderingContext to use
eventSupportCallBack - - the call back for event handling
tree - - the Tree in question
imageManager - - the ImageManager to use to contain images.
Method Detail

createPathId

public static java.lang.String createPathId(TreePath treeNodePath,
                                            TreeModel model)
This returns a String identifier for a given TreePath. It simply consisys of its zeros based indexes within the TreeModel. The top most level will be known as [root].

And example is : [root][0][1][3] which is to say the 4th great grandchild child of the 2nd grandchild of the 1st child of the root node.

Parameters:
treeNodePath - - the TreePath to create an PathId for
model - - the model rom which to work out the child index of the nodes
Returns:
a String in the form [root][n][cn][gcn][ggcn]...

renderTree

public void renderTree()
This is called to render a given Tree as a series of tree rows.


renderTreeRow

public org.w3c.dom.Element renderTreeRow(java.lang.Object treeNode,
                                         TreePath treeNodePath)
This is called to render a given Tree node as tree row. It returns the Element containing the renderer tree row.