Why isn't my rect drawing until after the delay?
in
Programming Questions
•
3 years ago
I'm using this chunk of code, along with twitter4j, to graph out the use of the word "sandwich" as a test for another project.
Any thoughts?
- Twitter myTwitter;
- void setup()
- {
- size(500, 500);
- background(0);
- myTwitter = new Twitter("myUserName", "myPassword");
- }
- void draw()
- {
- background(0);
- try
- {
- Query query = new Query("sandwich");
- query.setRpp(10);
- QueryResult result = myTwitter.search(query);
- ArrayList tweets = (ArrayList) result.getTweets();
- for (int i = 0; i < tweets.size(); i++)
- {
- Tweet t = (Tweet) tweets.get(i);
- String user = t.getFromUser();
- String msg = t.getText();
- Date d = t.getCreatedAt();
- println("Tweet by " + user + " at " + d + ": " + msg);
- if (msg.indexOf("peanut") != -1 && msg.indexOf("jelly") != -1)
- {
- fill(250, 0, 0); //red
- }
- else
- {
- fill(255); //white
- }
-
- rect(0, i * 10, msg.length() * 3, 10);
- }// end for
- }//end try
- catch (TwitterException te)
- {
- println("Couldn't connect: " + te);
- }//end catch
- println("delay reached");
- delay(5000);
- println("delay elapsed");
- }//end draw
Any thoughts?
1