Class NatGridLayerPainter

  • All Implemented Interfaces:
    ILayerPainter

    public class NatGridLayerPainter
    extends NatLayerPainter
    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.

    • Constructor Detail

      • NatGridLayerPainter

        public NatGridLayerPainter​(NatTable natTable)
        Parameters:
        natTable - The NatTable instance for which the NatGridLayerPainter should render the background.
      • NatGridLayerPainter

        public NatGridLayerPainter​(NatTable natTable,
                                   org.eclipse.swt.graphics.Color gridColor)
        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 for CellConfigAttributes.GRID_LINE_COLOR will override this value at runtime.
      • NatGridLayerPainter

        public NatGridLayerPainter​(NatTable natTable,
                                   int defaultRowHeight)
        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

        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 for CellConfigAttributes.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.
    • Method Detail

      • 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 class NatLayerPainter
      • getDefaultRowHeight

        public int getDefaultRowHeight()
        Returns:
        The currently used height that is used to render fake rows. The pixel value is locally stored scaled.
      • 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 in here.