We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › Basic Winter Olympics sketch
Page Index Toggle Pages: 1
Basic Winter Olympics sketch (Read 2318 times)
Basic Winter Olympics sketch
Feb 19th, 2010, 7:14pm
 
Hello, I plan on making some kind of visualisation based on the winter olympics & bundles statistics/history stats etc. I have a basic sketch that plots out the medals won by a selection of countries that you can see here: http://www.samhumphrey.co.uk/testArea/medalTable.html , but its basically just a graph. I don't really know what I can do to bring more to it, I was thinking about adding more bits to it like reshuffling the graphs and redrawing according to other factors like average snowfall/population etc. The key issue here is that I'm thinking so far inside the box I think I'm well outside it! Any suggestions for interesting routes to explore would be much appreciated (please take into consideration that I am a novice!) Thanks, L.
Re: Basic Winter Olympics sketch
Reply #1 - Feb 19th, 2010, 7:26pm
 
try not to use P3D unless you need it, if you use a lot of text. Textrendering is really bad using P3D
Re: Basic Winter Olympics sketch
Reply #2 - Feb 19th, 2010, 10:43pm
 
you could use my animation library to animate sorting and shuffling somewhat like i did in this example: http://ekeneijeoma.com/processing/tween/examples/Tween_Bar_Graph/applet/index.html
Re: Basic Winter Olympics sketch
Reply #3 - Feb 19th, 2010, 11:22pm
 
sorry, i have nothing to add other than this is awesome
Re: Basic Winter Olympics sketch
Reply #4 - Feb 20th, 2010, 3:47am
 
Well thanks for your kind words but its a long way off yet! - will get looking at that library, thanks e,. L.
Re: Basic Winter Olympics sketch
Reply #5 - Feb 20th, 2010, 10:51am
 
Ok, I've put everything back into 2D, text is much better now.

I've had a look at your library, and managed to get it to draw a single column inside my sketch without breaking it, but no real success.
I've stripped out everything that isnt needed, so currently the sketch looks blank, as I cant figure out how to get the figures from my text file into the tween objects. Please help me to see what I'm doing wrong! - I've looked at the library reference but I dont particularly understand the  terms used in there either. Thanks!

The re-shuffled working sketch is here:http://samhumphrey.co.uk/testArea/medalTable2DInDraw.html
The and the stripped down code (broken) is here:http://samhumphrey.co.uk/public_html/testArea/brokencode.rtf
Re: Basic Winter Olympics sketch
Reply #6 - Feb 20th, 2010, 11:53am
 
looks nice but it's not moving and it's still maxing out my processor. noLoop()?
Re: Basic Winter Olympics sketch
Reply #7 - Feb 20th, 2010, 12:30pm
 
Yes i'm still trying to get the tweens working. any suggestions for more interesting formats for it to be plotted in? - e.g. i really like some of the things here:http://blog.blprnt.com/ because most of this chap's work normally takes on some kind of interesting form.
Re: Basic Winter Olympics sketch
Reply #8 - Feb 20th, 2010, 7:36pm
 
in "setup" and you should put x, y, width, and height values into an array (some of which youve done) and loop through them in "draw". if you do that then you can use the tween library to by doing

