Class CellPainterDecorator
- 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 Summary
Constructors Constructor Description CellPainterDecorator()
Creates aCellPainterDecorator
without any configuration to support initialization afterwards.CellPainterDecorator(ICellPainter baseCellPainter, CellEdgeEnum cellEdge, int spacing, ICellPainter decoratorCellPainter)
Will create aCellPainterDecorator
with the given amount of pixels as spacing between base and decoration painter, where the base painter is rendered dependent to the decoration.CellPainterDecorator(ICellPainter baseCellPainter, CellEdgeEnum cellEdge, int spacing, ICellPainter decoratorCellPainter, boolean paintDecorationDependent)
Will create aCellPainterDecorator
with the given amount of pixels as spacing between base and decoration painter.CellPainterDecorator(ICellPainter baseCellPainter, CellEdgeEnum cellEdge, int spacing, ICellPainter decoratorCellPainter, boolean paintDecorationDependent, boolean paintBg)
Will create aCellPainterDecorator
with the given amount of pixels as spacing between base and decoration painter.CellPainterDecorator(ICellPainter baseCellPainter, CellEdgeEnum cellEdge, ICellPainter decoratorCellPainter)
Will create aCellPainterDecorator
with the default spacing of 2 between base and decoration painter, where the base painter is rendered dependent to the decoration.CellPainterDecorator(ICellPainter baseCellPainter, CellEdgeEnum cellEdge, ICellPainter decoratorCellPainter, boolean paintDecorationDependent)
Will create aCellPainterDecorator
with the default spacing of 2 between base and decoration painter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ICellPainter
getBaseCellPainter()
org.eclipse.swt.graphics.Rectangle
getBaseCellPainterBounds(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
CellEdgeEnum
getCellEdge()
ICellPainter
getCellPainterAt(int x, int y, ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
ICellPainter
getDecoratorCellPainter()
org.eclipse.swt.graphics.Rectangle
getDecoratorCellPainterBounds(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
int
getPreferredHeight(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry)
Get the preferred height of the cell when rendered by this painter.int
getPreferredWidth(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry)
Get the preferred width of the cell when rendered by this painter.int
getSpacing()
void
paintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
void
setBaseCellPainter(ICellPainter baseCellPainter)
void
setCellEdge(CellEdgeEnum cellEdge)
void
setDecoratorCellPainter(ICellPainter decoratorCellPainter)
void
setPaintBackground(boolean paintBg)
Configure whether this CellPainterDecorator should paint the background or not.void
setPaintDecorationDependent(boolean paintDecorationDependent)
void
setSpacing(int spacing)
-
-
-
Constructor Detail
-
CellPainterDecorator
public CellPainterDecorator()
Creates aCellPainterDecorator
without any configuration to support initialization afterwards.- Since:
- 1.4
-
CellPainterDecorator
public CellPainterDecorator(ICellPainter baseCellPainter, CellEdgeEnum cellEdge, ICellPainter decoratorCellPainter)
Will create aCellPainterDecorator
with the default spacing of 2 between base and decoration painter, where the base painter is rendered dependent to the decoration.- Parameters:
baseCellPainter
- The baseICellPainter
that should be decoratedcellEdge
- The edge of the cell at which the decoration should be applieddecoratorCellPainter
- TheICellPainter
that should be used to render the decoration.
-
CellPainterDecorator
public CellPainterDecorator(ICellPainter baseCellPainter, CellEdgeEnum cellEdge, ICellPainter decoratorCellPainter, boolean paintDecorationDependent)
Will create aCellPainterDecorator
with the default spacing of 2 between base and decoration painter. If paintDecorationDependent is set tofalse
, the spacing will be ignored.- Parameters:
baseCellPainter
- The baseICellPainter
that should be decoratedcellEdge
- The edge of the cell at which the decoration should be applieddecoratorCellPainter
- TheICellPainter
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 aCellPainterDecorator
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 baseICellPainter
that should be decoratedcellEdge
- The edge of the cell at which the decoration should be appliedspacing
- The amount of pixels that should be used as spacing between decoration and base painterdecoratorCellPainter
- TheICellPainter
that should be used to render the decoration.
-
CellPainterDecorator
public CellPainterDecorator(ICellPainter baseCellPainter, CellEdgeEnum cellEdge, int spacing, ICellPainter decoratorCellPainter, boolean paintDecorationDependent)
Will create aCellPainterDecorator
with the given amount of pixels as spacing between base and decoration painter. If paintDecorationDependent is set tofalse
, the spacing will be ignored while the decoration is mainly rendered over the base painter.- Parameters:
baseCellPainter
- The baseICellPainter
that should be decoratedcellEdge
- The edge of the cell at which the decoration should be applieddecoratorCellPainter
- TheICellPainter
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 aCellPainterDecorator
with the given amount of pixels as spacing between base and decoration painter. If paintDecorationDependent is set tofalse
, the spacing will be ignored while the decoration is mainly rendered over the base painter.- Parameters:
baseCellPainter
- The baseICellPainter
that should be decoratedcellEdge
- The edge of the cell at which the decoration should be applieddecoratorCellPainter
- TheICellPainter
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 Detail
-
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 interfaceICellPainter
- 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 interfaceICellPainter
- 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 interfaceICellPainter
-
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 interfaceICellPainter
-
getBaseCellPainter
public ICellPainter getBaseCellPainter()
- Returns:
- The base
ICellPainter
that is decorated.
-
setBaseCellPainter
public void setBaseCellPainter(ICellPainter baseCellPainter)
- Parameters:
baseCellPainter
- The baseICellPainter
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
- TheICellPainter
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.
-
-