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_COLOR
orCellStyleAttributes.FOREGROUND_COLOR
CellStyleAttributes.GRADIENT_BACKGROUND_COLOR
orCellStyleAttributes.BACKGROUND_COLOR
ConfigRegistry
the
painting is skipped.
Can be used as a cell painter or a decorator.
-
Constructor Summary
ConstructorDescriptionCreates aGradientBackgroundPainter
with a gradient sweeping from left to right.GradientBackgroundPainter
(boolean vertical) Creates aGradientBackgroundPainter
where the sweeping direction can be set.GradientBackgroundPainter
(ICellPainter painter) Creates aGradientBackgroundPainter
as wrapper for the given painter with a gradient sweeping from left to right.GradientBackgroundPainter
(ICellPainter painter, boolean vertical) Creates aGradientBackgroundPainter
as wrapper for the given painter where the sweeping direction can be set. -
Method Summary
Modifier and TypeMethodDescriptionprotected org.eclipse.swt.graphics.Color
getBackgroundColour
(ILayerCell cell, IConfigRegistry configRegistry) Searches the background color to be used for gradient sweeping.protected org.eclipse.swt.graphics.Color
getForeGroundColour
(ILayerCell cell, IConfigRegistry configRegistry) Searches the foreground color to be used for gradient sweeping.boolean
void
paintCell
(ILayerCell cell, org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle bounds, IConfigRegistry configRegistry) void
setVertical
(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 aGradientBackgroundPainter
with a gradient sweeping from left to right. -
GradientBackgroundPainter
public GradientBackgroundPainter(boolean vertical) Creates aGradientBackgroundPainter
where the sweeping direction can be set.- Parameters:
vertical
- iftrue
sweeps from top to bottom, else sweeps from left to right.false
is default
-
GradientBackgroundPainter
Creates aGradientBackgroundPainter
as wrapper for the given painter with a gradient sweeping from left to right.- Parameters:
painter
- TheICellPainter
that is wrapped by thisGradientBackgroundPainter
-
GradientBackgroundPainter
Creates aGradientBackgroundPainter
as wrapper for the given painter where the sweeping direction can be set.- Parameters:
painter
- TheICellPainter
that is wrapped by thisGradientBackgroundPainter
vertical
- iftrue
sweeps from top to bottom, else sweeps from left to right.false
is 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:
paintCell
in interfaceICellPainter
- Overrides:
paintCell
in 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 theConfigRegistry
if there is a value for the attributeCellStyleAttributes.GRADIENT_FOREGROUND_COLOR
is registered. If there is one this value will be returned, if not it is checked if there is a value registered forCellStyleAttributes.FOREGROUND_COLOR
and returned. If there is no value registered for any of these attributes,null
will be returned which will skip the painting.- Parameters:
cell
- TheLayerCell
for which the style attributes should be retrieved out of theConfigRegistry
configRegistry
- TheConfigRegistry
to retrieve the attribute values from.- Returns:
- The
Color
to use as foreground color of the gradient sweeping ornull
if 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 theConfigRegistry
if there is a value for the attributeCellStyleAttributes.GRADIENT_BACKGROUND_COLOR
is registered. If there is one this value will be returned, if not it is checked if there is a value registered forCellStyleAttributes.BACKGROUND_COLOR
and returned. If there is no value registered for any of these attributes,null
will be returned which will skip the painting.- Parameters:
cell
- TheLayerCell
for which the style attributes should be retrieved out of theConfigRegistry
configRegistry
- TheConfigRegistry
to retrieve the attribute values from.- Returns:
- The
Color
to use as background color of the gradient sweeping ornull
if none was configured.
-
isVertical
public boolean isVertical()- Returns:
true
if sweeps from top to bottom, else sweeps from left to right. Default isfalse
- Since:
- 1.4
-
setVertical
public void setVertical(boolean vertical) - Parameters:
vertical
-true
if should sweep from top to bottom,false
if it should sweep from left to right. Default isfalse
- Since:
- 1.4
-