Class PaddingDecorator
- java.lang.Object
-
- org.eclipse.nebula.widgets.nattable.painter.cell.AbstractCellPainter
-
- org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper
-
- org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator
-
- All Implemented Interfaces:
ICellPainter
public class PaddingDecorator extends CellPainterWrapper
CellPainterWrapper that adds a padding between the cell border and the interior painter.
-
-
Constructor Summary
Constructors Constructor Description PaddingDecorator(ICellPainter interiorPainter)
Create a PaddingDecorator around the given interior painter, adding a padding of 2 pixels on every side.
If will paint the background color to fill the resulting gaps, in case the PaddingDecorator wraps e.g.PaddingDecorator(ICellPainter interiorPainter, boolean paintBg)
Create a PaddingDecorator around the given interior painter, adding a padding of 2 pixels on every side.
This constructor allows to configure whether the PaddingDecorator should itself paint the background to avoid gaps or not.PaddingDecorator(ICellPainter interiorPainter, int padding)
Create a PaddingDecorator around the given interior painter, adding a padding of the given number of pixels on every side.
If will paint the background color to fill the resulting gaps, in case the PaddingDecorator wraps e.g.PaddingDecorator(ICellPainter interiorPainter, int padding, boolean paintBg)
Create a PaddingDecorator around the given interior painter, adding a padding of the given number of pixels on every side.
This constructor allows to configure whether the PaddingDecorator should itself paint the background to avoid gaps or not.PaddingDecorator(ICellPainter interiorPainter, int topPadding, int rightPadding, int bottomPadding, int leftPadding)
Create a PaddingDecorator around the given interior painter, adding the padding specified for each side.
If will paint the background color to fill the resulting gaps, in case the PaddingDecorator wraps e.g.PaddingDecorator(ICellPainter interiorPainter, int topPadding, int rightPadding, int bottomPadding, int leftPadding, boolean paintBg)
Create a PaddingDecorator around the given interior painter, adding the padding specified for each side.
This constructor allows to configure whether the PaddingDecorator should itself paint the background to avoid gaps or not.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.eclipse.swt.graphics.Color
getBackgroundColor(ILayerCell cell, IConfigRegistry configRegistry)
Extract the background color that is registered for the given ILayerCell.int
getBottomPadding()
ICellPainter
getCellPainterAt(int x, int y, ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
org.eclipse.swt.graphics.Rectangle
getInteriorBounds(org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
Calculates the cell bounds that should be used for the internal painter out of the available bounds for this PaddingDecorator and the configured padding.int
getLeftPadding()
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
getRightPadding()
int
getTopPadding()
void
paintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
-
Methods inherited from class org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper
getWrappedPainter, getWrappedPainterBounds, setWrappedPainter
-
-
-
-
Constructor Detail
-
PaddingDecorator
public PaddingDecorator(ICellPainter interiorPainter)
Create a PaddingDecorator around the given interior painter, adding a padding of 2 pixels on every side.
If will paint the background color to fill the resulting gaps, in case the PaddingDecorator wraps e.g. a TextPainter but is itself not wrapped by a BackgroundPainter.- Parameters:
interiorPainter
- The painter that should be wrapped.
-
PaddingDecorator
public PaddingDecorator(ICellPainter interiorPainter, boolean paintBg)
Create a PaddingDecorator around the given interior painter, adding a padding of 2 pixels on every side.
This constructor allows to configure whether the PaddingDecorator should itself paint the background to avoid gaps or not. In case the PaddingDecorator is wrapped in another background painter, e.g. BackgroundImagePainter or GradientBackroundPainter, the paintBg parameter needs to befalse
to avoid rendering issues.- Parameters:
interiorPainter
- The painter that should be wrapped.paintBg
-true
if the PaddingDecorator should paint the background,false
if not.
-
PaddingDecorator
public PaddingDecorator(ICellPainter interiorPainter, int padding)
Create a PaddingDecorator around the given interior painter, adding a padding of the given number of pixels on every side.
If will paint the background color to fill the resulting gaps, in case the PaddingDecorator wraps e.g. a TextPainter but is itself not wrapped by a BackgroundPainter.- Parameters:
interiorPainter
- The painter that should be wrapped.padding
- The number of pixels that should be used as padding on every side.
-
PaddingDecorator
public PaddingDecorator(ICellPainter interiorPainter, int padding, boolean paintBg)
Create a PaddingDecorator around the given interior painter, adding a padding of the given number of pixels on every side.
This constructor allows to configure whether the PaddingDecorator should itself paint the background to avoid gaps or not. In case the PaddingDecorator is wrapped in another background painter, e.g. BackgroundImagePainter or GradientBackroundPainter, the paintBg parameter needs to befalse
to avoid rendering issues.- Parameters:
interiorPainter
- The painter that should be wrapped.padding
- The number of pixels that should be used as padding on every side.paintBg
-true
if the PaddingDecorator should paint the background,false
if not.
-
PaddingDecorator
public PaddingDecorator(ICellPainter interiorPainter, int topPadding, int rightPadding, int bottomPadding, int leftPadding)
Create a PaddingDecorator around the given interior painter, adding the padding specified for each side.
If will paint the background color to fill the resulting gaps, in case the PaddingDecorator wraps e.g. a TextPainter but is itself not wrapped by a BackgroundPainter.- Parameters:
interiorPainter
- The painter that should be wrapped.topPadding
- The number of pixels that should be used as padding on top.rightPadding
- The number of pixels that should be used as padding to the right.bottomPadding
- The number of pixels that should be used as padding at the bottom.leftPadding
- The number of pixels that should be used as padding to the left.
-
PaddingDecorator
public PaddingDecorator(ICellPainter interiorPainter, int topPadding, int rightPadding, int bottomPadding, int leftPadding, boolean paintBg)
Create a PaddingDecorator around the given interior painter, adding the padding specified for each side.
This constructor allows to configure whether the PaddingDecorator should itself paint the background to avoid gaps or not. In case the PaddingDecorator is wrapped in another background painter, e.g. BackgroundImagePainter or GradientBackroundPainter, the paintBg parameter needs to befalse
to avoid rendering issues.- Parameters:
interiorPainter
- The painter that should be wrapped.topPadding
- The number of pixels that should be used as padding on top.rightPadding
- The number of pixels that should be used as padding to the right.bottomPadding
- The number of pixels that should be used as padding at the bottom.leftPadding
- The number of pixels that should be used as padding to the left.paintBg
-true
if the PaddingDecorator should paint the background,false
if not.
-
-
Method Detail
-
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
- Overrides:
getPreferredWidth
in classCellPainterWrapper
- 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
- Overrides:
getPreferredHeight
in classCellPainterWrapper
- 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
- Overrides:
paintCell
in classCellPainterWrapper
-
getInteriorBounds
public org.eclipse.swt.graphics.Rectangle getInteriorBounds(org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry)
Calculates the cell bounds that should be used for the internal painter out of the available bounds for this PaddingDecorator and the configured padding.- Parameters:
adjustedCellBounds
- The cell bounds of the cell to render.configRegistry
- TheIConfigRegistry
needed for accessing the dpi converter.- Returns:
- The cell bounds that are available for the interior painter.
- Since:
- 2.0
-
getBackgroundColor
protected org.eclipse.swt.graphics.Color getBackgroundColor(ILayerCell cell, IConfigRegistry configRegistry)
Extract the background color that is registered for the given ILayerCell.- Parameters:
cell
- The cell for which the background color is requested.configRegistry
- The IConfigRegistry which contains the style configurations.- Returns:
- The background color that should be used to render the background of the given cell.
-
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
- Overrides:
getCellPainterAt
in classCellPainterWrapper
-
getTopPadding
public int getTopPadding()
- Returns:
- The top padding added by this
PaddingDecorator
. - Since:
- 1.4
-
getRightPadding
public int getRightPadding()
- Returns:
- The right padding added by this
PaddingDecorator
. - Since:
- 1.4
-
getBottomPadding
public int getBottomPadding()
- Returns:
- The bottom padding added by this
PaddingDecorator
. - Since:
- 1.4
-
getLeftPadding
public int getLeftPadding()
- Returns:
- The left padding added by this
PaddingDecorator
. - Since:
- 1.4
-
-