I'm working on an Wiremod EGP Designer in java and I am having issues with an array list being blank in the draw function. When I add the data to the array list I print the array size and it shows that there is data but in the draw function it is printing 0 for the array list size.
This is the link to the draw function:
https://github.com/zippy36jr/Wiremod-EGP-Designer/blob/eb2ee4248ecdc276a001114142dd2737347c0528/EGP%20Designer/src/egpDesigner/Main/PreviewWindow.java#L64
I am adding the data to the array list in the function on line 74.
ScreenShot of output:
https://i.imgur.com/qsIxDyT.png
Are you using the list anywhere else and maybe invalidating its contents? Your insert function seems good, however you also pass the array list's reference to another object at the end of it, Maybe double all of your actions on the list before and after, verifying they are working as intended.
Smells like a threading issue, I can't look into the code myself because I have never used this Processing framework you are using.
However when objects change spontaneously in code I assume you think is running in sequence, then it is usually a threading issue, I would look into how the "PApplet" is drawing changes, usually in these sort of frameworks there is a rendering thread being run separately from the main thread, if you change an object on the main thread it won't also change on the rendering thread.
My educated guess is that you are adding the elements on one thread, but draw() being a rendering function, runs on a rendering thread, so when you print from the draw function you are actually in another object on another thread.
You might also want to make sure you have set up the interaction between JavaFX and Processing correctly, specifically I am worried about the way you are handling adding data from JavaFX but the drawing is happening in Processing, the code may not be running on the same thread for these functions.
After looking at the docs for PApplet:
Processing uses active mode rendering. All animation tasks happen on the "Processing Animation Thread". The setup() and draw() methods are handled by that thread, and events (like mouse movement and key presses, which are fired by the event dispatch thread or EDT) are queued to be safely handled at the end of draw().
Hope this sets you on the right track.
Sorry, you need to Log In to post a reply to this thread.