}
@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);