SAE21_2022/ModificationsTab.java
2023-04-26 17:35:23 +02:00

61 lines
2.3 KiB
Java

import java.awt.event.MouseEvent;
public class ModificationsTab {
// --------------------------------------------
public static final boolean LIBRE = true;
public static final boolean OCCUPE = false;
// --------------------------------------------
private boolean[][] cetteGrille;
private MouseEvent cetEvent;
private int[] tabEtat;
private int cetteLigne;
private int cetteColone;
private Affichage rafraichir;
private PanneauModification cePanel;
// -------------------------------------------------------------------------------------------------------------------------------------------------
public ModificationsTab(PanneauModification panneauModification, boolean[][] grilleTab, int[] unTab, MouseEvent unEvent){
this.cetteGrille = grilleTab;
this.cetEvent = unEvent;
this.cePanel = panneauModification;
Cellules notreCellule = (Cellules) cetEvent.getSource();
this.cetteLigne = notreCellule.getLigne();
this.cetteColone = notreCellule.getColone();
this.tabEtat = unTab;
/* ========================================= */
boolean radio1Selected = this.cePanel.GetButtonBW().isSelected();
boolean radio2Selected = this.cePanel.GetButtonE().isSelected(); // ENTREE
boolean radio3Selected = this.cePanel.GetButtonS().isSelected(); //SORTIE
/* ========================================= */
//System.out.println("Etat de la case avant cliqué : "+this.cetteGrille[this.cetteLigne][this.cetteColone]);
if(this.cetteGrille[this.cetteLigne][this.cetteColone] == OCCUPE){
this.cetteGrille[this.cetteLigne][this.cetteColone] = LIBRE;
} else {
if(notreCellule.getType()==Cellules.ENTREE || notreCellule.getType()==Cellules.SORTIE){
this.cetteGrille[this.cetteLigne][this.cetteColone] = LIBRE;
} else if (radio1Selected==true) {
this.cetteGrille[this.cetteLigne][this.cetteColone] = OCCUPE;
}
}
this.rafraichir = new Affichage(notreCellule, panneauModification, unTab, this.cetteGrille[this.cetteLigne][this.cetteColone]);
}
public int[] getGateState(){
this.tabEtat = this.rafraichir.getGateState();
return this.tabEtat;
}
}