Class NatGridLayerPainter
java.lang.Object
org.eclipse.nebula.widgets.nattable.painter.layer.NatLayerPainter
org.eclipse.nebula.widgets.nattable.painter.layer.NatGridLayerPainter
- All Implemented Interfaces:
ILayerCommandHandler<RowSizeConfigurationCommand>
,ILayerPainter
public class NatGridLayerPainter
extends NatLayerPainter
implements ILayerCommandHandler<RowSizeConfigurationCommand>
Specialization of NatLayerPainter that fills the background with grid lines
to create the same look and feel as native table controls. It is possible to
specify the grid line color directly or via ConfigRegistry
CellConfigAttributes.GRID_LINE_COLOR
, where the ConfigRegistry entry
will win over direct configuration.
If there should be several fake rows rendered, you need to set the default row height that should be used for rendering the fake row lines. Otherwise this will be skipped and only the column lines will be rendered to the bottom.
-
Field Summary
Fields inherited from class org.eclipse.nebula.widgets.nattable.painter.layer.NatLayerPainter
natTable
-
Constructor Summary
ConstructorsConstructorDescriptionNatGridLayerPainter
(NatTable natTable) NatGridLayerPainter
(NatTable natTable, int defaultRowHeight) NatGridLayerPainter
(NatTable natTable, int defaultRowHeight, boolean registerCommandHandler) NatGridLayerPainter
(NatTable natTable, org.eclipse.swt.graphics.Color gridColor) NatGridLayerPainter
(NatTable natTable, org.eclipse.swt.graphics.Color gridColor, int defaultRowHeight) NatGridLayerPainter
(NatTable natTable, org.eclipse.swt.graphics.Color gridColor, int defaultRowHeight, boolean registerCommandHandler) -
Method Summary
Modifier and TypeMethodDescriptionboolean
doCommand
(ILayer targetLayer, RowSizeConfigurationCommand command) int
int
protected void
paintBackground
(ILayer natLayer, org.eclipse.swt.graphics.GC gc, int xOffset, int yOffset, org.eclipse.swt.graphics.Rectangle rectangle, IConfigRegistry configRegistry) void
Register ourself asILayerCommandHandler
for theRowSizeConfigurationCommand
on the NatTable instance.void
setDefaultRowHeight
(int defaultRowHeight) void
Unregister ourself asILayerCommandHandler
for theRowSizeConfigurationCommand
from the NatTable instance.Methods inherited from class org.eclipse.nebula.widgets.nattable.painter.layer.NatLayerPainter
adjustCellBounds, paintLayer, paintOverlays
-
Constructor Details
-
NatGridLayerPainter
- Parameters:
natTable
- The NatTable instance for which the NatGridLayerPainter should render the background.
-
NatGridLayerPainter
- Parameters:
natTable
- The NatTable instance for which the NatGridLayerPainter should render the background.gridColor
- The Color that should be used to render the grid lines. Note that an entry forCellConfigAttributes.GRID_LINE_COLOR
will override this value at runtime.
-
NatGridLayerPainter
- Parameters:
natTable
- The NatTable instance for which the NatGridLayerPainter should render the background.defaultRowHeight
- The row height that should be used to render fake rows to the bottom. Setting a value of 0 will avoid rendering fake row lines.
-
NatGridLayerPainter
- Parameters:
natTable
- The NatTable instance for which the NatGridLayerPainter should render the background.defaultRowHeight
- The row height that should be used to render fake rows to the bottom. Setting a value of 0 will avoid rendering fake row lines.registerCommandHandler
- If set totrue
this class registers asILayerCommandHandler
for theRowSizeConfigurationCommand
on the NatTable instance.- Since:
- 2.3
-
NatGridLayerPainter
public NatGridLayerPainter(NatTable natTable, org.eclipse.swt.graphics.Color gridColor, int defaultRowHeight) - Parameters:
natTable
- The NatTable instance for which the NatGridLayerPainter should render the background.gridColor
- The Color that should be used to render the grid lines. Note that an entry forCellConfigAttributes.GRID_LINE_COLOR
will override this value at runtime.defaultRowHeight
- The row height that should be used to render fake rows to the bottom. Setting a value of 0 will avoid rendering fake row lines.
-
NatGridLayerPainter
public NatGridLayerPainter(NatTable natTable, org.eclipse.swt.graphics.Color gridColor, int defaultRowHeight, boolean registerCommandHandler) - Parameters:
natTable
- The NatTable instance for which the NatGridLayerPainter should render the background.gridColor
- The Color that should be used to render the grid lines. Note that an entry forCellConfigAttributes.GRID_LINE_COLOR
will override this value at runtime.defaultRowHeight
- The row height that should be used to render fake rows to the bottom. Setting a value of 0 will avoid rendering fake row lines.registerCommandHandler
- If set totrue
this class registers asILayerCommandHandler
for theRowSizeConfigurationCommand
on the NatTable instance.- Since:
- 2.3
-
-
Method Details
-
paintBackground
protected void paintBackground(ILayer natLayer, org.eclipse.swt.graphics.GC gc, int xOffset, int yOffset, org.eclipse.swt.graphics.Rectangle rectangle, IConfigRegistry configRegistry) - Overrides:
paintBackground
in classNatLayerPainter
-
getConfiguredDefaultRowHeight
public int getConfiguredDefaultRowHeight()- Returns:
- The currently configured unscaled height that is used to render fake rows.
- Since:
- 2.3
-
getDefaultRowHeight
public int getDefaultRowHeight()- Returns:
- The currently used height that is used to render fake rows scaled to match the NatTable scaling.
-
setDefaultRowHeight
public void setDefaultRowHeight(int defaultRowHeight) - Parameters:
defaultRowHeight
- The value that should be used to render fake rows. The value needs to be given in pixels, as the scaling calculation is done on rendering.
-
registerCommandHandler
public void registerCommandHandler()Register ourself asILayerCommandHandler
for theRowSizeConfigurationCommand
on the NatTable instance. This enables automatic updates of thedefaultRowHeight
if it is updated viaRowSizeConfigurationCommand
.- Since:
- 2.3
-
unregisterCommandHandler
public void unregisterCommandHandler()Unregister ourself asILayerCommandHandler
for theRowSizeConfigurationCommand
from the NatTable instance.- Since:
- 2.3
-
doCommand
- Specified by:
doCommand
in interfaceILayerCommandHandler<RowSizeConfigurationCommand>
- Parameters:
targetLayer
- the target layercommand
- the command- Returns:
- true if the command has been handled, false otherwise
- Since:
- 2.3
-
getCommandClass
- Specified by:
getCommandClass
in interfaceILayerCommandHandler<RowSizeConfigurationCommand>
-