SAE21_2022/ModificationsTab.java

58 lines
2.2 KiB
Java
Raw Normal View History

import java.awt.event.MouseEvent;
public class ModificationsTab {
// --------------------------------------------
public static final boolean LIBRE = true;
public static final boolean OCCUPE = false;
public static final int COULOIR=0;
public static final int MUR=1;
public static final int ENTREE=2;
public static final int SORTIE=3;
// --------------------------------------------
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(); // MUR / COULOIR
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;
}
}