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 & HelpIntegration › Working with Jetty Webserver and Processing
Page Index Toggle Pages: 1
Working with Jetty Webserver and Processing (Read 883 times)
Working with Jetty Webserver and Processing
Jan 28th, 2010, 5:39pm
 
Hi all,
  I'm trying to develop an analytics application, where I want to do basically a combination of the Zipcode map and the map on chapter 3.  Before attempting that I'm just trying to print a shape, as on page 335 (if you have the book Visualizing Data).

My jetty server and data is all queued up ready to go.  Right now its in an ArrayList.

I'm not sure the best way to go about this.  What I thought was that my Jetty server would run, asking for user input, then I'd compute and generate the data, then pass everything off to a Visualizer object which has all the Processing functions.  Since I want to print a map of the US like in the book, I thought I would save the map first as an image, then open it back up again when I'm ready, or just generate a byte array.

Here is my code for the Visualizer object:
Code:
public class Visualizer  {

       static final int RECTANGLE=0;
       static final int ELLIPSE = 1;
       int kind = 0;
       PApplet parent;
       public Visualizer() {

       }

       public Visualizer(PApplet parent, int kind) {
               this.parent = parent;
               this.kind = kind;
       }
       public void setup()
       {
               parent.size(200,200);
       }
       public void draw() {
               if (kind == RECTANGLE) {
                       parent.rect(20,20,60,60);
               } else if(kind == ELLIPSE) {
                       parent.ellipse(50,50,30,30);
               }
       }
       public void saveImage() {
               parent.save("path/to/folder/ellipse.jpg");
       }
}


Then I'd call in my Jetty Handler:

Visualizer vis = new Visualizer();
vis.draw();
vis.saveImage();

The only problem is that I'm getting a NullPointerException at either the rect or ellipse in the draw method.

Do you have any ideas? Is there a better way going about doing what I'm trying to do?  I thought about having a Processing webserver running in the background as well that I would query.
Re: Working with Jetty Webserver and Processing
Reply #1 - Jan 29th, 2010, 2:45am
 
Quote:
Visualizer vis = new Visualizer();

Use the constructor with parameters, instead.
Page Index Toggle Pages: 1