2015-03-23 1 views
3

Je veux créer une légende pour un graphique à barres, qui ressemble à:2+ Créer plusieurs légendes de texte en italique

| | | | 
//// 

où | : colonne de données, /: est une légende pour chaque colonne

Je ne pouvais pas obtenir la légende de texte correcte, essayez plusieurs transformation maxtrix, mais aucune ne fonctionne correctement.

for (int col = 0; col < 4; col++) { 
         // Draw emotions legends 
       applet.fill(100); 
       applet.textFont(font, 20); 

       // perform matrix transform 
       applet.rotate(-0.75f); 
       applet.translate(col * columnW, h); 

       // draw text 
       applet.text(legends[col], 0, 0); 

       // undo matrix 
       applet.translate(-col * columnW, -h); 
       applet.rotate(0.75f); 
} 

S'il vous plaît aider :(

Répondre

1

Pour ceux qui veulent connaître la réponse:

for (int col = 0; col < 4; col++) { 
       applet.pushMatrix(); 
       applet.translate(col * blockW, h); 
       // Rotate the text 
       applet.rotate(-0.75f); 

       // Display the text 
       applet.text(Emotion.values()[col].toString(), 0, 0); 
       applet.popMatrix(); 
}