Storing tweets in objects
After talking with a programmer friend I discovered how best to track the tweets I'm analyzing and sort them and assign x, y, and z coordinates. He suggested writing an object so that each tweet can be an instance of that object, put into an array, sorted, the coordinate assigned, resorted by rule number two, then the next coordinate assigned, and so on. Then each object has three coordinates and an id and the coordinates can be written to a text file and loaded into a 3D visualization program I found. Below is the code for the object. It defines a Tweet object then creates a new tweet with fake values and prints those values to the console.
Tweet tweet;
int l;
String[] lines;
int index = 0;
Tweet[] tweets = new Tweet[100];
void setup(){
lines = loadStrings("tweets0.txt");
}
void draw(){
if (index < lines.length) {
String[] pieces = split(lines[index], '~');
if(pieces.length == 3){
/* tweet = new Tweet(1, 0, 0, 0, pieces[0], pieces[1], pieces[2]);
tweets[index] = tweet;*/
tweets[index] = new Tweet(index, 0, 0, 0, pieces[0], pieces[1], pieces[2]);
println(tweets[index].username);
}
}
if(index < 99){
index = index + 1;
}
else noLoop();
}
class Tweet {
int id;
int xcord;
int ycord;
int zcord;
String username;
String date;
String content;
Tweet(int tempid, int tempxcord, int tempycord, int tempzcord, String tempuser, String tempdate, String tempcontent) {
id = tempid;
xcord = tempxcord;
ycord = tempycord;
zcord = tempzcord;
username = tempuser;
date = tempdate;
content = tempcontent;
}
}