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
CellPainterWrapper that adds a padding between the cell border and the
interior painter.
-
Constructor Summary
ConstructorsConstructorDescriptionPaddingDecorator(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
Modifier and TypeMethodDescriptionprotected org.eclipse.swt.graphics.ColorgetBackgroundColor(ILayerCell cell, IConfigRegistry configRegistry) Extract the background color that is registered for the given ILayerCell.intgetCellPainterAt(int x, int y, ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle adjustedCellBounds, IConfigRegistry configRegistry) org.eclipse.swt.graphics.RectanglegetInteriorBounds(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.intintgetPreferredHeight(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry) Get the preferred height of the cell when rendered by this painter.intgetPreferredWidth(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry) Get the preferred width of the cell when rendered by this painter.intintvoidpaintCell(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 Details
-
PaddingDecorator
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
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 befalseto avoid rendering issues.- Parameters:
interiorPainter- The painter that should be wrapped.paintBg-trueif the PaddingDecorator should paint the background,falseif not.
-
PaddingDecorator
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
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 befalseto 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-trueif the PaddingDecorator should paint the background,falseif 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 befalseto 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-trueif the PaddingDecorator should paint the background,falseif not.
-
-
Method Details
-
getPreferredWidth
public int getPreferredWidth(ILayerCell cell, org.eclipse.swt.graphics.GC gc, IConfigRegistry configRegistry) Description copied from interface:ICellPainterGet the preferred width of the cell when rendered by this painter. Used for auto-resize.- Specified by:
getPreferredWidthin interfaceICellPainter- Overrides:
getPreferredWidthin 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:ICellPainterGet the preferred height of the cell when rendered by this painter. Used for auto-resize.- Specified by:
getPreferredHeightin interfaceICellPainter- Overrides:
getPreferredHeightin 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:
paintCellin interfaceICellPainter- Overrides:
paintCellin 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- TheIConfigRegistryneeded 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:
getCellPainterAtin interfaceICellPainter- Overrides:
getCellPainterAtin 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
-