The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

"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

  • 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
  • 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.
  • 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.