We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Problem with Processing 1.1
Page Index Toggle Pages: 1
Problem with Processing 1.1 (Read 918 times)
Problem with Processing 1.1
Apr 9th, 2010, 10:51am
 
I have a sketch that runs without problems using Processing 1.09.
With Processing 1.1 I receive the following error message:
unexspected token: aRectangle

and

processing.app.debug.RunnerException: unexpected token: aRectangle
at processing.app.Sketch.preprocess(Unknown Source)
at processing.app.Sketch.preprocess(Unknown Source)
at processing.app.Sketch.build (Unknown Source)
at processing.app.Sketch.build (Unknown Source)
at processing.app.Editor$DefaultRunHandler.run  (Unknown Source)
at java.lang.Thread.run(Thread.java:619)

The sketch is quite big (8 classes, lots LOCs), so I have to narrow the
problem down, which is not so easy in such a context.

Any advice how to do that and for what to look, probably with some background knowledge of 1.1 ?
Re: Problem with Processing 1.1
Reply #1 - Apr 10th, 2010, 2:17am
 
Indeed, you don't provide much information! You should indicate at least what aRectangle is on your program...

But I can guess: it is probably an object of type java.awt.Rectangle.
I advise to read the list of revisions when you have an issue with a new version: "Changed how imports are handled in sketches. This may break some sketches that use java.xxx packages that aren't covered in the Processing reference."
That means that sketches using these packages must now explicitly import them:
import java.awt.Rectangle; or import java.awt.*; if you use several classes from there.
Re: Problem with Processing 1.1
Reply #2 - Apr 10th, 2010, 7:26am
 
Sorry for not providing sufficient information. I tried to be precise and did not want to produce too much information noise.

I did read the release note of 1.1 and indeed imported java.awt.Rectangle and tested that with 1.09 and 1.1.
But: The import-statement is in a processing tab, which holds a class, but outside the class definition. Rectangle is only used in the class
of that tab.

Looks something like this:

import cl.eye.*;
import hypermedia.video.*;
import java.awt.Rectangle;
.
.
OpenCV opencv;
.
class cam{
 boolean movement;
 cam(){
 }
 boolean detectedFace(){
   .
   .
   Rectangle[] faces = opencv.detect( 1.2, 3, OpenCV.HAAR_DO_CANNY_PRUNING, 40, 40 );

     for( int i=0; i<faces.length; i++ ) {
     rect( faces[i].x, faces[i].y, faces[i].width, faces[i].height );
     face=true;
   }
   return face;
 }

I thought this is legal and should work.
Reading your comment I changed that and copied the java.awt.Rectangle import to the main tab of my sketch: Now it works also with 1.1: Surprize! at least for me.
I dont understand why, was just a guess. Could you explain please?
Re: Problem with Processing 1.1
Reply #3 - Apr 10th, 2010, 1:00pm
 
Frankly, I don't know, so I can only guess.
I have little experience with multi-tab projects and I rarely had the need to import new stuff, so I made a little project with two tabs. On the second one, I made a little class with a function creating a java.awt.Rectangle and using a javax.xml.XMLConstants constant with both classes being imported in this tab.
As I expected, Processing detected the imports in the second tab and moved them to the start of the generated Java file.
Both in 1.0.5 and in 1.1.
Re: Problem with Processing 1.1
Reply #4 - Apr 11th, 2010, 12:41am
 
Thank you for your effort.
So we will leave this as is: A mystical behaeviour in my sketch..and
their is probably something else in my sketch, that I dont see, somehow interfering with this import statement.
Page Index Toggle Pages: 1