| How to get preferred size for a custom cell correctly? [message #1005736] |
Mon, 28 January 2013 08:24  |
Alex Kipling Messages: 211 Registered: July 2012 |
Senior Member |
|
|
For getting a preferred size of a cell - I am doing:
ILayerCell cell = natTable.getCellByPosition(colIndex, rowIndex);
ICellPainter cellPainter = natTable.getCellPainter(colIndex, rowIndex, cell, configRegistry);
int preferredColWidth = cellPainter.getPreferredWidth(cell, gc, configRegistry);
This returnes another values, than the values which I get, when doubleclicking the cell border.
How do I get the correct preferred cell width?
|
|
|
|
| Re: How to get preferred size for a custom cell correctly? [message #1005749 is a reply to message #1005745] |
Mon, 28 January 2013 09:38   |
Alex Kipling Messages: 211 Registered: July 2012 |
Senior Member |
|
|
I analized the AutoResizeColumnCommand - it ends up in triggerg the MaxCellBoundsHelper.getPreferedColumnWidths(IConfigRegistry configRegistry, GCFactory gcFactory, ILayer layer, int[]columnPositions) {
Is that the correct way of getting the preferred column width, or is there a more easy one?
I do not want to use the AutoResizeColumnCommand, because I have a lot of data and AutoResizeColumnCommand walks over each row in the column (not virtual visible rows only).
I would like to restrict the autoColumnWidth to the visible rows only. (I want go over visible Rows, and find the max width for each column)
[Updated on: Mon, 28 January 2013 09:38] Report message to a moderator
|
|
|
|
|
|
| Re: How to get preferred size for a custom cell correctly? [message #1006068 is a reply to message #1006043] |
Tue, 29 January 2013 12:24  |
Alex Kipling Messages: 211 Registered: July 2012 |
Senior Member |
|
|
Thnx Dirk.
here is the code, which gets the visible rows:
/**
* @return the index of the first visible row
*/
private int getFirstVisibleRow() {
int firstRowIndex = viewportLayer.getRowPositionByIndex(0) * -1;
return firstRowIndex;
}
/**
* @return the index of the last visible row
*/
private int getLastVisibleRow() {
int firstVisibleRow = getFirstVisibleRow();
int lastVisibleRow = firstVisibleRow + viewportLayer.getRowCount() - 1;
return lastVisibleRow;
}
|
|
|
Powered by
FUDForum. Page generated in 0.08820 seconds