Class CellStyleUtil

java.lang.Object
org.eclipse.nebula.widgets.nattable.style.CellStyleUtil

public final class CellStyleUtil extends Object
Helper class to handle cell styles.
  • Method Details

    • getCellStyle

      public static IStyle getCellStyle(ILayerCell cell, IConfigRegistry configRegistry)
      Return an IStyle for a cell that contains the transitive style informations.
      Parameters:
      cell - The ILayerCell for which the style information is requested.
      configRegistry - The IConfigRegistry needed to retrieve the transitive style information.
      Returns:
      The transitive style information for the given cell.
    • getHorizontalAlignmentPadding

      public static int getHorizontalAlignmentPadding(IStyle cellStyle, org.eclipse.swt.graphics.Rectangle rectangle, int contentWidth)
      Calculates the padding needed at the left for horizontal alignment.
      Parameters:
      cellStyle - The style information from which the horizontal alignment configuration is extracted.
      rectangle - The rectangle to paint into.
      contentWidth - The width of the content that should be painted into the rectangle.
      Returns:
      The padding needed at the left to align the content horizontally.
    • getHorizontalAlignmentPadding

      public static int getHorizontalAlignmentPadding(HorizontalAlignmentEnum horizontalAlignment, org.eclipse.swt.graphics.Rectangle rectangle, int contentWidth)
      Calculates the padding needed at the left for horizontal alignment.
      Parameters:
      horizontalAlignment - The horizontal alignment that should be applied. Defaults to HorizontalAlignmentEnum.CENTER if null.
      rectangle - The rectangle to paint into.
      contentWidth - The width of the content that should be painted into the rectangle.
      Returns:
      The padding needed at the left to align the content horizontally.
    • getVerticalAlignmentPadding

      public static int getVerticalAlignmentPadding(IStyle cellStyle, org.eclipse.swt.graphics.Rectangle rectangle, int contentHeight)
      Calculates the padding needed at the top for vertical alignment.
      Parameters:
      cellStyle - The style information from which the vertical alignment configuration is extracted.
      rectangle - The rectangle to paint into.
      contentHeight - The height of the content that should be painted into the rectangle.
      Returns:
      The padding needed at the top to align the content vertically.
    • getVerticalAlignmentPadding

      public static int getVerticalAlignmentPadding(VerticalAlignmentEnum verticalAlignment, org.eclipse.swt.graphics.Rectangle rectangle, int contentHeight)
      Calculates the padding needed at the top for vertical alignment.
      Parameters:
      verticalAlignment - The vertical alignment that should be applied. Defaults to VerticalAlignmentEnum.MIDDLE if null.
      rectangle - The rectangle to paint into.
      contentHeight - The height of the content that should be painted into the rectangle.
      Returns:
      The padding needed at the top to align the content vertically.
    • getAllBackgroundColors

      @Deprecated public static List<org.eclipse.swt.graphics.Color> getAllBackgroundColors(ILayerCell cell, IConfigRegistry configRegistry, String displayMode)
      Collects all background colors configured for the given ILayerCell.
      Parameters:
      cell - The ILayerCell for which the background colors are requested.
      configRegistry - The IConfigRegistry needed to retrieve the transitive style information.
      displayMode - The DisplayMode for which the background color configuration is requested.
      Returns:
      The collection of all background colors that are configured transitively for the given cell.
    • getAllBackgroundColors

      public static List<org.eclipse.swt.graphics.Color> getAllBackgroundColors(ILayerCell cell, IConfigRegistry configRegistry, DisplayMode displayMode)
      Collects all background colors configured for the given ILayerCell.
      Parameters:
      cell - The ILayerCell for which the background colors are requested.
      configRegistry - The IConfigRegistry needed to retrieve the transitive style information.
      displayMode - The DisplayMode for which the background color configuration is requested.
      Returns:
      The collection of all background colors that are configured transitively for the given cell.
      Since:
      2.0
    • getFont

      public static org.eclipse.swt.graphics.Font getFont(IStyle cellStyle, IConfigRegistry configRegistry)
      Extracts the Font from the given cell style and returns a scaled variant if needed.
      Parameters:
      cellStyle - The IStyle to extract the Font from.
      configRegistry - The IConfigRegistry needed to check for the scaling factor.
      Returns:
      The Font to use.
      Since:
      2.0