Combining processing applications into one large executable?

I created these 3 applications. Each of them collects data from user input and creates a csv file. 2 of them rely on the LEAP motion controller. I am trying to find a way to combine them all into one program. Any tips on how I can do this? Can I just nest them in a class, and then each of them will be called for each program separately? Or do I need to stop by and rewrite everything to work together? Each application makes a very different use of draw () with all types of flags and noLoop () and Loop () cause a pause when it is necessary to collect data, so rewriting everything as 1 will be difficult. In addition, the code is extremely sloppy in its current form. I basically hacked and collected battle bits to get everyone to do what I needed to do. Each of them is a mess, so combining all into one program seems like it will be a real nightmare.

Is there anyway to pack them, since one end of the other automatically opens? How do you like how on a web page you can simply link or automatically open another page after closing? Each application just needs to be run once, so I donโ€™t have to worry about going back and forth.

In the end, I'm going to create a visualization that updates in real time with data from these applications. I think I can create a web application for this part because I want the visualization to be viewable from multiple locations / platforms.

I have included a link to delete all codes. Someone suggested embedding the application directly in Java using the Swing Interface. Now I am reading this one which, I think, explains how to do this. I never used Java Swing before I get lost now ....

Link Link

+2
source share
3 answers

In fact, there are quite a few implementation questions. Do you want just one big application or do you also want them to be different? Do you want to run three ready-made applications or want to combine the source code? You can also add them to libraries ... As for your comment in another question ( Create several windows of one sketch in the Processing section ), yes, of course, you can create another PApplet to store your application. I slightly modified the demo example.

Here I created two sketches of RedBG and BlueBG as follows:

int counter = 0; public void setup() { size(400, 400); counter = 0; } public void draw() { background(255, counter, counter); fill(255-counter); text(String.valueOf(counter), width*0.5, height*0.5, width, height); counter++; } 

This red, blue has background(counter, counter, 255); , and both of them work as correct sketches. Then I took two codes and placed them on different tabs in the sketch of the controller and wrapped them in classes as follows:

 public class RedBG extends PApplet { int counter = 0; public void setup() { size(400, 400); counter = 0; } public void draw() { background(255, counter, counter); fill(255-counter); text(String.valueOf(counter), width*0.5, height*0.5, width, height); counter++; } } 

Then the controller class is just a modification of my answer in here . Here is his code:

 import javax.swing.*; PApplet r, b; PFrame rf, bf; String nextWindow = "red"; int controllerCounter = 200; String control = "preparing..."; void setup() { size(400, 400); r = new RedBG(); b = new BlueBG(); frame.setTitle("controller"); fill(0); } void draw() { background(255); if (controllerCounter < 1) { switchState(); controllerCounter = 200; } control = null; control = "Launching " + nextWindow + " in: " + controllerCounter; text(control, width*0.5, height*0.5, width, height); controllerCounter--; } void switchState() { if (nextWindow == null) { stopApplet(b); nextWindow = "red"; } else if (nextWindow.equals("red")) { startApplet(r); nextWindow = "blue"; } else if (nextWindow.equals("blue")) { stopApplet(r); startApplet(b); nextWindow = null; } } void startApplet(final PApplet p) { if (p == null) return; final PFrame f = new PFrame(p); p.frame = f; f.setTitle(p.getClass() + " window"); //this thread is only necessary if you are restarting the PApplets Thread t = new Thread(new Runnable() { public void run() { p.setup(); } }); t.run(); } void stopApplet(PApplet p) { if (p == null || p.frame == null) return; p.dispose(); p.frame.dispose(); } public class PFrame extends JFrame { public PFrame(PApplet p) { setSize(400, 400); add(p); p.init(); show(); } } 

Two classes that came from the sketches:

 public class BlueBG extends PApplet { int counter = 0; public void setup() { size(400, 400); counter = 0; } public void draw() { background(counter, counter, 255); fill(255-counter); text(String.valueOf(counter), width*0.5, height*0.5, width, height); counter++; } } 

and

 public class RedBG extends PApplet { int counter = 0; public void setup() { size(400, 400); counter = 0; } public void draw() { background(255, counter, counter); fill(255-counter); text(String.valueOf(counter), width*0.5, height*0.5, width, height); counter++; } } 

In short, take all of your code from three thumbnails (all tabs), drop them into a new tab in the thumbnail of the controller and wrap it with a class extending PApplet.

Unfortunately, you cannot have the tabs of your three thumbnails in the thumbnail of the controller unless you change your code. In the modified example below, only lala1 () and lala3 () are displayed in the blue window. lala2 () is in the controller window ...

 public class BlueBG extends PApplet { int counter = 0; public void setup() { size(400, 400); counter = 0; } public void draw() { background(counter, counter, 255); fill(255-counter); text(String.valueOf(counter), width*0.5, height*0.5, width, height); counter++; lala1(); lala2(); lala3(this); } public void lala1() { fill(255, 255, 0); ellipse(100, 100, 100, 100); } } public void lala2() { fill(255, 0, 255); ellipse(150, 150, 100, 100); } public void lala3(PApplet p) { p.fill(0, 255, 255); p.ellipse(200, 200, 100, 100); } 

And last but not least, sometimes the code will throw a NullPointerException and strange error messages, such as "the absence of pushMatrix () to jump with popMatrix ()" when calling the background method. This is caused by the call to setup() in the startApplet() method, and this is a concurrency problem, so it requires deeper thinking and knowledge ... As a temporary measure, I made it call setup() from the thread ... If you are not going to repeat the process, then the whole thread is not needed, and you do not need to setup() every time.!

PS This is a hack slash solution ... My suggestion is to combine your thumbnails into one and do it right ...

+3
source

Simple solution: just create a batch file and add one line for each application. To wait for the next next call like this:

 START /WAIT MyApp1.exe START /WAIT MyApp2.exe START /WAIT MyApp3.exe 
+2
source

Take a look at http://www.onar3d.com/mother/ This is a VJ library that brings together a bunch of small thumbnails into a presentation. You will need to add a code for each of your sketches so they can talk, and you will need to write a short sketch for the sequence of sketches.

All applications will live inside one processing sketch, so you will not have a single application and window, and then the next, all this will be one seamless experience. If this is less than desirable, then @krowe's solution is simple and reliable.

+1
source

All Articles