RFR: 8242523: Update the animation and clip envelope classes

Nir Lisker nlisker at openjdk.java.net
Wed May 13 00:25:36 UTC 2020


On Wed, 6 May 2020 14:18:06 GMT, Ambarish Rapte <arapte at openjdk.org> wrote:

>> Mostly refactoring in preparation of the upcoming fixes. The changes might look like a lot, but it's mostly rearranging
>> of methods. Summery of changes:
>> ### Animation
>> * Added `isNearZero` and `areNearEqual` methods that deal with `EPSILON` checks.
>> * Added `isStopped`, `isRunning` and `isPaused` convenience methods.
>> * Added `runHandler` method to deal with running the handler.
>> * Moved methods to be grouped closer to where they are used rather than by visibility.
>> * Removed the static import for `TickCalculation`.
>> * Various small subjective readability changes.
>> * Behavioral changes: switching `autoReverse` and `onFinished` properties from "Simple" to "Base" properties; and lazily
>>   initializing the `cuePoints` map.
>> 
>> ### Clip Envelopes
>> * Added `MultiLoopClipEnvelope` as an intermediate parent for infinite and finite clip envelopes.
>> * Rearranged methods order to be consistent.
>> * Replaced the `checkBounds` method with a new overload of `Utils.clamp`.
>> * Renamed `pos` to `cyclePos`.
>> * Extracted common methods: `changedDirection` and `ticksRateChange`
>> * Added internal documentation.
>> 
>> Also corrected a typo in `TicksCalculation` and added an explanation for an animation test.
>
> modules/javafx.graphics/src/main/java/javafx/animation/Animation.java line 142:
> 
>> 141:     }
>> 142:
>> 143:     /*
> 
> Both these methods seem like they belong to Utils.java. If moved to Utils.java then the all the calls
> `(Math.abs(currentRate - rate) < EPSILON)` can be changed to use these methods from Utils.java. If we move these
> methods then, Utils.java also needs to declare  `static final double EPSILON = 1e-12;`  and the EPSILON here can be
> initialized as `private static final double EPSILON = Utils.EPSILON;`

I agree that these methods are better suited there, but I'm not sure the same epsilon value will be suitable for other
places that will want to use these. That value is somewhat arbitrary anyway I think.

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

PR: https://git.openjdk.java.net/jfx/pull/196


More information about the openjfx-dev mailing list