SAE21_2022/ModificationsTab.java

55 lines
2.2 KiB
Java
Raw Normal View History

import java.awt.event.MouseEvent;
public class ModificationsTab {
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;
/* ========================================= */
2023-04-26 17:35:23 +02:00
boolean radio1Selected = this.cePanel.GetButtonBW().isSelected();
boolean radio2Selected = this.cePanel.GetButtonE().isSelected(); // ENTREE
boolean radio3Selected = this.cePanel.GetButtonS().isSelected(); //SORTIE
/* ========================================= */
2023-04-26 17:35:23 +02:00
//System.out.println("Etat de la case avant cliqué : "+this.cetteGrille[this.cetteLigne][this.cetteColone]);
if(this.cetteGrille[this.cetteLigne][this.cetteColone] == Cellules.OCCUPE){
this.cetteGrille[this.cetteLigne][this.cetteColone] = Cellules.LIBRE;
2023-04-26 17:35:23 +02:00
} else {
if(notreCellule.getType()==Cellules.ENTREE || notreCellule.getType()==Cellules.SORTIE){
this.cetteGrille[this.cetteLigne][this.cetteColone] = Cellules.LIBRE;
2023-04-26 17:35:23 +02:00
} else if (radio1Selected==true) {
this.cetteGrille[this.cetteLigne][this.cetteColone] = Cellules.OCCUPE;
2023-04-26 17:35:23 +02:00
}
}
this.rafraichir = new Affichage(notreCellule, panneauModification, unTab, this.cetteGrille[this.cetteLigne][this.cetteColone]);
}
public int[] getGateState(){
this.tabEtat = this.rafraichir.getGateState();
return this.tabEtat;
}
}