///////////////////////////TIRETTE public class Tirette { int x,y,xpos,xbut,longueur,couleur1,couleur2; float valmin,valmax,coef,valeur; String titre; boolean survol,drag; PFont lafonte; //********************************************************** public Tirette(int x,int y,int longueur,float valmin ,float valmax,String titre,PFont lafont){ this.x=x; this.y=y; this.xpos=x; this.xbut=x; this.survol=false; this.drag=false; this.longueur=longueur; this.valmin=valmin; this.valmax=valmax; this.coef=(valmax-valmin)/(2*longueur); this.titre=titre; this.valeur=(valmin+valmax)/2; this.couleur1=255; this.couleur2=125; this.lafonte=lafont; } //****************************************************** public void actualiser(){ if(!mousePressed && drag) drag=false; survol= (mouseX>x-longueur)&&(mouseXy-10)&&(mouseY1)xpos+=(xbut-xpos)/3; this.calculer(); this.dessinerbarre(); } //**************************************************** public void calculer(){ valeur=valmin+(xpos-x+longueur)*coef; } public float getValeur(){ return valeur; } public void setValeur(float v){ xpos=Math.round((v-valmin)/(float)coef )+x -longueur;println(xpos); xbut=xpos; } //**************************************************** public void dessinerbarre(){ stroke(couleur1); noFill(); line(x-longueur,y-3,x+longueur,y-3); beginShape(TRIANGLES);noFill(); stroke((couleur1+couleur2)/2); vertex(xpos,y-1);vertex(xpos-8,y+10);vertex(xpos+8,y+10); endShape(); fill(couleur1); float v2=Math.round(valeur*100.0f)/100.0f; text(titre+" "+v2,xpos+10,y+9); } //**************************************************** public void setposition(float valeur){ xpos=(int)((valeur-valmin)/coef+x-longueur); xbut=xpos; } }