Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » NatTable 1.3.0 DPI calculation issues when resizing columns(Rounding problems when up-/downscaling DPI-pixel values while resizing columns)
NatTable 1.3.0 DPI calculation issues when resizing columns [message #1730744] Thu, 28 April 2016 08:23 Go to next message
Markus Barbey is currently offline Markus BarbeyFriend
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 ... Sad

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
Re: NatTable 1.3.0 DPI calculation issues when resizing columns [message #1730796 is a reply to message #1730744] Thu, 28 April 2016 14:10 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Quote:
Can you tell me, if it is legitim to disable DPI conversion?


Sure, it was added to support the upscaling of the OS. It didn't before so people complained about that. You will then simply don't have upscaling.

Quote:
Maybe you have some other solutino ideas, to get this issue properly solved in a 1.3.0 installation?


Nope

Quote:
Is this fixed in 1.4.0?


I hear this the first time, so no there is nothing fixed yet. But 1.4 is not released yet, so feel free to create a ticket and provide a patch. Sounds like your approach with the AbstractDpiConverter is on the right track. But the same issue is in GUIHelper for some conversion methods. You can not change that locally as it is a static helper class. But you could test to modify this aswell and see if your rendering issues are also solved with that. In that case we would have a solution that would fix the issue in the upcoming 1.4 release.
Re: NatTable 1.3.0 DPI calculation issues when resizing columns [message #1730850 is a reply to message #1730796] Fri, 29 April 2016 09:21 Go to previous messageGo to next message
Markus Barbey is currently offline Markus BarbeyFriend
Messages: 8
Registered: April 2016
Junior Member
Dirk Fauth wrote on Thu, 28 April 2016 14:10
I hear this the first time, so no there is nothing fixed yet. But 1.4 is not released yet, so feel free to create a ticket and provide a patch. Sounds like your approach with the AbstractDpiConverter is on the right track. But the same issue is in GUIHelper for some conversion methods. You can not change that locally as it is a static helper class.


So I will check the GUIHelper as well... and how to provide a patch - never did that before Wink

Dirk Fauth wrote on Thu, 28 April 2016 14:10
But you could test to modify this aswell and see if your rendering issues are also solved with that. In that case we would have a solution that would fix the issue in the upcoming 1.4 release.


The rendering issues had been solved already by injecting the new DpiConverter right after the NatTable creation (as the original is set there).

Injecting the DpiConverter after the NatTable configure process had been too late.

Re: NatTable 1.3.0 DPI calculation issues when resizing columns [message #1730858 is a reply to message #1730850] Fri, 29 April 2016 10:42 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Quote:
how to provide a patch - never did that before


There is always a first time. Wink
We have a contribution guide: https://eclipse.org/nattable/documentation.php?page=contribution_guide
And the free ebook by Lars Vogel is also very helpful on this topic (to understand the tooling and the process): http://www.vogella.com/books/eclipsecontribution.html

Quote:
The rendering issues had been solved already by injecting the new DpiConverter


You mentioned that this way there where rendering issues on hovering regarding some borders. I suppose this should be fixed with modifying the GUIHelper aswell.

Note that there was an issue for big data sets, so we changed the implementation from Float to Double, which means you additionally need to cast the result of Math.round() to int.
Re: NatTable 1.3.0 DPI calculation issues when resizing columns [message #1731762 is a reply to message #1730858] Tue, 10 May 2016 04:34 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Since there was no further response on this I created the ticket myself and provided a patch based on the proposal.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=493282
https://git.eclipse.org/r/#/c/72361/

It would be great if someone could verify that things are now working better.

Note that the patch has not yet been merged to master. So for testing you would need to checkout the NatTable sources and apply the patch locally.
Re: NatTable 1.3.0 DPI calculation issues when resizing columns [message #1732021 is a reply to message #1731762] Wed, 11 May 2016 21:28 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I pushed the changes to master in preparation for the 1.4.0 release. Please verify if it is now working as expected with the latest snapshot build.
Re: NatTable 1.3.0 DPI calculation issues when resizing columns [message #1732170 is a reply to message #1732021] Fri, 13 May 2016 08:38 Go to previous message
Markus Barbey is currently offline Markus BarbeyFriend
Messages: 8
Registered: April 2016
Junior Member
Hi Dirk,

just checked the 1.4.0.201605122025 snapshot and the resizing issue with DPI conversion is gone Smile

Thanks for fixing it that quickly
Markus
Previous Topic:NatTable Tree Grid Filtering
Next Topic:Multiple Rows deletion in NatTable
Goto Forum:
  


Current Time: Sat Apr 27 00:04:36 GMT 2024

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

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

Back to the top