Bonjour,
Je cherche à faire passer un projet qui est en Swing en JavaFX.
Je demande simplement si quelqu'un peut me renseigner en me disant si c'est possible. Je prends l'exemple avec une classe où j'ai bcp de difficulté à trouver ce qui correspond en JavaFX.
Si vous pensez que c'est 'presque' pas possible, me le signaler

Voici la classe :
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
50
51
52
53
54
55
56
57
58
59
 
public class PlanComponent extends JComponent {
private static final float MARGIN = 40;
private float scale = 0.5f;
 
   public PlanComponent() { 
      setOpaque(true);
  } 
 
   @Override
   public Dimension getPreferredSize() {
       if (isPreferredSizeSet()) {
           return super.getPreferredSize();
       } else {
           Insets insets = getInsets();
           Rectangle2D planBounds = getPlanBounds();
           return new Dimension(Math.round(((float)planBounds.getWidth() + MARGIN * 2)* this.scale) + insets.left + insets.right, Math.round(((float)planBounds.getHeight() + MARGIN * 2)* this.scale) + insets.top + insets.bottom);
       } 
    } 
 
    private Rectangle2D getPlanBounds() {
        Rectangle2D planBounds =  new Rectangle2D.Float(0, 0, 1000, 1000);
        for (Wall wall : home.getWalls()) { 
             planBounds.add(wall.getXStart(), wall.getYStart());
             planBounds.add(wall.getXEnd(), wall.getYEnd());
        }  
        return planBounds; 
    }
 
    @Override
    protected void paintComponent(Graphics g) {
         Graphics2D g2D = (Graphics2D)g.create();
         paintBackground(g2D);
         Insets insets = getInsets();
         g2D.clipRect(insets.left, insets.top, getWidth() - insets.left - insets.right, getHeight() - insets.top - insets.bottom); 
         Rectangle2D planBounds = getPlanBounds();
         g2D.translate(insets.left + (MARGIN - planBounds.getMinX()) * this.scale, insets.top + (MARGIN - planBounds.getMinY()) * this.scale);
         g2D.scale(scale, scale);
         paintContent(g2D);
         g2D.dispose(); 
     } 
 
      private void paintBackground(Graphics2D g2D) {
	  if (isOpaque()) {
               Color backgroundColor = UIManager.getColor("window");
               g2D.setColor(backgroundColor);  
               g2D.fillRect(0, 0, getWidth(), getHeight());
          }
      }  
 
       private void paintContent(Graphics2D g2D) {
          g2D.setColor(getForeground());
          for (Wall wall : this.home.getWalls()) {
               Line2D line = new Line2D.Float(wall.getXStart(),wall.getYStart(), wall.getXEnd(), wall.getYEnd());
               g2D.setStroke(new BasicStroke(wall.getThickness(), BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
               g2D.draw(line);
          } 
       } 
}
Merci pour tout renseignement.

Bien à vous.