void draw() { nTime = millis() - nTimeStart; pushMatrix(); pushStyle(); background(240,240,240); textFont(gFont); textAlign(LEFT, LEFT); fill(0); text("Microsoft vs. Apple", 40,33,500,33); textFont(gFont2); fill(128); textAlign(LEFT, CENTER); textFont(gFont3); fill(128); textAlign(LEFT, LEFT); text("(Please press key 1,2,3 to see three different queries)", 330, 50, 1000, 50); textAlign(RIGHT, RIGHT); text("Project 1: Processing Visualization Project, MAT 259 Winter 2012", 450, 40, 900, 40); text("by Yoon Chung Han", 450, 57, 900, 57); /*stroke(50); strokeWeight(0.5); line(1030,110,1030,720);*/ switch(displayMode) { case 1: draw_DisplayMode1(); break; case 2: draw_DisplayMode2(); break; case 3: draw_DisplayMode3(); break; default: break; } popStyle(); popMatrix(); } // DisplayMode 1: Dewey class void draw_DisplayMode1() { // animation float fAlpha1 = (float)nTime/1000.0f*fAnimateMode1Ratio1Speed; float fAlpha2 = ((float)nTime/1000.0f-1.0f/fAnimateMode1Ratio1Speed)*fAnimateMode1Ratio2Speed; if( fAlpha1 < .0f ) fAlpha1 = .0f; if( fAlpha1 > 1.0f ) fAlpha1 = 1.0f; if( fAlpha2 < .0f ) fAlpha2 = .0f; if( fAlpha2 > 1.0f ) fAlpha2 = 1.0f; int nAlpha1 = (int) (fAlpha1 * 255.0f); int nAlpha2 = (int) (fAlpha2 * 255.0f); // draw 1 fill(128, 128, 128, nAlpha1); textAlign(LEFT, CENTER); textFont(gFont2); text("1. Dewey Class", 40, 70, 200, 70 ); textFont(gFont4); textAlign(LEFT, CENTER); fill(91,154,182, nAlpha1); text("Microsoft",600, 70, 750, 70); // 1 fill(196,71,71, nAlpha1); text("Apple",720, 70, 800, 70); // 1 textFont(gFont3); textAlign(RIGHT, CENTER); text("000-099 - Computer science", 450, 116, 900, 116); text("100-199 – Philosophy+psychology", 450, 156, 900, 156); text("200-299 – Religion", 450, 196, 900, 196); text("300-399 – Social sciences", 450, 236, 900, 236); text("400-499 – Language", 450, 276, 900, 276); text("500-599 – Science", 450, 316, 900, 316); text("600-699 – Technology", 450, 356, 900, 356); text("700-799 – Arts", 450, 396, 900, 396); text("800-899 – Literature", 450, 436, 900, 436); text("900-999 – History", 450, 476, 900, 476); for( int i=0; i<10; i++ ) { textAlign(LEFT, CENTER); textFont(gFont3); fill(128, 128, 128, nAlpha1); //text(str(i), 590, 80 + i*20, 590, 80 + i*20 + 20 ); //text(str(pResult_Div10a_Apple[i]), 200, 70 + i*20, 250, 70 + i*20 + 20 ); //text(str(pResult_Div10a_Microsoft[i]), 300, 70 + i*20, 350, 70 + i*20 + 20 ); } // draw 2 for(int i = 0;i<10;i++){ stroke(91,154,182); strokeCap(SQUARE); strokeWeight(60); line (700, 110+(i+1)*(300/5), 700-(pResult_Div10a_Microsoft[i]/15)*fAlpha2, 110+(i+1)*(300/5)); stroke(196,71,71); strokeCap(SQUARE); strokeWeight(60); line (700,110+(i+1)*(300/5), 700+(pResult_Div10a_Apple[i]/15)*fAlpha2, 110+(i+1)*(300/5)); } } // DisplayMode 2: Total number of checked out books by years void draw_DisplayMode2() { // animation float fAlpha1 = (float)nTime/1000.0f*fAnimateMode2Ratio1Speed; float fAlpha2 = ((float)nTime/1000.0f-1.0f/fAnimateMode2Ratio1Speed)*fAnimateMode2Ratio2Speed; if( fAlpha1 < .0f ) fAlpha1 = .0f; if( fAlpha1 > 1.0f ) fAlpha1 = 1.0f; if( fAlpha2 < .0f ) fAlpha2 = .0f; if( fAlpha2 > 1.0f ) fAlpha2 = 1.0f; int nAlpha1 = (int) (fAlpha1 * 255.0f); int nAlpha2 = (int) (fAlpha2 * 255.0f); // draw 1 fill(128, 128, 128, nAlpha1); textAlign(LEFT, CENTER); textFont(gFont2); text("2. Number of checked out books every year", 40, 70, 800, 70); textFont(gFont3); textAlign(CENTER, CENTER); text("(Please roll over the mouse at the center of circles)", 300, 220, 750, 220); textFont(gFont4); textAlign(LEFT, CENTER); fill(91,154,182, nAlpha1); text("Microsoft",600, 200, 750, 200); // 2 fill(196,71,71, nAlpha1); text("Apple",720, 200, 950, 200); // 2 // draw 2 stroke(100, 100, 100); strokeWeight(0.5); fill(255, 255, 255); //ellipse(300,600,300,300); // number of checked out books of microsoft for(int i = 0;i<10;i++){ float mapped = map (pResult_Div10b_Microsoft[i], 1, 8399, 10, 10 + 270*fAlpha2); float mapped2 = map (mapped, 10, 150, 1, 1 + 19*fAlpha2); stroke(91,154,182); strokeWeight(mapped2); fill(69,39,47); ellipse(150+(i+1)*(width/30), height*2/4, mapped, mapped); // if mouse is roll-over, each number of month is appeared if(dist(mouseX, mouseY, 150+(i+1)*(width/30), height*2/4) < 6){ // strokeWeight(7); fill(255, 255, 255); ellipse(150+(i+1)*(width/30), height*2/4,6,6); // textFont(font0); fill(60, 60, 60); textAlign(CENTER); textFont(gFont2); text("["+str(pResult_Div10b_Microsoft[i])+"]", 150+(i+1)*(width/30), 153+height*3/4); //text(str(pResult_Div10a_Microsoft[i]), 582-(pResult_Div10a_Microsoft[i]/15), 100+(i+1)*(300/10)); textFont(gFont3); if (i+1 > 9){ text("20"+(i+1), 150+(i+1)*(width/30), 133+height*3/4); } else { text("200"+(i+1), 150+(i+1)*(width/30), 133+height*3/4); } } } // number of checked out books of apple for(int i = 0;i<10;i++){ float mapped3 = map (pResult_Div10b_Apple[i], 1, 8399, 10, 10 + 270*fAlpha2); float mapped4 = map (mapped3, 10, 150, 1, 1 + 19*fAlpha2); stroke(196,71,71); strokeWeight(mapped4); fill(69,39,47); ellipse(750+(i+1)*(width/30), height*2/4, mapped3, mapped3); if(dist(mouseX, mouseY, 750+(i+1)*(width/30), height*2/4) < 6){ //strokeWeight(7); fill(255, 255, 255); ellipse(750+(i+1)*(width/30), height*2/4,6,6); fill(60, 255, 255); textAlign(CENTER); textFont(gFont2); fill(128); text("["+str(pResult_Div10b_Apple[i])+"]", 750+(i+1)*(width/30), 150+height*3/4); textFont(gFont3); if (i+1 > 9){ text("20"+(i+1), 750+(i+1)*(width/30), 130+height*3/4); } else { text("200"+(i+1), 750+(i+1)*(width/30), 130+height*3/4); } } } } // DisplayMode 3: Best top 10 books of microsoft/apple books void draw_DisplayMode3() { // Best top 100 books of microsoft/apple books fill(128); textAlign(LEFT, CENTER); textFont(gFont2); text("3. Best Top 10 checked out items", 40, 70, 400, 70); for (int i = 0; i<10; i++){ fill(91,154,182); textFont(gFont4); textSize(50-(i*3.5)); text(Microsoft[i], 80, 200+(i*40)); // list of best 10 of microsoft books fill(196,71,71); text(Apple[i], 700, 200+(i*40)); // list of best 10 of apple books smooth(); } }