Search in sources :

Example 6 with BorderStyle

use of net.sourceforge.nattable.style.BorderStyle in project translationstudio8 by heartsome.

the class BorderStyleEditorPanel method getNewValue.

public BorderStyle getNewValue() {
    if (!noBordersCheckBox.getSelection()) {
        Color borderColor = colorPicker.getSelectedColor();
        LineStyleEnum lineStyle = lineStylePicker.getSelectedLineStyle();
        int borderThickness = thicknessPicker.getSelectedThickness();
        return new BorderStyle(borderThickness, borderColor, lineStyle);
    }
    return null;
}
Also used : BorderStyle(net.sourceforge.nattable.style.BorderStyle) Color(org.eclipse.swt.graphics.Color) LineStyleEnum(net.sourceforge.nattable.style.BorderStyle.LineStyleEnum)

Example 7 with BorderStyle

use of net.sourceforge.nattable.style.BorderStyle in project translationstudio8 by heartsome.

the class LineBorderDecorator method getPreferredWidth.

public int getPreferredWidth(LayerCell cell, GC gc, IConfigRegistry configRegistry) {
    BorderStyle borderStyle = getBorderStyle(cell, configRegistry);
    int borderThickness = borderStyle != null ? borderStyle.getThickness() : 0;
    return super.getPreferredWidth(cell, gc, configRegistry) + (borderThickness * 2);
}
Also used : BorderStyle(net.sourceforge.nattable.style.BorderStyle)

Example 8 with BorderStyle

use of net.sourceforge.nattable.style.BorderStyle in project translationstudio8 by heartsome.

the class LineBorderDecorator method paintCell.

public void paintCell(LayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) {
    BorderStyle borderStyle = getBorderStyle(cell, configRegistry);
    int borderThickness = borderStyle != null ? borderStyle.getThickness() : 0;
    Rectangle interiorBounds = new Rectangle(rectangle.x + borderThickness, rectangle.y + borderThickness, rectangle.width - (borderThickness * 2), rectangle.height - (borderThickness * 2));
    super.paintCell(cell, gc, interiorBounds, configRegistry);
    if (borderStyle == null || borderThickness <= 0) {
        return;
    }
    // Save GC settings
    Color originalForeground = gc.getForeground();
    int originalLineWidth = gc.getLineWidth();
    int originalLineStyle = gc.getLineStyle();
    gc.setLineWidth(borderThickness);
    Rectangle borderArea = new Rectangle(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
    if (borderThickness >= 1) {
        int shift = 0;
        int areaShift = 0;
        if ((borderThickness % 2) == 0) {
            shift = borderThickness / 2;
            areaShift = (shift * 2);
        } else {
            shift = borderThickness / 2;
            areaShift = (shift * 2) + 1;
        }
        borderArea.x += shift;
        borderArea.y += shift;
        borderArea.width -= areaShift;
        borderArea.height -= areaShift;
    }
    gc.setLineStyle(LineStyleEnum.toSWT(borderStyle.getLineStyle()));
    gc.setForeground(borderStyle.getColor());
    gc.drawRectangle(borderArea);
    // Restore GC settings
    gc.setForeground(originalForeground);
    gc.setLineWidth(originalLineWidth);
    gc.setLineStyle(originalLineStyle);
}
Also used : BorderStyle(net.sourceforge.nattable.style.BorderStyle) Color(org.eclipse.swt.graphics.Color) Rectangle(org.eclipse.swt.graphics.Rectangle)

Example 9 with BorderStyle

use of net.sourceforge.nattable.style.BorderStyle in project translationstudio8 by heartsome.

the class DefaultNatTableStyleConfiguration method configureRegistry.

public void configureRegistry(IConfigRegistry configRegistry) {
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, cellPainter);
    Style cellStyle = new Style();
    cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, bgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, fgColor);
    cellStyle.setAttributeValue(CellStyleAttributes.FONT, font);
    cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, hAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, vAlign);
    cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, borderStyle);
    configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle);
    configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDisplayConverter());
}
Also used : Style(net.sourceforge.nattable.style.Style) BorderStyle(net.sourceforge.nattable.style.BorderStyle) DefaultDisplayConverter(net.sourceforge.nattable.data.convert.DefaultDisplayConverter)

Aggregations

BorderStyle (net.sourceforge.nattable.style.BorderStyle)9 Style (net.sourceforge.nattable.style.Style)4 Color (org.eclipse.swt.graphics.Color)3 DefaultDisplayConverter (net.sourceforge.nattable.data.convert.DefaultDisplayConverter)1 LineStyleEnum (net.sourceforge.nattable.style.BorderStyle.LineStyleEnum)1 HorizontalAlignmentEnum (net.sourceforge.nattable.style.HorizontalAlignmentEnum)1 IStyle (net.sourceforge.nattable.style.IStyle)1 VerticalAlignmentEnum (net.sourceforge.nattable.style.VerticalAlignmentEnum)1 Font (org.eclipse.swt.graphics.Font)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1