Moving a processing project to Eclipse

I've been working on the Processing project for a while and now I want to move it to Eclipse. I have installed Proclipse with my Eclipse environment.

I have a lot of files with the extension ".pde". However, Proclipse files end in ".java". And there are many dependency problems with all pde files. How do I convert my project?

===============

Thanks everyone! There doesn't seem to be a one-touch solution, I refactored all of the code following an approach similar to George's answer. Plus changing all file extensions from ".pde" to ".java".

+3


source to share


2 answers


Jose is doing very well. Proclipsing already simplifies the creation of a machining project.

The easiest (but not the cleanest way to get your processing code running in eclipse would be doing the following:

  • Copy the code from the main tab to a class generated by Procliping that extends PApplet (removing default functions / existing empty setup () and draw () settings), but still in class scope ({})
  • Make processing functions from the inserted code (setup / draw / keyPressed / keyReleased / mousePressed / etc.) Public (for example public void setup(){//etc.

    instead of void setup(){//etc.

    )
  • Paste the rest of the code from other tabs into the same java class generated by Proclipsing
  • Add f flag (explicit float flag) to float values ​​(e.g. 3.0

    becomes 3.0f

    )
  • If you are using libraries, Procliping should help with this: right click on the project and go to the Procliping project properties. If you set the correct path to the Processing folder (eg Documents / Processing) additional libraries will be added, so you just need to mark / include them. Otherwise you will need to manually copy the .jar file of each library and paste into your lib project folder, then right click on the .jar files in eclipse and select Build Path> Add to Build Path

Update Here's a slightly simpler approach using the Export Export Application feature. I'll explain this workflow using Daniel Shiffman Boids example from Examples> Themes> Simulate> Flocking as it has multiple tabs and classes.

  • Export the application. This will create the application folder, including the original folder with Flocking.java (as I mentioned above, the processing actually bundles all your tabs into one .java class).
  • Create a new Procliping project
  • Paste the code from the processing-generated class into the Proclipsing-generated class after the statement package

    (a package is a folder in which multiple classes can be stored, so use that to keep things organized in a folder-friendly order based on what classes)
  • Update the static main method at the bottom to use the fully qualified class name (hence the class name prefixed with the package name)

At this point, hopefully most of the errors should be gone. Try to run your code as Java application now.



The problem is that you have one massive class that is still difficult to maintain, probably the reason you are moving to eclipse in 1st place. Now is the time to refactor (restructure your code), and luckily, Eclipse has some great tools for that. If you see duplicate code, this is a great candidate for a feature. You can try to select this code by right clicking, then choosing Refactoring> Extract Method . Values ​​that change in repeated code can be retrieved as arguments / parameters.

Inner classes have to move into new .java files, and if you use special processing functions in those classes, you have several options:

  • Passing PApplet as an argument to these classes (for example, link to "Host Processing in Eclipse" article).
  • Using static PApplet methods (e.g. PApplet.map()

    instead of map()

    )
  • Implementing PConstants in a class
  • Passing a renderer ( PGraphics ) if the class only uses drawing rendering

Most importantly though, you should have a little familiarity with Java (compiling a HelloWorld program from scratch that will shine on handling inner classes) and especially some OOP concepts (composition, inheritance, and maybe a few basic design patterns as visitor or MVC) in the future. This is of course if you are new to these concepts :)

Update Simplified updated instructions for Proclipsing are now available as here . The first two minutes illustrate the main process, and the rest are some of the refactoring concepts mentioned above.

+2


source


Check this link http://www.learningprocessing.com/tutorials/processing-in-eclipse/ here you can find a more detailed explanation of everything related to this topic.

The most important thing to know when moving from an IDE to another, such as Eclipse, is that in processing all classes are treated as inner classes, they are classes within the larger PApplet.

First you need to import the processing library inside your Eclipse project, then you have 2 ways to get you to work with the code.



You can go from PApplet to your main class and add whatever you handle there, including all of your other clans like internal clans.

Or you can work with these clans separately, calling the same PApplet instance every time you want to join the processing.

+4


source







All Articles