2023-04-18 12:29:43 +02:00
|
|
|
import java.awt.*;
|
2023-04-28 20:26:26 +02:00
|
|
|
/**
|
2023-04-28 23:16:23 +02:00
|
|
|
* Class qui met en place une grille totalement vide et c'est donc a l'utilisateur de créer son la à partir de rien
|
2023-04-28 20:26:26 +02:00
|
|
|
* @version 1.1
|
|
|
|
* @author Matthis Fauvet
|
|
|
|
*/
|
2023-04-18 12:29:43 +02:00
|
|
|
public class FenetreVideGrille extends Fenetre{
|
|
|
|
|
2023-04-23 23:34:51 +02:00
|
|
|
private int taille;
|
2023-04-18 18:38:32 +02:00
|
|
|
|
2023-04-26 13:13:15 +02:00
|
|
|
private int[] tabCouleur;
|
2023-04-23 23:34:51 +02:00
|
|
|
private boolean[][] grille;
|
2023-04-25 11:42:59 +02:00
|
|
|
private Cellules[][] grilleCellules;
|
2023-04-26 13:13:15 +02:00
|
|
|
|
|
|
|
private Modifications modif;
|
2023-04-28 23:16:23 +02:00
|
|
|
|
2023-04-28 20:37:41 +02:00
|
|
|
/**
|
2023-04-28 23:16:23 +02:00
|
|
|
* Comme pour fenetreRndmGrille, on réupère la taille
|
|
|
|
* @param taille = taille du lab a créer
|
2023-04-28 20:37:41 +02:00
|
|
|
*/
|
2023-04-23 23:34:51 +02:00
|
|
|
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-26 13:13:15 +02:00
|
|
|
this.tabCouleur = new int[] {0, 0};
|
2023-04-18 12:29:43 +02:00
|
|
|
}
|
2023-04-28 23:16:23 +02:00
|
|
|
|
2023-04-28 20:37:41 +02:00
|
|
|
/**
|
2023-04-28 23:16:23 +02:00
|
|
|
* Méthode qui permet de créer un tab vide et qui ajoute les modifications
|
|
|
|
* Modification : Ecoute les event
|
|
|
|
* Panneau modification : fenetre qui permet de créer / modifier le Lab a notre guise
|
2023-04-28 20:37:41 +02:00
|
|
|
*/
|
2023-04-28 23:16:23 +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);
|
2023-04-28 19:17:35 +02:00
|
|
|
this.fenetre.setLocation(300, 150);
|
2023-04-18 12:29:43 +02:00
|
|
|
|
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();
|
2023-04-26 13:13:15 +02:00
|
|
|
|
|
|
|
/* ======= Valeurs aléatoire pour l'entre et la sortie ========== */
|
2023-04-23 23:34:51 +02:00
|
|
|
|
|
|
|
for(int i=0; i<taille; i++){
|
|
|
|
for(int j=0; j<taille; j++){
|
2023-04-28 19:17:35 +02:00
|
|
|
grille[i][j] = Cellules.LIBRE;
|
2023-04-26 13:13:15 +02:00
|
|
|
|
|
|
|
this.modif = new Modifications(interfacePanel, grille,this.tabCouleur);
|
|
|
|
|
|
|
|
Cellules cellules = new Cellules(i,j, Cellules.COULOIR);
|
2023-04-23 23:34:51 +02:00
|
|
|
this.fenetre.add(cellules);
|
|
|
|
cellules.addMouseListener(modif);
|
2023-04-26 13:13:15 +02:00
|
|
|
grilleCellules[i][j] = cellules;
|
|
|
|
|
2023-04-23 23:34:51 +02:00
|
|
|
this.tabCouleur = modif.getGateState();
|
2023-04-18 12:29:43 +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
|
|
|
}
|