 |
Author |
Topic: P5 vs Eclipse (Read 30328 times) |
|
Euskadi
|
Re: P5 vs Eclipse
« Reply #45 on: Jan 31st, 2005, 1:56am » |
|
I gave up. I have this policy that after three beers or two hours (which ever comes first), if I can't figure a problem out I give up and try something else. So, I'm using Eclipse to edit my stuff -- really like the outlining, formating of my code -- but when it's time to click "run" I drop it into P5.
|
|
|
|
depth

|
Re: P5 vs Eclipse
« Reply #46 on: Jan 31st, 2005, 7:46pm » |
|
_C - been a while since your post, but your problem requires you pass a reference to your main sketch (that extends BApplet). from an earlier post by amoeba: Quote: Code: class foo extends BApplet { ... public void loop() { bar.draw(this); } } class bar { public void draw(BApplet b) { b.ellipse(100,100, 10,10); } } |
| |
|
|
|
|
|
eskimoblood

|
Re: P5 vs Eclipse
« Reply #47 on: Feb 25th, 2005, 12:40am » |
|
I try to use a color variable, but eclipse told me that "color cannot be resolved or is not a type". Code: public class visuals extends BApplet{ color cl1; void setup() { size(1200,800); smooth(); } } |
|
|
« Last Edit: Feb 25th, 2005, 12:41am by eskimoblood » |
|
|
|
|
fjen
|
Re: P5 vs Eclipse
« Reply #48 on: Feb 25th, 2005, 9:23am » |
|
yep. that's something the preprocessor handles in processing. if you are using any other environment you have to change: processing -> other color -> int float 0.0 -> float 0.0f #ff00ff -> 0xffff00ff so, your example goes: Code: public class visuals extends BApplet{ int cl1; void setup() { size(1200,800); smooth(); } } |
| /F
|
|
|
|
eskimoblood

|
Re: P5 vs Eclipse
« Reply #49 on: Feb 25th, 2005, 4:02pm » |
|
Ok if got this, but when ever I use int cl1=color(1,1,1), my applet chrashed on running. This is the error "java.lang.NullPointerException at BApplet.color(BApplet.java:3296)"
|
|
|
|
fjen
|
Re: P5 vs Eclipse
« Reply #50 on: Feb 25th, 2005, 4:48pm » |
|
my guess is that this is not related to color() ... you probably did initialze the variable at global scope (outside any of the functions) ... like this (?): your class { int c = color(1,1,1); void setup() { println(c); } void loop() { } } this gives the same exception because c is not yet initialzed when it is accessed in println(). try not to initialize your global variables like this, initialize them inside setup() ... your class { int c; void setup() { c = color(1,1,1); println(c); ... } } [ if the above is not the case then i don't know .. don't have eclipse installed. maybe you can give a minimal sketch that gives the same exception? ] /F
|
|
|
|
eskimoblood

|
Re: P5 vs Eclipse
« Reply #51 on: Feb 25th, 2005, 5:27pm » |
|
Ok here is a overview. I have 2 classes. The main class with setup and loop and a second class to draw objects on the screen. Both classes extends the BApplet class. Code: //-------------------------------------------// // the main class // //-------------------------------------------// class mainClass extends BApplet{ drawClass[] a=new drawClass[2] void setup(){ size(400,400); for(int i=0, i<a.length;i++){ a[i]=new drawClass(); } } void loop(){ for(int i=0, i<a.length;i++){ a[i].drawMe; } } } //-------------------------------------------// // the second class // //-------------------------------------------// class drawClass extends BApplet{ int cl; float myX; float myY; drawClass(){ cl=color(20,20,20); myX=random(width); myY=random(height); } void drawMe(){ fill(cl); translate(myX,myY) beginShape(POLYGON); bezierVertex(0,0); bezierVertex(10,10); bezierVertex(0,10); endShape(); } } |
| if I add a void setup methode to the second class and give cl a value it works fine until the drawMe methode, where every command is call a NullPointerException.
|
|
|
|
fjen
|
Re: P5 vs Eclipse
« Reply #52 on: Feb 25th, 2005, 5:48pm » |
|
yikes, that's a weired setup ... obviously you shouldn't do that. to use the BApplet methods in your second class pass it an instance of you main class like this: main { other o; setup() { o = new other(this); } } other { int c; main parent; other (main p) { parent = p; c = parent.color(1,1,1); } drawMe() { parent.fill(c); } } the way you did it there is no connection between main and drawclass ... the have seperate canvases, seperate run threads, oh-lala, ... no good. /F
|
|
|
|
eskimoblood

