That does appear to be the one I'm looking for. My next problem follows, then:
I am creating a class within processing (bone -- it's used for skeletal animation). Previously, I used a static Processing array with a maximum of some number of elements. Now, when I include and use Java's Vector class, it seems adding new elements to the list works fine -- my code goes right through that stage. However, it dies when I try to retrieve an element from the list.
The method in question is:
Code:bone link (int which) { return children.elementAt(which); }
The error seems to be as simple as: Vector.elementAt() returns a java.lang.Object, however, my method is supposed to return a bone. Is there a way to change the typing of this, so that it returns as it ought?
You'll have to forgive me, I've spent the last few years shying away from statically typed languages (and Java especially) for this very reason.
Code:class bone {
// constants
color[] colors = { color(0, 0, 0), color(0, 0, 255), color(191, 0, 255), color(255, 0, 0) };
// variables
float x, y, z, a, b ,c;
Vector children;
// methods
bone (float x, float y, float z) { this.x = x; this.y = y; this.z = z; a = b = c; children = new Vector(); }
bone rotate (float a, float b, float c) { this.a = a; this.b = b; this.c = c; return this; }
bone link (bone child) { children.addElement(child); return this; }
bone link (int which) { return children.elementAt(which); }
void draw () {
pushMatrix();
rotateX(a); rotateY(b); rotateZ(c); translate(x, y, z);
stroke(0); line(0, 0, 0, -x, -y, -z);
fill(colors[len]); noStroke(); sphere(4);
for(int i = 0; i < len; ++i) children[i].draw();
popMatrix();
}
}
You can see the previous iteration in all it's glory at: http://www.rpi.edu/~laporj2/art/dynamic/processing/walkie/index.html