Options

"Separate Threads for two independent operators using Java Swing"

GhostriderGhostrider Member Posts: 60 Contributor II
edited June 2019 in Help
I have two separate operators which open a JFrame and do some rendering.  The rendering is very CPU consuming and I would like to run both on a separate threads.  The two operators and JFrames are completely independent.  Is there any way to run the rendering on separate threads?  If I recall correctly, there's only 1 swing thread.  Just seeing if there's anything that can be done to get around that restriction.
Tagged:

Answers

  • Options
    landland RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 2,531 Unicorn
    Hi,
    you could render into a buffered image and after finishing pass the buffered image to the awt event thread to paint it.

    Greetings,
      Sebastian
  • Options
    GhostriderGhostrider Member Posts: 60 Contributor II
    That's a very good idea.  I've never tried that before, but thanks for the suggestion.  I'll look into it.

    Update: Is there an example of drawing to bufferedImage within RapidMiner?  I know RapidMiner uses JFreeChart and I can see if-statements for bufferedImage drawing in JFreeChart's XYItemRenderer object.
  • Options
    landland RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 2,531 Unicorn
    Hi,
    you can just retrieve the graphics object from a buffered image and render into it using the paint Component method as you would do for a JPanel.
    By the way: It is generally discouraged to access any awt methods inside operators. This would cause the process to crash in server or command line mode.
    I would suggest storing the results in an IOObject, registering a renderer for this result object and then you can take a look at the object instead of outputs created during the process. This way it is much easier to maintain results for documentation, you can even report them.


    Greetings,
      Sebastian
Sign In or Register to comment.