I've been working on a Processing project for a while, and now want to move it into Eclipse. I've installed Proclipse with my Eclipse environment.
I've a lot of files with the extension of ".pde". However the Proclipse files all ends with ".java". And there's a lot of dependency issues with all the pde files. How should I convert my project?
===============
Thanks everyone! There doesn't seem to be a one-button solution, I refactored all the code following an approach similar to George's answer. Plus changing all the file extensions from ".pde" to ".java".
Jose's advice is pretty good. Proclipsing already makes creating a Processing project easy.
The easiest (but not cleanest way to get your Processing code running in eclipse would be taking these steps:
public void setup(){//etc.
instead ofvoid setup(){//etc.
)3.0
becomes3.0f
)Update Here is a slightly simpler approach using Processing's Export Application feature. I will explain this workflow using the Daniel Shiffman's Boids example from Examples > Topics > Simulate > Flocking since it has multiple tabs and classes.
package
statement.(a package is a folder can hold multiple classes, so use this to keep things tidy/nicely organized in folders based on what the classes do)At this point hopefully most of the errors should have disappeared. Try to run your code as a Java Application now.
The problem is at this point you have one massive class which is still hard to maintain, probably the reason you're moving to eclipse in the 1st place. Now would be the time to refactor(restructure your code) and luckily eclipse has some great tools for that. If you see repetitive code, that's a great candidate for a function. You can try selecting that code , right clicking then choosing Refactor > Extract Method. The values that change in the repeated code can be extracted as arguments/parameters.
Inner classes should move to new .java files and if you use Processing specific functionalities in those classes you've got multiple options:
PApplet.map()
instead ofmap()
)Most importantly though you should familiarize yourself a little bit with Java (compiling a HelloWorld program from scratch which will shine a light on Processing's inner classes) and especially some OOP concepts(composition, inheritance and perhaps a few basic design patterns (such as Visitor or MVC) in the future. This of course, if you're new to these concepts :)
Update the simplified updated instructions for Proclipsing are now available as a video here. The first two minutes illustrate the basic process and the rest covers some of the refactoring concepts mentioned above.
Check this link http://www.learningprocessing.com/tutorials/processing-in-eclipse/ here you can find a more detail explanation of everything concerning this topic.
The most important thing to know when moving from the Processing IDE to another one like Eclipse, is that in Processing all classes are treated as inner classes, they are classes inside of the larger PApplet.
First you need to import the Processing library inside you Eclipse project, then you have 2 ways to make you code work.
You can extend from PApplet in your main class and add all you Processing code there, including all your other clases like inner clases.
Or you could work those clases separately by calling the same instance of PApplet every time you want to accede Processing stuff.