Package org.eclipse.nebula.widgets.nattable.style

Examples of org.eclipse.nebula.widgets.nattable.style.BorderStyle


    }

    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;
View Full Code Here


    }

    @Override
    public void paintCell(ILayerCell cell, GC gc, Rectangle rectangle,
            IConfigRegistry configRegistry) {
        BorderStyle borderStyle = getBorderStyle(cell, configRegistry);
        int borderThickness = borderStyle != null ? borderStyle.getThickness()
                : 0;

        // check how many border lines are configured for that cell
        List<String> labels = cell.getConfigLabels().getLabels();

        int leftBorderThickness = 0;
        int rightBorderThickness = 0;
        int topBorderThickness = 0;
        int bottomBorderThickness = 0;

        if (labels.contains(LEFT_LINE_BORDER_LABEL))
            leftBorderThickness = borderThickness;
        if (labels.contains(RIGHT_LINE_BORDER_LABEL))
            rightBorderThickness = borderThickness;
        if (labels.contains(TOP_LINE_BORDER_LABEL))
            topBorderThickness = borderThickness;
        if (labels.contains(BOTTOM_LINE_BORDER_LABEL))
            bottomBorderThickness = borderThickness;

        Rectangle interiorBounds = new Rectangle(rectangle.x
                + leftBorderThickness, rectangle.y + topBorderThickness,
                (rectangle.width - leftBorderThickness - rightBorderThickness),
                (rectangle.height - topBorderThickness - bottomBorderThickness));
        super.paintCell(cell, gc, interiorBounds, configRegistry);

        if (borderStyle == null
                || borderThickness <= 0
                || (leftBorderThickness == 0 && rightBorderThickness == 0
                        && topBorderThickness == 0 && bottomBorderThickness == 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 correction = 0;

            if ((borderThickness % 2) == 0) {
                shift = borderThickness / 2;
            } else {
                shift = borderThickness / 2;
                correction = 1;
            }

            if (leftBorderThickness >= 1) {
                borderArea.x += shift;
                borderArea.width -= shift;
            }

            if (rightBorderThickness >= 1) {
                borderArea.width -= shift + correction;
            }

            if (topBorderThickness >= 1) {
                borderArea.y += shift;
                borderArea.height -= shift;
            }

            if (bottomBorderThickness >= 1) {
                borderArea.height -= shift + correction;
            }
        }

        gc.setLineStyle(LineStyleEnum.toSWT(borderStyle.getLineStyle()));
        gc.setForeground(borderStyle.getColor());

        // if all borders are set draw a rectangle
        if (leftBorderThickness > 0 && rightBorderThickness > 0
                && topBorderThickness > 0 && bottomBorderThickness > 0) {
            gc.drawRectangle(borderArea);
View Full Code Here

    }

    public PercentageBarCellPainter(int outerPadding) {
        super(new PaddingDecorator(new LineBorderDecorator(
                new PercentageBarDecorator(new TextPainter(false, false)),
                new BorderStyle()), outerPadding));
    }
View Full Code Here

        this.defaultBorderStyle = defaultBorderStyle;
    }

    public int getPreferredWidth(ILayerCell 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);
    }
View Full Code Here

                + (borderThickness * 2);
    }

    public int getPreferredHeight(ILayerCell cell, GC gc,
            IConfigRegistry configRegistry) {
        BorderStyle borderStyle = getBorderStyle(cell, configRegistry);
        int borderThickness = borderStyle != null ? borderStyle.getThickness()
                : 0;

        return super.getPreferredHeight(cell, gc, configRegistry)
                + (borderThickness * 2);
    }
View Full Code Here

    }

    private BorderStyle getBorderStyle(ILayerCell cell,
            IConfigRegistry configRegistry) {
        IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
        BorderStyle borderStyle = cellStyle
                .getAttributeValue(CellStyleAttributes.BORDER_STYLE);
        if (borderStyle == null) {
            borderStyle = defaultBorderStyle;
        }
        return borderStyle;
View Full Code Here

        return borderStyle;
    }

    public void paintCell(ILayerCell 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);
View Full Code Here

        // 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 borderStyle = cellStyle != null ? cellStyle
                .getAttributeValue(CellStyleAttributes.BORDER_STYLE) : null;

        // if there is no border style configured, use the default one for
        // backwards compatibility
        if (borderStyle == null) {
            gc.setLineStyle(SWT.LINE_CUSTOM);
            gc.setLineDash(new int[] { 1, 1 });
            gc.setForeground(GUIHelper.COLOR_BLACK);
        } else {
            gc.setLineStyle(LineStyleEnum.toSWT(borderStyle.getLineStyle()));
            gc.setLineWidth(borderStyle.getThickness());
            gc.setForeground(borderStyle.getColor());
        }
    }
View Full Code Here

    @Test
    public void loadBorderStyleSettings() throws Exception {
        Style style = StylePersistor.loadStyle(TEST_PREFIX, propertiesFixture);

        BorderStyle borderStyle = style
                .getAttributeValue(CellStyleAttributes.BORDER_STYLE);
        assertEquals(2, borderStyle.getThickness());
        assertEquals(100, borderStyle.getColor().getRed());
        assertEquals(110, borderStyle.getColor().getGreen());
        assertEquals(120, borderStyle.getColor().getBlue());
        assertEquals(LineStyleEnum.DASHDOTDOT, borderStyle.getLineStyle());
    }
View Full Code Here

public class BorderStylePersistenceTest {

    @Test
    public void toStringCreatesAPersistableString() throws Exception {
        BorderStyle borderStyle = new BorderStyle();
        assertEquals("1|0,0,0|SOLID", borderStyle.toString());
    }
View Full Code Here

TOP

Related Classes of org.eclipse.nebula.widgets.nattable.style.BorderStyle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.