Search in sources :

Example 6 with VerticalAlignmentEnum

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());
}
Also used : VerticalAlignmentEnum(org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) Test(org.junit.Test)

Example 7 with VerticalAlignmentEnum

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);
}
Also used : IStyle(org.eclipse.nebula.widgets.nattable.style.IStyle) HorizontalAlignmentEnum(org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum) VerticalAlignmentEnum(org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum)

Aggregations

VerticalAlignmentEnum (org.eclipse.nebula.widgets.nattable.style.VerticalAlignmentEnum)7 HorizontalAlignmentEnum (org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum)6 BorderStyle (org.eclipse.nebula.widgets.nattable.style.BorderStyle)4 Color (org.eclipse.swt.graphics.Color)4 Style (org.eclipse.nebula.widgets.nattable.style.Style)3 Font (org.eclipse.swt.graphics.Font)3 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)2 IOverlayPainter (org.eclipse.nebula.widgets.nattable.painter.IOverlayPainter)2 NatTableBorderOverlayPainter (org.eclipse.nebula.widgets.nattable.painter.NatTableBorderOverlayPainter)2 ICellPainter (org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter)2 IStyle (org.eclipse.nebula.widgets.nattable.style.IStyle)2 Test (org.junit.Test)2 Iterator (java.util.Iterator)1 List (java.util.List)1 CSSStylableElement (org.eclipse.e4.ui.css.core.dom.CSSStylableElement)1 Gradient (org.eclipse.e4.ui.css.core.dom.properties.Gradient)1 ICSSValueConverter (org.eclipse.e4.ui.css.core.dom.properties.converters.ICSSValueConverter)1 CSS2FontProperties (org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontProperties)1 CSSElementContext (org.eclipse.e4.ui.css.core.engine.CSSElementContext)1 IDisplayConverter (org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter)1