org.eclipse.nebula.widgets.nattable.tree.painter
Class IndentedTreeImagePainter

java.lang.Object
  extended by org.eclipse.nebula.widgets.nattable.painter.cell.AbstractCellPainter
      extended by org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper
          extended by org.eclipse.nebula.widgets.nattable.tree.painter.IndentedTreeImagePainter
All Implemented Interfaces:
ICellPainter

public class IndentedTreeImagePainter
extends CellPainterWrapper

Implementation of CellPainterWrapper that is used to render tree structures in NatTable. It puts indentation to tree nodes to visualize the tree structure and adds expand/collapse icons corresponding to the state if a tree node has children.


Constructor Summary
IndentedTreeImagePainter()
          Creates an IndentedTreeImagePainter.
IndentedTreeImagePainter(int treeIndent)
          Creates an IndentedTreeImagePainter.
IndentedTreeImagePainter(int treeIndent, CellEdgeEnum cellEdge, TreeImagePainter treeImagePainter)
           
IndentedTreeImagePainter(int treeIndent, ICellPainter interiorPainter, boolean paintBg, boolean interiorPainterToSpanFullWidth)
          Creates a IndentedTreeImagePainter that uses the given ICellPainter as base ICellPainter and decorate it with the TreeImagePainter on the right edge of the cell.
IndentedTreeImagePainter(int treeIndent, ICellPainter interiorPainter, CellEdgeEnum cellEdge, boolean paintBg, int spacing, boolean paintDecorationDependent)
          Creates a IndentedTreeImagePainter that uses the given ICellPainter as base ICellPainter.
IndentedTreeImagePainter(int treeIndent, ICellPainter interiorPainter, CellEdgeEnum cellEdge, ICellPainter decoratorPainter, boolean paintBg, int spacing, boolean paintDecorationDependent)
          Creates a IndentedTreeImagePainter that uses the given ICellPainter as base ICellPainter.
IndentedTreeImagePainter(int treeIndent, TreeImagePainter treeImagePainter)
          Creates an IndentedTreeImagePainter using the given indentation per depth and ICellPainter for painting the icons in the tree.
IndentedTreeImagePainter(ITreeRowModel<?> treeRowModel)
          Deprecated. Use constructor without ITreeRowModel parameter
IndentedTreeImagePainter(ITreeRowModel<?> treeRowModel, int treeIndent)
          Deprecated. Use constructor without ITreeRowModel parameter
IndentedTreeImagePainter(ITreeRowModel<?> treeRowModel, int treeIndent, TreeImagePainter treeImagePainter)
          Deprecated. Use constructor without ITreeRowModel parameter
 
Method Summary
protected  int getIndent(int depth)
           
 int getPreferredWidth(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry)
          Get the preferred width of the cell when rendered by this painter.
 ICellPainter getTreeImagePainter()
           
 org.eclipse.swt.graphics.Rectangle getWrappedPainterBounds(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry)
           
 void paintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry)
           
 void setBaseCellPainter(ICellPainter cellPainter)
           
 void setTreeImagePainter(ICellPainter cellPainter)
           
 
Methods inherited from class org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper
getCellPainterAt, getPreferredHeight, getWrappedPainter, setWrappedPainter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndentedTreeImagePainter

@Deprecated
public IndentedTreeImagePainter(ITreeRowModel<?> treeRowModel)
Deprecated. Use constructor without ITreeRowModel parameter

Creates an IndentedTreeImagePainter based on the given ITreeRowModel. Will use 10 pixels for indentation per depth and a default TreeImagePainter for rendering the icons in the tree.

Parameters:
treeRowModel - The ITreeRowModel that is needed to get information about tree states like depth, children and expand/collapse.

IndentedTreeImagePainter

@Deprecated
public IndentedTreeImagePainter(ITreeRowModel<?> treeRowModel,
                                           int treeIndent)
