void checkuser(String username){ CalcLock = true; Curstatus = "accessing last.fm...this may take a while..."; //String getthisuser = convertencoding(username); try { xmlcharts = new XMLElement(this, "http://ws.audioscrobbler.com/1.0/user/"+username+"/topartists.xml"); } catch (Exception e) { Curstatus = "User "+username+" not Found or Connection Lost"; } if (Curstatus.equals("User not Found or Connection Lost") == false){ Curstatus = "User Found"; activeuser = username; remove(textField); TFbutton.active = false; } tree.active = true; field.active = true; time.active = true; CalcLock = false; } void chartsloader(String username, String period){ CalcLock = true; personalcharts = new CL_charts[artistnum]; Curstatus = "Loading "+period+" Charts for "+username; try { xmlcharts = new XMLElement(this, "http://ws.audioscrobbler.com/1.0/user/"+username+"/topartists.xml?type="+period); } catch (Exception e) { Curstatus = "Connection Lost"; } statusfeld.draw(); int numattribute = xmlcharts.getChildCount(); for (int i = 0; i < numattribute; i++) { personalcharts[i] = new CL_charts(); XMLElement artistdata = xmlcharts.getChild(i); XMLElement kid = artistdata.getChild("name"); personalcharts[i].artist = kid.getContent(); kid = artistdata.getChild("playcount"); personalcharts[i].playcount = kid.getContent(); } artistnum = numattribute; //println(artistnum); if (doOnce == false){ //doOnce == true loader.stop(); } doOnce = false; //reset arrays fuer neustart dingenskirchen array1 = new String[0]; array1b = new String[0]; array2 = new String[0]; array2b = new String[0]; array3 = new String[0]; array3b = new String[0]; array4 = new String[0]; array4b = new String[0]; array5 = new String[0]; array5b = new String[0]; array6 = new String[0]; array6b = new String[0]; array1tag = ""; array2tag = ""; array3tag = ""; array4tag = ""; array5tag = ""; //ende reset array loader = new CL_artisttagloader(this); loader.start(); //} //else { //CalcLock = false; //} } void sortbytag(int numartists){ String [] taglist = new String [numartists]; int [] tagcount = new int [numartists]; String toptag1[] = { "0","0" }; String toptag2[] = { "0","0" }; String toptag3[] = { "0","0" }; String toptag4[] = { "0","0" }; String misctags[] = { }; boolean addmisc = true; //einmal bitte ueberall 1 setzen for (int i=0; i < numartists; i++){ taglist[i] = personalcharts[i].tag; tagcount[i] = 1; } //durchzaehlen was wie oft da ist for (int i=0; i < numartists; i++){ for (int n=i+1; n < numartists; n++){ if (taglist[i].equals(taglist[n]) == true){ tagcount[i] = tagcount[i]+1; tagcount[n] = tagcount[n]+1; } } } //suche die 4 tags mit der hoechsten anzahl for (int i=0; i < numartists; i++){ if ((taglist[i].equals(toptag1[1]) == false) && (taglist[i].equals(toptag2[1]) == false) && (taglist[i].equals(toptag3[1]) == false) && (taglist[i].equals(toptag4[1]) == false) ) { if (tagcount[i] > int(toptag1[0])){ arraycopy(toptag3, toptag4); arraycopy(toptag2, toptag3); arraycopy(toptag1, toptag2); toptag1[0] = str(tagcount[i]); toptag1[1] = taglist[i]; } else if ((tagcount[i] > int(toptag2[0])) && (tagcount[i] < int(toptag1[0]))){ arraycopy(toptag3, toptag4); arraycopy(toptag2, toptag3); toptag2[0] = str(tagcount[i]); toptag2[1] = taglist[i]; } else if ((tagcount[i] > int(toptag3[0])) && (tagcount[i] < int(toptag2[0]))){ arraycopy(toptag3, toptag4); toptag3[0] = str(tagcount[i]); toptag3[1] = taglist[i]; } else if ((tagcount[i] > int(toptag4[0])) && (tagcount[i] < int(toptag3[0]))){ toptag4[0] = str(tagcount[i]); toptag4[1] = taglist[i]; } } } //restliche tags in misctags schmeissen for (int i=0; i < numartists; i++){ addmisc = true; if ((taglist[i].equals(toptag1[1]) == false) && (taglist[i].equals(toptag2[1]) == false) && (taglist[i].equals(toptag3[1]) == false) && (taglist[i].equals(toptag4[1]) == false)) { for (int n=0; n < misctags.length; n++){ if (misctags[n].equals(taglist[i]) == true) addmisc = false; } if (addmisc == true){ misctags = append(misctags, taglist[i]); //println("misctags: "+taglist[i]); } } } //println(toptag1[0]+" "+toptag1[1]); //println(toptag2[0]+" "+toptag2[1]); //println(toptag3[0]+" "+toptag3[1]); //println(toptag4[0]+" "+toptag4[1]); array1tag = toptag1[1]; array2tag = toptag2[1]; array3tag = toptag3[1]; array4tag = toptag4[1]; array5tag = "miscellaneous"; String do1 = toptag1[1]; String do2 = toptag2[1]; String do3 = toptag3[1]; String do4 = toptag4[1]; boolean pendulum1 = false; boolean pendulum2 = false; boolean pendulum3 = false; boolean pendulum4 = false; boolean pendulum5 = false; boolean pendulum6 = false; //durchgehn und alle artistnamen eines genres in die 2 dafur vorgesehenen arrays rotzen for (int i=0; i< numartists; i++){ if (personalcharts[i].tag.equals(do1)){ if (pendulum1 == false){ array1 = append(array1, personalcharts[i].artist); pendulum1 = true; } else { array1b = append(array1b, personalcharts[i].artist); pendulum1 = false; } } else if (personalcharts[i].tag.equals(do2)){ if (pendulum2 == false){ array2 = append(array2, personalcharts[i].artist); pendulum2 = true; } else { array2b = append(array2b, personalcharts[i].artist); pendulum2 = false; } } else if (personalcharts[i].tag.equals(do3)){ if (pendulum3 == false){ array3 = append(array3, personalcharts[i].artist); pendulum3 = true; } else { array3b = append(array3b, personalcharts[i].artist); pendulum3 = false; } } else if (personalcharts[i].tag.equals(do4)){ if (pendulum4 == false){ array4 = append(array4, personalcharts[i].artist); pendulum4 = true; } else { array4b = append(array4b, personalcharts[i].artist); pendulum4 = false; } } else if ( (personalcharts[i].tag.equals(do1) == false) && (personalcharts[i].tag.equals(do2) == false) && (personalcharts[i].tag.equals(do3) == false) && (personalcharts[i].tag.equals(do4) == false) ) { if ((pendulum5 == false) && (pendulum6 == false)){ array5 = append(array5, personalcharts[i].artist); pendulum6 = true; } else if ((pendulum5 == false) && (pendulum6 == true)){ array6 = append(array6, personalcharts[i].artist); pendulum5 = true; //pendulum6 = false; } else if ((pendulum5 == true) && (pendulum6 == true)){ array5b = append(array5b, personalcharts[i].artist); pendulum6 = false; } else if ((pendulum5 == true) && (pendulum6 == false)){ array6b = append(array6b, personalcharts[i].artist); pendulum5 = false; } } } CalcLock = false; ChartsLoaded = true; Curstatus = "Loading and Sorting Done"; // loader.stop(); } class CL_charts { String artist, playcount, tag; }