Java Magazine, May/June 2018
ORACLE COM JAVAMAGAZINE MAY JUNE 2018 45 design patterns Platform runLater while pointQueue isEmpty PointPojo point pointQueue poll coordinate transformation from data to canvas pixels double x transformXToScreen point x double y transformYToScreen point y encourage the object to be garbage collected sooner point null g fillOval x y radius radius return size This code features a commented call to Platform runLater For those unfamiliar with this feature the JavaFX platform provides the runLater interface as a blocking but thread safe way to run code and make changes to a JavaFX GUI Any code placed inside a runLater block will be executed in a Runnable thread The Runnable will be executed at some point later by the JavaFX platform but we wont have control over the timing I will examine performance for both using and not using runLater calls In this method I continuously pull PointPojo objects from the concurrent queue using the poll method until the queue is empty After each poll call I transform the data to screen coordinates and render to the canvas using the fillOval x y radius radius call Without using the runLater option I achieve the following performance Total elapsed time Total ns 24242446 0 s 24 ms 242 us 446 ns Drew batch size of 64434 These numbers will fluctuate of course but they represent a median for time and points processed within that time However at this pace and number of points I quickly run into
You must have JavaScript enabled to view digital editions.