Class FillHandleLayerPainter

All Implemented Interfaces:
ILayerPainter

public class FillHandleLayerPainter extends SelectionLayerPainter
Extended SelectionLayerPainter that renders an additional border around cells that are selected via fill handle. By default the additional fill handle border style is a green solid 2 pixel sized line. This BorderStyle can be configured via IConfigRegistry using the config label FillHandleConfigAttributes.FILL_HANDLE_REGION_BORDER_STYLE.

You can also register a different cell style for cells in the fill handle region by configuring a style for the label SelectionStyleLabels.FILL_HANDLE_REGION

This ILayerPainter also renders a border around cells that are currently copied to the InternalCellClipboard. For this an InternalCellClipboard needs to be set to this painter. Note that a global instance of InternalCellClipboard can be retrieved via NatTable.getInternalCellClipboard().

Since:
1.4
See Also:
  • Field Details

    • handleBounds

      protected org.eclipse.swt.graphics.Rectangle handleBounds
      The bounds of the current visible selection handle or null if no fill handle is currently rendered.
    • clipboard

      protected InternalCellClipboard clipboard
      The InternalCellClipboard that is used to identify whether a cell is currently copied. Can be null to disable special rendering of copied cells.
  • Constructor Details

    • FillHandleLayerPainter

      public FillHandleLayerPainter()
      Create a SelectionLayerPainter that renders gray grid lines and uses the default clipping behavior.
    • FillHandleLayerPainter

      public FillHandleLayerPainter(org.eclipse.swt.graphics.Color gridColor)
      Create an FillHandleLayerPainter that renders grid lines in the specified color and uses the default clipping behavior.
      Parameters:
      gridColor - The color that should be used to render the grid lines.
    • FillHandleLayerPainter

      public FillHandleLayerPainter(boolean clipLeft, boolean clipTop)
      Create an FillHandleLayerPainter that renders gray grid lines and uses the specified clipping behavior.
      Parameters:
      clipLeft - Configure the rendering behavior when cells overlap. If set to true the left cell will be clipped, if set to false the right cell will be clipped. The default value is false.
      clipTop - Configure the rendering behavior when cells overlap. If set to true the top cell will be clipped, if set to false the bottom cell will be clipped. The default value is false.
    • FillHandleLayerPainter

      public FillHandleLayerPainter(org.eclipse.swt.graphics.Color gridColor, boolean clipLeft, boolean clipTop)
      Create an FillHandleLayerPainter that renders grid lines in the specified color and uses the specified clipping behavior.
      Parameters:
      gridColor - The color that should be used to render the grid lines.
      clipLeft - Configure the rendering behavior when cells overlap. If set to true the left cell will be clipped, if set to false the right cell will be clipped. The default value is false.
      clipTop - Configure the rendering behavior when cells overlap. If set to true the top cell will be clipped, if set to false the bottom cell will be clipped. The default value is false.
    • FillHandleLayerPainter

      public FillHandleLayerPainter(InternalCellClipboard clipboard)
      Create an FillHandleLayerPainter that renders gray grid lines and uses the default clipping behavior. It also renders a border around internally copied cells.
      Parameters:
      clipboard - The InternalCellClipboard that stores the cells that are currently copied.
    • FillHandleLayerPainter

      public FillHandleLayerPainter(InternalCellClipboard clipboard, org.eclipse.swt.graphics.Color gridColor)
      Create an FillHandleLayerPainter that renders grid lines in the specified color and uses the default clipping behavior.
      Parameters:
      clipboard - The InternalCellClipboard that stores the cells that are currently copied.
      gridColor - The color that should be used to render the grid lines.
    • FillHandleLayerPainter

      public FillHandleLayerPainter(InternalCellClipboard clipboard, boolean clipLeft, boolean clipTop)
      Create an FillHandleLayerPainter that renders gray grid lines and uses the specified clipping behavior.
      Parameters:
      clipboard - The InternalCellClipboard that stores the cells that are currently copied.
      clipLeft - Configure the rendering behavior when cells overlap. If set to true the left cell will be clipped, if set to false the right cell will be clipped. The default value is false.
      clipTop - Configure the rendering behavior when cells overlap. If set to true the top cell will be clipped, if set to false the bottom cell will be clipped. The default value is false.
    • FillHandleLayerPainter

      public FillHandleLayerPainter(InternalCellClipboard clipboard, org.eclipse.swt.graphics.Color gridColor, boolean clipLeft, boolean clipTop)
      Create an FillHandleLayerPainter that renders grid lines in the specified color and uses the specified clipping behavior.
      Parameters:
      clipboard - The InternalCellClipboard that stores the cells that are currently copied.
      gridColor - The color that should be used to render the grid lines.
      clipLeft - Configure the rendering behavior when cells overlap. If set to true the left cell will be clipped, if set to false the right cell will be clipped. The default value is false.
      clipTop - Configure the rendering behavior when cells overlap. If set to true the top cell will be clipped, if set to false the bottom cell will be clipped. The default value is false.
  • Method Details

    • paintLayer

      public void paintLayer(ILayer natLayer, org.eclipse.swt.graphics.GC gc, int xOffset, int yOffset, org.eclipse.swt.graphics.Rectangle pixelRectangle, IConfigRegistry configRegistry)
      Specified by:
      paintLayer in interface ILayerPainter
      Overrides:
      paintLayer in class SelectionLayerPainter
      Parameters:
      natLayer - The layer to paint.
      gc - GC used for painting
      xOffset - x offset of the layer from the origin of the table
      yOffset - y offset of the layer from the origin of the table
      pixelRectangle - area the layer can paint in
      configRegistry - IConfigRegistry in use by NatTable. Useful for looking up associated painters.
    • paintFillHandle

      protected void paintFillHandle(ILayerCell fillHandleCell, org.eclipse.swt.graphics.GC gc, int xOffset, int yOffset, IConfigRegistry configRegistry)
    • paintCopyBorder

      protected void paintCopyBorder(ILayer natLayer, org.eclipse.swt.graphics.GC gc, int xOffset, int yOffset, org.eclipse.swt.graphics.Rectangle pixelRectangle, IConfigRegistry configRegistry)
    • isFillHandleRegion

      protected boolean isFillHandleRegion(ILayerCell cell)
      Parameters:
      cell - The ILayerCell to check.
      Returns:
      true if the cell is part of the fill handle region, false if not.
    • isFillHandleCell

      protected boolean isFillHandleCell(ILayerCell cell)
      Parameters:
      cell - The ILayerCell to check.
      Returns:
      true if the cell is the bottom right cell in a fill region, false if not.
    • getHandleRegionBorderStyle

      protected BorderStyle getHandleRegionBorderStyle(IConfigRegistry configRegistry)
      Get the border style that should be used to render the border for cells that are currently part of the fill handle region. Checks the IConfigRegistry for a registered IStyle for the FillHandleConfigAttributes.FILL_HANDLE_REGION_BORDER_STYLE label. If none is registered, a default line style will be returned.
      Parameters:
      configRegistry - The IConfigRegistry to retrieve the style information from.
      Returns:
      The border style that should be used
      Since:
      1.5
    • getHandleColor

      protected org.eclipse.swt.graphics.Color getHandleColor(IConfigRegistry configRegistry)
      Returns the color that should be used to render the fill handle. If the IConfigRegistry is null or does not contain configurations for the color of the fill handle, a default dark green color is used.
      Parameters:
      configRegistry - The IConfigRegistry needed to determine the configured fill handle color. Can be null which results in returning a default dark green color.
      Returns:
      the color that should be used
      Since:
      1.5
    • getHandleBorderStyle

      protected BorderStyle getHandleBorderStyle(IConfigRegistry configRegistry)
      Returns the border style that should be used to render the border of the fill handle. If the IConfigRegistry is null or does not contain configurations for styling the border of the fill handle, a default style is used.
      Parameters:
      configRegistry - The IConfigRegistry needed to determine the configured fill handle border style. Can be null which results in returning a default style.
      Returns:
      the border style that should be used
      Since:
      1.5
    • getCopyBorderStyle

      protected BorderStyle getCopyBorderStyle(IConfigRegistry configRegistry)
      Get the border style that should be used to render the border for cells that are currently copied to the InternalCellClipboard. Checks the ConfigRegistry for a registered IStyle for the SelectionStyleLabels.COPY_BORDER_STYLE label. If none is registered, a default line style will be used to render the border.
      Parameters:
      configRegistry - The ConfigRegistry to retrieve the style information from.
      Returns:
      the border style that should be used
      Since:
      1.6
    • getSelectionHandleBounds

      public org.eclipse.swt.graphics.Rectangle getSelectionHandleBounds()
      Returns:
      The bounds of the current visible selection handle or null if no fill handle is currently rendered.
    • getClipboard

      public InternalCellClipboard getClipboard()
      Returns:
      The InternalCellClipboard that is used to identify whether a cell is currently copied or null if special rendering of copied cells is disabled.
    • setClipboard

      public void setClipboard(InternalCellClipboard clipboard)
      Parameters:
      clipboard - The InternalCellClipboard that should be used to identify whether a cell is currently copied or null to disable special rendering of copied cells.