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

Kevin Rushforth kcr at openjdk.org
Mon Dec 12 23:07:01 UTC 2022


On Mon, 12 Dec 2022 22:27:49 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> Okay I see what you're getting at, your first suggestion would not be correct, it's supposed to be what you suggest in the 2nd one.  So what I want is:
>> 
>>      (scrollMagnitude / nanosPassed) * NANOS_TO_SECONDS
>> 
>> or:
>> 
>>      (scrollMagnitude * NANOS_TO_SECONDS) / nanosPassed
>> 
>> ...but that's the same as what I 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)

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

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


More information about the openjfx-dev mailing list