package fr.umlv.gmi.pvc.ihm;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridLayout;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedList;
import java.util.StringTokenizer;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import fr.umlv.gmi.pvc.algo.Algo;
import fr.umlv.gmi.pvc.algo.impl.Algo2opt;
import fr.umlv.gmi.pvc.algo.impl.AlgoElastique;
import fr.umlv.gmi.pvc.algo.impl.AlgoPpv;
import fr.umlv.gmi.pvc.algo.impl.AlgoPrim;
import fr.umlv.gmi.pvc.algo.impl.AlgoRecuit;
import fr.umlv.gmi.pvc.algo.impl.InsertionPlusProche;
import fr.umlv.gmi.pvc.algo.impl.SepEval;
import fr.umlv.gmi.pvc.algo.model.Arc;
import fr.umlv.gmi.pvc.algo.model.ArcDessin;
import fr.umlv.gmi.pvc.algo.model.Graphe;
import fr.umlv.gmi.pvc.algo.model.Point;
import fr.umlv.gmi.pvc.algo.model.PointElastique;
import fr.umlv.gmi.pvc.utils.Chrono;
/**
Interface graphique pour le projet - Utilise le DesktopPane
*/
public class InterfaceGraphique extends JFrame{
Graphe g;
int typeOptimisation=1; // 1 pour vitesse, 2 pour mémoire
// boolean avecAffichage;
static String[] nomAlgo={"Plus Proche Voisin","Insertion Plus Proche","2-échange","Prim","L'élastique","Le récuit simulé","Séparation et évaluation"};
javax.swing.Timer timer;
JInternalFrame dessin;
JInternalFrame menu;
JInternalFrame fVilles;
JInternalFrame fResult;
JPanel panel1;
JPanel panel2;
JMenuBar menuBar;
JMenu menuFichier;
JMenuItem menuFermer;
JMenu menuOptimisation;
JMenuItem menuVitesse;
JMenuItem menuMemoire;
JMenu menuHelp;
JMenuItem menuAPropos;
JSlider jSlider;
JDesktopPane desktop;
PanelDessin panelDessin;
GridBagConstraints gbc=new GridBagConstraints();
JComboBox algoList;
JLabel label1;
JTextField field1;
JLabel label2;
JTextField field2;
JLabel label3;
JTextField field3;
JLabel label4;
JLabel label5;
JTextField field4;
JButton buttonStart;
JButton buttonStartQuick;
JButton buttonVilles;
/**
Constructeur de l'InterfaceGraphique
*/
public InterfaceGraphique(){
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle("Visualisation des heuristiques du PVC");
LayoutManager[] layouts={new FlowLayout(),new GridLayout(1,0)};
desktop=new JDesktopPane();
setContentPane(desktop);
g=new Graphe(30,500,500,1);
panelDessin=new PanelDessin(g,10,100,null);
dessin=new JInternalFrame("Fenêtre de Visualisation",false,false,false,true);
dessin.setVisible(true);
dessin.setSize(510,550);
menu=new JInternalFrame("Menu",false,false,false,true);
menu.setVisible(true);
menu.setSize(200,230);
fVilles=new JInternalFrame("Generation des Villes",false,false,false,true);
fVilles.setVisible(true);
fVilles.setSize(200,120);
fResult=new JInternalFrame("Resultats",false,false,false,true);
fResult.setVisible(true);
fResult.setSize(200,120);
desktop.add(dessin);
dessin.setLocation(230,10);
desktop.add(menu);
menu.setLocation(10,152);
desktop.add(fVilles);
fVilles.setLocation(10,10);
desktop.add(fResult);
fResult.setLocation(10,410);
jSlider=new JSlider();
initMenuBar();
initFVilles();
initFResult();
initMenu();
}
/**
Affiche la fenêtre "A propos"
*/
public void afficheAPropos(){
JOptionPane.showMessageDialog(this,
" PVC - Le Problème du Voyageur de Commerce \n" +
" Représentation graphique des algorithmes \n\n" +
"Le Tétour Clément [clement.letetour@gmail.com] \n" +
"Bolalima Mohammed [mbolalima@etudiant.univ-mlv.fr] \n" +
"UMLV - V1.0 2002 \n"+
"UMLV - V1.1 Janvier 2009 \n",
"A propos",
JOptionPane.INFORMATION_MESSAGE,
new ImageIcon("bin/logoPVC.jpg"));
}
/**
Affiche la fenêtre "manque de mémoire"
*/
public void afficheWarning(){
JOptionPane.showMessageDialog(this,
" PVC - Le Problème du Voyageur de Commerce \n\n Mémoire insuffisante: changez de mode"
,"Warning"
,JOptionPane.INFORMATION_MESSAGE
);
}
/**
Initialisation du MENU
*/
public void initMenuBar(){
final ImageIcon iconSelect = new ImageIcon("bin/selected.gif",
"coché");
final ImageIcon iconNotSelect = new ImageIcon("bin/notSelected.gif",
"pas coché");
ImageIcon iconInformation = new ImageIcon("bin/information.gif",
"Icon Information");
menuBar=new JMenuBar();
menuFichier=new JMenu("Fichier");
menuFermer=new JMenuItem("Quitter");
menuFermer.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
System.exit(0);
}
});
menuOptimisation=new JMenu("Type d'optimisation");
menuVitesse=new JMenuItem("Priorité vitesse",iconSelect);
menuVitesse.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
typeOptimisation=1;
try{
g=new Graphe(g,1);}catch (OutOfMemoryError oe){afficheWarning();}
menuVitesse.setIcon(iconSelect);
menuMemoire.setIcon(iconNotSelect);
g.tabDist= new double[g.nbPoint][g.nbPoint];
g.calcTabDist();
}
});
menuMemoire=new JMenuItem("Priorité mémoire",iconNotSelect);
menuMemoire.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
typeOptimisation=2;
g=new Graphe(g,2);
menuVitesse.setIcon(iconNotSelect);
menuMemoire.setIcon(iconSelect);
g.tabDist=null;
}
});
menuHelp=new JMenu("?");
menuAPropos=new JMenuItem("A propos",iconInformation);
menuAPropos.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
afficheAPropos();
}
});
menuFichier.add(menuFermer);
menuOptimisation.add(menuVitesse);
menuOptimisation.add(menuMemoire);
menuHelp.add(menuAPropos);
menuBar.add(menuFichier);
menuBar.add(menuOptimisation);
menuBar.add(menuHelp);
this.setJMenuBar(menuBar);
}
/**
Méthode d'initialisation de la frame Villes
*/
public void initFVilles(){
label1 =new JLabel("Nb de villes: ");
label5= new JLabel("(Max 2500 en priorité vitesse)");
field1=new JTextField("20",4);
field1.setHorizontalAlignment(JTextField.CENTER);
buttonVilles=new JButton("GO");
buttonVilles.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
StringTokenizer token=new StringTokenizer(field1.getText());
String tmp=token.nextToken();
int nbVilles=Integer.parseInt(tmp);
try{
g=new Graphe(nbVilles,500,500,typeOptimisation);
}catch (OutOfMemoryError ome){afficheWarning();}
dessin.remove(panelDessin);
panelDessin.graphe=g;
panelDessin.algo=null;
panelDessin.typeAlgo=100;
dessin.getContentPane().add(panelDessin);
desktop.validate();
dessin.repaint();
}
});
fVilles.getContentPane().setLayout(new FlowLayout());
fVilles.getContentPane().add(label1);
fVilles.getContentPane().add(label5);
fVilles.getContentPane().add(field1);
fVilles.getContentPane().add(buttonVilles);
}
/**
Méthode d'initialisation de la frame de visualisation des Résultats
*/
public void initFResult(){
label3=new JLabel("Distance : ");
field3=new JTextField("0",6);
field3.setEnabled(false);
field3.
没有合适的资源?快使用搜索试试~ 我知道了~
fr.rar_ME_voyageur de commerce
共52个文件
class:27个
java:17个
xml:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 122 浏览量
2022-09-21
08:11:37
上传
评论
收藏 65KB RAR 举报
温馨提示
implémentation du problème de voyageur de commerce en java
资源推荐
资源详情
资源评论
收起资源包目录
fr.rar (52个子文件)
fr
test
build.xml 4KB
manifest.mf 85B
src
fr
umlv
gmi
pvc
algo
Algo.java 524B
model
Graphe.java 3KB
ArcDessin.java 555B
Point.java 2KB
Arc.java 978B
PointElastique.java 600B
impl
AlgoPrim.java 4KB
Algo2opt.java 3KB
InsertionPlusProche.java 4KB
SepEval.java 3KB
AlgoElastique.java 6KB
AlgoRecuit.java 5KB
MonArbre.java 4KB
AlgoPpv.java 2KB
utils
Chrono.java 803B
ihm
InterfaceGraphique.java 18KB
Main.java 243B
nbproject
build-impl.xml 48KB
private
private.properties 96B
project.xml 510B
genfiles.properties 475B
project.properties 2KB
build
classes
.netbeans_automatic_build 0B
fr
umlv
gmi
pvc
Main.class 572B
algo
model
PointElastique.class 853B
ArcDessin.class 1KB
Point.class 2KB
Graphe.class 3KB
Arc.class 1KB
Algo.class 573B
impl
AlgoPrim.class 3KB
SepEval.class 2KB
MonArbre.class 2KB
AlgoElastique.class 5KB
InsertionPlusProche.class 3KB
Algo2opt.class 3KB
AlgoPpv.class 2KB
AlgoRecuit.class 4KB
utils
Chrono.class 718B
ihm
InterfaceGraphique$7.class 905B
InterfaceGraphique$5.class 2KB
InterfaceGraphique$8.class 1KB
InterfaceGraphique$6.class 905B
InterfaceGraphique$3.class 1KB
InterfaceGraphique$2.class 2KB
InterfaceGraphique$1.class 814B
InterfaceGraphique$4.class 798B
InterfaceGraphique$SliderListener.class 1KB
InterfaceGraphique$PanelDessin.class 3KB
InterfaceGraphique.class 12KB
共 52 条
- 1
资源评论
寒泊
- 粉丝: 76
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功