use of org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum in project nebula.widgets.nattable by eclipse.
the class BoxingStyleTest method retreivedCellShouldHaveTopAlignment.
// Vertical alignment
@Test
public void retreivedCellShouldHaveTopAlignment() {
// Register vertical alignment
final VerticalAlignmentEnum vAlignment = VerticalAlignmentEnum.TOP;
this.cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, vAlignment);
this.configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, this.cellStyle, DisplayMode.NORMAL, AlternatingRowConfigLabelAccumulator.EVEN_ROW_CONFIG_TYPE);
// Check cell vertical alignment
ILayerCell cell = this.natTable.getCellByPosition(2, 3);
Assert.assertEquals(vAlignment.name(), this.configRegistry.getConfigAttribute(CellConfigAttributes.CELL_STYLE, cell.getDisplayMode(), cell.getConfigLabels().getLabels()).getAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT).name());
}
use of org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum 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);
}
Aggregations