class FloatingTerm { // properties String term; int ti; int[]termArrCount; float tx; float ty; int datei; int termCount; String termFinal = ""; color Colour; boolean fixFill = false; Particle particle; int MaxTermHeight = 150; int MinTermHeight = 9; float termWidth; // constructors FloatingTerm(String term, int ti){ this.term = term; this.ti = ti; particle = words[ti]; } // methods void updatePosition(){ //println(p.position().x()); tx = particle.position().x(); ty = particle.position().y(); } void addData(int[]termArrCount){ this.termArrCount = termArrCount; } void updateTerm(int datei, float tx, float ty, color Colour){ this.tx = tx; this.ty = ty; this.datei = datei; this.Colour = Colour; //split the term and get rid of the + signs String termTxt[] = split(term, '+'); termFinal = termTxt[0]; for(int j = 1; j < termTxt.length; j++){ termFinal = termFinal + " " + termTxt[j]; } //get the count for the given date termCount = int(termArrCount[datei]); termH[ti] = termCount; if (termH[ti] > 24) { termH[ti] = termH[ti] / 3; } if (termH[ti] > MaxTermHeight) { termH[ti] = MaxTermHeight; } if(termH[ti] <= MinTermHeight){ termH[ti] = MinTermHeight; } //make the text green if(termClicked == ti){ fill(88, 156, 28); } else { fill(Colour); } //set the font size to a proportion of the count textFont(font, termH[ti]); textAlign(LEFT, BOTTOM); termWidth = textWidth(termFinal); //display the text text(termFinal, tx, ty); // display a number under the letters textAlign(LEFT, TOP); textFont(font, 10); text(termCount, tx, ty + 5); } }