|
Re: P5 vs Eclipse
« Reply #53 on: Feb 26th, 2005, 2:15pm » |
|
Thanks fjen for your help. Slowly I understand how processing works. And now the next question. I use the beginShape methode and get an error by passing POLYGON. I figured out that beginShape needs an int as argument. But which?
|
|
|
|
fjen
|
Re: P5 vs Eclipse
« Reply #54 on: Feb 26th, 2005, 3:01pm » |
|
uff, you sure should use the variables, not the values (as they might change) ... try using (since it's a static variable): ...beginShape( BConstants.POLYGON ); or with your instance of BApplet from the previous example: parent.beginShape( parent.POLYGON ); /F
|
« Last Edit: Feb 26th, 2005, 3:05pm by fjen » |
|
|
|
|
eskimoblood

|
Re: P5 vs Eclipse
« Reply #55 on: Feb 26th, 2005, 4:15pm » |
|
This seems to work: parent.beginShape(BConstants.POLYGON);
|
|
|
|
fry
|
Re: P5 vs Eclipse
« Reply #56 on: Feb 26th, 2005, 4:58pm » |
|
add "implements BConstants" you your class, i.e.: public class SomethingElse implements BConstants so that you don't have to use BConstants.XXXXX. also, using things like parent.XXXX for a constant is bad, since some newer compilers (the jikes that will ship with the next version of p5) will complain about it.
|
« Last Edit: Feb 26th, 2005, 4:59pm by fry » |
|
|
|
|
michelle
|
Re: P5 vs Eclipse
« Reply #57 on: Mar 15th, 2005, 4:22pm » |
|
Hi, I tried to use Ant, in order to export the processing project out of ellipse, but I always get the following message: Buildfile: D:\Daten_allgemein\eclipse_space\helloP5\build.xml init: BUILD FAILED: D:\Daten_allgemein\eclipse_space\helloP5\build.xml:25: path to Processing's export classes missing I tried several things but nothing helped, what shell I do thanks for helping Michelle on Dec 30th, 2003, 8:04pm, toxi wrote:exporting applets _____________________________________ building applets is (initially) not as straight forward as with the PDE. instead we'll use Ant (included in the eclipse installation) to export our project as applet. this gives us much more flexibility, but we need to set up a few more preferences first: 1) open "window menu > preferences" and expand "ant > runtime". In the "classpaths" tab, select "add JARs.." and choose both "pde.jar" and "comm.jar" from the Processing "/lib" folder (same as in step 3 above). click "apply". 2) now select the "properties" tab in the same dialog and choose "add". use "java.home" as name (without the quotes) and for the value type in the path to where you have installed your Java SDK in the beginning. Eg. C:\j2sdk142. again "apply" and then press "ok" to close the preferences dialog box. 3) download this ant build file and copy it into your eclipse project folder. 4) now open "run menu > external tools > external tools..." and select "ant build". click "new" to create a new setting. give the setting a name, eg. "P5 export". then, in the "main" tab, the location of the build file should already be filled in automatically. Eg. "${workspace_loc:/HelloP5/build.xml}". we also need to set the base directory to the location of our project. to do this, click "browse workspace" and select the current project. the base directory value should be something like that: "${workspace_loc:/HelloP5}". there's one more little change needed here, though, in order to use the correct naming for the generated .jar file and its HTML wrapper file. copy the following into the "arguments" textbox: Code:-Dproject_name=${project_name} |
| click "apply" to activate these settings. 5) next, select the "properties" tab, where we will define 3 more parameters for the HTML file generation. for each property click "add..." and use the following value pairs: name: applet.width value: the width of your sketch, as used in the size() statement of your sketch. name: applet.height value: the height of your sketch name: classpath.processing.export value: the path Processing's /lib/export folder (eg. C:\processing-0067\lib\export ) there's another optional property to add some comments for the applet, which will appear in the HTML file: name: applet.comments value: whatever you want users to know about your work (can contain html) you should now see all the properties in the list. click "apply" once more. 6) press "run" to export the applet. the build script will now do the following: * create a new folder /applet within your project root * compile the sketch as java1.1 compatible applet * build a jar file incl. all Bagel classes and contents of the /data folder (if present) * create a zip file of all files in the /src folder * generate a validating XHTML1.0 wrapper file which is compatible with the upcoming IE (vs. Eola) security update now, that you have a working Ant export setting, you can run it via "run menu > external tools > p5 export". an example of this all is here: http://www.toxi.co.uk/p5/eclipse/hello/ have fun & a happy new 2004! |
|
|
|
|
|
eskimoblood

|
Re: P5 vs Eclipse
« Reply #58 on: Mar 15th, 2005, 5:33pm » |
|
Take a look at run-> external tool-> external tool-> proerties tab. There must be a variable called classpath.processing.export with the path to your processing-0068\lib\export folder as value. If not create them.
|
|
|
|
michelle
|
Re: P5 vs Eclipse
« Reply #59 on: Mar 16th, 2005, 12:13pm » |
|
Hi, I did so (Name: classpath.processing.export Value: C:\Programme\Processing-0068\lib\export\), but still the same note in the console window. Can you give me an other hint Thanks Michelle on Mar 15th, 2005, 5:33pm, eskimoblood wrote:Take a look at run-> external tool-> external tool-> proerties tab. There must be a variable called classpath.processing.export with the path to your processing-0068\lib\export folder as value. If not create them. |
|
|
|
|
|
|