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
|
${BUILD}/Graphic/Controller/ObservateurChangeGroupe.class
|
||||||
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/View/FenetreEtudiant.java
|
${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/Model.class : ${SRC}/Graphic/Model.java \
|
||||||
${BUILD}/Graphic/View/FenetreGroupe.class \
|
${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
|
${JAVAC} ${JAVAC_OPTIONS} ${SRC}/Graphic/Model.java
|
||||||
|
|
||||||
## Controller ##
|
## Controller ##
|
||||||
|
@ -20,6 +20,7 @@ import fr.iutfbleau.projetIHM2022FI2.API.Groupe;
|
|||||||
import fr.iutfbleau.projetIHM2022FI2.API.TypeGroupe;
|
import fr.iutfbleau.projetIHM2022FI2.API.TypeGroupe;
|
||||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurChangeGroupe;
|
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurChangeGroupe;
|
||||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurFenetre;
|
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.FenetreEtudiant;
|
||||||
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.FenetreGroupe;
|
import fr.iutfbleau.projetIHM2022FI2.Graphic.View.FenetreGroupe;
|
||||||
import fr.iutfbleau.projetIHM2022FI2.MNP.AbstractGroupeFactoryNP;
|
import fr.iutfbleau.projetIHM2022FI2.MNP.AbstractGroupeFactoryNP;
|
||||||
@ -32,22 +33,42 @@ public class Model{
|
|||||||
private Set<Groupe> promo;
|
private Set<Groupe> promo;
|
||||||
private JFrame fenetre;
|
private JFrame fenetre;
|
||||||
public Model(){
|
public Model(){
|
||||||
this.getPromo();
|
this.fenetre=new JFrame();
|
||||||
this.fenGr=new FenetreGroupe(this.promo.iterator().next(), this);
|
this.fenetre.setSize(1200, 720);
|
||||||
this.fenEtu=new FenetreEtudiant(this.promo.iterator().next());
|
this.fenetre.setLocation(100,100);
|
||||||
this.fenetre=new JFrame();
|
Chargement ch=new Chargement();
|
||||||
this.fenetre.setSize(1200, 720);
|
this.fenetre.add(ch, BorderLayout.CENTER);
|
||||||
this.fenetre.setLocation(100,100);
|
this.fenetre.setVisible(true);
|
||||||
this.fenetre.addWindowListener(new ObservateurFenetre());
|
this.promo=new LinkedHashSet<>();
|
||||||
this.fenetre.setLayout(new GridLayout(2,1));
|
this.getPromo(ch);
|
||||||
this.fenetre.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
switch(this.promo.size()){
|
||||||
this.fenetre.add(new JScrollPane(this.fenGr));
|
case 0:
|
||||||
this.fenetre.add(new JScrollPane(this.fenEtu));
|
this.fenGr=new FenetreGroupe(null, this);
|
||||||
this.fenetre.setVisible(true);
|
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);
|
||||||
|
this.fenetre.addWindowListener(new ObservateurFenetre());
|
||||||
|
this.fenetre.setLayout(new GridLayout(2,1));
|
||||||
|
this.fenetre.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
|
this.fenetre.add(new JScrollPane(this.fenGr));
|
||||||
|
this.fenetre.add(new JScrollPane(this.fenEtu));
|
||||||
|
this.fenetre.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getPromo(){
|
private void getPromo(Chargement chargement){
|
||||||
this.promo=new LinkedHashSet<>();
|
|
||||||
try{
|
try{
|
||||||
Class.forName("org.mariadb.jdbc.Driver");
|
Class.forName("org.mariadb.jdbc.Driver");
|
||||||
try{
|
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;");
|
"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{
|
try{
|
||||||
ResultSet rs = pst.executeQuery();
|
ResultSet rs = pst.executeQuery();
|
||||||
|
rs.last();
|
||||||
|
int nbpromo=rs.getRow();
|
||||||
|
rs=pst.executeQuery();
|
||||||
try{
|
try{
|
||||||
while(rs.next()){
|
while(rs.next()){
|
||||||
//on image qu'il puisse avoir plusieur promo
|
//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));
|
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
|
//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){
|
}catch(SQLException e){
|
||||||
System.out.println("erreur dans la prise de resultat");
|
System.out.println("erreur dans la prise de resultat");
|
||||||
@ -86,7 +110,7 @@ public class Model{
|
|||||||
System.out.println("pilote non disponible");
|
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);
|
this.addEtudiant(g, cnx);
|
||||||
try{
|
try{
|
||||||
PreparedStatement pst= cnx.prepareStatement(
|
PreparedStatement pst= cnx.prepareStatement(
|
||||||
@ -94,11 +118,19 @@ public class Model{
|
|||||||
try{
|
try{
|
||||||
pst.setString(1, String.valueOf(g.getId()));
|
pst.setString(1, String.valueOf(g.getId()));
|
||||||
ResultSet rs=pst.executeQuery();
|
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{
|
try{
|
||||||
while(rs.next()){
|
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);
|
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);
|
g.addSousGroupe(nouveau);
|
||||||
this.addSousGroupe(nouveau, cnx);
|
this.addSousGroupe(nouveau, cnx, ch, pourcent/nbsous);
|
||||||
}
|
}
|
||||||
}catch(SQLException e){
|
}catch(SQLException e){
|
||||||
System.out.println("erreur dans la prise de resultat");
|
System.out.println("erreur dans la prise de resultat");
|
||||||
@ -113,6 +145,7 @@ public class Model{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void addEtudiant(Groupe g, Connection cnx){
|
private void addEtudiant(Groupe g, Connection cnx){
|
||||||
try{
|
try{
|
||||||
PreparedStatement pst= cnx.prepareStatement(
|
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{
|
public class FenetreEtudiant extends JPanel{
|
||||||
private Set<Etudiant> etu;
|
private Set<Etudiant> etu;
|
||||||
public FenetreEtudiant(Groupe g){
|
public FenetreEtudiant(Groupe g){
|
||||||
super(new GridLayout(57, 1));
|
super();
|
||||||
this.etu=g.getEtudiants();
|
if(g!=null){
|
||||||
for(Etudiant e: this.etu){
|
this.setLayout(new GridLayout(57, 1));
|
||||||
this.add(new JLabel(e.monPrint()));
|
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,20 +13,25 @@ import fr.iutfbleau.projetIHM2022FI2.Graphic.Controller.ObservateurChangeGroupe;
|
|||||||
public class FenetreGroupe extends JPanel{
|
public class FenetreGroupe extends JPanel{
|
||||||
private Groupe g;
|
private Groupe g;
|
||||||
public FenetreGroupe(Groupe g, Model m){
|
public FenetreGroupe(Groupe g, Model m){
|
||||||
super(new GridLayout(15, 1));
|
super();
|
||||||
this.g=g;
|
this.g=g;
|
||||||
JButton bout=new JButton("point point");
|
if(g!=null){
|
||||||
bout.addActionListener(new ObservateurChangeGroupe(m, this.g.getPointPoint()));
|
this.setLayout(new GridLayout(15, 1));
|
||||||
this.add(bout);
|
JButton bout=new JButton("point point");
|
||||||
this.add(new JLabel(g.getName()));
|
bout.addActionListener(new ObservateurChangeGroupe(m, this.g.getPointPoint()));
|
||||||
this.add(new JLabel("id= "+String.valueOf(g.getId())));
|
this.add(bout);
|
||||||
this.add(new JLabel("min= "+String.valueOf(g.getMin())));
|
this.add(new JLabel(g.getName()));
|
||||||
this.add(new JLabel("max= "+String.valueOf(g.getMax())));
|
this.add(new JLabel("id= "+String.valueOf(g.getId())));
|
||||||
this.add(new JLabel("Sous groupe"));
|
this.add(new JLabel("min= "+String.valueOf(g.getMin())));
|
||||||
for(Groupe gr: g.getSousGroupes()){
|
this.add(new JLabel("max= "+String.valueOf(g.getMax())));
|
||||||
JButton b=new JButton(gr.getName());
|
this.add(new JLabel("Sous groupe"));
|
||||||
b.addActionListener(new ObservateurChangeGroupe(m, gr));
|
for(Groupe gr: g.getSousGroupes()){
|
||||||
this.add(b);
|
JButton b=new JButton(gr.getName());
|
||||||
|
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