affichage echelonne

This commit is contained in:
Luc Dartois 2024-02-29 11:06:48 +01:00
parent d323b41816
commit 766b32070d
2 changed files with 7 additions and 6 deletions

View File

@ -24,11 +24,12 @@ public class JGraphe extends JComponent{
} }
/** /**
* Cree une fenetre pour afficher le graphe * Cree une fenetre carree pour afficher le graphe
* @param taille taille de la fenetre a creer
*/ */
public void affiche(){ public void affiche(int taille){
JFrame fenetre=new JFrame(); JFrame fenetre=new JFrame();
fenetre.setSize(120*this.g.getOrdre(),120*this.g.getOrdre()); fenetre.setSize(taille,taille);
fenetre.setLocation(100,100); fenetre.setLocation(100,100);
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
fenetre.add(this); fenetre.add(this);
@ -42,7 +43,7 @@ public class JGraphe extends JComponent{
@Override @Override
public void paintComponent(Graphics pinceau){ public void paintComponent(Graphics pinceau){
int n=this.g.getOrdre(); int n=this.g.getOrdre();
int taille=100*n; int taille = this.getWidth();
int r=taille/20; int r=taille/20;
int origine=taille/2; int origine=taille/2;
int distance=4*origine/5; int distance=4*origine/5;

View File

@ -37,7 +37,7 @@ public class TestGraphe{
System.out.println(t==14*2); System.out.println(t==14*2);
//Exemple de graphe orienté. //Exemple de graphe oriente.
Graphe g=new Graphe(5,true); Graphe g=new Graphe(5,true);
g.ajoutArete(0,2); g.ajoutArete(0,2);
g.ajoutArete(0,4); g.ajoutArete(0,4);
@ -51,6 +51,6 @@ public class TestGraphe{
System.out.println(g.sommeVoisins()==8); System.out.println(g.sommeVoisins()==8);
JGraphe gr=new JGraphe(europe); JGraphe gr=new JGraphe(europe);
gr.affiche(); gr.affiche(500);
} }
} }