Bonjour,
En fait je suis parti de ce fichier data.txt qui se trouve la http://www.tsp.gatech.edu/world/dj38.tsp normalement je dois avoir un graphe comme ceci graphe http://www.tsp.gatech.edu/world/djpoints.html
seulement j ai pas du tout le meme resultat.
Ma question est comment puige modifier mon code histoire d avoir le meme graphe que sur le site.

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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
 
public class Drawtree extends Applet {
 
   int width, height;
 
    private int x1;
    private int y1;
    private int x2;
    private int y2;
    ArrayList<String> listes = new ArrayList<String>();
 
   public void init() {
      width = getSize().width;
      height = getSize().height;
      setBackground( Color.black );
      String filePath = "data.txt";
 
       BufferedReader buff = null;
    try {
        buff = new BufferedReader(new FileReader(filePath));
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
 
        String line;
        int cpt;
 
        cpt = 0;
        while (cpt < 10)
        {
            try {
                line = buff.readLine();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            cpt++;
        }
        try {
            while ((line = buff.readLine()) != null)
                listes.add(line);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
   }
 
 
 
   public ArrayList<String> getListes() {
    return listes;
}
 
 
 
public void setListes(ArrayList<String> listes) {
    this.listes = listes;
}
 
   public void paint( Graphics g ) {
 
    int width,heigh;
       width = getSize().width;
       heigh = getSize().height;
       setBackground(Color.BLACK);
 
       String line, line2;
 
       String []save;
       String []save2;
 
       listes = this.getListes();
       g.setColor(Color.green);
 
       int sizeX=getSize().width;
    int sizeY=getSize().height;
    int scaleX=sizeX/30;
    int scaleY=(sizeY-70)/30;
       for (int i = 0; i < listes.size(); i++)
           {
               line = (String)listes.get(i);
               g.setColor(Color.green);
               //g.drawString(line, 0, 0);
               save = line.split(" ");
               //g.drawString(line, 0, 0);    
               line2 = (String)listes.get(++i);
               save2 = line2.split(" ");
               x1 = (int)Float.parseFloat(save[1])/100;
                     y1 = (int)Float.parseFloat(save[2])/100;
                     x2 = (int)Float.parseFloat(save2[1])/100;
                 y2 = (int)Float.parseFloat(save2[2])/100;
 
               g.translate(30, 20);
 
               g.setColor(Color.green);
 
               g.drawRect(x1, y1,1,1);
 
               g.drawRect(x2, y2,1,1);
 
      }
 
   }
}