Java Magazine, May/June 2018
ORACLE COM JAVAMAGAZINE MAY JUNE 2018 40 design patterns primaryStage setScene scene primaryStage show To simplify the example and to facilitate the data generation and rendering I define a few global variables for example int setSize 100000 Here setSize is the total number of objects generated by the producer thread with each burst The consumer thread must receive each burst of randomly generated data points process it asynchronously and then visualize the points To stress the various patterns in this article I will increase the size of the burst by increasing the setSize variable An interesting follow up to this discussion would be connecting this variable to a JavaFX GUI control Doing so would allow the user to dynamically increase or decrease the stress created by my implementations To add some complexity to the example I create a custom Object called PointPojo which has member fields for the x and y data coordinates The PointPojo constructor is smart enough to implement a few interesting geometric equations for each field to make plotting the data interesting The data set exists within a numeric range unrelated to screen pixels So to graph the data on screen I must transform the data to a numeric range compatible with the screen Data values will range from 10 to 10 with a total range of 20 in both the x and y axes By predefining the possible data ranges using the following variables the coordinate transformations are simplified later double totalMinX 10 double totalRangeX 20 double totalMinY 10 double totalRangeY 20 To assist with debugging the initial development and to assess performance effectiveness I need a timing metric for the diferent methods of the application The downloadable listing
You must have JavaScript enabled to view digital editions.