save de tout

This commit is contained in:
fauvet 2023-04-26 17:35:23 +02:00
parent 5fee4722cf
commit 48827f3897
4 changed files with 50 additions and 47 deletions

View File

@ -1,7 +1,6 @@
public class Affichage { import javax.swing.CellEditor;
public static final boolean LIBRE = true;
public static final boolean OCCUPE = false;
public class Affichage {
private Cellules cetteCellules; private Cellules cetteCellules;
private PanneauModification cePanel; private PanneauModification cePanel;
@ -28,38 +27,29 @@ public class Affichage {
boolean radio2Selected = this.cePanel.GetButtonE().isSelected(); // ENTREE boolean radio2Selected = this.cePanel.GetButtonE().isSelected(); // ENTREE
boolean radio3Selected = this.cePanel.GetButtonS().isSelected(); //SORTIE boolean radio3Selected = this.cePanel.GetButtonS().isSelected(); //SORTIE
//System.out.println("le type de la cell vaut : " + this.cetteCellules.getType());
//System.out.println("Etat des deux valeur : " + this.caseEntrortie[0] + " "+ this.caseEntrortie[1]);
if(radio2Selected==true && this.caseEntrortie[0]==0){ if(radio2Selected==true && this.caseEntrortie[0]==0){
if(this.caseEntrortie[0]==1){ this.cetEtat=ModificationsTab.LIBRE;
this.caseEntrortie[0]=0;
} else if(this.caseEntrortie[1]==1){
this.caseEntrortie[1]=0;
}
this.caseEntrortie[0]=1;
this.cetteCellules.setType(Cellules.ENTREE); this.cetteCellules.setType(Cellules.ENTREE);
this.cetteCellules.peindre(Cellules.ENTREE); this.cetteCellules.peindre(Cellules.ENTREE);
this.caseEntrortie[0]=1;
} else if(radio3Selected==true && this.caseEntrortie[1]==0){ } else if(radio3Selected==true && this.caseEntrortie[1]==0){
if(this.caseEntrortie[0]==1){ this.cetEtat=ModificationsTab.LIBRE;
this.caseEntrortie[0]=0;
} else if(this.caseEntrortie[1]==1){
this.caseEntrortie[1]=0;
}
this.caseEntrortie[1]=1;
this.cetteCellules.setType(Cellules.SORTIE); this.cetteCellules.setType(Cellules.SORTIE);
this.cetteCellules.peindre(Cellules.SORTIE); this.cetteCellules.peindre(Cellules.SORTIE);
} else if(radio1Selected==true && this.cetEtat==true){ this.caseEntrortie[1]=1;
if(this.caseEntrortie[0]==1){ } else if(this.cetEtat == ModificationsTab.LIBRE && radio1Selected==true){
if(this.cetteCellules.getType()==Cellules.ENTREE){
this.caseEntrortie[0]=0; this.caseEntrortie[0]=0;
} else if(this.caseEntrortie[1]==1){ } else if(this.cetteCellules.getType()==Cellules.SORTIE){
this.caseEntrortie[1]=0; this.caseEntrortie[1]=0;
} }
this.cetteCellules.setType(Cellules.COULOIR); this.cetteCellules.setType(Cellules.COULOIR);
this.cetteCellules.peindre(Cellules.COULOIR); this.cetteCellules.peindre(Cellules.COULOIR);
} else if(radio1Selected==true && this.cetEtat==OCCUPE){ } else if(this.cetEtat == ModificationsTab.OCCUPE && radio1Selected==true){
if(this.caseEntrortie[0]==1){
this.caseEntrortie[0]=0;
} else if(this.caseEntrortie[1]==1){
this.caseEntrortie[1]=0;
}
this.cetteCellules.setType(Cellules.MUR); this.cetteCellules.setType(Cellules.MUR);
this.cetteCellules.peindre(Cellules.MUR); this.cetteCellules.peindre(Cellules.MUR);
} }

View File

@ -65,6 +65,7 @@ public class FenetreRndmGrille extends Fenetre{
this.fenetre.add(cellules); this.fenetre.add(cellules);
cellules.addMouseListener(modif); cellules.addMouseListener(modif);
grilleCellules[i][j] = cellules; grilleCellules[i][j] = cellules;
grille[i][j] = ModificationsTab.LIBRE;
} }
else if(compteur == ValeurSortie) else if(compteur == ValeurSortie)
{ {
@ -72,6 +73,7 @@ public class FenetreRndmGrille extends Fenetre{
this.fenetre.add(cellules); this.fenetre.add(cellules);
cellules.addMouseListener(modif); cellules.addMouseListener(modif);
grilleCellules[i][j] = cellules; grilleCellules[i][j] = cellules;
grille[i][j] = ModificationsTab.LIBRE;
} }
else if(grille[i][j] == true) else if(grille[i][j] == true)
{ {

View File

@ -51,8 +51,6 @@ public class Lecture {
} }
} }
/* =========================================================================================================================================================================== /* ===========================================================================================================================================================================
* *
* GET_OFFSET * GET_OFFSET
@ -68,12 +66,12 @@ public class Lecture {
/* Ouverture d'un flux */ /* Ouverture d'un flux */
InputStream fis = new FileInputStream(this.ce_chemin); InputStream fis = new FileInputStream(this.ce_chemin);
int cette_taille=fis.available();/*cette_taille prend une aproximation de la taille du flux */ int cetteTaille=fis.available();/*cette_taille prend une aproximation de la taille du flux */
int ce_compteur = 0, temp; int ceCompteur = 0, temp;
int [] ce_tableau = new int[cette_taille-4]; /*-5 pour le header mais +1 pour le -1 de fin de fichier. */ int [] ceTableau = new int[cetteTaille-4]; /*-5 pour le header mais +1 pour le -1 de fin de fichier. */
int [] ce_tableau_temp = new int[8]; /*C'est le tab qui va stocker les différents octets */ int [] ceTableauTemp = new int[8]; /*C'est le tab qui va stocker les différents octets */
int[] ce_tab_to_return = new int[0];; /*Tableau qui va être renvoyé et qui va contenir tous les bits dans le non ordre */ int[] ceResultat = new int[0];; /*Tableau qui va être renvoyé et qui va contenir tous les bits dans le non ordre */
/*On skip les 5 premiers octets */ /*On skip les 5 premiers octets */
for(int i=0;i<5;i++){ for(int i=0;i<5;i++){
@ -85,26 +83,33 @@ public class Lecture {
while(data != -1){ while(data != -1){
this.data = fis.read(); this.data = fis.read();
ce_tableau[ce_compteur]=this.data; ceTableau[ceCompteur]=this.data;
ce_compteur=ce_compteur+1; ceCompteur=ceCompteur+1;
} }
/* =============================================================================================================================== */ /* ========================================================================================== */
//Utilisation du tableau différent pour créer un tableau avec tout les octets mais dans le bon sens grace a ma superbe classe Outils ;) // Utilisation du tableau différent pour créer un tableau avec tout les
//System.out.println("la taille du tableau vaut : "+ce_tableau.length); // octets mais dans le bon sens grace a ma superbe classe Outils ;)
for(int m=0; m<ce_tableau.length; m++){ //length -1 car on ne veux pas traiter le -1;
temp = ce_tableau[m]; //System.out.println("la taille du tableau vaut : "+ceTableau.length);
for(int m=0; m<ceTableau.length; m++){
temp = ceTableau[m];
for(int n=0; n<8; n++){ //repetition 8 fois pour traiter les 8 bits for(int n=0; n<8; n++){ //repetition 8 fois pour traiter les 8 bits
ce_tableau_temp[n] = temp&1; ceTableauTemp[n] = temp&1;
//System.out.print(ceTableauTemp[n]+" ");
temp = temp >> 1; temp = temp >> 1;
} }
//outils.printInt(outils.reverse(ce_tableau_temp), 8); //outils.printInt(outils.reverse(ce_tableau_temp), 8);
ce_tab_to_return = outils.concatenate(ce_tab_to_return, outils.reverse(ce_tableau_temp)); ceResultat = outils.concatenate(ceResultat, outils.reverse(ceTableauTemp));
} }
/* =================================================================================================================================== */ for(int i=0; i<ceResultat.length; i++){
System.out.println("le resultats vaut : "+ceResultat[i]);
}
/* =================================== Fermeture fichier ==================================== */
try{ try{
fis.close(); fis.close();
@ -112,7 +117,7 @@ public class Lecture {
System.out.println("erreur lors de la fermeture"); System.out.println("erreur lors de la fermeture");
return null; return null;
} }
return ce_tab_to_return; return ceResultat;
} }
catch(IOException e){ catch(IOException e){
System.out.println("erreur d'ouverture"); System.out.println("erreur d'ouverture");

View File

@ -33,15 +33,21 @@ public class ModificationsTab {
/* ========================================= */ /* ========================================= */
boolean radio1Selected = this.cePanel.GetButtonBW().isSelected();
boolean radio2Selected = this.cePanel.GetButtonE().isSelected(); // ENTREE boolean radio2Selected = this.cePanel.GetButtonE().isSelected(); // ENTREE
boolean radio3Selected = this.cePanel.GetButtonS().isSelected(); //SORTIE boolean radio3Selected = this.cePanel.GetButtonS().isSelected(); //SORTIE
/* ========================================= */ /* ========================================= */
if(this.cetteGrille[this.cetteLigne][this.cetteColone] == LIBRE && radio2Selected==false && radio3Selected==false ){ //System.out.println("Etat de la case avant cliqué : "+this.cetteGrille[this.cetteLigne][this.cetteColone]);
this.cetteGrille[this.cetteLigne][this.cetteColone] = OCCUPE; if(this.cetteGrille[this.cetteLigne][this.cetteColone] == OCCUPE){
} else if(this.cetteGrille[this.cetteLigne][this.cetteColone] == OCCUPE){ this.cetteGrille[this.cetteLigne][this.cetteColone] = LIBRE;
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]); this.rafraichir = new Affichage(notreCellule, panneauModification, unTab, this.cetteGrille[this.cetteLigne][this.cetteColone]);