Deprecated. Use constructor without ITreeRowModel parameter

Creates an IndentedTreeImagePainter based on the given ITreeRowModel. Will use the given number of pixels for indentation per depth and a default TreeImagePainter for rendering the icons in the tree.

Parameters:
treeRowModel - The ITreeRowModel that is needed to get information about tree states like depth, children and expand/collapse.
treeIndent - The number of pixels to indent per depth.

IndentedTreeImagePainter

@Deprecated
public IndentedTreeImagePainter(ITreeRowModel<?> treeRowModel,
                                           int treeIndent,
                                           TreeImagePainter treeImagePainter)
Deprecated. Use constructor without ITreeRowModel parameter

Creates an IndentedTreeImagePainter based on the given ITreeRowModel, indentation per depth and ICellPainter for painting the icons in the tree.

Parameters:
treeRowModel - The ITreeRowModel that is needed to get information about tree states like depth, children and expand/collapse.
treeIndent - The number of pixels to indent per depth.
treeImagePainter - The TreeImagePainter that should be used to paint the images in the tree. It needs to be of type of TreeImagePainter that paints expand/collapse/leaf icons regarding the node state, because the ui bindings for expand/collapse are registered against that type.

IndentedTreeImagePainter

public IndentedTreeImagePainter()
Creates an IndentedTreeImagePainter. Will use 10 pixels for indentation per depth and a default TreeImagePainter for rendering the icons in the tree.


IndentedTreeImagePainter

public IndentedTreeImagePainter(int treeIndent)
Creates an IndentedTreeImagePainter. Will use the given number of pixels for indentation per depth and a default TreeImagePainter for rendering the icons in the tree.

Parameters:
treeIndent - The number of pixels to indent per depth.

IndentedTreeImagePainter

public IndentedTreeImagePainter(int treeIndent,
                                TreeImagePainter treeImagePainter)
Creates an IndentedTreeImagePainter using the given indentation per depth and ICellPainter for painting the icons in the tree.

Parameters:
treeIndent - The number of pixels to indent per depth.
treeImagePainter - The ICellPainter that should be used to paint the images in the tree. It needs to be of type of TreeImagePainter that paints expand/collapse/leaf icons regarding the node state, because the ui bindings for expand/collapse are registered against that type.

IndentedTreeImagePainter

public IndentedTreeImagePainter(int treeIndent,
                                CellEdgeEnum cellEdge,
                                TreeImagePainter treeImagePainter)

IndentedTreeImagePainter

public IndentedTreeImagePainter(int treeIndent,
                                ICellPainter interiorPainter,
                                CellEdgeEnum cellEdge,
                                boolean paintBg,
                                int spacing,
                                boolean paintDecorationDependent)
Creates a IndentedTreeImagePainter that uses the given ICellPainter as base ICellPainter. It will use the TreeImagePainter as decorator for tree state related decorations at the specified cell edge, which can be configured to render the background or not via method parameter. With the additional parameters, the behaviour of the created CellPainterDecorator can be configured in terms of rendering.

Parameters:
treeIndent - The number of pixels to indent per depth.
interiorPainter - the base ICellPainter to use
cellEdge - the edge of the cell on which the tree state indicator decoration should be applied
paintBg - flag to configure whether the TreeImagePainter should paint the background or not
spacing - the number of pixels that should be used as spacing between cell edge and decoration
paintDecorationDependent - flag to configure if the base ICellPainter should render decoration dependent or not. If it is set to false, the base painter will always paint at the same coordinates, using the whole cell bounds, true will cause the bounds of the cell to shrink for the base painter.

IndentedTreeImagePainter

public IndentedTreeImagePainter(int treeIndent,
                                ICellPainter interiorPainter,
                                CellEdgeEnum cellEdge,
                                ICellPainter decoratorPainter,
                                boolean paintBg,
                                int spacing,
                                boolean paintDecorationDependent)
