I'm currently stuck on a task of drawing a continous line between specific columns using nattable. I've drawn the lines on each cell with CustomLineBorderDecorator. Problem is between each row there is a thin gray line This gray line is visible inbetween the singular segments of the Border hat each cell generates. I need a continous line from Header to bottom of the table. How can i get there?
If you want to draw over the grid lines, you need to implement an IOverlayPainter
. ICellPainter
like the CustomLineBorderDecorator
will only paint inside a cell.
A simple version could look like this:
natTable.addOverlayPainter(new IOverlayPainter() {
@Override
public void paintOverlay(GC gc, ILayer layer) {
Color beforeColor = gc.getForeground();
gc.setForeground(GUIHelper.COLOR_RED);
int gridBorderX = natTable.getStartXOfColumnPosition(4) - 1;
gc.drawLine(gridBorderX, 0, gridBorderX, layer.getHeight() - 1);
gc.setForeground(beforeColor);
}
});
But that version for example does not take into account scrolling.
The SNAPSHOT builds contain the HideIndicatorOverlayPainter
that does some more checks to render such a line based on a label inside the header regions. But you could adapt that to find the position to render label based.