From 180a4e23fec3e9fb4560f7ddd4abd1d138fe5a4e Mon Sep 17 00:00:00 2001 From: fauvet Date: Tue, 18 Apr 2023 12:29:43 +0200 Subject: [PATCH] UPDATE 1>10 - Creation bon GIT - voir SAE21_2023 --- .vscode/launch.json | 21 +++++++ Exporter.java | 26 +++++++++ Fenetre.java | 17 ++++++ FenetreDefSize.java | 81 +++++++++++++++++++++++++ FenetreImpGrille.java | 68 +++++++++++++++++++++ FenetreInit.java | 57 ++++++++++++++++++ FenetreRndmGrille.java | 116 ++++++++++++++++++++++++++++++++++++ FenetreVideGrille.java | 38 ++++++++++++ FileImport.java | 22 +++++++ Lecture.java | 119 +++++++++++++++++++++++++++++++++++++ ModificationsFRG.java | 59 +++++++++++++++++++ ModificationsFVG.java | 59 +++++++++++++++++++ OptionsBoutonsFRG.java | 24 ++++++++ OptionsBoutonsFVG.java | 19 ++++++ OptionsFRG.java | 130 +++++++++++++++++++++++++++++++++++++++++ OptionsFVG.java | 129 ++++++++++++++++++++++++++++++++++++++++ Start.java | 6 ++ azert.java | 19 ++++++ creer.java | 21 +++++++ importer.java | 46 +++++++++++++++ outils.java | 43 ++++++++++++++ petit.lab | Bin 0 -> 7 bytes taille_su.java | 30 ++++++++++ 23 files changed, 1150 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 Exporter.java create mode 100644 Fenetre.java create mode 100644 FenetreDefSize.java create mode 100644 FenetreImpGrille.java create mode 100644 FenetreInit.java create mode 100644 FenetreRndmGrille.java create mode 100644 FenetreVideGrille.java create mode 100644 FileImport.java create mode 100644 Lecture.java create mode 100644 ModificationsFRG.java create mode 100644 ModificationsFVG.java create mode 100644 OptionsBoutonsFRG.java create mode 100644 OptionsBoutonsFVG.java create mode 100644 OptionsFRG.java create mode 100644 OptionsFVG.java create mode 100644 Start.java create mode 100644 azert.java create mode 100644 creer.java create mode 100644 importer.java create mode 100644 outils.java create mode 100644 petit.lab create mode 100644 taille_su.java diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..7ae62a4 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "Current File", + "request": "launch", + "mainClass": "${file}" + }, + { + "type": "java", + "name": "test", + "request": "launch", + "mainClass": "test", + "projectName": "SAE21_2023_49188ab1" + } + ] +} \ No newline at end of file diff --git a/Exporter.java b/Exporter.java new file mode 100644 index 0000000..adccee6 --- /dev/null +++ b/Exporter.java @@ -0,0 +1,26 @@ +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; + } + + protected 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> 1; + } + + ce_tab_to_return = ToolBox.concatenate(ce_tab_to_return, ToolBox.reverse(ce_tableau_temp)); + } + + /* =================================================================================================================================== */ + + try{ + fis.close(); + } catch(IOException e){ + System.out.println("erreur lors de la fermeture"); + return null; + } + return ce_tab_to_return; + } + catch(IOException e){ + System.out.println("erreur d'ouverture"); + return null; + } + } +} diff --git a/ModificationsFRG.java b/ModificationsFRG.java new file mode 100644 index 0000000..f184ab3 --- /dev/null +++ b/ModificationsFRG.java @@ -0,0 +1,59 @@ +import java.awt.event.*; +import javax.swing.JPanel; + +import java.awt.*; + +public class ModificationsFRG implements MouseListener { + private int[] ce_tableau ; + private OptionsFRG options; + + public ModificationsFRG(OptionsFRG options, int[] un_tab){ + this.options = options; + this.ce_tableau = un_tab; + } + + public void mouseClicked(MouseEvent e) { + JPanel notre_Panel = (JPanel) e.getSource(); + + Color test = notre_Panel.getBackground(); + + // Accéder aux boutons radios de l'objet Options + boolean radio1Selected = options.GetButtonBW().isSelected(); + boolean radio2Selected = options.GetButtonE().isSelected(); + boolean radio3Selected = options.GetButtonS().isSelected(); + + if(test==Color.WHITE && radio1Selected==true){ + notre_Panel.setBackground(Color.BLACK); + } else if(test==Color.BLACK && radio1Selected==true){ + notre_Panel.setBackground(Color.WHITE); + }else if(radio1Selected==true && (test==Color.RED || test==Color.BLUE)){ + if(test==Color.BLUE){ + notre_Panel.setBackground(Color.WHITE); + this.ce_tableau[0] = 0; + } else if(test==Color.RED){ + notre_Panel.setBackground(Color.WHITE); + this.ce_tableau[1] = 0; + } + } else if(test!=Color.BLUE && radio2Selected==true && this.ce_tableau[0]==0){ + notre_Panel.setBackground(Color.BLUE); + this.ce_tableau[0]=1; + } else if(test!=Color.RED && radio3Selected==true && this.ce_tableau[1]==0){ + this.ce_tableau[1]=1; + notre_Panel.setBackground(Color.RED); + } + + } + + protected int[] getValues(){ + return this.ce_tableau; + } + + public void mouseExited(MouseEvent e) { + // Laisser cette méthode vide si vous n'avez pas besoin de l'utiliser + } + + // Les méthodes suivantes ne sont pas utilisées dans cet exemple, donc nous les laissons vides + public void mouseReleased(MouseEvent e) {} + public void mousePressed(MouseEvent e) {} + public void mouseEntered(MouseEvent e) {} +} diff --git a/ModificationsFVG.java b/ModificationsFVG.java new file mode 100644 index 0000000..a307691 --- /dev/null +++ b/ModificationsFVG.java @@ -0,0 +1,59 @@ +import java.awt.event.*; +import javax.swing.JPanel; + +import java.awt.*; + +public class ModificationsFVG implements MouseListener { + private int[] ce_tableau ; + private OptionsFVG options; + + public ModificationsFVG(OptionsFVG options, int[] un_tab){ + this.options = options; + this.ce_tableau = un_tab; + } + + public void mouseClicked(MouseEvent e) { + JPanel notre_Panel = (JPanel) e.getSource(); + + Color test = notre_Panel.getBackground(); + + // Accéder aux boutons radios de l'objet Options + boolean radio1Selected = options.GetButtonBW().isSelected(); + boolean radio2Selected = options.GetButtonE().isSelected(); + boolean radio3Selected = options.GetButtonS().isSelected(); + + if(test==Color.WHITE && radio1Selected==true){ + notre_Panel.setBackground(Color.BLACK); + } else if(test==Color.BLACK && radio1Selected==true){ + notre_Panel.setBackground(Color.WHITE); + }else if(radio1Selected==true && (test==Color.RED || test==Color.BLUE)){ + if(test==Color.BLUE){ + notre_Panel.setBackground(Color.WHITE); + this.ce_tableau[0] = 0; + } else if(test==Color.RED){ + notre_Panel.setBackground(Color.WHITE); + this.ce_tableau[1] = 0; + } + } else if(test!=Color.BLUE && radio2Selected==true && this.ce_tableau[0]==0){ + notre_Panel.setBackground(Color.BLUE); + this.ce_tableau[0]=1; + } else if(test!=Color.RED && radio3Selected==true && this.ce_tableau[1]==0){ + this.ce_tableau[1]=1; + notre_Panel.setBackground(Color.RED); + } + + } + + protected int[] getValues(){ + return this.ce_tableau; + } + + public void mouseExited(MouseEvent e) { + // Laisser cette méthode vide si vous n'avez pas besoin de l'utiliser + } + + // Les méthodes suivantes ne sont pas utilisées dans cet exemple, donc nous les laissons vides + public void mouseReleased(MouseEvent e) {} + public void mousePressed(MouseEvent e) {} + public void mouseEntered(MouseEvent e) {} +} diff --git a/OptionsBoutonsFRG.java b/OptionsBoutonsFRG.java new file mode 100644 index 0000000..28dee7c --- /dev/null +++ b/OptionsBoutonsFRG.java @@ -0,0 +1,24 @@ +import java.awt.event.*; + +public class OptionsBoutonsFRG implements ActionListener{ + private String Reponses1="Quitter", Reponses2="Sauvegarder"; + private String cet_event; + private Exporter test; + private FenetreRndmGrille ce_frg; + + protected OptionsBoutonsFRG(FenetreRndmGrille un_frg){ + this.ce_frg = un_frg; + } + + public void actionPerformed(ActionEvent e){ + this.cet_event=e.getActionCommand(); + if (cet_event.equals(this.Reponses1)){ + System.exit(1); + } + else if (cet_event.equals(this.Reponses2)){ + System.out.println("Test1"); + this.test = new Exporter(this.ce_frg); + this.test.jsp(); + } + } +} \ No newline at end of file diff --git a/OptionsBoutonsFVG.java b/OptionsBoutonsFVG.java new file mode 100644 index 0000000..56fb319 --- /dev/null +++ b/OptionsBoutonsFVG.java @@ -0,0 +1,19 @@ +import java.awt.event.*; + +public class OptionsBoutonsFVG implements ActionListener{ + private String Reponses1="Quitter", Reponses2="Sauvegarder"; + private String cet_event; + + protected OptionsBoutonsFVG(FenetreVideGrille FVG){ + + } + + public void actionPerformed(ActionEvent e){ + this.cet_event=e.getActionCommand(); + if (cet_event.equals(this.Reponses1)){ + System.exit(1); + } + else if (cet_event.equals(this.Reponses2)){ + } + } +} \ No newline at end of file diff --git a/OptionsFRG.java b/OptionsFRG.java new file mode 100644 index 0000000..e1591ea --- /dev/null +++ b/OptionsFRG.java @@ -0,0 +1,130 @@ +import java.awt.*; +import javax.swing.*; + +public class OptionsFRG extends Fenetre { + public JRadioButton radio1; + public JRadioButton radio2; + public JRadioButton radio3; + private FenetreRndmGrille ce_frg; + + public OptionsFRG(FenetreRndmGrille un_frg){ + super(); + this.fenetre.setSize(400, 600); + this.fenetre.setLocation(1100, 200); + this.ce_frg = un_frg; + } + + protected void SetUp(){ + GridLayout gestionnaire = new GridLayout(4,1); + this.fenetre.setLayout(gestionnaire); + + /* Création du premier panneau */ + + JLabel un_d_text = new JLabel(" Etape 1 : création du labyrinthe"); + + JPanel un_Panel = new JPanel(); + un_Panel.setBackground(Color.CYAN); + + un_Panel.add(un_d_text, BorderLayout.CENTER); + + JPanel un_Panel2 = new JPanel(); + un_Panel2.setBackground(Color.CYAN); + un_Panel2.setLayout(new BoxLayout(un_Panel2, BoxLayout.Y_AXIS)); + un_Panel2.add(Box.createVerticalGlue()); + un_Panel2.add(un_Panel); + un_Panel2.add(Box.createVerticalGlue()); + + this.fenetre.add(un_Panel2, BorderLayout.CENTER); + + /*Création du deuxième panneau */ + + JPanel un_Panel3 = new JPanel(); + JButton un_Button1 = new JButton("Sauvegarder"); + + JPanel un_Panel4 = new JPanel(); + un_Panel4.add(un_Button1); + + un_Panel3.setBackground(Color.CYAN); + un_Panel4.setBackground(Color.CYAN); + + un_Panel3.setBackground(Color.CYAN); + un_Panel3.setLayout(new BoxLayout(un_Panel3, BoxLayout.Y_AXIS)); + un_Panel3.add(Box.createVerticalGlue()); + un_Panel3.add(un_Panel4); + un_Panel3.add(Box.createVerticalGlue()); + + this.fenetre.add(un_Panel3, BorderLayout.CENTER); + + /* Nouveau panneau grille choix */ + + JPanel un_Panel10 = new JPanel(); + JPanel un_Panel11 = new JPanel(); + + radio1 = new JRadioButton("Construire ou Effacer"); + radio2 = new JRadioButton("Entrée"); + radio3 = new JRadioButton("Sortie"); + + radio1.setBackground(Color.CYAN); + radio2.setBackground(Color.CYAN); + radio3.setBackground(Color.CYAN); + + radio1.setSelected(true); + + ButtonGroup group = new ButtonGroup(); + group.add(radio1);group.add(radio2); group.add(radio3); + + un_Panel11.add(radio1); + un_Panel11.add(radio2); + un_Panel11.add(radio3); + + un_Panel10.setBackground(Color.CYAN); + un_Panel10.setLayout(new BoxLayout(un_Panel10, BoxLayout.Y_AXIS)); + un_Panel10.add(Box.createVerticalGlue()); + un_Panel10.add(un_Panel11); + un_Panel10.add(Box.createVerticalGlue()); + + + un_Panel10.setBackground(Color.CYAN); + un_Panel11.setBackground(Color.CYAN); + this.fenetre.add(un_Panel10, BorderLayout.CENTER); + + /*Création du deuxième panneau */ + + JPanel un_Panel5 = new JPanel(); + JButton un_Button2 = new JButton("Quitter"); + + JPanel un_Panel6 = new JPanel(); + un_Panel6.add(un_Button2, BorderLayout.CENTER); + + un_Panel5.setBackground(Color.CYAN); + un_Panel6.setBackground(Color.CYAN); + + un_Panel5.setBackground(Color.CYAN); + un_Panel5.setLayout(new BoxLayout(un_Panel5, BoxLayout.Y_AXIS)); + un_Panel5.add(Box.createVerticalGlue()); + un_Panel5.add(un_Panel6); + un_Panel5.add(Box.createVerticalGlue()); + + this.fenetre.add(un_Panel5, BorderLayout.CENTER); + + /* */ + + OptionsBoutonsFRG hahaha = new OptionsBoutonsFRG(this.ce_frg); + un_Button1.addActionListener(hahaha); + un_Button2.addActionListener(hahaha); + + /* Evenement */ + + this.fenetre.setVisible(true); + } + + protected JRadioButton GetButtonBW() { + return radio1; + } + protected JRadioButton GetButtonE() { + return radio2; + } + protected JRadioButton GetButtonS() { + return radio3; + } +} diff --git a/OptionsFVG.java b/OptionsFVG.java new file mode 100644 index 0000000..6608ffa --- /dev/null +++ b/OptionsFVG.java @@ -0,0 +1,129 @@ +import java.awt.*; +import javax.swing.*; + +public class OptionsFVG extends Fenetre { + public JRadioButton radio1; + public JRadioButton radio2; + public JRadioButton radio3; + private FenetreVideGrille FVG; + + public OptionsFVG(FenetreVideGrille FVG) { + super(); + this.fenetre.setSize(400, 600); + this.fenetre.setLocation(1100, 200); + } + + protected void set_up(){ + GridLayout gestionnaire = new GridLayout(4,1); + this.fenetre.setLayout(gestionnaire); + + /* Création du premier panneau */ + + JLabel un_d_text = new JLabel(" Etape 1 : création du labyrinthe"); + + JPanel un_Panel = new JPanel(); + un_Panel.setBackground(Color.CYAN); + + un_Panel.add(un_d_text, BorderLayout.CENTER); + + JPanel un_Panel2 = new JPanel(); + un_Panel2.setBackground(Color.CYAN); + un_Panel2.setLayout(new BoxLayout(un_Panel2, BoxLayout.Y_AXIS)); + un_Panel2.add(Box.createVerticalGlue()); + un_Panel2.add(un_Panel); + un_Panel2.add(Box.createVerticalGlue()); + + this.fenetre.add(un_Panel2, BorderLayout.CENTER); + + /*Création du deuxième panneau */ + + JPanel un_Panel3 = new JPanel(); + JButton un_Button1 = new JButton("Sauvegrder"); + + JPanel un_Panel4 = new JPanel(); + un_Panel4.add(un_Button1); + + un_Panel3.setBackground(Color.CYAN); + un_Panel4.setBackground(Color.CYAN); + + un_Panel3.setBackground(Color.CYAN); + un_Panel3.setLayout(new BoxLayout(un_Panel3, BoxLayout.Y_AXIS)); + un_Panel3.add(Box.createVerticalGlue()); + un_Panel3.add(un_Panel4); + un_Panel3.add(Box.createVerticalGlue()); + + this.fenetre.add(un_Panel3, BorderLayout.CENTER); + + /* Nouveau panneau grille choix */ + + JPanel un_Panel10 = new JPanel(); + JPanel un_Panel11 = new JPanel(); + + radio1 = new JRadioButton("Mur et Couloir"); + radio2 = new JRadioButton("Entrée"); + radio3 = new JRadioButton("Sortie"); + + radio1.setBackground(Color.CYAN); + radio2.setBackground(Color.CYAN); + radio3.setBackground(Color.CYAN); + + radio1.setSelected(true); + + ButtonGroup group = new ButtonGroup(); + group.add(radio1);group.add(radio2); group.add(radio3); + + un_Panel11.add(radio1); + un_Panel11.add(radio2); + un_Panel11.add(radio3); + + un_Panel10.setBackground(Color.CYAN); + un_Panel10.setLayout(new BoxLayout(un_Panel10, BoxLayout.Y_AXIS)); + un_Panel10.add(Box.createVerticalGlue()); + un_Panel10.add(un_Panel11); + un_Panel10.add(Box.createVerticalGlue()); + + + un_Panel10.setBackground(Color.CYAN); + un_Panel11.setBackground(Color.CYAN); + this.fenetre.add(un_Panel10, BorderLayout.CENTER); + + /*Création du deuxième panneau */ + + JPanel un_Panel5 = new JPanel(); + JButton un_Button2 = new JButton("Quitter"); + + JPanel un_Panel6 = new JPanel(); + un_Panel6.add(un_Button2, BorderLayout.CENTER); + + un_Panel5.setBackground(Color.CYAN); + un_Panel6.setBackground(Color.CYAN); + + un_Panel5.setBackground(Color.CYAN); + un_Panel5.setLayout(new BoxLayout(un_Panel5, BoxLayout.Y_AXIS)); + un_Panel5.add(Box.createVerticalGlue()); + un_Panel5.add(un_Panel6); + un_Panel5.add(Box.createVerticalGlue()); + + this.fenetre.add(un_Panel5, BorderLayout.CENTER); + + /* */ + + OptionsBoutonsFVG hahaha = new OptionsBoutonsFVG(this.FVG); + un_Button1.addActionListener(hahaha); + un_Button2.addActionListener(hahaha); + + /* Evenement */ + + this.fenetre.setVisible(true); + } + + protected JRadioButton GetButtonBW() { + return radio1; + } + protected JRadioButton GetButtonE() { + return radio2; + } + protected JRadioButton GetButtonS() { + return radio3; + } +} diff --git a/Start.java b/Start.java new file mode 100644 index 0000000..2ea58f7 --- /dev/null +++ b/Start.java @@ -0,0 +1,6 @@ +public class Start { + public static void main(String[] args) { + FenetreInit une_fenetre = new FenetreInit(); + une_fenetre.Initialisation(); + } +} \ No newline at end of file diff --git a/azert.java b/azert.java new file mode 100644 index 0000000..7b1c526 --- /dev/null +++ b/azert.java @@ -0,0 +1,19 @@ +public class azert { + public static void main(String[] Args){ + int i = 6, j, compteur=0; + int[] tab = new int[8]; + int[] copie = new int[8]; + for(j=0; j<8; j++){ + tab[j] = i&1; + i = i >> 1; + /*System.out.println(j+" bits reverse = "+tab[j]);*/ + } + for(j=7; j>0; j--){ + copie[j]=tab[compteur]; + compteur++; + } + for(j=0; j<8; j++){ + System.out.println(j+" bits reverse = "+copie[j]); + } + } +} \ No newline at end of file diff --git a/creer.java b/creer.java new file mode 100644 index 0000000..50307f9 --- /dev/null +++ b/creer.java @@ -0,0 +1,21 @@ +import javax.swing.*; +import java.awt.event.*; + +public class creer implements ActionListener { + private String cet_event, f_option = "Nouvelle Grille"; + private JFrame cette_frame; + + public creer(JFrame frame_initial){ + super(); + this.cette_frame=frame_initial; + } + + public void actionPerformed(ActionEvent e){ + this.cet_event=e.getActionCommand(); + this.cette_frame.dispose(); + if (cet_event.equals(f_option)){ + FenetreDefSize hehe = new FenetreDefSize(); + hehe.MiseEnPlace(); + } + } +} \ No newline at end of file diff --git a/importer.java b/importer.java new file mode 100644 index 0000000..d56fbac --- /dev/null +++ b/importer.java @@ -0,0 +1,46 @@ +import java.awt.event.*; +import javax.swing.JFrame; + +public class importer implements ActionListener { + String cette_option; + String cet_event; + String ce_chemin; + JFrame cette_frame; + Lecture cette_lecture; + FenetreImpGrille cette_fenetre; + int valeur0, valeur1, valeur2, valeur3, valeur4; + + + public importer(JFrame une_frame){ + this.cette_option="Importer Grille"; + this.cette_frame = une_frame; + } + + public void actionPerformed(ActionEvent e){ + this.cet_event=e.getActionCommand(); + if(cet_event.equals(this.cette_option)){ + System.out.println("Importation de la grille"); + + /*cherche le chemin du fichier */ + FileImport un_test = new FileImport(); + this.ce_chemin = un_test.Parcours(); + + /*lecture du fichier */ + this.cette_lecture = new Lecture(this.ce_chemin); + this.valeur0=this.cette_lecture.GetHeader(0); + this.valeur1=this.cette_lecture.GetHeader(1); + this.valeur2=this.cette_lecture.GetHeader(2); + this.valeur3=this.cette_lecture.GetHeader(3); + this.valeur4=this.cette_lecture.GetHeader(4); + + /*Fermeture de la première fenètre */ + cette_frame.dispose(); + + /* Ouverture de la nouvelle */ + + this.cette_fenetre = new FenetreImpGrille(); + + cette_fenetre.ImporterGrille(this.valeur0, this.valeur1, this.valeur2, this.valeur3, this.valeur4, this.cette_lecture.GetOffset()); + } + } +} \ No newline at end of file diff --git a/outils.java b/outils.java new file mode 100644 index 0000000..388c167 --- /dev/null +++ b/outils.java @@ -0,0 +1,43 @@ +public class outils { + protected outils(){ + } + + public int[] reverse(int[] un_tableau) { + int taille = un_tableau.length; + + int[] cette_copie; + cette_copie = new int[un_tableau.length]; + int compteur=taille; + + for(int j=0; j