diff --git a/Affichage.java b/Affichage.java index e151fe3..6bbf8df 100644 --- a/Affichage.java +++ b/Affichage.java @@ -1,9 +1,4 @@ public class Affichage { - public static final int COULOIR=0; - public static final int MUR=1; - public static final int ENTREE=2; - public static final int SORTIE=3; - public static final boolean LIBRE = true; public static final boolean OCCUPE = false; @@ -40,8 +35,8 @@ public class Affichage { this.caseEntrortie[1]=0; } this.caseEntrortie[0]=1; - this.cetteCellules.setType(ENTREE); - this.cetteCellules.peindre(ENTREE); + this.cetteCellules.setType(Cellules.ENTREE); + this.cetteCellules.peindre(Cellules.ENTREE); } else if(radio3Selected==true && this.caseEntrortie[1]==0){ if(this.caseEntrortie[0]==1){ this.caseEntrortie[0]=0; @@ -49,24 +44,24 @@ public class Affichage { this.caseEntrortie[1]=0; } this.caseEntrortie[1]=1; - this.cetteCellules.setType(SORTIE); - this.cetteCellules.peindre(SORTIE); + this.cetteCellules.setType(Cellules.SORTIE); + this.cetteCellules.peindre(Cellules.SORTIE); } else if(radio1Selected==true && this.cetEtat==true){ if(this.caseEntrortie[0]==1){ this.caseEntrortie[0]=0; } else if(this.caseEntrortie[1]==1){ this.caseEntrortie[1]=0; } - this.cetteCellules.setType(COULOIR); - this.cetteCellules.peindre(COULOIR); + this.cetteCellules.setType(Cellules.COULOIR); + this.cetteCellules.peindre(Cellules.COULOIR); } else if(radio1Selected==true && this.cetEtat==OCCUPE){ if(this.caseEntrortie[0]==1){ this.caseEntrortie[0]=0; } else if(this.caseEntrortie[1]==1){ this.caseEntrortie[1]=0; } - this.cetteCellules.setType(MUR); - this.cetteCellules.peindre(MUR); + this.cetteCellules.setType(Cellules.MUR); + this.cetteCellules.peindre(Cellules.MUR); } } } diff --git a/Ecriture.java b/Ecriture.java index 4d7d65f..7f6add4 100644 --- a/Ecriture.java +++ b/Ecriture.java @@ -15,7 +15,7 @@ public class Ecriture { fichierSortie = new FileOutputStream(this.filePath); // Ecriture du tableau de bytes dans le fichier - fichierSortie.write(tabBytes); + fichierSortie.write(this.tabHeader); // Ecriture du tableau d'octets binaires dans le fichier for (String flags : this.tabOffSet) { diff --git a/FenetreRndmGrille.java b/FenetreRndmGrille.java index d439241..9322cdb 100644 --- a/FenetreRndmGrille.java +++ b/FenetreRndmGrille.java @@ -2,11 +2,6 @@ import java.awt.*; import java.util.Random; public class FenetreRndmGrille extends Fenetre{ - public static final int COULOIR=0; - public static final int MUR=1; - public static final int ENTREE=2; - public static final int SORTIE=3; - public static final int RANDOM=1; private int taille; @@ -66,28 +61,28 @@ public class FenetreRndmGrille extends Fenetre{ if(compteur == ValeurEntre) { - Cellules cellules = new Cellules(i,j, ENTREE); + Cellules cellules = new Cellules(i,j, Cellules.ENTREE); this.fenetre.add(cellules); cellules.addMouseListener(modif); grilleCellules[i][j] = cellules; } else if(compteur == ValeurSortie) { - Cellules cellules = new Cellules(i, j, SORTIE); + Cellules cellules = new Cellules(i, j, Cellules.SORTIE); this.fenetre.add(cellules); cellules.addMouseListener(modif); grilleCellules[i][j] = cellules; } else if(grille[i][j] == true) { - Cellules cellules = new Cellules(i, j, COULOIR); + Cellules cellules = new Cellules(i, j, Cellules.COULOIR); this.fenetre.add(cellules); cellules.addMouseListener(modif); grilleCellules[i][j] = cellules; } else { - Cellules cellules = new Cellules(i, j, MUR); + Cellules cellules = new Cellules(i, j, Cellules.MUR); this.fenetre.add(cellules); cellules.addMouseListener(modif); grilleCellules[i][j] = cellules; diff --git a/FenetreVideGrille.java b/FenetreVideGrille.java index 3ec1289..9d20fec 100644 --- a/FenetreVideGrille.java +++ b/FenetreVideGrille.java @@ -1,22 +1,21 @@ import java.awt.*; public class FenetreVideGrille extends Fenetre{ - 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 int taille; + private int[] tabCouleur; private boolean[][] grille; private Cellules[][] grilleCellules; - private int[] tabCouleur; + + private Modifications modif; public FenetreVideGrille(int taille){ super(); this.taille = taille; this.grille = new boolean[this.taille][this.taille]; this.grilleCellules = new Cellules[this.taille][this.taille]; + this.tabCouleur = new int[] {0, 0}; } public void videGrille(){ @@ -29,26 +28,23 @@ public class FenetreVideGrille extends Fenetre{ PanneauModification interfacePanel = new PanneauModification(this.grille, this.taille, this.grilleCellules, this.fenetre); interfacePanel.SetUp(); - - /* =============================================================== */ - - - /* =============================================================== */ - + + /* ======= Valeurs aléatoire pour l'entre et la sortie ========== */ for(int i=0; i 0){ this.tabTemp = new String[(this.cetteTaille*this.cetteTaille)/8+1]; - this.ceCompteur = ((this.cetteTaille*this.cetteTaille)/8)+1; this.octetRemaining = (this.cetteTaille*this.cetteTaille)+(this.cetteTaille*this.cetteTaille)%8; } String tempString = ""; boolean[] tabHorizontal = new boolean[this.cetteTaille*this.cetteTaille]; tabHorizontal = outils.PutToVertical(this.cetteGrille, this.cetteTaille); - - outils.printBool(tabHorizontal, this.cetteTaille); // Transformation du tableau de boolean en un tableau de chaine de String qui stock des nombre sous formes de byte int compteur1=0; @@ -86,15 +76,14 @@ public class PreEcriture { FileNameExtensionFilter filter = new FileNameExtensionFilter("Fichiers .lab", "lab"); chooser.setFileFilter(filter); int returnVal = chooser.showSaveDialog(null); - if(returnVal == JFileChooser.APPROVE_OPTION) { - String nomFichier = chooser.getSelectedFile().getName(); - if(!nomFichier.endsWith(".lab")) { - nomFichier += ".lab"; - } - String contenu = "Contenu du fichier .lab"; + if (returnVal == JFileChooser.APPROVE_OPTION) { File fichier = chooser.getSelectedFile(); + String nomFichier = fichier.getName(); + if (!nomFichier.endsWith(".lab")) { + fichier = new File(fichier.getAbsolutePath() + ".lab"); + } return fichier.getAbsolutePath(); } return null; - } + } } diff --git a/SAVE.txt b/SAVE.txt deleted file mode 100644 index 2c72c8e..0000000 --- a/SAVE.txt +++ /dev/null @@ -1,118 +0,0 @@ -import javax.swing.*; -import java.awt.*; -import java.util.Random; -import javax.swing.border.Border; - -public class FenetreRndmGrille extends Fenetre{ - private int[] tab_de_int; - private int taille; - private int ValeurEntre; - private int ValeurSortie; - - private int[][] grille; - - public FenetreRndmGrille(int taille){ - super(); - this.tab_de_int = new int[] {1, 1}; - this.taille = taille; - this.grille = new int[this.taille][this.taille]; - } - - public void randomGrille(){ - this.fenetre.setSize(600, 600); - this.fenetre.setLocation(450, 200); - - GridLayout gestionnaire = new GridLayout(this.taille,this.taille); - this.fenetre.setLayout(gestionnaire); - - OptionsFRG un_Test = new OptionsFRG(this); - un_Test.SetUp(); - - /* ======= Valeurs aléatoire pour l'entre et la sortie ========== */ - - Random rand = new Random(); - this.ValeurEntre = rand.nextInt(this.taille*this.taille); - this.ValeurSortie = rand.nextInt(this.taille*this.taille); - if(this.ValeurSortie == this.ValeurEntre){ - while(this.ValeurSortie == this.ValeurEntre){ - this.ValeurSortie = rand.nextInt(this.taille*this.taille); - } - } - - /* =============================================================== */ - - int compteur=0; - - for(int i=0; i