SAE21_2022/ModificationsTab.java

55 lines
2.0 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 radio2Selected = this.cePanel.GetButtonE().isSelected(); // ENTREE
boolean radio3Selected = this.cePanel.GetButtonS().isSelected(); //SORTIE
/* ========================================= */
if(this.cetteGrille[this.cetteLigne][this.cetteColone] == LIBRE && radio2Selected==false && radio3Selected==false ){
this.cetteGrille[this.cetteLigne][this.cetteColone] = OCCUPE;
} else if(this.cetteGrille[this.cetteLigne][this.cetteColone] == OCCUPE){
this.cetteGrille[this.cetteLigne][this.cetteColone] = LIBRE;
}
this.rafraichir = new Affichage(notreCellule, panneauModification, unTab, this.cetteGrille[this.cetteLigne][this.cetteColone]);
}
public int[] getGateState(){
this.tabEtat = this.rafraichir.getGateState();
return this.tabEtat;
}
}