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;
}
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);
}
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);
}
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());
}
Aggregations