-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPanneau.java
76 lines (66 loc) · 1.88 KB
/
Panneau.java
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
import javax.swing.*;
import java.awt.*;
public class Panneau extends JPanel
{ private boolean affiche;
private Environnement e1;
public Panneau()
{ affiche = false;
}
public void init(Environnement e2)
{ affiche = true;
e1 = e2;
}
public void stop()
{ affiche = false;
}
public void paintComponent(Graphics g)
{ //Rectangles de fond
g.setColor(Color.BLACK);
g.fillRect(10,10,480,360);
g.setColor(Color.GRAY);
g.fillRect(10,385,630,181);
g.fillRect(650,385,140,181);
//Carrés légende
g.setColor(Color.BLUE);
g.fillRect(660,450,10,10);
g.setColor(Color.RED);
g.fillRect(660,480,10,10);
g.setColor(Color.BLACK);
g.fillRect(660,420,10,10);
//Contours
g.drawRect(9,384,631,182);
g.drawRect(649,384,141,182);
g.setColor(Color.WHITE);
g.drawRect(660,450,10,10);
g.drawRect(660,480,10,10);
g.drawRect(660,420,10,10);
if (affiche)
{ //Obtenir la dimension par calcul simple
int dim = (480/e1.getNbLignes());
//Représentation simulation
for (int i=0;i<e1.getNbLignes();i++)
{ for (int j=0;j<e1.getNbColonnes();j++)
{ if (e1.getTabT(i,j).getVivant()) //i et j sont inversés (nbL et nbC dans Environnement)
{ g.setColor(Color.BLUE);
g.fillRect((10+dim*i),(10+dim*j),dim,dim);
}
else if (e1.getTabR(i,j).getVivant())
{ g.setColor(Color.RED);
g.fillRect((10+dim*i),(10+dim*j),dim,dim);
}
}
}
//Courbe
for (int i=0; i<630; i++)
{ g.setColor(Color.BLUE);
//nbpoisson*180/maxpoissons -> maxpoissons = (360/dim)*(480/dim)
g.fillRect((10+i),(566-((e1.getCourbeThons(i)*180)/((360/dim)*(480/dim)))),1,1);
g.setColor(Color.RED);
g.fillRect((10+i),(566-((e1.getCourbeRequins(i)*180)/((360/dim)*(480/dim)))),1,1);
//Contour
g.setColor(Color.BLACK);
g.drawRect(9,384,631,182);
}
}
}
}