/**
  * Searches the foreground color to be used for gradient sweeping. First checks the {@link
  * org.eclipse.nebula.widgets.nattable.config.ConfigRegistry} if there is a value for the
  * attribute {@link CellStyleAttributes#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 for {@link
  * CellStyleAttributes#FOREGROUND_COLOR} and returned. If there is no value registered for any of
  * these attributes, <code>null</code> will be returned which will skip the painting.
  *
  * @param cell The {@link org.eclipse.nebula.widgets.nattable.layer.cell.LayerCell} for which the
  *     style attributes should be retrieved out of the {@link
  *     org.eclipse.nebula.widgets.nattable.config.ConfigRegistry}
  * @param configRegistry The {@link org.eclipse.nebula.widgets.nattable.config.ConfigRegistry} to
  *     retrieve the attribute values from.
  * @return The {@link Color} to use as foreground color of the gradient sweeping or <code>null
  *     </code> if none was configured.
  */
 protected Color getForeGroundColour(ILayerCell cell, IConfigRegistry configRegistry) {
   Color fgColor =
       CellStyleUtil.getCellStyle(cell, configRegistry)
           .getAttributeValue(CellStyleAttributes.GRADIENT_FOREGROUND_COLOR);
   return fgColor != null
       ? fgColor
       : CellStyleUtil.getCellStyle(cell, configRegistry)
           .getAttributeValue(CellStyleAttributes.FOREGROUND_COLOR);
 }
 /**
  * Searches the background color to be used for gradient sweeping. First checks the {@link
  * org.eclipse.nebula.widgets.nattable.config.ConfigRegistry} if there is a value for the
  * attribute {@link CellStyleAttributes#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 for {@link
  * CellStyleAttributes#BACKGROUND_COLOR} and returned. If there is no value registered for any of
  * these attributes, <code>null</code> will be returned which will skip the painting.
  *
  * @param cell The {@link org.eclipse.nebula.widgets.nattable.layer.cell.LayerCell} for which the
  *     style attributes should be retrieved out of the {@link
  *     org.eclipse.nebula.widgets.nattable.config.ConfigRegistry}
  * @param configRegistry The {@link org.eclipse.nebula.widgets.nattable.config.ConfigRegistry} to
  *     retrieve the attribute values from.
  * @return The {@link Color} to use as background color of the gradient sweeping or <code>null
  *     </code> if none was configured.
  */
 protected Color getBackgroundColour(ILayerCell cell, IConfigRegistry configRegistry) {
   Color bgColor =
       CellStyleUtil.getCellStyle(cell, configRegistry)
           .getAttributeValue(CellStyleAttributes.GRADIENT_BACKGROUND_COLOR);
   return bgColor != null
       ? bgColor
       : CellStyleUtil.getCellStyle(cell, configRegistry)
           .getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR);
 }
  @Override
  public ICellPainter getCellPainterAt(
      final int x,
      final int y,
      final ILayerCell cell,
      final GC gc,
      final Rectangle adjustedCellBounds,
      final IConfigRegistry configRegistry) {

    final int klickOffset = getKlickOffset(cell);

    // need to take the alignment into account
    final IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);

    final HorizontalAlignmentEnum horizontalAlignment =
        cellStyle.getAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT);
    int horizontalAlignmentPadding = 0;
    switch (horizontalAlignment) {
      case LEFT:
        horizontalAlignmentPadding = klickOffset;
        break;
      case CENTER:
        horizontalAlignmentPadding = klickOffset;
        break;
      case RIGHT:
        break;
      default:
        break;
    }

    final VerticalAlignmentEnum verticalAlignment =
        cellStyle.getAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT);
    int verticalAlignmentPadding = 0;
    switch (verticalAlignment) {
      case TOP:
        verticalAlignmentPadding = klickOffset;
        break;
      case MIDDLE:
        verticalAlignmentPadding = klickOffset;
        break;
      case BOTTOM:
        break;
      default:
        break;
    }

    return super.getCellPainterAt(
        x - horizontalAlignmentPadding,
        y - verticalAlignmentPadding,
        cell,
        gc,
        adjustedCellBounds,
        configRegistry);
  }