//import processing.candy.*; //import processing.xml.*; import proxml.*; /*static public void main(String args[]) { PApplet.main(new String[] { "--present", "body_checking" }); }*/ // save data to xml XMLElement users; //XMLElement svg; XMLInOut xmlInOut; int sw = 1000; int sh = 700; //SVG man, wman, stm, stw; PImage man, wman, stm, stw; float mx, my; float multi; float eW,eH; int userCount; boolean focuson; //timecheck float timeCheck; boolean startHide; //info of backpannel behind body float pannelW ; float pannelH ; // declare object GUI inputU; //user input array set String[] vValueX, aValueX, sValueX, vValueY, aValueY, sValueY; int[] userGender; int[] userAge; PFont helv10,helv11,helv12,ari9; String url = "http://www.experiencecode.com/prox/userbodyidea.xml"; void setup(){ size(1000, 700); smooth(); noStroke(); frameRate(30); //demo xml check---------------------------------- xmlInOut = new XMLInOut(this); try{ xmlInOut.loadElement(url); XMLElement users = xmlInOut.loadElementFrom(url); } catch(Exception e){ //if the xml file could not be loaded it has to be created xmlEvent(new XMLElement(url)); } // xml end---------------------------------------- /* //xml check---------------------------------- xmlInOut = new XMLInOut(this); try{ xmlInOut.loadElement("userbodyidea.xml"); } catch(Exception e){ //if the xml file could not be loaded it has to be created xmlEvent(new XMLElement("users")); } // xml end---------------------------------------- */ //fontload helv10 = loadFont("Helvetica-Normal-10.vlw"); helv11 = loadFont("Helvetica-Normal-11.vlw"); helv12 = loadFont("Helvetica-Normal-12.vlw"); ari9 = loadFont("ArialMT-9.vlw"); // user input array // userCount = 0; vValueX = new String[0]; aValueX = new String[0]; sValueX = new String[0]; vValueY = new String[0]; aValueY = new String[0]; sValueY = new String[0]; userGender = new int[0]; userAge = new int[0]; //import svg man = loadImage("man_f.png"); wman = loadImage("wman_f.png"); stm = loadImage("st_f.png"); stw = loadImage("stw_f.png"); /*man = new SVG(this, "man_f.svg"); wman = new SVG(this, "wman_f.svg"); stm = new SVG(this, "st_f.svg"); stw = new SVG(this, "stw_f.svg");*/ inputU = new GUI(sw/3, 90); userCount = users.countChildren(); //get xmlelement ----------------------------------------- users.printElementTree(" "); XMLElement user_info; XMLElement user_demographic; XMLElement user_value; // data update from saved xml start----------------------------------------------------- if(users.countChildren()>0){ for(int i = 0; i < users.countChildren();i++){ user_info = users.getChild(i); user_demographic = user_info.getChild(0); user_value = user_info.getChild(1); //demographic userGender = splice(userGender, user_demographic.getIntAttribute("gender"), i); userAge = splice(userAge, user_demographic.getIntAttribute("age"), i); //user value vValueX = splice(vValueX, user_value.getAttribute("visualX"), i); vValueY = splice(vValueY, user_value.getAttribute("visualY"), i); aValueX = splice(aValueX, user_value.getAttribute("audioX"), i); aValueY = splice(aValueY, user_value.getAttribute("audioY"), i); sValueX = splice(sValueX, user_value.getAttribute("spaceX"), i); sValueY = splice(sValueY, user_value.getAttribute("spaceY"), i); } } // data update from saved xml end----------------------------------------------------- } void xmlEvent(XMLElement element){ users = element; users.printElementTree(" "); XMLElement name; XMLElement gender; XMLElement age; } void draw(){ background(15); //roundBox(10,570,sw-20, sh-580,20); bg_display(); fill(26,26,26); rect(sw/3, 0, sw/3, sh); bodypannel(10); dot_display(); noStroke(); //age grid grid_display(); grid_display2(); // body pannel //button area inputU.display(); // for(int i=0; i= sw/3 && mouseX+7.5 <= sw/3+sw/3 && mouseY+7.5 >= 160 && mouseY+7.5 <= 600 ){ focuson = true; mx = mouseX; my = mouseY; println("mx "+ mx + ": my "+my ); } else{ focuson = false; } for(int i=0; i<3; i++){ if(inputU.spot[i].selected && mouseY>200 ){ inputU.spot[i].duplicate(inputU.spot[i].id); inputU.spot[i].id +=1; } } if(inputU.saveB.isOver && inputU.showInput){ for(int i=0; i<3; i++){ inputU.spot[i].savePoint(); inputU.gender.selectId = 0; inputU.age.selectId = 0; inputU.spot[i].reset(); } addDot(); saveDotXml(); userCount +=1; println(userCount); } if(( inputU.cancelB.isOver || inputU.refreshB.isOver ) && inputU.showInput){ for(int i=0; i<3; i++){ inputU.gender.selectId = 0; inputU.age.selectId = 0; inputU.spot[i].reset(); } } } void addDot(){ vValueX = splice(vValueX, inputU.spot[0].dotX, userCount); vValueY = splice(vValueY, inputU.spot[0].dotY, userCount); aValueX = splice(aValueX, inputU.spot[1].dotX, userCount); aValueY = splice(aValueY, inputU.spot[1].dotY, userCount); sValueX = splice(sValueX, inputU.spot[2].dotX, userCount); sValueY = splice(sValueY, inputU.spot[2].dotY, userCount); println("uc"+userCount); userGender = splice(userGender, inputU.ug, userCount); userAge = splice(userAge, inputU.ua, userCount); } void saveDotXml(){ //save xml part XMLElement user_info = new XMLElement("user_info"); users.addChild(user_info); // user demographic XMLElement user_demographic = new XMLElement("user_demographic"); user_demographic.addAttribute("user_no", userCount); user_demographic.addAttribute("gender",userGender[userCount]); user_demographic.addAttribute("age",userAge[userCount]); user_info.addChild(user_demographic); // user vale XMLElement user_value = new XMLElement("user_value"); user_value.addAttribute("visualX",vValueX[userCount]); user_value.addAttribute("visualY",vValueY[userCount]); user_value.addAttribute("audioX",aValueX[userCount]); user_value.addAttribute("audioY",aValueY[userCount]); user_value.addAttribute("spaceX",sValueX[userCount]); user_value.addAttribute("spaceY",sValueY[userCount]); user_info.addChild(user_value); //save data into xml file // xmlInOut.saveElement(users,"userbodyidea.xml"); //demo_ save data into xml file xmlInOut.loadElement(url); } void visualDot(int kk){ if(userGender[kk] == 1){ multi = 325; } else{ multi = -335; } String listX[] = split(vValueX[kk], ','); String listY[] = split(vValueY[kk], ','); int k = listX.length; for(int i=0; i 40){ startHide = true; timeCheck = 31; mouseX = sw; mouseY = sh; noCursor(); } } else if(mouseX-pmouseX !=0){ timeCheck =0; startHide = false; cursor(ARROW); } }//end of hide mouse // grid_display() void grid_display(){ for(int i=0; i< 8 ; i++){ fill(255,20); float grid = 40+(10+(10*i)); rect(50, grid+10, sw/3-50, 1); String[] ageGroup = {"00-to-10 ","11-to-20","21-to-30","31-to-40","41-to-50","51-to-60","61-to-70","over 70s"}; fill(70); textFont(ari9); text(ageGroup[i], 10 , grid+14); } fill(60,125,23); rect(130, sh-90, 10,10); fill(120); textFont(ari9); text("Visual Sensations", 150 , sh-81); text("Audio Sensations", 150 , sh-66); text("Spatial Sensations", 150 , sh-51); fill(49,108,222); rect(130, sh-75, 10,10); fill(206,88,33); rect(130, sh-60, 10,10); }//--- end of grid_display() // grid_display() void grid_display2(){ for(int i=0; i< 8 ; i++){ fill(255,20); float grid = 40+(10+(10*i)); rect(sw-sw/3, grid+10, sw/3-50, 1); String[] ageGroup = {"00-to-10 ","11-to-20","21-to-30","31-to-40","41-to-50","51-to-60","61-to-70","over 70s"}; fill(70); textFont(ari9); text(ageGroup[i], sw-45 , grid+14); } fill(60,125,23); rect((sw-sw/3)+120, sh-90, 10,10); fill(120); textFont(ari9); text("Visual Sensations", (sw-sw/3)+140 , sh-81); text("Audio Sensations", (sw-sw/3)+140 , sh-66); text("Spatial Sensations", (sw-sw/3)+140 , sh-51); fill(49,108,222); rect((sw-sw/3)+120, sh-75, 10,10); fill(206,88,33); rect((sw-sw/3)+120, sh-60, 10,10); }//--- end of grid_display() //----------------------------------------------- //grid_display void dot_display(){ float[][] distances; float maxDistance; maxDistance = dist(sh/2,sw/2, sh, sw); int gLine_Num = 32; int gRow_Num = 24; int pointArr = gLine_Num*gRow_Num; float gap = 0; float sellwidth = (sw-((gLine_Num-1)*gap))/gLine_Num; float sellheight = (sh-((gRow_Num-1)*gap))/gRow_Num; distances = new float[gRow_Num+1][gLine_Num+1 ]; eW = sellwidth; eH = sellheight; for(int i=0; i< gLine_Num+1 ; i++){ for(int j=0; j< gRow_Num+1 ; j++){ float dista = dist(sh/2, sw/2, (sellheight+gap)*j, (sellwidth+gap)*i); distances[j][i] = 255-(dista/maxDistance*255); noStroke(); fill( distances[j][i],30); rect((sellwidth+gap)*i-2, (sellheight+gap)*j, 5, 1); rect((sellwidth+gap)*i, (sellheight+gap)*j-2, 1, 5); } } }//end of grid_display ////-------------------------------------------------------- //bg_display() void bg_display(){ beginShape(QUAD_STRIP); fill(51,51,51); vertex(0,0); vertex(sw,0); fill(51,51,51); vertex(0,sh); vertex(sw,sh); endShape(); }//end of bg_display