Ajout chargement pour faire styler
This commit is contained in:
parent
c06ff537ad
commit
e9fac29412
@ -105,10 +105,13 @@ ${BUILD}/Graphic/View/FenetreEtudiant.class :${SRC}/Graphic/View/FenetreEtudiant
|
||||
${BUILD}/Graphic/Controller/ObservateurChangeGroupe.class
|
||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/View/FenetreEtudiant.java
|
||||
|
||||
${BUILD}/Graphic/View/Chargement.class : ${SRC}/Graphic/View/Chargement.java
|
||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/View/Chargement.java
|
||||
|
||||
${BUILD}/Graphic/Model.class : ${SRC}/Graphic/Model.java \
|
||||
${BUILD}/Graphic/View/FenetreGroupe.class \
|
||||
${BUILD}/Graphic/View/FenetreEtudiant.class
|
||||
${BUILD}/Graphic/View/FenetreEtudiant.class \
|
||||
${BUILD}/Graphic/View/Chargement.class
|
||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/Model.java
|
||||
|
||||
## Controller ##
|
||||
|
@ -20,6 +20,7 @@ import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.API.TypeGroupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurChangeGroupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurFenetre;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.Chargement;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.FenetreEtudiant;
|
||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.FenetreGroupe;
|
||||
import fr.iutfbleau.projetIHM2022FI2.MNP.AbstractGroupeFactoryNP;
|
||||
@ -32,9 +33,30 @@ public class Model{
|
||||
private Set<Groupe> promo;
|
||||
private JFrame fenetre;
|
||||
public Model(){
|
||||
this.getPromo();
|
||||
this.fenetre=new JFrame();
|
||||
this.fenetre.setSize(1200, 720);
|
||||
this.fenetre.setLocation(100,100);
|
||||
Chargement ch=new Chargement();
|
||||
this.fenetre.add(ch, BorderLayout.CENTER);
|
||||
this.fenetre.setVisible(true);
|
||||
this.promo=new LinkedHashSet<>();
|
||||
this.getPromo(ch);
|
||||
switch(this.promo.size()){
|
||||
case 0:
|
||||
this.fenGr=new FenetreGroupe(null, this);
|
||||
this.fenEtu=new FenetreEtudiant(null);
|
||||
break;
|
||||
case 1:
|
||||
this.fenGr=new FenetreGroupe(this.promo.iterator().next(), this);
|
||||
this.fenEtu=new FenetreEtudiant(this.promo.iterator().next());
|
||||
break;
|
||||
default:
|
||||
this.fenGr=new FenetreGroupe(this.promo.iterator().next(), this);
|
||||
this.fenEtu=new FenetreEtudiant(this.promo.iterator().next());
|
||||
//modifier le boutou pour changer de promo
|
||||
break;
|
||||
}
|
||||
this.fenetre.dispose();
|
||||
this.fenetre=new JFrame();
|
||||
this.fenetre.setSize(1200, 720);
|
||||
this.fenetre.setLocation(100,100);
|
||||
@ -46,8 +68,7 @@ public class Model{
|
||||
this.fenetre.setVisible(true);
|
||||
}
|
||||
|
||||
private void getPromo(){
|
||||
this.promo=new LinkedHashSet<>();
|
||||
private void getPromo(Chargement chargement){
|
||||
try{
|
||||
Class.forName("org.mariadb.jdbc.Driver");
|
||||
try{
|
||||
@ -60,12 +81,15 @@ public class Model{
|
||||
"SELECT `id`, `nom`, `min`, `max`, `value`, `id-parent` FROM `Groupe` join `TYPE` on Groupe.Type=TYPE.name where Groupe.id=`Groupe`.`id-parent` ORDER BY Groupe.id ASC;");
|
||||
try{
|
||||
ResultSet rs = pst.executeQuery();
|
||||
rs.last();
|
||||
int nbpromo=rs.getRow();
|
||||
rs=pst.executeQuery();
|
||||
try{
|
||||
while(rs.next()){
|
||||
//on image qu'il puisse avoir plusieur promo
|
||||
this.promo.add(new GroupeNP(rs.getInt(1), rs.getString(2), rs.getInt(3), rs.getInt(4), TypeGroupe.getType(rs.getString(5)), null));
|
||||
//on y ajoute tous ses sous-groupe
|
||||
this.addSousGroupe(promo.iterator().next(), cnx);
|
||||
this.addSousGroupe(promo.iterator().next(), cnx, chargement, 100/nbpromo);
|
||||
}
|
||||
}catch(SQLException e){
|
||||
System.out.println("erreur dans la prise de resultat");
|
||||
@ -86,7 +110,7 @@ public class Model{
|
||||
System.out.println("pilote non disponible");
|
||||
}
|
||||
}
|
||||
private void addSousGroupe(Groupe g, Connection cnx){
|
||||
private void addSousGroupe(Groupe g, Connection cnx, Chargement ch, int pourcent){
|
||||
this.addEtudiant(g, cnx);
|
||||
try{
|
||||
PreparedStatement pst= cnx.prepareStatement(
|
||||
@ -94,11 +118,19 @@ public class Model{
|
||||
try{
|
||||
pst.setString(1, String.valueOf(g.getId()));
|
||||
ResultSet rs=pst.executeQuery();
|
||||
rs.last();
|
||||
int nbsous=rs.getRow();
|
||||
if(nbsous==0){
|
||||
ch.addPourcent(pourcent);
|
||||
System.out.println("add ce pourcentage: "+pourcent);
|
||||
return;
|
||||
}
|
||||
rs=pst.executeQuery();
|
||||
try{
|
||||
while(rs.next()){
|
||||
Groupe nouveau=new GroupeNP(rs.getInt(1), rs.getString(2), rs.getInt(3), rs.getInt(4), TypeGroupe.getType(rs.getString(5)), g);
|
||||
g.addSousGroupe(nouveau);
|
||||
this.addSousGroupe(nouveau, cnx);
|
||||
this.addSousGroupe(nouveau, cnx, ch, pourcent/nbsous);
|
||||
}
|
||||
}catch(SQLException e){
|
||||
System.out.println("erreur dans la prise de resultat");
|
||||
@ -113,6 +145,7 @@ public class Model{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addEtudiant(Groupe g, Connection cnx){
|
||||
try{
|
||||
PreparedStatement pst= cnx.prepareStatement(
|
||||
|
@ -0,0 +1,42 @@
|
||||
package fr.iutfbleau.projetIHM2022FI2.Graphic.View;
|
||||
|
||||
import java.awt.Graphics;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Class Dessinant les boutons du menu
|
||||
*/
|
||||
public class Chargement extends JComponent{
|
||||
private int pourcentage;
|
||||
|
||||
public Chargement(){
|
||||
this.pourcentage=0;
|
||||
}
|
||||
public void addPourcent(int n){
|
||||
this.pourcentage+=n;
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics pinceau) {
|
||||
// obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard
|
||||
Graphics2D secondPinceau = (Graphics2D) pinceau.create();
|
||||
secondPinceau.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
// 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(Color.BLUE);
|
||||
secondPinceau.setFont(new Font(Font.SANS_SERIF, Font.BOLD, (this.getWidth()/10)));
|
||||
FontMetrics metrics = secondPinceau.getFontMetrics(secondPinceau.getFont());
|
||||
secondPinceau.drawString("CHARGEMENT", (this.getWidth()/2-metrics.stringWidth("CHARGEMENT")/2), (this.getHeight()-metrics.getHeight())/3+metrics.getAscent());
|
||||
secondPinceau.drawRect(this.getWidth()/10, this.getHeight()/2, this.getWidth()/10*8, this.getHeight()/10);
|
||||
secondPinceau.fillRect(this.getWidth()/10, this.getHeight()/2, this.getWidth()/10*8/100*pourcentage, this.getHeight()/10);
|
||||
}
|
||||
}
|
@ -14,10 +14,15 @@ import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
|
||||
public class FenetreEtudiant extends JPanel{
|
||||
private Set<Etudiant> etu;
|
||||
public FenetreEtudiant(Groupe g){
|
||||
super(new GridLayout(57, 1));
|
||||
super();
|
||||
if(g!=null){
|
||||
this.setLayout(new GridLayout(57, 1));
|
||||
this.etu=g.getEtudiants();
|
||||
for(Etudiant e: this.etu){
|
||||
this.add(new JLabel(e.monPrint()));
|
||||
}
|
||||
}else{
|
||||
this.add(new JLabel("Il n'y a pas d'étudiant"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,10 @@ 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));
|
||||
super();
|
||||
this.g=g;
|
||||
if(g!=null){
|
||||
this.setLayout(new GridLayout(15, 1));
|
||||
JButton bout=new JButton("point point");
|
||||
bout.addActionListener(new ObservateurChangeGroupe(m, this.g.getPointPoint()));
|
||||
this.add(bout);
|
||||
@ -28,5 +30,8 @@ public class FenetreGroupe extends JPanel{
|
||||
b.addActionListener(new ObservateurChangeGroupe(m, gr));
|
||||
this.add(b);
|
||||
}
|
||||
}else{
|
||||
this.add(new JLabel("Il n'y a pas encore de Groupe"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user