Reputation: 251
I'm not much of a java programmer. I really like Scala a lot more than java. If I could I'd could I'd rather make processing libraries in Scala to use in Processing. I've been able to initiate new objects from my library in Processing, but I can't yet figure out how to reach methods or fields from my Scala object. I also can't seem to pass the current PApplet into the Scala object without an error. How I did it was by copying scala-library.jar into the lib folder of Processing so it can use scalaObjects.
If I do:
new Foo();
//or
Foo bar = new Foo();
There's no problem.
But if I do:
Foo bar = new Foo();
println(bar.baz);
It says baz doesn't exist, baz is just a string.
If I do:
new Foo(this);
It says Foo(library) doesn't exist.
I'm obviously missing something, is there someone much more knowledgeable than me out there who can give me a hint?
[update] Also, I noticed that when I do this in processing:
println(new Foo());
The console prints out, library.Foo@aa233f
Upvotes: 2
Views: 325
Reputation: 455
These are typical Java/Scala interop issues. You should give the definition code of Foo to get specific help, but you can find lots of existing help/info by searching for scala interop.
Have you had a look at SPDE? It's an offshot of Processing which supports Scala. If it's mature enough, you may be better off using it rather than dealing with all these interop issues.
Upvotes: 1