Bonjour,
je dessine une graphe mais apparement je perd de la précision à cause de la conversion float->int(cf image).Les marques ne sont pas faite jusqu'au bout .
Voici mon code
Existe-il des algo pour eviter de perdre de la precision ?
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 protected void paintComponent(Graphics g) { super.paintComponent(g); if(map == null)return; double uX = getWidth() / map.width; double uY = getHeight() / map.height; int mX = getWidth() / 2; int mY = getHeight() / 2; g.drawLine(mX, 0, mX, getHeight()); g.drawLine(0, mY, getWidth(), mY); //les trait sur l'axe vertical for(int i = 0; i < map.height; i++){ g.drawLine(mX - 5,(int)(i*uY), mX + 5,(int)(i*uY)); } //les trait sur l'axe horizontal for(int i = 0; i < map.width; i++){ g.drawLine((int)(i*uX), mY - 5, (int)(i*uX), mY + 5 ); } }
merci d'avance.
Partager