correction de bug MPD et premiere navigation Groupe et Etudiant

This commit is contained in:
2022-11-13 04:01:11 +01:00
parent 82c4b78930
commit 5116d7a998
9 changed files with 166 additions and 90 deletions

View File

@@ -0,0 +1,23 @@
package fr.iutfbleau.projetIHM2022FI2.Graphic.View;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.GridLayout;
import java.util.Set;
import fr.iutfbleau.projetIHM2022FI2.API.Etudiant;
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
public class FenetreEtudiant extends JPanel{
private Set<Etudiant> etu;
public FenetreEtudiant(Groupe g){
super(new GridLayout(57, 1));
this.etu=g.getEtudiants();
for(Etudiant e: this.etu){
this.add(new JLabel(e.monPrint()));
}
}
}

View File

@@ -0,0 +1,32 @@
package fr.iutfbleau.projetIHM2022FI2.Graphic.View;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.GridLayout;
import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
import fr.iutfbleau.projetIHM2022FI2.Graphic.Model;
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurChangeGroupe;
public class FenetreGroupe extends JPanel{
private Groupe g;
public FenetreGroupe(Groupe g, Model m){
super(new GridLayout(15, 1));
this.g=g;
JButton bout=new JButton("point point");
bout.addActionListener(new ObservateurChangeGroupe(m, this.g.getPointPoint()));
this.add(bout);
this.add(new JLabel(g.getName()));
this.add(new JLabel("id= "+String.valueOf(g.getId())));
this.add(new JLabel("min= "+String.valueOf(g.getMin())));
this.add(new JLabel("max= "+String.valueOf(g.getMax())));
this.add(new JLabel("Sous groupe"));
for(Groupe gr: g.getSousGroupes()){
JButton b=new JButton(gr.getName());
b.addActionListener(new ObservateurChangeGroupe(m, gr));
this.add(b);
}
}
}

View File

@@ -1,52 +0,0 @@
package fr.iutfbleau.projetIHM2022FI2.Graphic.View;
import fr.iutfbleau.projetIHM2022FI2.API.*;
import javax.swing.JComponent;
import java.awt.Graphics;
import java.util.LinkedList;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontMetrics;
public class PaintGroupe extends JComponent {
private LinkedList<Groupe> tabGroupe=new LinkedList<Groupe>();
public PaintGroupe(){}
@Override
protected void paintComponent(Graphics pinceau) {
// obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard
Graphics secondPinceau = pinceau.create();
// obligatoire : si le composant n'est pas censé être transparent
if (this.isOpaque()) {
// obligatoire : on repeint toute la surface avec la couleur de fond
secondPinceau.setColor(this.getBackground());
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
}
// maintenant on dessine ce que l'on veut
secondPinceau.setColor(this.getForeground());
int y=100;
for(Groupe g: this.tabGroupe){
secondPinceau.setColor(Color.BLACK);
secondPinceau.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 40));
FontMetrics metrics = secondPinceau.getFontMetrics(secondPinceau.getFont());
secondPinceau.drawString(g.getName().toUpperCase(), (this.getWidth()/2-metrics.stringWidth(g.getName().toUpperCase())/2), (y-metrics.getAscent()));
g.getName();
y+=100;
}
}
public void addGroupe(Groupe g){
this.tabGroupe.add(g);
this.repaint();
}
public boolean removeGroupe(Groupe g){
int i=this.tabGroupe.indexOf(g);
if(i==-1){
return false;
}else{
this.tabGroupe.remove(i);
}
this.repaint();
return true;
}
}