Class 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 Detail

      • 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,
                                        ICellPainter 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. When using the DefaultTreeLayerConfiguration the content painter 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.
        Since:
        1.6
      • IndentedTreeImagePainter

        public IndentedTreeImagePainter​(int treeIndent,
                                        CellEdgeEnum cellEdge,
                                        ICellPainter treeImagePainter)
        Creates an IndentedTreeImagePainter using the given indentation per depth and ICellPainter for painting the icons in the tree to the specified cell edge.
        Parameters:
        treeIndent - The number of pixels to indent per depth.
        cellEdge - the edge of the cell on which the tree state indicator decoration should be applied
        treeImagePainter - The ICellPainter that should be used to paint the images in the tree. When using the DefaultTreeLayerConfiguration the content painter 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.
        Since:
        1.6
      • 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)
        Parameters:
        cellPainter - The base ICellPainter that should be used to render the cell content.
      • 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,
                                IConfigRegistry configRegistry)
        Parameters:
        depth - The depth/level in the tree structure for which the indent is requested.
        configRegistry - The IConfigRegistry needed for accessing the dpi converter.
        Returns:
        The number of pixels the content should be indented.
        Since:
        2.0
      • getDepth

        protected int getDepth​(ILayerCell cell)
        Parameters:
        cell - The cell for which the depth/level in the tree structure is requested.
        Returns:
        The depth/level in the tree structure the given cell is located.
        Since:
        1.4