Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 70 lines (62 sloc) 2.45 KB
/*
The Article class represents the Wikipedia articles that are rendered as spheres in the final visualization.
*/
class Article {
String title;
public String parent;
int level;
public float[] prinComp = new float[8];
boolean visible;
public Article() {
this.title = "";
this.level = 0;
this.parent = "";
// float arrays are set to zeros by default
}
public Article(String title_, String parent_, int level_, float[] prinComp_){
this.title = title_;
this.parent = parent_;
this.level = level_;
// Map principle components
this.prinComp[0] = map(prinComp_[0], -0.4094028, 0.6702876, -MAX_RENDER_DIST, MAX_RENDER_DIST); // X
this.prinComp[1] = map(prinComp_[1], -0.4262940, 0.7053004, -MAX_RENDER_DIST, MAX_RENDER_DIST); // Y
this.prinComp[2] = map(prinComp_[2], -0.3464782, 0.6421811, -MAX_RENDER_DIST, MAX_RENDER_DIST); // Z
this.prinComp[3] = map(prinComp_[3], -0.3702722, 0.5380188, 10, 360); // Red
this.prinComp[4] = map(prinComp_[4], -0.3905856, 0.7148252, 10, 360); // Green
this.prinComp[5] = map(prinComp_[5], -0.3051968, 0.5752281, 10, 360); // Blue
this.prinComp[6] = map(prinComp_[6], -0.3117960, 0.5103850, 1, 10); // size
}
/*
Method to display the article in Processing as a sphere in 3D space. The transparency method comes into
play when the user is searching for a particular article. That way we can grey-out the unnecessary articles
and show the selected ones in full color.
@param transparency A float between _ and _. Used for the sphere's transparency.
*/
public void display(float transparency){
colorMode(RGB, 360, 360, 360, 360);
stroke(color(this.prinComp[3], this.prinComp[4], this.prinComp[5], transparency));
strokeWeight(this.prinComp[6]);
point(this.prinComp[0], this.prinComp[1], this.prinComp[2]);
}
/*
Remnders the title of the articles as text near the corresponding sphere. Uses pushMatrix()
so that the titles are always oriented towards the camera.
*/
public void writeTitle(){
pushMatrix();
translate(this.prinComp[0], this.prinComp[1], this.prinComp[2]);
rotateX(cam.getRotations()[0]);
rotateY(cam.getRotations()[1]);
rotateZ(cam.getRotations()[2]);
textSize(50);
fill(color(250, 0, 0, 300));
text(this.title, 0, 0, 0);
popMatrix();
}
public float[] getPCs(){
return(this.prinComp);
}
public String getTitle(){
return(this.title);
}
}
You can’t perform that action at this time.