2023-04-18 12:29:43 +02:00
|
|
|
import java.awt.*;
|
|
|
|
|
|
|
|
public class FenetreVideGrille extends Fenetre{
|
2023-04-23 23:34:51 +02:00
|
|
|
public static final int COULOIR=0;
|
|
|
|
public static final int MUR=1;
|
|
|
|
public static final int ENTREE=2;
|
|
|
|
public static final int SORTIE=3;
|
2023-04-18 12:29:43 +02:00
|
|
|
|
2023-04-23 23:34:51 +02:00
|
|
|
private int taille;
|
2023-04-18 18:38:32 +02:00
|
|
|
|
2023-04-23 23:34:51 +02:00
|
|
|
private boolean[][] grille;
|
2023-04-25 11:42:59 +02:00
|
|
|
private Cellules[][] grilleCellules;
|
2023-04-23 23:34:51 +02:00
|
|
|
private int[] tabCouleur;
|
|
|
|
|
|
|
|
public FenetreVideGrille(int taille){
|
2023-04-18 12:29:43 +02:00
|
|
|
super();
|
2023-04-23 23:34:51 +02:00
|
|
|
this.taille = taille;
|
|
|
|
this.grille = new boolean[this.taille][this.taille];
|
2023-04-25 11:42:59 +02:00
|
|
|
this.grilleCellules = new Cellules[this.taille][this.taille];
|
2023-04-18 12:29:43 +02:00
|
|
|
}
|
|
|
|
|
2023-04-23 23:34:51 +02:00
|
|
|
public void videGrille(){
|
|
|
|
|
2023-04-18 12:29:43 +02:00
|
|
|
this.fenetre.setSize(600, 600);
|
|
|
|
this.fenetre.setLocation(450, 200);
|
|
|
|
|
2023-04-23 23:34:51 +02:00
|
|
|
GridLayout gestionnaire = new GridLayout(this.taille,this.taille);
|
2023-04-18 12:29:43 +02:00
|
|
|
this.fenetre.setLayout(gestionnaire);
|
2023-04-18 18:38:32 +02:00
|
|
|
|
2023-04-25 11:42:59 +02:00
|
|
|
PanneauModification interfacePanel = new PanneauModification(this.grille, this.taille, this.grilleCellules, this.fenetre);
|
2023-04-23 23:34:51 +02:00
|
|
|
interfacePanel.SetUp();
|
|
|
|
|
|
|
|
/* =============================================================== */
|
|
|
|
|
|
|
|
|
|
|
|
/* =============================================================== */
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i<taille; i++){
|
|
|
|
for(int j=0; j<taille; j++){
|
|
|
|
Modifications modif = new Modifications(interfacePanel, this.grille, this.tabCouleur);
|
|
|
|
|
|
|
|
grille[i][j] = true;
|
|
|
|
Cellules cellules = new Cellules(i, j, COULOIR);
|
|
|
|
this.fenetre.add(cellules);
|
|
|
|
cellules.addMouseListener(modif);
|
2023-04-18 18:38:32 +02:00
|
|
|
|
2023-04-23 23:34:51 +02:00
|
|
|
this.tabCouleur = modif.getGateState();
|
2023-04-18 12:29:43 +02:00
|
|
|
}
|
|
|
|
}
|
2023-04-18 18:38:32 +02:00
|
|
|
|
2023-04-23 23:34:51 +02:00
|
|
|
this.fenetre.setVisible(true);
|
2023-04-18 18:38:32 +02:00
|
|
|
}
|
2023-04-18 12:29:43 +02:00
|
|
|
}
|