Problem while using Processing on Eclipse

hi there, i was trying to use processing on eclipse. So for that i followed the proclipsing method and even succeeded. I ran a small program on java. But i was not able to write code for the program with more than one .pde file and even not able to find out that how to use android mode and javascript in eclipse.

I have used 3 .pde files that are sonic painter, brushes, android_api so how could i code this in eclipse.

here is the code :

SONIC PAINTER

Maxim maxim;
AudioPlayer player;
AudioPlayer player2;
void setup()
{
  maxim = new Maxim(this);
  player = maxim.loadFile("drum.wav");
  player.setLooping(true);
  player2 = maxim.loadFile("bells.wav");
  player2.setLooping(true);
  player2.volume(1.2);
  background(0);
}
void draw()
{}
void mouseDragged()
{  
  player.play();
  player2.play();
  float red = map(mouseX,0, width ,0,255);
  float blue = map(mouseY,0,width,0,255);
  float green = dist(mouseX,mouseY,width/2,height/2);
  float speed = dist(pmouseX,pmouseY,mouseX,mouseY);
  float alpha = map(speed, 0, 20, 0 ,5);
  float lineWidth = map(speed, 0, 10, 10, 1);
  lineWidth = constrain(lineWidth, 0, 10);
  noStroke();
  fill(0,alpha);
  stroke(red,green,blue,255);
  strokeWeight(lineWidth);
  brush4(pmouseX,pmouseY,mouseX,mouseY,lineWidth);
  
   player2.ramp(1.,1000);
  player2.speed((float) mouseX/width/2);
 
}
void mouseReleased()
{ player2.ramp(0.,1000);
  noStroke();
  fill(0);
  rect(0,0, width, height);
}

BRUSHES:

void brush1(float x,float y, float px, float py, float lineWidth) {
  strokeWeight(lineWidth);
  ellipse(x,y,px,py); 
  
  return;
}


void brush2(float x,float y, float px, float py, float lineWidth) {
  strokeWeight(lineWidth);
  pushMatrix();
  translate(x,y);
  rotate(random(px));
  rect(0+random(50),0+random(50),10,10); 
  popMatrix();
  return;
}

void brush3(float x,float y, float px, float py, float lineWidth) {
  strokeWeight(lineWidth);
  pushMatrix();
  translate(x,y);
  rotate(random(px));
  line(0+random(50),0+random(50),0,0);
  rotate(random(px));
  line(0+random(50),0+random(50),0,0);
  rotate(random(px));
  line(0+random(50),0+random(50),0,0);
  popMatrix();

  return;
}

void brush4(float x,float y, float px, float py, float lineWidth) {
  strokeWeight(lineWidth);
  line(px,py,x,y);
  line(px,py,x,y);
  line(width/2+((width/2)-px),py,width/2+((width/2)-x),y);
  line(px,height/2+((height/2)-py),x,height/2+((height/2)-y));
  line(width/2+((width/2)-px),height/2+((height/2)-py),width/2+((width/2)-x),height/2+((height/2)-y));
  return;
}

void brush5(float x,float y, float px, float py, float lineWidth) {
  strokeWeight(lineWidth);
  line(px,py,x,y);
  line(width/2+((width/2)-px),py,width/2+((width/2)-x),y);
  line(px,height/2+((height/2)-py),x,height/2+((height/2)-y));
  line(width/2+((width/2)-px),height/2+((height/2)-py),width/2+((width/2)-x),height/2+((height/2)-y));
  line(width/2+((width/2)-py),width/2-((width/2)-px),width/2+((width/2)-y),width/2-((width/2)-x));
  line(height/2-((height/2)-py),width/2-((width/2)-px),height/2-((height/2)-y),width/2-((width/2)-x));
  line(width/2+((width/2)-py),height/2+((height/2)-px),width/2+((width/2)-y),height/2+((height/2)-x));
  line(width/2-((width/2)-py),height/2+((height/2)-px),width/2-((width/2)-y),height/2+((height/2)-x));
  return;
}

void brush6(float x,float y, float px, float py, float lineWidth) {
  strokeWeight(lineWidth);
  px=px+random(50);
  py=py+random(50);
  ellipse(x,y,px,py);
  ellipse(width/2+((width/2)-x),y,px,py);
  ellipse(x,height/2+((height/2)-y),px,py);
  ellipse(width/2+((width/2)-x),height/2+((height/2)-y),px,py);
  ellipse(width/2+((width/2)-y),width/2-((width/2)-x),px,py);
  ellipse(height/2-((height/2)-y),width/2-((width/2)-x),px,py);
  ellipse(width/2+((width/2)-y),height/2+((height/2)-x),px,py);
  ellipse(width/2-((width/2)-y),height/2+((height/2)-x),px,py);  
  return;
}

void brush7(float x,float y, float px, float py, float lineWidth) {
  strokeWeight(lineWidth);
  line(px,py,x,y);
  line(width/2+((width/2)-px),py,width/2+((width/2)-x),y);
  return;
}

so help me to sort out this problem so that i could code it on eclipse

Tagged:

