RFR: JDK-8298060: Fix precision bug in gesture recognizer classes [v3]

John Hendrikx jhendrikx at openjdk.org
Thu Dec 15 12:26:13 UTC 2022


On Mon, 12 Dec 2022 23:02:42 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:

>> John Hendrikx has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains five commits:
>> 
>>  - Merge remote-tracking branch 'upstream/master' into feature/precision-problem-in-gesture-recognizers
>>  - Make RotateGestureRecognizer easier to test
>>  - Revert all changes to RotateGestureRecognizer
>>  - General clean ups
>>    
>>    - Made constants written in capitals final
>>    - Made fields final that can be final
>>    - Made fields and methods private that can be private
>>    - Renamed constants that aren't constant to camel case
>>    - Fixed spelling errors
>>    - Re-ordered fields (statics at the top)
>>    - Removed redundant initial values
>>    - Removed unused fields and parameters
>>    - Optimized imports
>>    - Removed commented out code
>>  - Fix precision problems in gesture recognizers
>
> inline

@kevinrushforth 

Please advise if I should continue on this road:

I've reverted `RotateGestureRecognizer` to add a test case first.

To make `RotateGestureRecognizer` testable I had to make it public and abstract away the need for `ViewScene` as constructor parameter, see the `Make RotateGestureRecognizer easier to test` commit.  I also added a test case (90% coverage).

If you are okay with these changes (I needed to change `GlassViewEventHandler` and add a small interface), I can do the same for the Zoom & ScrollGestureRecognizers. 

The test I added reveals the precision problem when you uncomment the line: `passTime(Long.MAX_VALUE / 1000 / 1000 - 10000000);`  -- the accuracy problem of converting longs to doubles then breaks the test.  The newer version of the code works (after I fixed the calculation by adding parenthesis).

-------------

PR: https://git.openjdk.org/jfx/pull/966


More information about the openjfx-dev mailing list