Coloring grid lines with GridLineCellLayerPainter [message #1798338] |
Thu, 15 November 2018 11:05  |
Eclipse User |
|
|
|
Hi,
we're having the requirement to change the color of the grid lines based on specific cell positions.
Currently we think about sub-classing the GridLineCellLayerPainter in order to provide a alternative implementation for GridLineCellLayerPainter.drawGridLines. This would work, but we would need to copy most of the code of the private methods drawHorizontalLines and drawVerticalLines.
Of course this is not a good idea, so we tought about providing a possible patch to enhance the GridLineCellLayerPainter:
private void drawVerticalLines(ILayer natLayer, GC gc, Rectangle rectangle, int adjustment) {
[...]
if (gridColorEvaluator != null) {
graphics.setForeground(gridColorEvaluator.getColorForLabel(cellLabel));
[code][/code]}
graphics.drawLine(xCoord, rectangle.y, xCoord, endY);
graphics.setForeground(getGridColor());
[...]
(Same for: drawHorizontalLines)
Basically the idea is that the color of the grid line is based on specific labels which are set elsewhere. The mapping label to color is done by a GridColorEvalutor which could be set if required.
Could this patch be the way to go or is there another solution to solve this problem? We actually did not find a solution by searching the forum, maybe we missed something here...
|
|
|
Re: Coloring grid lines with GridLineCellLayerPainter [message #1798519 is a reply to message #1798338] |
Tue, 20 November 2018 01:27  |
Eclipse User |
|
|
|
Changing the existing code is one option. I typically see such a requirement as an addition on top of the default mechanisms, and instead of making changes to the default GridLineCellLayerPainter and increase the complexity there for all users, I typically implement an IOverlayPainter that paints custom things on top.
The HideIndicatorOverlayPainter is an implementation that I recently added to render indicators in the header to visualize hidden columns/rows. That basically does the same as you require. It inspects labels in cells and draws on top of the grid lines.
I personally find that approach better in terms of modularity and encapsulation then introducing a new mechanism in the GridLineCellLayerPainter. Which is of course not a bad design in general, I just think for that special case the IOverlayPainter is less intrusive.
|
|
|
Powered by
FUDForum. Page generated in 0.03235 seconds