RFR: JDK-8298060: Fix precision bug in gesture recognizer classes
John Hendrikx
jhendrikx at openjdk.org
Tue Dec 13 08:45:46 UTC 2022
On Mon, 12 Dec 2022 23:02:06 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:
>> I just needed you to confirm that this is indeed correct.
>>
>> Perhaps a default method `double nanosToSeconds(long)` in `GestureRecognizer` would be clearer?
>
> But is it correct? The previous code computed a deltaTime in seconds as `((currentNanos - startNanos) / 1e9)`, and then divided the `scrollMagnitude` by that. I think that the equivalent to the old code is:
>
>
> scrollMagnitude / (nanosPassed * NANOS_TO_SECONDS)
It turns out it is not correct, the parenthesis are indeed required, not sure how I could have missed it. I'm going to see if I can add a test to this as they're missing to ensure it does the same before/after (aside from precision).
-------------
PR: https://git.openjdk.org/jfx/pull/966
More information about the openjfx-dev
mailing list