From 9f1f7cb7d7082667e38a5890623f043108dadfe8 Mon Sep 17 00:00:00 2001 From: fauvet Date: Sun, 23 Apr 2023 23:34:51 +0200 Subject: [PATCH] =?UTF-8?q?Grosse=20Update=20-=2020,=20Apres=20avoir=20tra?= =?UTF-8?q?vaill=C3=A9=20sur=20un=20autre=20repertoire=20git=20pour=20ne?= =?UTF-8?q?=20pas=20perdre=20tout=20mon=20pr=C3=A9c=C3=A9dent=20travail,?= =?UTF-8?q?=20voici=20la=20nouvelle=20version=20qui=20est=20au=20m=C3=AAme?= =?UTF-8?q?=20stade?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ASupprimer.java | 24 ---- Affichage.java | 62 ++++++++ Cellules.java | 73 ++++++++++ ChoixEtTaille.java | 4 +- Ecrire.java | 12 -- Enregistrer.java | 35 ----- Exporter.java | 26 ---- ExporterFRG.java | 27 ---- ExporterFVG.java | 25 ---- FenetreImpGrille.java | 62 ++++---- FenetreInit.java | 4 +- FenetreRndmGrille.java | 150 +++++++++----------- FenetreVideGrille.java | 77 +++++----- GestionModif.java | 24 ++++ Modifications.java | 34 +++++ ModificationsFRG.java | 59 -------- ModificationsFVG.java | 59 -------- ModificationsTab.java | 57 ++++++++ OptionsBoutonsFRG.java | 24 ---- OptionsBoutonsFVG.java | 23 --- OptionsFVG.java | 130 ----------------- OptionsFRG.java => PanneauModification.java | 55 ++----- PrintGrille.java | 11 ++ README.md | 2 - SAVE.txt | 118 +++++++++++++++ TEMP.txt | 82 +++++++++++ creer.java | 8 +- importer.java | 4 +- 28 files changed, 616 insertions(+), 655 deletions(-) delete mode 100644 ASupprimer.java create mode 100644 Affichage.java create mode 100644 Cellules.java delete mode 100644 Ecrire.java delete mode 100644 Enregistrer.java delete mode 100644 Exporter.java delete mode 100644 ExporterFRG.java delete mode 100644 ExporterFVG.java create mode 100644 GestionModif.java create mode 100644 Modifications.java delete mode 100644 ModificationsFRG.java delete mode 100644 ModificationsFVG.java create mode 100644 ModificationsTab.java delete mode 100644 OptionsBoutonsFRG.java delete mode 100644 OptionsBoutonsFVG.java delete mode 100644 OptionsFVG.java rename OptionsFRG.java => PanneauModification.java (83%) create mode 100644 PrintGrille.java delete mode 100644 README.md create mode 100644 SAVE.txt create mode 100644 TEMP.txt diff --git a/ASupprimer.java b/ASupprimer.java deleted file mode 100644 index d6a9867..0000000 --- a/ASupprimer.java +++ /dev/null @@ -1,24 +0,0 @@ -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Random; - -public class ASupprimer { - - public static void main(String[] args) { - byte[] bytes = {9, 0, 0, 7, 7}; - String fileName = "Grand.lab"; - - try (FileOutputStream outputStream = new FileOutputStream(fileName)) { - outputStream.write(bytes); - System.out.println("Les 5 premiers octets ont été écrits avec succès !"); - - byte[] randomBytes = new byte[10]; - new Random().nextBytes(randomBytes); - outputStream.write(randomBytes); - System.out.println("10 octets aléatoires ont été ajoutés au fichier !"); - } catch (IOException e) { - System.err.println("Erreur lors de la création ou de l'écriture du fichier " + fileName); - e.printStackTrace(); - } - } -} diff --git a/Affichage.java b/Affichage.java new file mode 100644 index 0000000..e16bff8 --- /dev/null +++ b/Affichage.java @@ -0,0 +1,62 @@ +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; + + private Cellules cetteCellules; + private PanneauModification cePanel; + + private boolean cetEtat; + + private int[] caseEntrortie; + + public Affichage(Cellules uneCellules, PanneauModification unPanel, int[] tabEntre, boolean unEtat){ + this.cetteCellules = uneCellules; + this.cePanel = unPanel; + this.cetEtat = unEtat; + this.caseEntrortie = tabEntre; + + repaint(); + } + + public int[] getGateState(){ + return this.caseEntrortie; + } + + public void repaint(){ + // Accéder aux boutons radios de l'objet Options + boolean radio1Selected = this.cePanel.GetButtonBW().isSelected(); // MUR / COULOIR + boolean radio2Selected = this.cePanel.GetButtonE().isSelected(); // ENTREE + boolean radio3Selected = this.cePanel.GetButtonS().isSelected(); //SORTIE + + if(radio2Selected==true && this.caseEntrortie[0]==0){ + this.caseEntrortie[0]=1; + this.cetteCellules.setType(ENTREE); + this.cetteCellules.peindre(ENTREE); + } else if(radio3Selected==true && this.caseEntrortie[1]==0){ + this.caseEntrortie[1]=1; + this.cetteCellules.setType(SORTIE); + this.cetteCellules.peindre(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); + } 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); + } + } +} diff --git a/Cellules.java b/Cellules.java new file mode 100644 index 0000000..1b45704 --- /dev/null +++ b/Cellules.java @@ -0,0 +1,73 @@ +import java.awt.Color; +import javax.swing.JComponent; + +import java.awt.Graphics; + +public class Cellules extends JComponent{ + 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 Color backgroundColor; + + private int cetteLigne; + private int cetteColone; + private int ceType; + + public Cellules(int uneLigne, int uneColone, int type){ + super(); + this.cetteLigne=uneLigne; + this.cetteColone=uneColone; + + this.ceType = type; + + peindre(ceType); + } + + public int getLigne(){ + return this.cetteLigne; + } + + public int getColone(){ + return this.cetteColone; + } + + public int getType(){ + return this.ceType; + } + + public void setType(int newType){ + if(newType==COULOIR){ + this.ceType = COULOIR; + } else if(newType==MUR){ + this.ceType = MUR; + } else if(newType==ENTREE){ + this.ceType = ENTREE; + } else if(newType==SORTIE){ + this.ceType = SORTIE; + } + } + + public void peindre(int peinture){ + if(peinture==COULOIR){ + backgroundColor = Color.WHITE; + } else if(peinture==MUR){ + backgroundColor = Color.BLACK; + } else if(peinture==ENTREE){ + backgroundColor = Color.BLUE; + } else if(peinture==SORTIE){ + backgroundColor = Color.RED; + } + + repaint(); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + g.setColor(backgroundColor); + g.fillRect(0, 0, getWidth(), getHeight()); + } +} \ No newline at end of file diff --git a/ChoixEtTaille.java b/ChoixEtTaille.java index 21564a3..66af1a3 100644 --- a/ChoixEtTaille.java +++ b/ChoixEtTaille.java @@ -19,12 +19,12 @@ public class ChoixEtTaille extends JFrame implements ActionListener { if(this.ce_group.getSelection().getActionCommand()=="Grille randomisée"){ FenetreRndmGrille cette_fenetre = new FenetreRndmGrille(Integer.parseInt(valleur_taille)); - cette_fenetre.RandomGrille(); + cette_fenetre.randomGrille(); } else if(this.ce_group.getSelection().getActionCommand()=="Grille vide"){ FenetreVideGrille cette_fenetre = new FenetreVideGrille(Integer.parseInt(valleur_taille)); - cette_fenetre.CreerVide(); + cette_fenetre.videGrille(); } } } \ No newline at end of file diff --git a/Ecrire.java b/Ecrire.java deleted file mode 100644 index ef31d6a..0000000 --- a/Ecrire.java +++ /dev/null @@ -1,12 +0,0 @@ -import java.io.*; - -public class Ecrire { - - public Ecrire(String filePath, int[] tableau, int[] tableau2){ - try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) { - writer.write("Contenu du fichier"); - } catch (IOException ex) { - System.err.println("Une erreur s'est produite lors de l'écriture dans le fichier : " + ex.getMessage()); - } - } -} diff --git a/Enregistrer.java b/Enregistrer.java deleted file mode 100644 index b208f40..0000000 --- a/Enregistrer.java +++ /dev/null @@ -1,35 +0,0 @@ -import javax.swing.*; -import javax.swing.filechooser.FileNameExtensionFilter; -import java.io.*; - -public class Enregistrer { - - public Enregistrer(){ - - } - - public File GetPath(){ - JFileChooser fileChooser = new JFileChooser(); - fileChooser.setDialogTitle("Save file"); - - // Filtre pour n'afficher que les fichiers de type .txt - FileNameExtensionFilter filter = new FileNameExtensionFilter("Fichier hexadecimal (*.lab)", "lab"); - fileChooser.setFileFilter(filter); - - // Afficher la boîte de dialogue "enregistrer sous" - int userSelection = fileChooser.showSaveDialog(null); - - if (userSelection == JFileChooser.APPROVE_OPTION) { - File fileToSave = fileChooser.getSelectedFile(); - - // Ajouter l'extension .txt si elle n'a pas été saisie - if (!fileToSave.getAbsolutePath().endsWith(".lab")) { - fileToSave = new File(fileToSave.getAbsolutePath() + ".lab"); - } - - return fileToSave; - } - - return null; - } -} diff --git a/Exporter.java b/Exporter.java deleted file mode 100644 index e441fc9..0000000 --- a/Exporter.java +++ /dev/null @@ -1,26 +0,0 @@ -import javax.swing.JPanel; - -public class Exporter { - private int[] infos_grille; - private JPanel[][] composanteGrille; - private FenetreRndmGrille cetteFrg; - private int Taille; - - public Exporter(FenetreRndmGrille uneFrg){ - this.cetteFrg = uneFrg; - } - - public void jsp(){ - this.infos_grille=this.cetteFrg.get_info(); - this.Taille=this.infos_grille[0]; - this.composanteGrille=this.cetteFrg.getGrille(); - for(int i=0; i