Answers

  • edited October 2013
    • Please, don't make all caps subjects, making you like yelling. Fixed that.
    • Use the <pre lang="processing">...</pre> tags to format your code (or, alternatively, indent it with one tab or 4 spaces, but it is a bit less practical in the editor).
    • The backtick symbol is more made to format inline code.
    • GoToLoop, thanks for the help, but since I formatted the code in the post itself, I removed your message that was just doing that. B-)
    • This Tools section was intended for the tools to use in the PDE (and to install from it), but hey, it is also fitting for Eclipse-related messages. :)
  • Thanks PhiLho for editing, and yes actually i found tool section best one to post the problem. But my problem still remain unsolved, that how could this android mode which we use in processing can be obtained on eclipse so that by simply running the code we can run the app on the device.

  • Yes, sorry, I don't use Proclipsing, nor Android coding, so I can't help you beyond these forum issues...

  • The first thing to understand is that when creating a sketch in Processing, you are using the Java language, but not in a form that the Java compiler will recognize. PS has a pre-processor that converts the sketch code into valid Java code. When you move to Eclipse you will have to do this yourself, you can't simply copy the pde files over.

    Now I have never used JavaScript mode or Android mode in Eclipse so all I can do is get you started creating Java Mode sketches in Eclipse.

    In the Eclipse workspace create a folder called libs and into this copy core.jar and any other library jars you are using. Read here for information on locating the core.jar file.

    Now in Eclipse create a new Java Project. The next stage is to link the core.jar file , right-click on the project name and select Build Path | Configure Build Path from the popup menu, clcik on the Libraries tab and click on the Add External JAR button, locate and select the core.jar in the libs folder you created.

    In your project right click on the src folder and select New | Class - call it Hello World.

    When the class opens in the editor change it so it looks like this.

    import processing.core.*;
    
    public class HelloWorld extends PApplet {
    
        public void setup(){
            size(300,300);
    
        }
    
        public void draw(){
             background(255);
    
        }
    
    }  // end of class HelloWorld
    

    If you have a sketch with multiple pde tabs then place all the code inside the one class, in this case HelloWorld.

    HTH

  • You need to put the code for Sonic painter in the file Proclipsing created for you when you created the project.

    You need to put the code for Brushes in a new class-file (called Brushes).

    Have a look at the Processing in Eclipse tutorial, section Processing in Eclipse with Multiple Classes.

  • You need to put the code for Brushes in a new class-file (called Brushes).

    Since the original code did not use classes the brush code can go in the same class as the Sonic Painter code. To put this code in a top-level class (e.g. Brushes.java) would involve a lot of work because all the graphic drawing commands would need to be prefixed with a reference to the PApplet object/

  • Thank u quark and RbSCR, But i already know that. Actually through proclipsing technique we can directly start with a new project on eclipse of processing. eclipse itself manage to provide skeleton of the processing sketch so we dont have to worry about the core libraries. I have already made sonic painter on eclipse using PApplet and its running too, but the thing is what can i do to run the program on android device through eclipse same as we do in processing i.e by simply changing the mode to android and then running the code? do i have to use those emulator and all in eclipse to make my processing program run on eclipse?

    its very annoying as i am trying to find some solution from last 3 days, but neither i have got it from processing forum nor eclipse forum. i thing i should discuss this somewhere on android based forum.

  • by simply changing the mode to android and then running the code

    I don't believe this can be done - modes is part of the Processing IDE and so not available in Eclipse. I suspect that you would have to link your Eclipse project with the Android SDK and libraries manually.

    Also there has been no development on Proclipsing for 3 years, so it may not work with some of the newer features in Processing.

  • edited October 2013

    I need to be frank with you: Run away from Proclipsing.

    As to my knowledge, Proclipsing was an initiative started few years ago with the thought in mind of marrying simplicity of processing and the power of Eclipse. But as it turned out - you can't take super sophisticated tool Eclipse and make it simplier with addition of plugin. Eventually it becomes neither powerful, neither simple. And I guess this was the reason why development of this tool was abandoned. I tried Proclipsing for one day to realize how unconvenient it was.

    Probably the main problem of Proclipsing is that the sketch code you write is not recognized by Eclipse as java-code. So you have no access to main tools: navigation though code, proper debugging, commentary, inline syntax checking and so on.

    The reason people find Proclipsing useful, is because they don't have to declare the bolerplate code "class extends PApplet" and they have access to PApplet methods from any sketch tab. But if you're on the path to learn Eclipse and be more professional, then avoiding doing this, means that you actually avoid the power of Eclipse and object oriented programming.

    I see no single benefit of using Proclipsing as opposed to using PDE. Especially after announcement of the PDE X http://www.mkmoharana.com/2013/09/announcing-pde-x.html

    On top of that Proclipsing doesn't work with Android mode. Building(compiling) android sketches, is very different process as opposed to buidling regular java-mode sketch. First difference is that it uses completely different version of core.jar vs java-mode sketches. You can find android version of core.jar under this path processingSketchFolder\modes\AndroidMode\android-core.zip. Despite it's called android-core.zip it is actually android version of core.jar file.

    Other things include: different compliation, build, linking and signing and packaging processes. All of those things are availble in PDE Android mode. Or if you have Eclipse with Android Tools.

    If you want to develop your sketch in Eclipse for android, then what you ahve to do:

    a) download/install Eclipse with Android Developer Tools and corresponding SDKs

    b) start new Android project

    c) add to the project dependency on library android-core.zip (probaly you will have to rename file into android-core.jar)

    d) Add your MyAndroidSketch.java which should be looking smth like this:

    class MyAndroidSketch extend PApplet
    {
      void setup(){
          ...
       }
       void draw(){
         ....
       }
    }
    

    to your project's file tree.

    e) edit your AndroidManifest.xml and make sure that default activity is pointing to MyAndroidSketch

    f) if everything was done properly it will probably compile and run on your device/emulator

    So again: Run away from Proclipsing.

Sign In or Register to comment.