We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProcessing DevelopmentLibraries,  Tool Development › Dynamic Variable Adjustments - New Package
Page Index Toggle Pages: 1
Dynamic Variable Adjustments - New Package (Read 2473 times)
Dynamic Variable Adjustments - New Package
Sep 15th, 2006, 6:16am
 
Hello all,

I have been learning Processing in the past couple of weeks.  I found that I wanted to make changes to the values of variables to see the effect on my program.  I was keeping these values in constants, but it was time consuming to close the applet, modify the constant, and then restart the applet.  I wanted to see the effects of manipulating variables instantly.

To solve this, I wrote a package that is very simple to use to change the values of variables on the fly.  All you have to do is include the package, name the variables you want access to with a prefix, and include a call a static method in the draw method.  OMenu reads the code, extracts the appropriate variables based on the name, and gives you an interface to modify those variables.

Unfortunately, it will not run in the applet.  I am using reflection to get a list of all the variables in the PApplet.  This seems to work fine when I run through the IDE, but when I run the exported applet in a browser, I see lots of access violations.  I assume it’s the security settings of Applet.  In any case, I find this tool invaluable for development.

Please send me any suggestions or comments.  I threw up a webpage with instructions on how to use the package as well as the .jar file and the source code at  http://mythmar.homelinux.com/proapplet .  Everything is still a little rough, which is fine for my usage, but if people are interested, I'll try to clean up the interface and package.  Also, please let me know if you have any suggestions or comments.

-Omar
Re: Dynamic Variable Adjustments - New Package
Reply #1 - Sep 16th, 2006, 11:55am
 
This sounds like a very smart thing to pull off Smiley And probably should be expected not to work with applets.

I'll check this thing out some time. It's a great idea!
Re: Dynamic Variable Adjustments - New Package
Reply #2 - Sep 17th, 2006, 3:44am
 
Thanks.  I want to make it into a full menuing package.  I haven't seen one out there for Processing.

Of course to do this, I will need to solve the Applet access issue.  I was discussing it with a coworker, and he suggested that I would have to sign the applet.  This will probably mean signing the applet that Processing outputs.  Has anyone attempted to do this before?  Any luck?

-Omar
Re: Dynamic Variable Adjustments - New Package
Reply #3 - Sep 19th, 2006, 4:55pm
 
Sounds great .. i'll have a look at it.
I just thought about implementing the whole stuff in a separated window with a full-gui. Maybe thats not much processing like ... but it could be very handy.
I remember myself lounching a hundred of times an applet, just for getting a text or button at the right position. What a dream if one could do this at runtime!!!

well well if I have a little spare time (which isn't that unlikely..) we'll seee
Re: Dynamic Variable Adjustments - New Package
Reply #4 - Sep 19th, 2006, 7:27pm
 
A separate window is a good idea.  It could be really powerful.

I tried to make the Jar file as MVC as possible.  I wasn't as consistent as I intended though.

If you want to create a new presentation, the class ODisplay will be the place to do it.  Currently, ODisplay gets the PApplet and asks it to draw the text on itself.  If you wanted a separate window, you could just create some kind of Swing or Applet window and throw your information in there.  At that point, you could probably include real Java components (sliders, text boxes, radio boxes for Booleans, etc) to adjust your variables.

Doing that does exaggerate the issue of not being able to run in a browser though.
Re: Dynamic Variable Adjustments - New Package
Reply #5 - Sep 19th, 2006, 9:10pm
 
Yeah that's what i thought abaout.. maby on the left a treeView, which would make it possible to "browse" thru the Objects, accessing all public fields.

Well, I'll try that one, got to figure out how exactly the whole JTree works Smiley.
If you call it from within the applet it shouldnt be even a problem to use it in a browser. As far is i know you can easely open a new window from an applet, thus it certanly is possible to add some content to it.. but i don't know if there are any further problems....
Re: Dynamic Variable Adjustments - New Package
Reply #6 - Mar 15th, 2009, 8:38pm
 
I'm guessing the same approach the controlP5 library requires for applets might work for you.  

Apparently, if every function and variable is declared "public" at the root scope, your library might have better luck introspecting them in the applet security level.

Hope that helps,
-jd
Page Index Toggle Pages: 1