JyMol.invokeLater()

When JyMol is used in conjunction with other GUI elements in Java, such as AWT or Swing, CPU utilization can become a strained resource. When users are controlling JyMOL with a mouse and a GUI element, such as a Table, could be resorting a large number of rows, the JyMOL workspace could suffer rendering quality and smoothness.

This is not the easiest issue to address, and sometimes it requires a keen way to break down the computations necessary, implement datamodels underlying toolkits such as Swing, and change thread priorities.

To help these situations, we have added a way to invoke computations after JyMOL is using the resources for rendering. In a similar way Swing provides a function SwingUtilities.invokeLater() (see Java API), we now provide a JyMol.invokeLater() function that calls a run() function on the Runnable argument after JyMol is finished rendering. If it is not busy rendering, then it gets called immediately. This function does not automatically avoid the possibility that if the user tries to interact again before the run() function is finished. This will still need to be avoided programmatically using the JyMol callbacks (i.e., if you implement a large computation inside the run() function, you will want to pause the computation if the user starts controlling the workspace to avoid sub-par rendering).