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 Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static List<org.eclipse.swt.graphics.Color>
getAllBackgroundColors(ILayerCell cell, IConfigRegistry configRegistry, String displayMode)
Deprecated.static List<org.eclipse.swt.graphics.Color>
getAllBackgroundColors(ILayerCell cell, IConfigRegistry configRegistry, DisplayMode displayMode)
Collects all background colors configured for the givenILayerCell
.static IStyle
getCellStyle(ILayerCell cell, IConfigRegistry configRegistry)
Return anIStyle
for a cell that contains the transitive style informations.static org.eclipse.swt.graphics.Font
getFont(IStyle cellStyle, IConfigRegistry configRegistry)
Extracts theFont
from the given cell style and returns a scaled variant if needed.static int
getHorizontalAlignmentPadding(HorizontalAlignmentEnum horizontalAlignment, org.eclipse.swt.graphics.Rectangle rectangle, int contentWidth)
Calculates the padding needed at the left for horizontal alignment.static int
getHorizontalAlignmentPadding(IStyle cellStyle, org.eclipse.swt.graphics.Rectangle rectangle, int contentWidth)
Calculates the padding needed at the left for horizontal alignment.static int
getVerticalAlignmentPadding(IStyle cellStyle, org.eclipse.swt.graphics.Rectangle rectangle, int contentHeight)
Calculates the padding needed at the top for vertical alignment.static int
getVerticalAlignmentPadding(VerticalAlignmentEnum verticalAlignment, org.eclipse.swt.graphics.Rectangle rectangle, int contentHeight)
Calculates the padding needed at the top for vertical alignment.
-
-
-
Method Detail
-
getCellStyle
public static IStyle getCellStyle(ILayerCell cell, IConfigRegistry configRegistry)
Return anIStyle
for a cell that contains the transitive style informations.- Parameters:
cell
- TheILayerCell
for which the style information is requested.configRegistry
- TheIConfigRegistry
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 toHorizontalAlignmentEnum.CENTER
ifnull
.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 toVerticalAlignmentEnum.MIDDLE
ifnull
.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)
Deprecated.Collects all background colors configured for the givenILayerCell
.- Parameters:
cell
- TheILayerCell
for which the background colors are requested.configRegistry
- TheIConfigRegistry
needed to retrieve the transitive style information.displayMode
- TheDisplayMode
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 givenILayerCell
.- Parameters:
cell
- TheILayerCell
for which the background colors are requested.configRegistry
- TheIConfigRegistry
needed to retrieve the transitive style information.displayMode
- TheDisplayMode
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 theFont
from the given cell style and returns a scaled variant if needed.- Parameters:
cellStyle
- TheIStyle
to extract theFont
from.configRegistry
- TheIConfigRegistry
needed to check for the scaling factor.- Returns:
- The
Font
to use. - Since:
- 2.0
-
-