Creates a IndentedTreeImagePainter that uses the given ICellPainter as base ICellPainter. It will use the given ICellPainter as decorator for tree state related decorations at the specified cell edge, which can be configured to render the background or not via method parameter. With the additional parameters, the behaviour of the created CellPainterDecorator can be configured in terms of rendering.

Parameters:
treeIndent - The number of pixels to indent per depth.
interiorPainter - the base ICellPainter to use
cellEdge - the edge of the cell on which the tree state indicator decoration should be applied
decoratorPainter - the ICellPainter that should be used to paint the tree state related decoration
paintBg - flag to configure whether the CellPainterDecorator should paint the background or not
spacing - the number of pixels that should be used as spacing between cell edge and decoration
paintDecorationDependent - flag to configure if the base ICellPainter should render decoration dependent or not. If it is set to false, the base painter will always paint at the same coordinates, using the whole cell bounds, true will cause the bounds of the cell to shrink for the base painter.

IndentedTreeImagePainter

public IndentedTreeImagePainter(int treeIndent,
                                ICellPainter interiorPainter,
                                boolean paintBg,
                                boolean interiorPainterToSpanFullWidth)
Creates a IndentedTreeImagePainter that uses the given ICellPainter as base ICellPainter and decorate it with the TreeImagePainter on the right edge of the cell. This constructor gives the opportunity to configure the behaviour of the TreeImagePainter and the CellPainterDecorator for some attributes. Remains because of downwards compatibility.

Parameters:
treeIndent - The number of pixels to indent per depth.
interiorPainter - the base ICellPainter to use
paintBg - flag to configure whether the TreeImagePainter should paint the background or not
interiorPainterToSpanFullWidth - flag to configure how the bounds of the base painter should be calculated
Method Detail

getTreeImagePainter

public ICellPainter getTreeImagePainter()
Returns:
The ICellPainter that is used to paint the images in the tree. Usually it is some type of TreeImagePainter that paints expand/collapse/leaf icons regarding the node state.

setTreeImagePainter

public void setTreeImagePainter(ICellPainter cellPainter)
Parameters:
cellPainter - The ICellPainter that should be used to paint the images in the tree. Usually it is some type of TreeImagePainter that paints expand/collapse/leaf icons regarding the node state.

setBaseCellPainter

public void setBaseCellPainter(ICellPainter cellPainter)

getWrappedPainterBounds

public org.eclipse.swt.graphics.Rectangle getWrappedPainterBounds(ILayerCell cell,
                                                                  org.eclipse.swt.graphics.GC gc,
                                                                  org.eclipse.swt.graphics.Rectangle bounds,
                                                                  IConfigRegistry configRegistry)
Overrides:
getWrappedPainterBounds in class CellPainterWrapper

paintCell

public void paintCell(ILayerCell cell,
                      org.eclipse.swt.graphics.GC gc,
                      org.eclipse.swt.graphics.Rectangle bounds,
                      IConfigRegistry configRegistry)
Specified by:
paintCell in interface ICellPainter
Overrides:
paintCell in class CellPainterWrapper

getPreferredWidth

public int getPreferredWidth(ILayerCell cell,
                             org.eclipse.swt.graphics.GC gc,
                             IConfigRegistry configRegistry)
Description copied from interface: ICellPainter
Get the preferred width of the cell when rendered by this painter. Used for auto-resize.

Specified by:
getPreferredWidth in interface ICellPainter
Overrides:
getPreferredWidth in class CellPainterWrapper
Parameters:
cell - The cell for which the preferred width is requested.
gc - The GC that is used for rendering.
configRegistry - The IConfigRegistry that contains the configuration used for rendering.
Returns:
The preferred width of the given cell when rendered by this painter.

getIndent

protected int getIndent(int depth)
Parameters:
depth - The depth/level in the tree structure for which the indent is requested.
Returns:
The number of pixels the content should be indented.


Copyright © 2015. All rights reserved.