use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.
the class LineBorderDecorator method getBorderStyle.
private BorderStyle getBorderStyle(ILayerCell cell, IConfigRegistry configRegistry) {
IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
BorderStyle borderStyle = cellStyle.getAttributeValue(CellStyleAttributes.BORDER_STYLE);
if (borderStyle == null) {
borderStyle = this.defaultBorderStyle;
}
return borderStyle;
}
use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.
the class PaddingDecorator method getCellPainterAt.
@Override
public ICellPainter getCellPainterAt(int x, int y, ILayerCell cell, GC gc, Rectangle adjustedCellBounds, IConfigRegistry configRegistry) {
// need to take the alignment into account
IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
HorizontalAlignmentEnum horizontalAlignment = cellStyle.getAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT);
int horizontalAlignmentPadding = 0;
switch(horizontalAlignment) {
case LEFT:
horizontalAlignmentPadding = GUIHelper.convertHorizontalPixelToDpi(this.leftPadding);
break;
case CENTER:
horizontalAlignmentPadding = GUIHelper.convertHorizontalPixelToDpi(this.leftPadding) / 2;
break;
}
VerticalAlignmentEnum verticalAlignment = cellStyle.getAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT);
int verticalAlignmentPadding = 0;
switch(verticalAlignment) {
case TOP:
verticalAlignmentPadding = GUIHelper.convertHorizontalPixelToDpi(this.topPadding);
break;
case MIDDLE:
verticalAlignmentPadding = GUIHelper.convertHorizontalPixelToDpi(this.topPadding) / 2;
break;
}
return super.getCellPainterAt(x - horizontalAlignmentPadding, y - verticalAlignmentPadding, cell, gc, adjustedCellBounds, configRegistry);
}
use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.
the class SelectionLayerPainter method getBorderStyle.
/**
* Get the border style that should be used to render the border for cells
* that are currently selected. Checks the {@link IConfigRegistry} for a
* registered {@link IStyle} for the
* {@link SelectionConfigAttributes#SELECTION_GRID_LINE_STYLE} label or the
* {@link SelectionStyleLabels#SELECTION_ANCHOR_GRID_LINE_STYLE} label. If
* none is registered, a default line style will be returned.
*
* @param configRegistry
* The {@link IConfigRegistry} to retrieve the style information
* from.
*
* @return The border style that should be used
*
* @since 1.5
*/
protected BorderStyle getBorderStyle(IConfigRegistry configRegistry) {
BorderStyle borderStyle = configRegistry.getConfigAttribute(SelectionConfigAttributes.SELECTION_GRID_LINE_STYLE, DisplayMode.SELECT);
// check for backwards compatibility style configuration
if (borderStyle == null) {
// Note: If there is no style configured for the
// SelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLE
// label, the style configured for DisplayMode.SELECT will be
// retrieved by this call.
// Ensure that the selection style configuration does not contain a
// border style configuration to avoid strange rendering behavior.
// By default there is no border configuration added, so there
// shouldn't be issues with backwards compatibility. And if there
// are some, they can be solved easily by adding the necessary
// border style configuration.
IStyle cellStyle = configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, DisplayMode.SELECT, SelectionStyleLabels.SELECTION_ANCHOR_GRID_LINE_STYLE);
borderStyle = cellStyle != null ? cellStyle.getAttributeValue(CellStyleAttributes.BORDER_STYLE) : null;
}
// if there is no border style configured, use the default
if (borderStyle == null) {
borderStyle = new BorderStyle(1, GUIHelper.COLOR_BLACK, LineStyleEnum.DOTTED, BorderModeEnum.CENTERED);
}
return borderStyle;
}
use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.
the class DefaultNatTableThemeConfiguration method getCornerSelectionStyle.
@Override
protected IStyle getCornerSelectionStyle() {
IStyle cellStyle = new Style();
cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.cornerSelectionBgColor);
cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, this.cornerSelectionFgColor);
cellStyle.setAttributeValue(CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, this.cornerSelectionGradientBgColor);
cellStyle.setAttributeValue(CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, this.cornerSelectionGradientFgColor);
cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, this.cornerSelectionHAlign);
cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, this.cornerSelectionVAlign);
cellStyle.setAttributeValue(CellStyleAttributes.FONT, this.cornerSelectionFont);
cellStyle.setAttributeValue(CellStyleAttributes.IMAGE, this.cornerSelectionImage);
cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, this.cornerSelectionBorderStyle);
cellStyle.setAttributeValue(CellStyleAttributes.PASSWORD_ECHO_CHAR, this.cornerSelectionPWEchoChar);
cellStyle.setAttributeValue(CellStyleAttributes.TEXT_DECORATION, this.cornerSelectionTextDecoration);
return cellStyle;
}
use of org.eclipse.nebula.widgets.nattable.style.IStyle in project nebula.widgets.nattable by eclipse.
the class DefaultNatTableThemeConfiguration method getDefaultHoverSelectionStyle.
@Override
protected IStyle getDefaultHoverSelectionStyle() {
IStyle cellStyle = new Style();
cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.defaultHoverSelectionBgColor);
cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, this.defaultHoverSelectionFgColor);
cellStyle.setAttributeValue(CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, this.defaultHoverSelectionGradientBgColor);
cellStyle.setAttributeValue(CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, this.defaultHoverSelectionGradientFgColor);
cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, this.defaultHoverSelectionHAlign);
cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, this.defaultHoverSelectionVAlign);
cellStyle.setAttributeValue(CellStyleAttributes.FONT, this.defaultHoverSelectionFont);
cellStyle.setAttributeValue(CellStyleAttributes.IMAGE, this.defaultHoverSelectionImage);
cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, this.defaultHoverSelectionBorderStyle);
cellStyle.setAttributeValue(CellStyleAttributes.PASSWORD_ECHO_CHAR, this.defaultHoverSelectionPWEchoChar);
cellStyle.setAttributeValue(CellStyleAttributes.TEXT_DECORATION, this.defaultHoverSelectionTextDecoration);
return cellStyle;
}
Aggregations