SAE21_2022/FenetreImpGrille.java

62 lines
2.7 KiB
Java
Raw Normal View History

import java.awt.*;
public class FenetreImpGrille extends Fenetre {
private boolean[][] grille;
public FenetreImpGrille(){
super();
}
public void ImporterGrille(int taille, int Lentre, int Centre, int Lortie, int Cortie, int[] tabGrille){
/* ================================================================ Déclaration des variables ============================================================================= */
int[][] ce_double_tab = new int[taille][taille];
this.grille = new boolean[taille][taille];
//System.out.println("LA TAILLE DE LA GRRILLE VAUT : "+tabGrille.length);
/* =============================================================== Gestion des paramètres de la fenètre ========================================================================== */
/*Création de la fenètre */
this.fenetre.setSize(600, 600);
/*Mise en place du grid layout */
GridLayout gestionnaire = new GridLayout(taille,taille);
this.fenetre.setLayout(gestionnaire);
/* ================================================================================================================================================================ */
/* remplissage du tab 1 */
int compteur=0;
for(int i=0; i<taille; i++){
for(int j=0; j<taille; j++){
ce_double_tab[j][i] = tabGrille[compteur];
compteur++;
}
}
/* ======================================================================================================================================= */
// Gestion du remplissage des case
for(int i=0; i<taille; i++){
for(int j=0; j<taille; j++){
if(ce_double_tab[i][j] == 0){
this.grille[i][j] = false;
} else {
this.grille[i][j] = true;
}
if((i*taille+j)==(Lentre*taille+Centre)){
Cellules cellules = new Cellules(i, j, Cellules.ENTREE);
this.fenetre.add(cellules);
} else if((i*taille+j)==(Lortie*taille+Cortie)){
Cellules cellules = new Cellules(i, j, Cellules.SORTIE);
this.fenetre.add(cellules);
} else if(ce_double_tab[i][j] == 1){
Cellules cellules = new Cellules(i, j, Cellules.MUR);
this.fenetre.add(cellules);
} else{
Cellules cellules = new Cellules(i, j, Cellules.COULOIR);
this.fenetre.add(cellules);
}
}
}
this.fenetre.setVisible(true);
outils.PrintGrilleBool(this.grille, taille);
}
}