ca.odell.glazedlists.swing
Class TreeTableCellRenderer

java.lang.Object
  extended by ca.odell.glazedlists.swing.TreeTableCellRenderer
All Implemented Interfaces:
TableCellRenderer

public class TreeTableCellRenderer
extends Object
implements TableCellRenderer

This renderer removes some of the burden of producing an appropriate looking component for the hierarchy column of a tree table. Specifically, it takes care of adding components to a panel that render a node location within the tree, but leaves the rendering of the data of the node to a delegate TableCellRenderer that is supplied in the constructor.

For example, in the following tree representation, the spacing and +/- icons would be added to each tree node by this renderer, while the data text would be added by the component returned from the delegate TableCellRenderer.

 - Cars
   + BMW
   - Ford
       Taurus
       Focus
   - Lexus
       ES 300
       LS 600h L
 

Author:
James Lemieux

Constructor Summary
TreeTableCellRenderer(TableCellRenderer delegate, TreeList treeList)
          Decorate the component returned from the delegate with extra components that display the tree node's location within the tree.
 
Method Summary
protected  TableCellRenderer createDelegateRenderer()
          Build the delegate TableCellRenderer that handles rendering the data of each tree node.
 void dispose()
          Cleanup the data within this renderer as it is no longer being used and must be prepared for garbage collection.
 TableCellRenderer getDelegate()
          Returns the delegate TableCellRenderer being decorated.
protected  int getIndent(TreeNodeData treeNodeData, boolean showExpanderForEmptyParent)
          Returns the number of pixels to indent the contents of the renderer.
protected  int getSpacer(TreeNodeData treeNodeData, boolean showExpanderForEmptyParent)
          Returns the number of pixels of space between the expand/collapse button and the node component.
 Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
          Return a decorated form of the component returned by the data TableCellRenderer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeTableCellRenderer

public TreeTableCellRenderer(TableCellRenderer delegate,
                             TreeList treeList)
Decorate the component returned from the delegate with extra components that display the tree node's location within the tree. If delegate is null then a DefaultTableCellRenderer will be used as the delegate.

Parameters:
delegate - the renderer that produces the data for the tree node
treeList - the data structure that answers questions about the tree node and the tree that contains it
Method Detail

createDelegateRenderer

protected TableCellRenderer createDelegateRenderer()
Build the delegate TableCellRenderer that handles rendering the data of each tree node.


getTableCellRendererComponent

public Component getTableCellRendererComponent(JTable table,
                                               Object value,
                                               boolean isSelected,
                                               boolean hasFocus,
                                               int row,
                                               int column)
Return a decorated form of the component returned by the data TableCellRenderer.

Specified by:
getTableCellRendererComponent in interface TableCellRenderer

getIndent

protected int getIndent(TreeNodeData treeNodeData,
                        boolean showExpanderForEmptyParent)
Returns the number of pixels to indent the contents of the renderer.

Parameters:
treeNodeData - hierarhical information about the node within the tree
showExpanderForEmptyParent - true indicates the expander button should always be present, even when no children yet exist

getSpacer

protected int getSpacer(TreeNodeData treeNodeData,
                        boolean showExpanderForEmptyParent)
Returns the number of pixels of space between the expand/collapse button and the node component.

Parameters:
treeNodeData - hierarhical information about the node within the tree
showExpanderForEmptyParent - true indicates the expander button should always be present, even when no children yet exist

getDelegate

public TableCellRenderer getDelegate()
Returns the delegate TableCellRenderer being decorated.


dispose

public void dispose()
Cleanup the data within this renderer as it is no longer being used and must be prepared for garbage collection.



Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by hbrands at 2013-02-12 20:58