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

Andy Goryachev angorya at openjdk.org
Mon Dec 12 17:02:33 UTC 2022


On Sat, 3 Dec 2022 22:17:55 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

> This includes a fix for the precision problem we've found as part of the graphics warnings clean ups.
> 
> I've included two commits, one with just the minimal fix, and one with the clean ups. I can drop off the 2nd commit if it is deemed to be of no added value.

Changes requested by angorya (Committer).

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/GestureRecognizer.java line 31:

> 29: 
> 30: interface GestureRecognizer extends GlassTouchEventListener {
> 31:     static final long INITIAL_VELOCITY_THRESHOLD_NANOS = 100L * 1000;

100_000L ?

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/RotateGestureRecognizer.java line 60:

> 58:             String s = System.getProperty("com.sun.javafx.gestures.rotate.threshold");
> 59:             if (s != null) {
> 60:                 rotationThresholdDegrees = Double.valueOf(s);

should we catch a NumberFormatException and re-throw it with a meaningful text message?  Or the current behavior is ok?

ditto on line 64

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/RotateGestureRecognizer.java line 304:

> 302: 
> 303:                         if (nanosPassed > INITIAL_VELOCITY_THRESHOLD_NANOS) {
> 304:                             initialInertiaRotationVelocity = currentRotation / nanosPassed * NANOS_TO_SECONDS;

is this correct?  shouldn't it be `currentRotation / (nanosPassed * NANOS_TO_SECONDS)` ?

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/ScrollGestureRecognizer.java line 64:

> 62:             s = System.getProperty("com.sun.javafx.gestures.scroll.inertia");
> 63:             if (s != null) {
> 64:                 scrollInertiaEnabled = Boolean.valueOf(s);

same comment about re-throwing an exception (x2)

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/ScrollGestureRecognizer.java line 252:

> 250:                         factorX = deltaX / scrollMagnitude;
> 251:                         factorY = deltaY / scrollMagnitude;
> 252:                         initialInertiaScrollVelocity = scrollMagnitude / nanosPassed * NANOS_TO_SECONDS;

is this correct?  shouldn't it be `scrollMagnitude / (nanosPassed * NANOS_TO_SECONDS)`?

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/ZoomGestureRecognizer.java line 65:

> 63:             s = System.getProperty("com.sun.javafx.gestures.zoom.inertia");
> 64:             if (s != null) {
> 65:                 zoomInertiaEnabled = Boolean.valueOf(s);

... and here

modules/javafx.graphics/src/main/java/com/sun/javafx/tk/quantum/ZoomGestureRecognizer.java line 277:

> 275: 
> 276:                         if (nanosPassed > INITIAL_VELOCITY_THRESHOLD_NANOS) {
> 277:                             initialInertiaZoomVelocity = (totalZoomFactor - prevTotalZoomFactor) / nanosPassed * NANOS_TO_SECONDS;

`(totalZoomFactor - prevTotalZoomFactor) / (nanosPassed * NANOS_TO_SECONDS);` ?

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

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


More information about the openjfx-dev mailing list