for (int i = 0; i < countryCount; i++)
   tweenGroup.addTween(new Tween(this, "Country_(Gold/Silver/Bronze)_" + i, 0f, metalCount/Height, duration(frames/seconds));
Re: Basic Winter Olympics sketch
Reply #9 - Feb 21st, 2010, 7:52am
 
^^Am I missing the first part of that post..?

Edit: hold that, I think i've got it, will put it up in a jiffy if i get it sorted out.
Re: Basic Winter Olympics sketch
Reply #10 - Feb 21st, 2010, 9:34am
 
Yep thats working much better thanks a lot Ekenei Smiley

http://samhumphrey.co.uk/testArea/medalTable2DInDrawTween.html
Re: Basic Winter Olympics sketch
Reply #11 - Feb 21st, 2010, 12:00pm
 
btw..
If you have to use P3D for performance, textMode(SCREEN) has been a savior for me!

Just thought I'd mention it!
Re: Basic Winter Olympics sketch
Reply #12 - Feb 22nd, 2010, 8:04am
 
Wicked that's going to come in very useful indeed, it seemed a bit crazy that the text rendered so badly but I didn't realise textMode existed! Cheers for that!
Re: Basic Winter Olympics sketch
Reply #13 - Feb 25th, 2010, 9:37am
 
Just in case anyone else fancies a play around with this year's Vancouver Olympics medals/competitors etc, I've made a bit of code that gets all the medallists' names, their nationalities, medals(g/s/b), and the event they won them in. I'm not sure it's done in the slickest way, but it might save someone else a bit of time!

Code:
//SOURCE: http://espn.go.com/olympics/winter/2010/results/_/date/20100220
String[] sourceAddressesByDateArray = new String[17];//17 days of olympics.
int anyMoreGroups = 1;

void setup(){
 size(200, 200);
 
 for(int i=0; i<sourceAddressesByDateArray.length; i++){//loop through the days results...
   sourceAddressesByDateArray[i] = "http://espn.go.com/olympics/winter/2010/results/_/date/201002"+(12+i);//gets the url of each day's results table.

 println("loading day"+(i+1)+"strings");
 String[] tempDaySourceLines = loadStrings(sourceAddressesByDateArray[i]);
 
if(tempDaySourceLines != null){// if I've got the source strings & it's ok continue..
 String tempDaySource = join(tempDaySourceLines, " ");//joins all source for day.
 String[] currentDayGroupsSourceArray = split(tempDaySource, "stathead");//splits the source into an array for each group( alpine/nordic etc).
 println(sourceAddressesByDateArray[i]);
 println("On this day there were "+(currentDayGroupsSourceArray.length-1)+" groups");
 //println(currentDayGroupsSourceArray);//prints array of all the day's groups source.
 
   for(int b=1; b<currentDayGroupsSourceArray.length; b++){//loop through groups and split into events.    
   String[] thisDaysEventsArray = split(currentDayGroupsSourceArray[b], "colhead");//splits the group into events.
   println((thisDaysEventsArray.length-1)+" events in group "+b);// Array [0] is group title.
   println(thisDaysEventsArray);//prints array of the day's events source.
   
   
   //THIS IS WITHIN EACH EVENT, OF ALL DAYS.
   //now within each event, get any medals awarded & get winner.
   for(int n=1; n<thisDaysEventsArray.length; n++){//for every event this day..
   int startGetEvent = thisDaysEventsArray[n].indexOf("\"4\">")+4;
   int endGetEvent = thisDaysEventsArray[n].indexOf("<", startGetEvent);
   String event = thisDaysEventsArray[n].substring(startGetEvent, endGetEvent);
   println("EVENT - "+event);
   
     if(thisDaysEventsArray[n].indexOf("medalimage-G")>=0){//if there is a GOLD medal in the current event..
       int startGetGoldCountry = thisDaysEventsArray[n].indexOf("&nbsp")+6;
       int endGetGoldCountry = thisDaysEventsArray[n].indexOf("&nbsp")+9;
       String goldCountry = thisDaysEventsArray[n].substring(startGetGoldCountry, endGetGoldCountry);
       println(goldCountry+" goldCountry");
       
       int preGetAthleteName = thisDaysEventsArray[n].indexOf("href")+4;
       int startGetAthleteName = thisDaysEventsArray[n].indexOf(">", preGetAthleteName)+1;
       int endGetAthleteName = thisDaysEventsArray[n].indexOf("<", startGetAthleteName);
       String athleteName = thisDaysEventsArray[n].substring(startGetAthleteName, endGetAthleteName);
       println(athleteName);
     }
   
     if(thisDaysEventsArray[n].indexOf("medalimage-S")>=0){//if there is a SILVER medal in the current event..
       int startGetSilverCountry = thisDaysEventsArray[n].indexOf("medalimage-S")+12;
       int endGetSilverCountry = thisDaysEventsArray[n].indexOf("&nbsp", startGetSilverCountry)+9;
       String silverCountry = thisDaysEventsArray[n].substring(endGetSilverCountry-3, endGetSilverCountry);
       println(silverCountry+" silverCountry");
       
       int lookFromIndex = thisDaysEventsArray[n].indexOf("medalimage-S");
       int preGetAthleteName = thisDaysEventsArray[n].indexOf("href", lookFromIndex)+4;
       int startGetAthleteName = thisDaysEventsArray[n].indexOf(">", preGetAthleteName)+1;
       int endGetAthleteName = thisDaysEventsArray[n].indexOf("<", startGetAthleteName);
       String athleteName = thisDaysEventsArray[n].substring(startGetAthleteName, endGetAthleteName);
       println(athleteName);
     }
         
     if(thisDaysEventsArray[n].indexOf("medalimage-B")>=0){//if there is a BRONZE medal in the current event..
       int startGetBronzeCountry = thisDaysEventsArray[n].indexOf("medalimage-B")+12;
       int endGetBronzeCountry = thisDaysEventsArray[n].indexOf("&nbsp", startGetBronzeCountry)+9;
       String bronzeCountry = thisDaysEventsArray[n].substring(endGetBronzeCountry-3, endGetBronzeCountry);
       println(bronzeCountry+" bronzeCountry");
       
       int lookFromIndex = thisDaysEventsArray[n].indexOf("medalimage-B");
       int preGetAthleteName = thisDaysEventsArray[n].indexOf("href", lookFromIndex)+4;
       int startGetAthleteName = thisDaysEventsArray[n].indexOf(">", preGetAthleteName)+1;
       int endGetAthleteName = thisDaysEventsArray[n].indexOf("<", startGetAthleteName);
       String athleteName = thisDaysEventsArray[n].substring(startGetAthleteName, endGetAthleteName);
       println(athleteName);
     }
     
     if(thisDaysEventsArray[n].indexOf("medalimage")<0){//if there are no medals to get for the event..
       println("No medals awarded for this event");
     }
     

     
   }//end of every event loop.
   }//end of group loop.
  }//end of if source != null.
    println(" ");//space out the printed blocks a bit.
 }//end of main loop.

}//end of setup.
Page Index Toggle Pages: 1