java.lang.Object
org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator
All Implemented Interfaces:
ICellPainter

public class CellPainterDecorator extends Object implements ICellPainter
Decorates a cell painter with another cell painter.
  • Constructor Details

    • CellPainterDecorator

      public CellPainterDecorator()
      Creates a CellPainterDecorator without any configuration to support initialization afterwards.
      Since:
      1.4
    • CellPainterDecorator

      public CellPainterDecorator(ICellPainter baseCellPainter, CellEdgeEnum cellEdge, ICellPainter decoratorCellPainter)
      Will create a CellPainterDecorator with the default spacing of 2 between base and decoration painter, where the base painter is rendered dependent to the decoration.
      Parameters:
      baseCellPainter - The base ICellPainter that should be decorated
      cellEdge - The edge of the cell at which the decoration should be applied
      decoratorCellPainter - The ICellPainter that should be used to render the decoration.
    • CellPainterDecorator

      public CellPainterDecorator(ICellPainter baseCellPainter, CellEdgeEnum cellEdge, ICellPainter decoratorCellPainter, boolean paintDecorationDependent)
      Will create a CellPainterDecorator with the default spacing of 2 between base and decoration painter. If paintDecorationDependent is set to false, the spacing will be ignored.
      Parameters:
      baseCellPainter - The base ICellPainter that should be decorated
      cellEdge - The edge of the cell at which the decoration should be applied
      decoratorCellPainter - The ICellPainter that should be used to render the decoration.
      paintDecorationDependent - Flag to specify whether the base painter should render dependent to the decoration painter or not.
    • CellPainterDecorator

      public CellPainterDecorator(ICellPainter baseCellPainter, CellEdgeEnum cellEdge, int spacing, ICellPainter decoratorCellPainter)
      Will create a CellPainterDecorator with the given amount of pixels as spacing between base and decoration painter, where the base painter is rendered dependent to the decoration.
      Parameters:
      baseCellPainter - The base ICellPainter that should be decorated
      cellEdge - The edge of the cell at which the decoration should be applied
      spacing - The amount of pixels that should be used as spacing between decoration and base painter
      decoratorCellPainter - The ICellPainter that should be used to render the decoration.
    • CellPainterDecorator

      public CellPainterDecorator(ICellPainter baseCellPainter, CellEdgeEnum cellEdge, int spacing, ICellPainter decoratorCellPainter, boolean paintDecorationDependent)
      Will create a CellPainterDecorator with the given amount of pixels as spacing between base and decoration painter. If paintDecorationDependent is set to false, the spacing will be ignored while the decoration is mainly rendered over the base painter.
      Parameters:
      baseCellPainter - The base ICellPainter that should be decorated
      cellEdge - The edge of the cell at which the decoration should be applied
      decoratorCellPainter - The ICellPainter that should be used to render the decoration.
      paintDecorationDependent - Flag to specify whether the base painter should render dependent to the decoration painter or not.
    • CellPainterDecorator

      public CellPainterDecorator(ICellPainter baseCellPainter, CellEdgeEnum cellEdge, int spacing, ICellPainter decoratorCellPainter, boolean paintDecorationDependent, boolean paintBg)
      Will create a CellPainterDecorator with the given amount of pixels as spacing between base and decoration painter. If paintDecorationDependent is set to false, the spacing will be ignored while the decoration is mainly rendered over the base painter.
      Parameters:
      baseCellPainter - The base ICellPainter that should be decorated
      cellEdge - The edge of the cell at which the decoration should be applied
      decoratorCellPainter - The ICellPainter that should be used to render the decoration.
      paintDecorationDependent - Flag to specify whether the base painter should render dependent to the decoration painter or not.
      paintBg - true if the PaddingDecorator should paint the background, false if not.
  • Method Details

    • setPaintDecorationDependent

      public void setPaintDecorationDependent(boolean paintDecorationDependent)
      Parameters:
      paintDecorationDependent - true if the base painter should render dependent to the decoration painter, false if the decoration should be rendered over the base painter.
    • setPaintBackground

      public void setPaintBackground(boolean paintBg)
      Configure whether this CellPainterDecorator should paint the background or not. By default it will paint the background to ensure the spacing is also painted in the configured background color. This will only cause issues in case another background painter like the GradientBackroundPainter should be used.
      Parameters:
      paintBg - true if this CellPainterDecorator should also paint the background, false if the background should not be painted.
    • 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
      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.
    • getPreferredHeight

      public int getPreferredHeight(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry)
      Description copied from interface: ICellPainter
      Get the preferred height of the cell when rendered by this painter. Used for auto-resize.
      Specified by:
      getPreferredHeight in interface ICellPainter
      Parameters:
      cell - The cell for which the preferred height is requested.
      gc - The GC that is used for rendering.
      configRegistry - The IConfigRegistry that contains the configuration used for rendering.
      Returns:
      The preferred height of the given cell when rendered by this painter.
    • paintCell

      public void paintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
      Specified by:
      paintCell in interface ICellPainter
    • getBaseCellPainterBounds

      public org.eclipse.swt.graphics.Rectangle getBaseCellPainterBounds(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
      Returns:
      The Rectangle which can be used by the base cell painter.
    • getDecoratorCellPainterBounds

      public org.eclipse.swt.graphics.Rectangle getDecoratorCellPainterBounds(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
      Returns:
      The Rectangle to paint the decoration.
    • getCellPainterAt

      public ICellPainter getCellPainterAt(int x, int y, ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
      Specified by:
      getCellPainterAt in interface ICellPainter
    • getBaseCellPainter

      public ICellPainter getBaseCellPainter()
      Returns:
      The base ICellPainter that is decorated.
    • setBaseCellPainter

      public void setBaseCellPainter(ICellPainter baseCellPainter)
      Parameters:
      baseCellPainter - The base ICellPainter that should be decorated.
    • getDecoratorCellPainter

      public ICellPainter getDecoratorCellPainter()
      Returns:
      The ICellPainter that is used to render the decoration.
    • setDecoratorCellPainter

      public void setDecoratorCellPainter(ICellPainter decoratorCellPainter)
      Parameters:
      decoratorCellPainter - The ICellPainter that should be used to render the decoration.
    • getCellEdge

      public CellEdgeEnum getCellEdge()
      Returns:
      The edge of the cell at which the decoration is applied.
    • setCellEdge

      public void setCellEdge(CellEdgeEnum cellEdge)
      Parameters:
      cellEdge - The edge of the cell at which the decoration should be applied.
    • getSpacing

      public int getSpacing()
      Returns:
      The spacing that is used between base painter and decoration painter.
    • setSpacing

      public void setSpacing(int spacing)
      Parameters:
      spacing - The spacing that should be used between base painter and decoration painter.