We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi guys, I have written an application using processing and I'd like to enable it to read PDE files that a user copies in the sketch folder. I've read some threads on using the Java classloader and also nested classes. The problem with classloader is that the user needs to compile a java or jar file and from what I understand a nested class doesn't quite work for this purpose since the nested sketch needs to be defined in the main application. Wanted to see if my understanding is correct and which thread is the latest and most suitable for this problem?
Cheers!
Answers
What do you do with the PDE files? Do you want to load them and display them by your application or do you want to be part of your sketch? Any pde file within your sketch folder will be loaded in separate tabs and all these pde files will be treated as a single pde file by the Processing IDE.
Maybe this next link could be relevant: http://forum.happycoding.io/t/how-to-make-a-processing-showcase/83/5
Kf
Nice recommendation @kfrajer -- I hadn't seen that before.
In addition, here are some related approaches that chain apps and/or use a launcher script to create a showcase or gallery:
I want to load a compiled and exported PDE into another compiled and exported PDE. So I have an exported main sketch that's designed to scan the folder for other exported PDEs and load them as part of the sketch. Sort of like how you would load a preset for a VST if you are familiar with that.
I suspect that your specific requirement that the second sketch also be exported as an application means that what you are trying to do will not work.
Are VST presets stand-alone applications that run without the VST?
Well, the second sketch is exported as an application in this example if I understand correctly? http://happycoding.io/examples/java/processing-in-java/processing-showcase
That's right, the individual sketches for the gallery/showcase can be exported from PDE in that example.
However, in that example the main showcase program is Java -- the class ProcessingShowcase isn't a processing sketch, and indeed it has a
main
instead of asetup()
/draw()
etc.I could be wrong -- maybe you can use
List<PApplet>
inside a master sketch as shown there. I'm just not sure how.Ok, so I think that'll work. The only thing left is reading the names of the sketch classes from the folder and adding them which is possible as well. I'll do a few experiments and post my results here. Thank you guys for your help.
Maybe fileFilter is what you need for this last post. For example: https://forum.processing.org/two/discussion/comment/38761/#Comment_38761
More at: https://forum.processing.org/two/search?Search=FileFilter
Kf
Interesting. That looks much easier than what I had in mind lol.
So I did some research and found out about reflection. Instead of loading say 10 sketches and stopping then hiding them one by one as I switch to the next, I thought it might be easier to have a simple class with one method in there and then call that method using reflection. This way, I'd have one sketch running. But for some reason this doesn't work, not sure why.
Anyone have a clue?
https://Forum.Processing.org/two/discussions/tagged?Tag=getclasses(),getdeclaredclasses()
Looking at this thread:
https://forum.processing.org/two/discussion/7036/multiple-screens#latest
What is the easiest way to modify each of the PApplet sketches after the whole code is exported? Do they have to be .jar files?
Actually on second thought I don't want to open separate sketches. I want to call different methods from withing a sketch. But I'm looking for a way to allow the user to modify these methods. It looks like I'll need beanshell or some type of code interpreter.
https://Forum.Processing.org/two/discussion/15151/how-to-convert-string-to-a-line-of-code#Item_9
Ok, so you import processing classes to javascript and then have JS evaluate processing code? Do I need P5 as well? Can I do the same with beanshell?
exec
are capable of running dynamic scripts.https://Forum.Processing.org/two/discussion/23324/executing-python-3-code-from-within-processing/p1#Item_38
https://GitHub.com/GoToLoop/command/blob/patch-1/src/deadpixel/command/Command.java
http://Lagers.org.uk/jasmine/
Hmm. Pretty cool stuff. Thanks a lot for laying out all the different options! :) I had no idea what P5 was actually. It sounds like either JS or Python should work for what I want to do.
If you opt for Java Mode + Nashorn JS approach, take a look at this example about pulse equation expressions evaluated via ScriptEngine::eval(): :ar!
There's also a corresponding p5.js online version which calls JS' eval() and uses lib dat.GUI: O:-)
index.html:
sketch.js:
So turns out processing 3.0a5 doesn't support python mode? ~X( I'm gonna play around with JS a little more. Going back to beanshell, does anyone have experience using it? This is my code so far and it just doesn't recognize any processing code. Do I need to import anything in my script?
this is the script:
Re:
Is there a specific reason you are using 3.0a5 instead of 3.3.6?
Processing 3.0a5 is essentially version 2.2.1. :-j
Anything compatible w/ 2.2.1 should be compatible w/ 3.0a5 as well. :>
I tried porting my code over to the latest version had some nasty errors so decided to finish this project in 3.0a5. I don't see python mode in the list when I try to add it.
that explains why I can't add the beanshell library no matter what I do. Right now I have it in my code folder. ~X( Ok, I'll downgrade to 2.2.1 and see what happens [-O<
I went down to 2.2.1, JS and python modes both installed but the rest of my code doesn't work anymore :( Can I copy the files for these modes into my old 3.0a5 folder? Where would they be stored?
As I've mentioned, 3.0a5 recognizes P3's sketchbook's path.
However, P2's Python Mode isn't compatible w/ P3, only 3.0a5 and less.
But you should instead use latest P3 version rather than older versions.