Class GradientBackgroundPainter
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.GradientBackgroundPainter
- All Implemented Interfaces:
ICellPainter
Paints the background of the cell with a gradient sweeping using the style
configuration. To configure the gradient sweeping the following style
attributes need to be configured in the
ConfigRegistry:
CellStyleAttributes.GRADIENT_FOREGROUND_COLORorCellStyleAttributes.FOREGROUND_COLORCellStyleAttributes.GRADIENT_BACKGROUND_COLORorCellStyleAttributes.BACKGROUND_COLOR
ConfigRegistry the
painting is skipped.
Can be used as a cell painter or a decorator.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates aGradientBackgroundPainterwith a gradient sweeping from left to right.GradientBackgroundPainter(boolean vertical) Creates aGradientBackgroundPainterwhere the sweeping direction can be set.GradientBackgroundPainter(ICellPainter painter) Creates aGradientBackgroundPainteras wrapper for the given painter with a gradient sweeping from left to right.GradientBackgroundPainter(ICellPainter painter, boolean vertical) Creates aGradientBackgroundPainteras wrapper for the given painter where the sweeping direction can be set. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.eclipse.swt.graphics.ColorgetBackgroundColour(ILayerCell cell, IConfigRegistry configRegistry) Searches the background color to be used for gradient sweeping.protected org.eclipse.swt.graphics.ColorgetForeGroundColour(ILayerCell cell, IConfigRegistry configRegistry) Searches the foreground color to be used for gradient sweeping.booleanvoidpaintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry) voidsetVertical(boolean vertical) Methods inherited from class org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper
getCellPainterAt, getPreferredHeight, getPreferredWidth, getWrappedPainter, getWrappedPainterBounds, setWrappedPainter
-
Constructor Details
-
GradientBackgroundPainter
public GradientBackgroundPainter()Creates aGradientBackgroundPainterwith a gradient sweeping from left to right. -
GradientBackgroundPainter
public GradientBackgroundPainter(boolean vertical) Creates aGradientBackgroundPainterwhere the sweeping direction can be set.- Parameters:
vertical- iftruesweeps from top to bottom, else sweeps from left to right.falseis default
-
GradientBackgroundPainter
Creates aGradientBackgroundPainteras wrapper for the given painter with a gradient sweeping from left to right.- Parameters:
painter- TheICellPainterthat is wrapped by thisGradientBackgroundPainter
-
GradientBackgroundPainter
Creates aGradientBackgroundPainteras wrapper for the given painter where the sweeping direction can be set.- Parameters:
painter- TheICellPainterthat is wrapped by thisGradientBackgroundPaintervertical- iftruesweeps from top to bottom, else sweeps from left to right.falseis default
-
-
Method Details
-
paintCell
public void paintCell(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry) - Specified by:
paintCellin interfaceICellPainter- Overrides:
paintCellin classCellPainterWrapper
-
getForeGroundColour
protected org.eclipse.swt.graphics.Color getForeGroundColour(ILayerCell cell, IConfigRegistry configRegistry) Searches the foreground color to be used for gradient sweeping. First checks theConfigRegistryif there is a value for the attributeCellStyleAttributes.GRADIENT_FOREGROUND_COLORis registered. If there is one this value will be returned, if not it is checked if there is a value registered forCellStyleAttributes.FOREGROUND_COLORand returned. If there is no value registered for any of these attributes,nullwill be returned which will skip the painting.- Parameters:
cell- TheLayerCellfor which the style attributes should be retrieved out of theConfigRegistryconfigRegistry- TheConfigRegistryto retrieve the attribute values from.- Returns:
- The
Colorto use as foreground color of the gradient sweeping ornullif none was configured.
-
getBackgroundColour
protected org.eclipse.swt.graphics.Color getBackgroundColour(ILayerCell cell, IConfigRegistry configRegistry) Searches the background color to be used for gradient sweeping. First checks theConfigRegistryif there is a value for the attributeCellStyleAttributes.GRADIENT_BACKGROUND_COLORis registered. If there is one this value will be returned, if not it is checked if there is a value registered forCellStyleAttributes.BACKGROUND_COLORand returned. If there is no value registered for any of these attributes,nullwill be returned which will skip the painting.- Parameters:
cell- TheLayerCellfor which the style attributes should be retrieved out of theConfigRegistryconfigRegistry- TheConfigRegistryto retrieve the attribute values from.- Returns:
- The
Colorto use as background color of the gradient sweeping ornullif none was configured.
-
isVertical
public boolean isVertical()- Returns:
trueif sweeps from top to bottom, else sweeps from left to right. Default isfalse- Since:
- 1.4
-
setVertical
public void setVertical(boolean vertical) - Parameters:
vertical-trueif should sweep from top to bottom,falseif it should sweep from left to right. Default isfalse- Since:
- 1.4
-