|
|
|
|
Re: Left border is not drawn [message #1177360 is a reply to message #1174874] |
Fri, 08 November 2013 23:31 |
Jan Krakora Messages: 477 Registered: December 2009 Location: Prague |
Senior Member |
|
|
Hi Dirk,
here is my customization to the GridLineCellLayerPainter for drawing the leftmost border
@Override
public Rectangle adjustCellBounds(int columnPosition, int rowPosition, Rectangle bounds) {
Rectangle rectangle = new Rectangle(
bounds.x,
bounds.y,
Math.max(bounds.width - 1, 0),
Math.max(bounds.height - 1, 0)
);
if (columnPosition == 0) {
rectangle.x += 1;
rectangle.width = Math.max(rectangle.width - 1, 0);
}
return rectangle;
}
private void drawVerticalLines(ILayer natLayer, GC gc, Rectangle rectangle) {
int endY = rectangle.y + Math.min(natLayer.getHeight() - 1, rectangle.height);
int columnPositionByX = natLayer.getColumnPositionByX(rectangle.x + rectangle.width);
int maxColumnPosition = columnPositionByX > 0 ? Math.min(natLayer.getColumnCount(), columnPositionByX) : natLayer.getColumnCount();
for (int columnPosition = natLayer.getColumnPositionByX(rectangle.x); columnPosition < maxColumnPosition; columnPosition++) {
if (columnPosition == 0) {
// draw the leftmost line
int x = natLayer.getStartXOfColumnPosition(columnPosition);
gc.drawLine(x, rectangle.y, x, endY);
}
final int size = natLayer.getColumnWidthByPosition(columnPosition);
if (size > 0) {
int x = natLayer.getStartXOfColumnPosition(columnPosition) + size - 1;
gc.drawLine(x, rectangle.y, x, endY);
}
}
}
|
|
|
Re: Left border is not drawn [message #1180896 is a reply to message #1177360] |
Mon, 11 November 2013 08:21 |
Dirk Fauth Messages: 2903 Registered: July 2012 |
Senior Member |
|
|
Hi Jan,
thanks for that! As far as I can see it looks nice and I like it as it solves the same rendering issue in case you have a simple NatTable composition without headers. Well, at least half the way.
I thought about your solution over the weekend and here are my thoughts:
1. Althought IMHO this is correct, I'm not sure if everybody shares that oppinion. That means, there might be people, projects and use cases where the left border should not be rendered. I'm not sure if it is a bug or intended that it is not drawn. So I would like to see it configurable. This can be done via ConfigRegistry or via flag in GridLineCellLayerPainter, as it is possible to set the GridLineCellLayerPainter instance to a layer. The default should stay as is, as the rendering in existing projects should not change without knowledge.
2. Like the left border, the top border is not drawn. In a grid that uses the default column header rendering you won't notice that because of the button style rendering, and of course you don't want it there as it might break the appearance (which is also true if you use a different rendering for the row header ). For completeness this should be also modified and configurable.
3. The SelectionLayerPainter needs to be adjusted too. Never noticed this before, but the selection anchor (dotted border around the selected cell) is not rendered for cells at the leftmost column position at the left. Simply adding your proposed solution additionally causes a white line to the left. IMHO the selection anchor should be always drawed completely and should not be configurable whether it should be rendered or not.
4. To be sure that we don't run into IP issues, the process for code contributions to a Eclipse project specifies that you should file a ticket in Bugzilla and contribute a patch.
http://eclipse.org/projects/dev_process/development_process.php
http://wiki.eclipse.org/Development_Resources#Users:_Contributing_To_A_Project
http://www.eclipse.org/projects/dev_process/ip-process-in-cartoons.php
I hope you share my opinion and are willing to contribute a modified version of your enhancement via Bugzilla. I really like the approach!
Greez,
Dirk
|
|
|
|
|
|
|
Re: Left border is not drawn [message #1200853 is a reply to message #1184155] |
Thu, 21 November 2013 12:51 |
Dirk Fauth Messages: 2903 Registered: July 2012 |
Senior Member |
|
|
Hi,
instead of modifying the existing rendering code, I thought that it maybe easier to simply render the border afterwards on top using an IOverlayPainter.
Could you try to attach this code and see if it is working correctly for you?
natTable.addOverlayPainter(new IOverlayPainter() {
@Override
public void paintOverlay(GC gc, ILayer layer) {
gc.drawLine(0, 0, 0, layer.getHeight()-1);
gc.drawLine(0, 0, layer.getWidth()-1, 0);
}
});
If it does I would create such a painter and commit it to NatTable core so it is possible to configure the borders easily.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05066 seconds