From: Frederic D. <de...@us...> - 2004-04-02 14:14:47
|
Update of /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/test/tr In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25282/src/org/fudaa/fudaa/test/tr Added Files: MatisseConvertGUI.java Log Message: Maj pour matisse test --- NEW FILE: MatisseConvertGUI.java --- /* * @file MatisseConvertGUI.java @creation 2 avr. 2004 @modification $Date: 2004/04/02 14:02:38 $ @license GNU General * Public License 2 @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne @mail * fud...@li... */ package org.fudaa.fudaa.test.tr; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.io.File; import javax.swing.BorderFactory; import javax.swing.JFrame; import javax.swing.JTextField; import com.memoire.bu.BuBorderLayout; import com.memoire.bu.BuButton; import com.memoire.bu.BuComboBox; import com.memoire.bu.BuGridLayout; import com.memoire.bu.BuLabel; import com.memoire.bu.BuPanel; import com.memoire.bu.BuPreferences; import com.memoire.bu.BuProgressBar; import com.memoire.bu.BuResource; import com.memoire.bu.BuTextField; import org.fudaa.dodico.commun.DodicoResource; import org.fudaa.dodico.commun.ProgressionInterface; import org.fudaa.dodico.fichiers.FileOperationSynthese; import org.fudaa.dodico.fortran.FortranBinaryInputStream; import org.fudaa.dodico.mnt.MNT; import org.fudaa.dodico.telemac.io.MatisseReader; import org.fudaa.dodico.telemac.io.SinusxFileFormat; import org.fudaa.ebli.dialog.EbliSimpleDialogPanel; import org.fudaa.fudaa.commun.FudaaLib; import org.fudaa.fudaa.commun.FudaaProgressionAdapter; import org.fudaa.fudaa.tr.TrPreferences; import org.fudaa.fudaa.tr.TrResource; /** * @author Fred Deniger * @version $Id: MatisseConvertGUI.java,v 1.1 2004/04/02 14:02:38 deniger Exp $ */ public class MatisseConvertGUI extends EbliSimpleDialogPanel { boolean containsData_; BuButton btCharger_; BuButton btOut_; JTextField in_; JTextField out_; BuComboBox cbFmt_; BuTextField txtFichier_; BuTextField txtZones_; BuTextField txtPoints_; BuTextField txtpolylignes_; BuTextField txtpolygones_; ProgressionInterface progress_; MNT mnt_; /** * */ public MatisseConvertGUI() { super(); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); BuPanel pnCharger = new BuPanel(); pnCharger.setBorder(BorderFactory.createTitledBorder(BorderFactory .createLineBorder(Color.DARK_GRAY), DodicoResource.getS("Entrée"))); pnCharger.setLayout(new BuGridLayout(2, 5, 5)); in_ = addLabelFileChooserPanel(pnCharger, TrResource.getS("Fichier") + ": ", "", false, false); addLabel(pnCharger, TrResource.getS("Architecture") + ": "); cbFmt_ = new BuComboBox(new String[] { FortranBinaryInputStream.SPARC_NAME, FortranBinaryInputStream.X86_NAME}); cbFmt_.setSelectedItem(FortranBinaryInputStream.getLocalMachineName()); pnCharger.add(cbFmt_); btCharger_ = new BuButton(DodicoResource.getS("Charger")); btCharger_.setIcon(BuResource.BU.loadMenuCommandIcon("analyser")); btCharger_.addActionListener(this); pnCharger.add(new BuLabel("")); pnCharger.add(btCharger_); BuPanel info = new BuPanel(); info.setBorder(BorderFactory.createTitledBorder( BorderFactory.createLineBorder(Color.DARK_GRAY), DodicoResource.getS("Informations"))); info.setLayout(new BuGridLayout(2, 5, 5)); txtFichier_ = addLabelStringText(info, TrResource.getS("Fichier analysé")); txtFichier_.setEditable(false); txtZones_ = addLabelDoubleText(info, TrResource.getS("Nombre de zones")); txtZones_.setEditable(false); txtPoints_ = addLabelDoubleText(info, TrResource.getS("Nombre total de points")); txtPoints_.setEditable(false); txtpolygones_ = addLabelDoubleText(info, TrResource.getS("Nombre total de polygones")); txtpolygones_.setEditable(false); txtpolylignes_ = addLabelDoubleText(info, TrResource.getS("Nombre total de polylignes")); txtpolylignes_.setEditable(false); BuPanel pnOut = new BuPanel(); pnOut.setBorder(BorderFactory.createTitledBorder(BorderFactory .createLineBorder(Color.DARK_GRAY), DodicoResource.getS("Sortie"))); pnOut.setLayout(new BuGridLayout(2, 5, 5)); out_ = addLabelFileChooserPanel(pnOut, TrResource.getS("Fichier de sortie") + ": ", "", false, false); pnOut.add(new BuLabel()); btOut_ = new BuButton(DodicoResource.getS("Sauvegarger")); btOut_.setIcon(BuResource.BU.loadMenuCommandIcon("enregistrer")); btOut_.addActionListener(this); btOut_.setEnabled(false); pnOut.add(btOut_); setLayout(new BuBorderLayout(10, 10)); BuPanel main = new BuPanel(); main.setLayout(new BuBorderLayout(10, 10)); main.add(pnCharger, BuBorderLayout.NORTH); main.add(info, BuBorderLayout.CENTER); main.add(pnOut, BuBorderLayout.SOUTH); add(main, BuBorderLayout.CENTER); BuProgressBar progress = new BuProgressBar(); progress_ = new FudaaProgressionAdapter(progress); add(progress, BuBorderLayout.SOUTH); } /** * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent _e) { Object s = _e.getSource(); if (s == btCharger_) charger(); else if(s==btOut_) save(); super.actionPerformed(_e); } private void charger() { String file = in_.getText().trim(); if (file.length() == 0) return; final File f = new File(file); if (!f.exists()) FudaaLib.showError(null, "Fichier non trouvé", "Le fichier " + f + " est introuvable"); new Thread() { public void run() { MatisseReader r = new MatisseReader(null); r.setProgressReceiver(progress_); r.setFile(f); FileOperationSynthese s = r.read(); if (s.containsFatalError()) FudaaLib.showError(null, "Erreur de lecture", s.getAnalyze().getFatalError() .getMessage()); mnt_ = (MNT) s.getSource(); if(mnt_==null) return; txtFichier_.setText(f.getAbsolutePath()); txtFichier_.setToolTipText(f.getAbsolutePath()); txtPoints_.setText(Double.toString(mnt_.getNbPointTotal())); txtpolygones_.setText(Double.toString(mnt_.getNbPolygoneTotal())); txtpolylignes_.setText(Double.toString(mnt_.getNbPolyligneTotal())); txtZones_.setText(Double.toString(mnt_.nbZones())); btOut_.setEnabled(true); progress_.setProgression(0); } }.start(); } private void save() { String file = out_.getText().trim(); System.out.println("sauvegarde dans "+file); if (file.length() == 0) return; final File f = new File(file); if (f.exists() && !f.canWrite()) FudaaLib.showError(null, "Impossible d'écrire", "Le fichier " + f + " est protégé"); if (mnt_ == null) FudaaLib.showError(null, "Pas de données", "Avant de sauvegarder un projet, vous devez analyser un fichier matisse"); new Thread() { public void run() { btCharger_.setEnabled(false); SinusxFileFormat.getInstance().getLastVersionInstance().write(f, mnt_.createZoneArray(), progress_); btCharger_.setEnabled(true); FudaaLib.showMessage(null,"OK","La sauvegarde qui va bien est finie"); progress_.setProgression(0); } }.start(); } /** * @param args non utilisee */ public static void main(String[] args) { JFrame f = new JFrame(TrResource.getS("Convertisseur Matisse")); f.setContentPane(new MatisseConvertGUI()); f.addWindowListener(new WindowListener() { public void windowActivated(WindowEvent _e) {} public void windowClosed(WindowEvent _e) { BuPreferences.BU.writeIniFile(); TrPreferences.TR.writeIniFile(); System.exit(0); } public void windowClosing(WindowEvent _e) {} public void windowDeactivated(WindowEvent _e) {} public void windowDeiconified(WindowEvent _e) {} public void windowIconified(WindowEvent _e) {} public void windowOpened(WindowEvent _e) {} }); f.pack(); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.show(); } } |