//Project 1 //Erica D. Cochran //ericac@andrew.cmu.edu //Section B //Copyright © Erica D. Cochran //November 15, 2009 //Carnegie Mellon University //Exploring Programming with Graphics //Pittsburgh, PA, USA //All Rights Reserved // Fill in this comment template with the required information /* Description of the data, event, or process you are animating: Data provides architecture graduation rates for Architecture students. Includes Bachelor, Master, and Doctoral. Each is identified by total, men, and women. Source of the information: Excel File of graduate records, The National Center for Educational Statistics, retrieved from http://nces.ed.gov/ Building Images 1950 - 2005, Great Buildings Collection, retrieved from http://www.greatbuildings.com/gbc.html Building Images 2006, Architectural Record Houses, retrieved http://archrecord.construction.com/projects/residential/archives/0604recordHouses.asp Building Images 2006, NY Times, retrieved http://www.nytimes.com/slideshow/2009/04/15/arts/design/20090415-smithsonian-slideshow_index.html Explain how the picture you are using with the animation relates to your data, event or process: Exploration of graduation population and distribution of sexes with architecture styles and buildings. Will there be any user input or control over the animation? Yes, the user shall select time periods. If yes, what control will the user have? The user shall use keys to move through timeline. As the user moves through time periods, each time period will identify text and photos Three photographs will appear for each time period along with text to identify significant descriptions of that time period. */ /** U.S. Graduates in Architecture
*/
//// Declare and initialize your array or arrays here:
String [] lines;
float [] GradVals;
float [] GradMales;
float [] GradFemales;
String [] yrs;
// Declare a PImage variable here
PFont f1;
PImage crown;
PImage dulles;
PImage guggen;
PImage gund;
PImage IMPei;
PImage WTC;
PImage BklynChildren;
PImage BrionVegaScarpa;
PImage NationalGallery;
PImage Javits;
PImage Menil;
PImage valerieLodge;
PImage alvaroSiza;
PImage bilbao;
PImage PetronasTowers;
PImage roseCenter;
PImage seattleLibrary;
PImage UCSF;
PImage MuseumAAH;
PImage newengland;
PImage siltcabin;
float marginH, marginV, section, imageGridH;
float xValue, yAxis;
// Code a setup() function here that sets the size, loads your picture,
// and displays it using the image() function.
void setup ()
{
size (800, 400);
background (232, 225, 225);
f1 = loadFont ("f1.vlw");
//1950's buildings
crown = loadImage ("crown.jpg");
dulles = loadImage ("dulles.jpg");
guggen = loadImage ("guggen.jpg");
//1960's buildings
gund = loadImage ("gund.jpg");
IMPei = loadImage ("IMPei.jpg");
WTC = loadImage ("WTC.jpg");
//1970's buildings
BklynChildren = loadImage ("BklynChildren.jpg");
BrionVegaScarpa = loadImage ("BrionVegaScarpa.jpg");
NationalGallery = loadImage ("NationalGallery.jpg");
//1980's buildings
Javits = loadImage ("Javits.jpg");
Menil = loadImage ("Menil.jpg");
valerieLodge = loadImage ("valerieLodge.jpg");
//1990's buildings
alvaroSiza = loadImage ("alvaroSiza.jpg");
bilbao = loadImage ("bilbao.jpg");
PetronasTowers = loadImage ("PetronasTowers.jpg");
//2000's buildings
roseCenter = loadImage ("roseCenter.jpg");
seattleLibrary = loadImage ("seattleLibrary.jpg");
UCSF = loadImage ("UCSF.jpg");
//2006 buildings
MuseumAAH = loadImage ("MuseumAAH.jpg");
newengland = loadImage ("newengland.jpg");
siltcabin = loadImage ("siltcabin.jpg");
//margins
marginH = .03125 * width;
marginV = .0625 * height;
//Sections: screen divided into 4 equal widths
section = .25 * width;
//image grids
imageGridH = .625 * height;
//reading stuff
lines = loadStrings("text2.txt");
GradVals = new float[lines.length];
yrs = new String[lines.length];
GradMales = new float[lines.length];
GradFemales = new float[lines.length];
//Axis values
xValue = (.75* width) / (GradVals.length);
yAxis = height *.75;
//the graphs and text
data();
drawGraph ();
hAxisText ();
vAxisText ();
}
// moved images to setup to allow user input and remove static view
void draw ()
{
// fill (232, 225, 225);
// rect (0, 0, width, height);
// draw1950 ();
// draw1960 ();
// draw1970 ();
// draw1980 ();
// draw1990 ();
// draw2000 ();
// draw2006 ();
//noLoop ();
}
void data()
{
//println("there are " + lines.length + " lines");
//global variables to store data for year and graduate total
//////////////////////////////////////////////////////////////////////////
String [ ] oneLine;
// for (int i=0; i < lines.length; i++)
// {
// println(lines[i]);
// }
for( int i = 0; i < lines.length; i++)
{
oneLine = split ( lines[i], "\t");
//println( oneLine.length);
//println( oneLine.length + " " + oneLine[4]);
yrs[i] = oneLine[0];
float value = float( oneLine[2] );
GradVals[i] = value;
// println( "String is " + oneLine[4] + " and the float value is " + value);
float valueM = float ( oneLine[4] );
GradMales[i] = valueM;
float valueF = float ( oneLine[5] );
GradFemales[i] = valueF;
}
// for(int i = 0; i < lines.length; i++)
// {
// println(GradVals[i] + " number of students who graduated in " + yrs[i]);
// }
}
void drawGraph ()
{
for (int i=0; i< GradVals.length-1; i++)
{
stroke (100, 100, 100, 30);
strokeWeight (1);
fill (247, 221, 20);
point ((xValue*i) + section, yAxis - ((GradVals [i]) * .03 ));
drawTrap ((xValue*i) + section, yAxis - ((GradVals [i]) * .03 ),
(xValue* (i+1) ) + section, yAxis - ((GradVals [i+1]) * .03 ),
yAxis);
fill (255, 104, 10);
drawTrap ((xValue*i) + section, yAxis - ((GradMales [i]) * .03 ),
(xValue* (i+1) ) + section, yAxis - ((GradMales [i+1]) * .03 ),
yAxis);
fill (158, 44, 229);
drawTrap ((xValue*i) + section, yAxis - ((GradFemales [i]) * .03 ),
(xValue* (i+1) ) + section, yAxis - ((GradFemales [i+1]) * .03 ),
yAxis);
}
strokeWeight (1);
line (section, yAxis, width, yAxis);
line (section, 0, section, yAxis);
drawLegend ();
}
//draws the legend and instructions
void drawLegend ()
{
fill (40);
rect (0, 0, section*.6, height);
textFont (f1, 20);
fill (247, 221, 20);
text ("Yellow \nTotal # Graduates", marginH/2, marginV);
fill (255, 104, 10);
text ("Orange \nTotal # Males", marginH/2, marginV+40);
fill (158, 44, 229);
text ("Purple \nTotal # Females", marginH/2, marginV+80);
fill (255);
text ("Press year # \nto see popular \nbuildings \nconstructed \nin recent decades",
marginH/2, marginV+140);
text ("5 = 1950's \n6 = 1960's \n7 = 1970's \n8 = 1980's \n9 = 1990's \n0 = 2000's \np = Present",
marginH/2, marginV+240);
fill (17, 21, 120);
text ("Press [space bar] to clear screen", width*.51, yAxis+80);
}
//horizontal text
void hAxisText ()
{
textFont (f1,20);
pushMatrix ();
translate (section/4, yAxis+20);
rotate (radians (270));
text ("NUMBER OF ARCHITECTURE GRADUATES", marginH*.8, marginV*4);
popMatrix ();
for (int i=0; i< yrs.length; i+=2)
{
text (yrs [i].substring(5), (xValue*i) + section, yAxis+20);
}
}
//vertical text
void vAxisText ()
{
textFont (f1,20);
text ("GRADUATION YEAR", width*.55, yAxis+50);
for (int i=0; i <= 10000; i+= 1000)
{
text (i, section -30, yAxis - (i * .03 ));
}
}
//helps make drawing the trapezoids easier
void drawTrap (float xb, float yb, float xe, float ye, float yc )
{
quad (xb, yb, xe, ye, xe, yc, xb, yc);
}
//identifies which keys bring up particular images for specified decade
void keyPressed ()
{
if (key == '5')
{
loop ();
draw1950 ();
}
else if (key == '6')
{
loop ();
draw1960 ();
}
else if (key == '7')
{
loop ();
draw1970 ();
}
else if (key == '8')
{
loop ();
draw1980 ();
}
else if (key == '9')
{
loop ();
draw1990 ();
}
else if (key == '0')
{
loop ();
draw2000 ();
}
else if (key == 'p')
{
loop ();
draw2006 ();
}
else if (key == ' ')
{
loop ();
fill (232, 225, 225);
rect (0, 0, width, height);
drawGraph ();
hAxisText ();
vAxisText ();
}
}
///////////////////// each decade contains three images
void draw1950 ()
{
image (crown, section + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (dulles, (2*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (guggen, (3*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
// lines are here to help visualize grid when no images are in view
//stroke (183, 165, 165);
//line (.25*width, 0, .25*width, height);
//line (.5*width, 0, .5*width, height);
//line (.75*width, 0, .75*width, height);
}
void draw1960 ()
{
image (gund, section + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (IMPei, (2*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (WTC, (3*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
}
void draw1970 ()
{
image (BklynChildren, section + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (BrionVegaScarpa, (2*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (NationalGallery, (3*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
}
void draw1980 ()
{
image (Javits, section + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (Menil, (2*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (valerieLodge, (3*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
}
void draw1990 ()
{
image (alvaroSiza, section + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (bilbao, (2*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (PetronasTowers, (3*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
}
void draw2000 ()
{
image (roseCenter, section + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (seattleLibrary, (2*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (UCSF, (3*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
}
void draw2006 ()
{
image (MuseumAAH, section + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (newengland, (2*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
image (siltcabin, (3*section) + marginH, marginV, section - (2*marginH), section - (2*marginV) );
}