Eclipse: Java and Processing mess.
import processing.core.*;
import processing.core.PGraphics;
import twitter4j.DirectMessage;
import twitter4j.Status;
import twitter4j.StatusDeletionNotice;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.TwitterStream;
import twitter4j.TwitterStreamFactory;
import twitter4j.User;
import twitter4j.UserList;
import twitter4j.UserStreamListener;
import twitter4j.AsyncTwitter;
import twitter4j.AsyncTwitterFactory;
public class processingTwitter extends PApplet {
public static void main(String args[]) {
PApplet.main(new String[] {"processingTwitter" });
TwitterStream twitterStream = new TwitterStreamFactory().getInstance();
twitterStream.addListener(listener);
twitterStream.user();
}
public void setup(){
size(800,600);
background(255);
}
static UserStreamListener listener = new UserStreamListener() {
public void onStatus(Status status) {
if(!status.getUser().getScreenName().equals("this_bottle")){
AsyncTwitter twitter = new AsyncTwitterFactory().getInstance();
twitter.updateStatus("thank you @" + status.getUser().getScreenName());
}
System.out.println("onStatus @" + status.getUser().getScreenName() + " - " + status.getText());
}
public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
System.out.println("Got a fucking status deletion notice id:" + statusDeletionNotice.getStatusId());
//================================================================================== //I tried different ways of doing it...
PGraphics dr = new PGraphics();
dr.fill(100);
dr.ellipse(400,300,50,50);
processingTwitter tw = new processingTwitter();
tw.circleDraw();
//==================================================================================
}
public void onDeletionNotice(long directMessageId, long userId) {
System.out.println("Got a direct message deletion notice id:" + directMessageId);
}
public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
System.out.println("Got a track limitation notice:" + numberOfLimitedStatuses);
}
public void onScrubGeo(long userId, long upToStatusId) {
System.out.println("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId);
}
public void onFriendList(long[] friendIds) {
System.out.print("onFriendList");
for (long friendId : friendIds) {
System.out.print(" " + friendId);
}
System.out.println();
}
public void onFavorite(User source, User target, Status favoritedStatus) {
System.out.println("onFavorite source:@"
+ source.getScreenName() + " target:@"
+ target.getScreenName() + " @"
+ favoritedStatus.getUser().getScreenName() + " - "
+ favoritedStatus.getText());
}
public void onUnfavorite(User source, User target, Status unfavoritedStatus) {
System.out.println("onUnFavorite source:@"
+ source.getScreenName() + " target:@"
+ target.getScreenName() + " @"
+ unfavoritedStatus.getUser().getScreenName()
+ " - " + unfavoritedStatus.getText());
}
public void onFollow(User source, User followedUser) {
System.out.println("onFollow source:@"
+ source.getScreenName() + " target:@"
+ followedUser.getScreenName());
}
public void onRetweet(User source, User target, Status retweetedStatus) {
System.out.println("onRetweet @"
+ retweetedStatus.getUser().getScreenName() + " - "
+ retweetedStatus.getText());
}
public void onDirectMessage(DirectMessage directMessage) {
System.out.println("onDirectMessage text:"
+ directMessage.getText());
}
public void onUserListMemberAddition(User addedMember, User listOwner, UserList list) {
System.out.println("onUserListMemberAddition added member:@"
+ addedMember.getScreenName()
+ " listOwner:@" + listOwner.getScreenName()
+ " list:" + list.getName());
}
public void onUserListMemberDeletion(User deletedMember, User listOwner, UserList list) {
System.out.println("onUserListMemberDeleted deleted member:@"
+ deletedMember.getScreenName()
+ " listOwner:@" + listOwner.getScreenName()
+ " list:" + list.getName());
}
public void onUserListSubscription(User subscriber, User listOwner, UserList list) {
System.out.println("onUserListSubscribed subscriber:@"
+ subscriber.getScreenName()
+ " listOwner:@" + listOwner.getScreenName()
+ " list:" + list.getName());
}
public void onUserListUnsubscription(User subscriber, User listOwner, UserList list) {
System.out.println("onUserListUnsubscribed subscriber:@"
+ subscriber.getScreenName()
+ " listOwner:@" + listOwner.getScreenName()
+ " list:" + list.getName());
}
public void onUserListCreation(User listOwner, UserList list) {
System.out.println("onUserListCreated listOwner:@"
+ listOwner.getScreenName()
+ " list:" + list.getName());
}
public void onUserListUpdate(User listOwner, UserList list) {
System.out.println("onUserListUpdated listOwner:@"
+ listOwner.getScreenName()
+ " list:" + list.getName());
}
public void onUserListDeletion(User listOwner, UserList list) {
System.out.println("onUserListDestroyed listOwner:@"
+ listOwner.getScreenName()
+ " list:" + list.getName());
}
public void onUserProfileUpdate(User updatedUser) {
System.out.println("onUserProfileUpdated user:@" + updatedUser.getScreenName());
}
public void onBlock(User source, User blockedUser) {
System.out.println("onBlock source:@" + source.getScreenName()
+ " target:@" + blockedUser.getScreenName());
}
public void onUnblock(User source, User unblockedUser) {
System.out.println("onUnblock source:@" + source.getScreenName()
+ " target:@" + unblockedUser.getScreenName());
}
public void onException(Exception ex) {
ex.printStackTrace();
System.out.println("onException:" + ex.getMessage());
}
};
public void circleDraw(){
fill(100);
ellipse(400,300,40,40);
}
public void draw(){
}
}