Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Coloring grid lines with GridLineCellLayerPainter
Coloring grid lines with GridLineCellLayerPainter [message #1798338] Thu, 15 November 2018 16:05 Go to next message
Frederik WystupFriend
Messages: 1
Registered: November 2018
Junior Member
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 06:27 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2704
Registered: July 2012
Senior Member
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.
Previous Topic:Release date
Next Topic:How to configure the borderline of ColumnGroups
Goto Forum:
  


Current Time: Fri Aug 23 22:46:51 GMT 2019

Powered by FUDForum. Page generated in 0.01711 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top