|
|
|
|
|
|
Re: Nattable 1.2.0: StackOverflowError when "Control Panel/Display text scaling" is major [message #1682506 is a reply to message #1670730] |
Tue, 17 March 2015 15:19   |
Eclipse User |
|
|
|
Hi,
any news on this? We encountered the same problem.
As the stack trace shows, the problem is localed in this method:
protected static final int findColumnPosition(int xOffset,
int columnOffset, ILayer layer, int x, int totalWidth,
int columnCount) {
double size = (double) (totalWidth - xOffset)
/ (columnCount - columnOffset);
int columnPosition = columnOffset + (int) ((x - xOffset) / size);
int startX = layer.getStartXOfColumnPosition(columnPosition);
int endX = startX + layer.getColumnWidthByPosition(columnPosition);
if (x < startX) {
return findColumnPosition(xOffset, columnOffset, layer, x, startX,
columnPosition);
} else if (x >= endX) {
return findColumnPosition(endX, columnPosition + 1, layer, x,
totalWidth, columnCount);
} else {
return columnPosition;
}
}
In our case at some point we reach the case where
Then the method is called recursively with:
columnOffset = columnPosition+1
In the called method this leads to:
columnOffset-columnCount = 0
Which results in an infinite size because of division by zero.
I have checked the conversions and found that the ConfigureScalingResult which is called results in a dpi of 120 whereas the GUIHelper method uses the dpiFactor of 1.25 for conversion.
public static int convertHorizontalPixelToDpi(int pixel) {
return Float.valueOf(pixel * getDpiFactor(getDpiX())).intValue();
}
I tried to put in a dpi of 125 in the ConfigureScalingCommand. This solves the problem. I know it is just a hack but I did not yet find out where the actual "miscalculation" takes place and exactly why.
I have solved the problem by calling the following command right after creation of the table.
table.getLayer().doCommand(new ConfigureScalingCommand(
new AbstractDpiConverter() {
@Override
protected void readDpiFromDisplay() {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
dpi = Display.getDefault().getDPI().x;
dpi = (int)(GUIHelper.getDpiFactor(dpi)*100);
}
});
}
},
new AbstractDpiConverter() {
@Override
protected void readDpiFromDisplay() {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
dpi = Display.getDefault().getDPI().y;
dpi = (int)(GUIHelper.getDpiFactor(dpi)*100);
}
});
}
}));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.32903 seconds