Processing sketch works in Java but not in JavaScript mode

I wrote a processing sketch for depicting the parallel coordinates visualization. The problem is that though it works fine in Java mode but shows a blank screen in JavaScript Mode. Can someone tell me what the problem is? I am using Processing 2.0. The error I receive in Firefox is as follows:

Use of getPreventDefault() is deprecated.  Use defaultPrevented instead. @ chrome://smarterwiki/content/jquery.js:3527
Error in parsing value for 'image-rendering'.  Declaration dropped. @ http://127.0.0.1:56763/
ReferenceError: Float is not defined @ http://127.0.0.1:56763/processing.js:10175

I cannot provide the code because it's part of a homework I still need to submit. Also, seeing the last line, I tried to replace all the instances of the float type with var type in the JavaScript mode but it didn't help.

Answers

  • Just speculation, but it looks like you are using a Float and not a float. The lower-case float is a primitive type, and the upper-case Float is a class that wraps the primitive type. It is possible to use them interchangeably in java code, but I doubt that the JS code generator knows what to do with the Float type.

    Do a find replace for Float -> float in your processing app, and see what happens.

  • Actually, for the JS Mode, it doesn't matter which data-type a variable was declared with. Everything becomes var anyways! :))
    However, when instantiating a class, we gotta check whether it was converted to Processing.JS already! <):)

  • @billautomata, you caught the issue correctly. I am using Float.isNaN() and Float.MAX_VALUE in parts of my code where I cannot do without them. That is causing the problems. Is there a way I can use something else for them?

  • Since I can't see your code I don't know for sure but it might just not work in javascript because it's a very different language than java! So even thought javascript mode looks really cool, for many things it just doesn't work or doesn't work properly.

  • @mcspud I know it will work because I tried removing the Float.isNaN() method and replaced the Float.MAX_VALUE with some random number; but though the sketch got displayed, the actual visualization went haywire. So I need to know how exactly to handle them yet keep them working.

  • I modified the code and now when I run in the JavaScript mode I get the following error on Firefoxx.

    Use of getPreventDefault() is deprecated.  Use defaultPrevented instead. @ chrome://smarterwiki/content/jquery.js:3527
    uncaught exception: Processing.js: Unable to execute pjs sketch: SyntaxError: identifier starts immediately after numeric literal
    

    Any idea what this could mean?

  • Looks like you have some syntax error in your code, or something that Firefox doesn't understand (saw this with some valid Java declarations, rejected in JS).

  • But it works well in Java mode. So how would I find where the syntax errors are for the JavaScript mode?

Sign In or Register to comment.