From e987137fe7df2b9500686b85fd9dbb1c3d17996b Mon Sep 17 00:00:00 2001 From: piquerez <corentin.piquerez1@etu.univ-lorraine.fr> Date: Wed, 24 May 2023 14:27:52 +0200 Subject: [PATCH] =?UTF-8?q?th=C3=A8me=20sombre=20d=C3=A9but,=20profs=20dan?= =?UTF-8?q?s=20fenetre=20de=20pr=C3=A9cision=20en=20cours?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shukan/ShukanController.java | 2 +- shukan/ShukanParameters.java | 15 +++++++++------ shukan/ShukanView.java | 19 ++++++++++++++++--- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/shukan/ShukanController.java b/shukan/ShukanController.java index 202d135..c0469ec 100644 --- a/shukan/ShukanController.java +++ b/shukan/ShukanController.java @@ -232,7 +232,7 @@ public class ShukanController new ShukanTex (data); else if (e.getSource()==bar.buttons[7]){ EventQueue.invokeLater(() -> { - ShukanParameters myParameters = new ShukanParameters("Changer de thème"); + ShukanParameters myParameters = new ShukanParameters("Changer de thème", canvas); myParameters.setSize(300, 300); myParameters.setVisible(true); }); diff --git a/shukan/ShukanParameters.java b/shukan/ShukanParameters.java index f97a2da..ebf29f0 100644 --- a/shukan/ShukanParameters.java +++ b/shukan/ShukanParameters.java @@ -11,10 +11,12 @@ class ShukanParameters extends JFrame { private JPanel pPrincipal,p, p1; /** buttons of the graphic interface */ private JButton changerdetheme, theme1, theme2, theme3, retour, changertouches, changercouleurs; - + /** view of the app */ + private ShukanView canvas; /** built a parameter window */ - public ShukanParameters(String titre) { + public ShukanParameters(String titre, ShukanView canvas) { super(titre); + this.canvas = canvas; p = new JPanel(new GridBagLayout()); GridBagConstraints gbcprinc = new GridBagConstraints(); @@ -41,11 +43,12 @@ class ShukanParameters extends JFrame { theme1 = new JButton("Thème sombre"); theme1.setPreferredSize(new Dimension(150, 25)); - /*theme1.addActionListener(new ActionListener() { - public void actionPerformed(ActionEVent e) { - getContentPane().setBackground(Color.BLACK); + theme1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + canvas.setBackgroundColor(Color.BLACK); } - });*/ + }); theme2 = new JButton("Thème clair"); theme2.setPreferredSize(new Dimension(150, 25)); diff --git a/shukan/ShukanView.java b/shukan/ShukanView.java index ae2c613..85cf540 100644 --- a/shukan/ShukanView.java +++ b/shukan/ShukanView.java @@ -65,7 +65,7 @@ public class ShukanView extends JPanel /** Background color */ - private final Color BACK_COLOR = Color.WHITE; + private Color BACK_COLOR = Color.WHITE; /** Grid color */ private final Color GRID_COLOR = Color.BLACK; /** Free module weeks color */ @@ -377,6 +377,7 @@ public class ShukanView extends JPanel int num_module = data.selectedModule(); int num_cursus = data.cursusNumber(); int num_semaine = data.selectedWeek()+data.startWeekNumber(); + // affiche la fenetre si il y a cours pendant cette periode if(data.isActiveWeek(num_semaine, num_module)) { @@ -385,6 +386,7 @@ public class ShukanView extends JPanel int[] week_activities = data.scheduleInWeek(num_module, data.selectedWeek()); int[] activities = data.activities(num_module); int nb_cours = week_activities.length; + boolean rajout_prof = false; JPanel cours = new JPanel(new GridLayout(nb_cours*3, 1)); JLabel[] noms_cours = new JLabel[nb_cours]; @@ -392,10 +394,17 @@ public class ShukanView extends JPanel JLabel[] profs = new JLabel[nb_cours]; for (int i =0; i<nb_cours; i++) { + String[] teachers = data.moduleTeachers(num_cursus, num_module, activities[week_activities[i]]); + String nom_profs = teachers[0]; + for (int j = 1; j<teachers.length; j++) + { + nom_profs+=" / "+teachers[j]; + } + System.out.println(); noms_cours[i] = new JLabel("Cours : "+data.activityName(activities[week_activities[i]])); noms_cours[i].setFont(new Font(noms_cours[i].getFont().getFamily(), noms_cours[i].getFont().getStyle()+Font.BOLD, noms_cours[i].getFont().getSize()+10)); duree[i] = new JLabel(" Durée : "+data.activityDuration(activities[week_activities[i]])+"h"); - profs[i] = new JLabel(" Professeur : "+data.subtitle(num_module)); + profs[i] = new JLabel(" Professeur : "+ nom_profs); cours.add(noms_cours[i]); cours.add(duree[i]); cours.add(profs[i]); @@ -407,5 +416,9 @@ public class ShukanView extends JPanel } } - + /** change the background color */ + public void setBackgroundColor(Color c){ + BACK_COLOR = c; + repaint(); + } } -- GitLab