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.