NatTable 1.3.0 DPI calculation issues when resizing columns [message #1730744] |
Thu, 28 April 2016 08:23 |
Markus Barbey Messages: 8 Registered: April 2016 |
Junior Member |
|
|
Hello there,
I just found an issue when DPI converters are used in NatTable 1.3.0 together with the auto resize column feature.
By configuring windows to use a larger screen representation (e.g. 125%) the AbstractDpiConverter is used for down-/upscaling DPI related pixel sizes to DPI "free" pixel sizes.
The "rounding" is done with a simple .intValue() call.
Code extract AbstractDpiConverter:
@Override
public int convertPixelToDpi(int pixel) {
return Float.valueOf(pixel * getCurrentDpiFactor()).intValue();
}
@Override
public int convertDpiToPixel(int dpi) {
return Float.valueOf(dpi / getCurrentDpiFactor()).intValue();
}
This caused ugly problems, as one of my columns has been auto resized to a 222 pixel value which has been downscaled to a 177 pixel value. Upscaling the 177 pixel value resulted in a 221 pixel value which is smaller as the minimum required column size of 222. So a new resize command has been triggered and calculated the same pixel values again and again and ...
The result of this issue has been a constantly repainting NatTable, which got visible by a "flickering" mouse pointer only (and an invisible drop down of performance).
First solution aproach:
As a first solution aproach, I injected a rounding DPI converter by, after the NatTable had been created and configured.
vNatTable.doCommand (new ConfigureScalingCommand (new RoundingHorizontalDpiConverter(), new RoundingVerticalDpiConverter()));
To do so, I created the Rounding*DpiConverter() classes with altered methods:
@Override
public int convertDpiToPixel (int pDpi)
{
return Math.round (Float.valueOf (pDpi / getCurrentDpiFactor ()));
}
@Override
public int convertPixelToDpi (int pPixel)
{
return Math.round (Float.valueOf (pPixel * getCurrentDpiFactor ()));
}
But this caused some new painting issues with my cell border painters, after hover cell highlighting had been performed.
Second solution aproach:
As a second solution aproach I simply disabled DPI conversion by calling
vNatTable.doCommand (new ConfigureScalingCommand (null, null));
after the NatTable had been created and configured. At a first glance it looked good - but I do not know, if I will get some other problems, that I simply do not see right now...
Can you tell me, if it is legitim to disable DPI conversion?
Maybe you have some other solutino ideas, to get this issue properly solved in a 1.3.0 installation?
Is this fixed in 1.4.0?
Bye
Markus
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03605 seconds