Bonjour à tous,

je développe une application RCP basée sur GEF. GEF me permet de dessiner des éléments à l'échelle sur sur une page A4. Mon appli affiche une page A4 (ou 1 pixel = 1 mm) et je dois pouvoir y ajouter des textes.

Pour cela j'ai redéfini une figure pour afficher comme ceci

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.awt.Graphics2D;
 
import org.bpy.stamp.philaeditor.gef.model.TextNode;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Font;
 
public class TextFigure extends Figure {
 
   private Rectangle rect;
 
   private Font font;
   private String textToDisplay;
 
   public TextFigure() {
   }
 
 
   public void setCurrentFont(Font f) {
      font = f;  
//      super.setFont(f);
   }
 
   public void setText(String text) {
      textToDisplay = text;
      super.setText(text);
   }
 
   public void setLayout(Rectangle rect) {
      this.rect = rect;
      setBounds(rect);
      rect.width += 2;
      rect.height += 2;
      getParent().setConstraint(this, rect);
   }
 
   protected void paintFigure(Graphics g) {
 
      g.setForegroundColor(ColorConstants.black);
      g.setFont(font);
 
      g.scale (0.35); //scales about the origin
      g.drawString(textToDisplay, 0,0);
    }
}

La font est du Tahoma.
L'échelle est de 0.35 pour repsecter 1mm = 1pixel
Mais voila rien ne s'affiche

Qui peut m'aider
Cordialement