|
From: <chr...@us...> - 2009-11-12 11:29:34
|
Revision: 5480
http://fudaa.svn.sourceforge.net/fudaa/?rev=5480&view=rev
Author: chrisc83
Date: 2009-11-12 11:29:18 +0000 (Thu, 12 Nov 2009)
Log Message:
-----------
OPEN - issue PREPRO-53: Ajout d'un panel pour le traitement du maillage
http://www.fudaa.fr/jira/browse/PREPRO-53
Modified Paths:
--------------
trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/gridprocess/GridProcessTaskModel.java
trunk/soft/fudaa-prepro/meshview/src/test/java/org/fudaa/fudaa/meshviewer/gridprocess/TestGridProcess.java
trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/telemac/TrTelemacAppliManager.java
Modified: trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/gridprocess/GridProcessTaskModel.java
===================================================================
--- trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/gridprocess/GridProcessTaskModel.java 2009-11-12 08:17:36 UTC (rev 5479)
+++ trunk/soft/fudaa-prepro/meshview/src/main/java/org/fudaa/fudaa/meshviewer/gridprocess/GridProcessTaskModel.java 2009-11-12 11:29:18 UTC (rev 5480)
@@ -1,18 +1,18 @@
package org.fudaa.fudaa.meshviewer.gridprocess;
import java.awt.Color;
-import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
import java.io.File;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.border.TitledBorder;
import javax.swing.filechooser.FileFilter;
@@ -22,15 +22,14 @@
import org.fudaa.ctulu.CtuluIOOperationSynthese;
import org.fudaa.ctulu.CtuluLibFile;
import org.fudaa.ctulu.CtuluLibString;
-import org.fudaa.ctulu.CtuluUI;
import org.fudaa.ctulu.ProgressionInterface;
import org.fudaa.ctulu.ProgressionUpdater;
import org.fudaa.ctulu.fileformat.FileFormat;
+import org.fudaa.ctulu.fileformat.FileFormatUnique;
import org.fudaa.ctulu.gui.CtuluFileChooserPanel;
import org.fudaa.ctulu.gui.CtuluLibDialog;
import org.fudaa.ctulu.gui.CtuluLibSwing;
import org.fudaa.ctulu.gui.CtuluOptionPane;
-import org.fudaa.ctulu.gui.CtuluUIDialog;
import org.fudaa.dodico.ef.EfDataAdapter;
import org.fudaa.dodico.ef.EfFrontierInterface;
import org.fudaa.dodico.ef.EfGridData;
@@ -57,8 +56,7 @@
import com.memoire.bu.BuBorderLayout;
import com.memoire.bu.BuButton;
import com.memoire.bu.BuCheckBox;
-import com.memoire.bu.BuContentFrame;
-import com.memoire.bu.BuDialog;
+import com.memoire.bu.BuComboBox;
import com.memoire.bu.BuGridLayout;
import com.memoire.bu.BuLabel;
import com.memoire.bu.BuNumericValueValidator;
@@ -68,20 +66,27 @@
import com.memoire.bu.BuTextField;
import com.memoire.bu.BuVerticalLayout;
-public class GridProcessTaskModel implements FudaaPanelTaskModel
+public class GridProcessTaskModel implements FudaaPanelTaskModel, ItemListener
{
public final static Color OK_COLOR = getOkColor();
public final static Color ERROR_COLOR = Color.RED;
-
- private BuPanel panel;
- private FileChooserPanel fileInGrid;
- private FileChooserPanel fileInCL;
- private FileChooserPanel fileOutGrid;
- private FileChooserPanel fileOutCL;
- private ChooseProcessPanel chooser;
- private boolean stop;
- private CtuluActivity currentActivity;
+ public final static String COMBO_IN = "COMBO_IN";
+ public final static String COMBO_OUT = "COMBO_OUT";
+ private BuPanel panel;
+ private FileChooserPanel fileInGrid;
+ private FileChooserPanel fileInCL;
+ private FileChooserPanel fileOutGrid;
+ private FileChooserPanel fileOutCL;
+ private ChooseProcessPanel chooser;
+ private FileFormatUniquePanel formatInGrid;
+ private FileFormatUniquePanel formatOutGrid;
+ private boolean stop;
+ private CtuluActivity currentActivity;
+ private List<FileFormatUnique> formatsToWrite;
+ private List<FileFormatUnique> formatsToRead;
+ private File fileIn;
+
private static Color getOkColor()
{
Color okColor = CtuluLibSwing.getDefaultLabelForegroundColor();
@@ -93,6 +98,41 @@
return okColor;
}
+ private static BuPanel createSubpanel(JComponent component1, JComponent component2)
+ {
+ BuPanel panel = new BuPanel(new BuGridLayout(2, 5, 5));
+
+ panel.add(component1);
+ panel.add(component2);
+
+ return panel;
+ }
+
+ public GridProcessTaskModel(FileFormat[] fileFormats, File fileIn)
+ {
+ this.formatsToWrite = new ArrayList<FileFormatUnique>();
+ this.formatsToRead = new ArrayList<FileFormatUnique>();
+ this.fileIn = fileIn;
+
+ for (int i = 0; i < fileFormats.length; i++)
+ {
+ if (fileFormats[i] instanceof FileFormatUnique)
+ {
+ FileFormatUnique fileFormat = (FileFormatUnique)fileFormats[i];
+
+ if (fileFormat.createWriter() != null)
+ {
+ this.formatsToWrite.add(fileFormat);
+ }
+
+ if (fileFormat.createReader() != null)
+ {
+ this.formatsToRead.add(fileFormat);
+ }
+ }
+ }
+ }
+
@SuppressWarnings("serial")
private static class ProcessException extends Exception
{
@@ -108,6 +148,59 @@
}
@SuppressWarnings("serial")
+ private static class FileFormatUniquePanel extends BuPanel
+ {
+ private BuComboBox combo;
+ private BuLabel label;
+ private FileFormatUnique[] formats;
+
+ public FileFormatUniquePanel(String title, FileFormatUnique[] formats)
+ {
+ this.label = new BuLabel(title);
+ this.formats = formats;
+ this.combo = new BuComboBox();
+
+ for (int i = 0; i < this.formats.length; i++)
+ {
+ this.combo.addItem(this.formats[i].getName());
+ }
+
+ this.setLayout(new BuGridLayout(2, 5, 5));
+ this.add(this.label);
+ this.add(this.combo);
+ }
+
+ public void setHtmlToolTip(String message)
+ {
+ this.combo.setToolTipText("<HTML>" + message + "</HTML>");
+ }
+
+ public FileFormatUnique getSelectedFormat()
+ {
+ return this.formats[this.combo.getSelectedIndex()];
+ }
+
+ public void setItemListener(ItemListener listener, String command)
+ {
+ this.combo.addItemListener(listener);
+ this.combo.setActionCommand(command);
+ }
+
+ public void selectFormatForFile(File file)
+ {
+ for (int i = 0; i < this.formats.length; i++)
+ {
+ if (this.formats[i].isAccepted(file))
+ {
+ this.combo.setSelectedIndex(i);
+
+ break;
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("serial")
private static class FileChooserPanel extends BuPanel implements Validator
{
private CtuluFileChooserPanel filePanel;
@@ -131,14 +224,24 @@
this.fileLabel = new BuLabel(title);
this.filePanel = new CtuluFileChooserPanel();
- this.filePanel.setExt(format.getExtensions()[0]);
- this.filePanel.setFilter(new FileFilter[] { format.createFileFilter() });
-
- setLayout(new BuGridLayout(2, 5, 5));
+ this.setFormat(format);
+
+ this.setLayout(new BuGridLayout(2, 5, 5));
this.add(this.fileLabel);
this.add(this.filePanel);
}
+ public void setFile(File file)
+ {
+ this.filePanel.setFile(file);
+ }
+
+ public void setFormat(FileFormat format)
+ {
+ this.filePanel.setExt(format.getExtensions()[0]);
+ this.filePanel.setFilter(new FileFilter[] { format.createFileFilter() });
+ }
+
public String getErrorMessage()
{
String result = null;
@@ -224,11 +327,6 @@
this.backEliminationCheckBox.addActionListener(this);
}
- private void setHtmlToolTip(JComponent component, String message)
- {
- component.setToolTipText("<HTML>" + message + "</HTML>");
- }
-
public void actionPerformed(ActionEvent arg0)
{
String cmd = arg0.getActionCommand();
@@ -269,11 +367,11 @@
this.setLayout(new BuVerticalLayout(2, true, false));
- this.add(this.createPanelWithHelpButton(this.createSubpanel(this.cleanGridCheckBox, this.minDistanceValue), "Permet de nettoyer le maillage.<BR/>Les points non utilis\xE9s sont supprim\xE9s ainsi que ceux dont leur distance \xE0 un autre point est inf\xE9rieur \xE0 la <I>distance minimale</I>.<BR/>Les \xE9l\xE9ments d\xE9g\xE9n\xE9r\xE9s ou superpos\xE9s sont supprim\xE9s."));
+ this.add(this.createPanelWithHelpButton(createSubpanel(this.cleanGridCheckBox, this.minDistanceValue), "Permet de nettoyer le maillage.<BR/>Les points non utilis\xE9s sont supprim\xE9s ainsi que ceux dont leur distance \xE0 un autre point est inf\xE9rieur \xE0 la <I>distance minimale</I>.<BR/>Les \xE9l\xE9ments d\xE9g\xE9n\xE9r\xE9s ou superpos\xE9s sont supprim\xE9s."));
this.add(this.createPanelWithHelpButton(this.refineEdgeCheckBox, "Permet de divis\xE9 des \xE9l\xE9ments de type T3 et Q4 en 4.<BR/>Ce r\xE9sultat est obtenu en ajoutant un nouveau point au centre de chaque segment.<BR/>Pour tout les autres types d'\xE9l\xE9ment un nouveau point est ajout\xE9 au centre de chaque segment et de chaque \xE9l\xE9ment.<BR/>Leurs points se trouvant sur leur pourtour sont reli\xE9 au point ajout\xE9 en leur centre."));
this.add(this.createPanelWithHelpButton(this.overstressedCheckBox, "Permet de modifier les \xE9l\xE9ments surcontraints (dont tout leurs points se trouvent sur la fronti\xE8re).<BR/>Ce r\xE9sultat est obtenu en ajoutant un point en leur centre et en reliant tout leurs autres points \xE0 celui-ci.<BR/>Les segments dont leurs points se trouvent sur la fronti\xE8re sont \xE9chang\xE9s."));
this.add(this.createPanelWithHelpButton(this.renumerationCheckBox, "Permet de modifier la num\xE9rotation des points afin d'utiliser le nouveau type de stockage des matrices.<BR/>Ils seront num\xE9rot\xE9s de celui appartenant au moins d'\xE9l\xE9ments \xE0 celui apparentant au plus d'\xE9l\xE9ments."));
- this.add(this.createPanelWithHelpButton(this.createSubpanel(this.backEliminationCheckBox, this.vectorLengthValue), ""));
+ this.add(this.createPanelWithHelpButton(createSubpanel(this.backEliminationCheckBox, this.vectorLengthValue), "Permet de renum\xE9roter les \xE9l\xE9ments du maillage de mani\xE8re \xE0 \xE9liminer les d\xE9pendances arri\xE8res.<BR/>Attention : un nombre minimum d'environ 500 \xE9l\xE9ments est requis pour l'activation de cette option."));
}
private BuPanel createPanelWithHelpButton(JComponent component, String helpMsg)
@@ -290,16 +388,6 @@
return panel;
}
- private BuPanel createSubpanel(BuCheckBox checkbox, BuTextField value)
- {
- BuPanel panel = new BuPanel(new BuGridLayout(2, 5, 5));
-
- panel.add(checkbox);
- panel.add(value);
-
- return panel;
- }
-
public String getErrorMessage()
{
String message = null;
@@ -533,27 +621,42 @@
private void initComponent()
{
- this.panel = new BuPanel(new BuVerticalLayout(2, true, false));
- this.fileInGrid = new FileChooserPanel(Messages.getString("gridprocess.gridFileIn.txt"), SerafinFileFormat.getInstance(), true);
- this.fileInCL = new FileChooserPanel(Messages.getString("gridprocess.clFileIn.txt"), TelemacCLFileFormat.getInstance());
- this.fileOutGrid = new FileChooserPanel(Messages.getString("gridprocess.gridFileOut.txt"), SerafinFileFormat.getInstance(), true);
- this.fileOutCL = new FileChooserPanel(Messages.getString("gridprocess.clFileOut.txt"), TelemacCLFileFormat.getInstance());
- this.chooser = new ChooseProcessPanel();
-
+ this.panel = new BuPanel(new BuVerticalLayout(2, true, false));
+ this.formatInGrid = new FileFormatUniquePanel("Format du fichier de maillage en entr\xE9e :", this.formatsToRead.toArray(new FileFormatUnique[0]));
+ this.formatOutGrid = new FileFormatUniquePanel("Format du fichier de maillage en sortie :", this.formatsToWrite.toArray(new FileFormatUnique[0]));
+ this.fileInGrid = new FileChooserPanel(Messages.getString("gridprocess.gridFileIn.txt"), this.formatInGrid.getSelectedFormat(), true);
+ this.fileInCL = new FileChooserPanel(Messages.getString("gridprocess.clFileIn.txt"), TelemacCLFileFormat.getInstance());
+ this.fileOutGrid = new FileChooserPanel(Messages.getString("gridprocess.gridFileOut.txt"), this.formatOutGrid.getSelectedFormat(), true);
+ this.fileOutCL = new FileChooserPanel(Messages.getString("gridprocess.clFileOut.txt"), TelemacCLFileFormat.getInstance());
+ this.chooser = new ChooseProcessPanel();
+
this.fileInGrid.setHtmlToolTip("Le chemin du fichier de maillage source");
this.fileInCL.setHtmlToolTip("Le chemin du fichier de conditions limites source");
this.fileOutGrid.setHtmlToolTip("Le chemin du fichier de maillage r\xE9sultat");
this.fileOutCL.setHtmlToolTip("Le chemin du fichier de conditions limites r\xE9sultat");
+ this.formatInGrid.setHtmlToolTip("Le format du fichier de maillage en entr\xE9e");
+ this.formatOutGrid.setHtmlToolTip("Le format du fichier de maillage en sortie");
+
+ this.formatInGrid.setItemListener(this, COMBO_IN);
+ this.formatOutGrid.setItemListener(this, COMBO_OUT);
+
+ if (this.fileIn != null)
+ {
+ this.formatInGrid.selectFormatForFile(this.fileIn);
+ this.fileInGrid.setFile(this.fileIn);
+ }
}
private void createUI()
{
this.panel.add(this.fileInGrid);
+ this.panel.add(this.formatInGrid);
this.panel.add(this.fileInCL);
this.panel.add(this.chooser);
this.panel.add(this.fileOutGrid);
+ this.panel.add(this.formatOutGrid);
this.panel.add(this.fileOutCL);
}
@@ -830,4 +933,18 @@
return this.doOperation(prog, analyse, backElimination, gridData);
}
+
+ public void itemStateChanged(ItemEvent arg0)
+ {
+ String command = ((BuComboBox)arg0.getSource()).getActionCommand();
+
+ if (command.equals(COMBO_IN))
+ {
+ this.fileInGrid.setFormat(this.formatInGrid.getSelectedFormat());
+ }
+ else if (command.equals(COMBO_OUT))
+ {
+ this.fileOutGrid.setFormat(this.formatOutGrid.getSelectedFormat());
+ }
+ }
}
Modified: trunk/soft/fudaa-prepro/meshview/src/test/java/org/fudaa/fudaa/meshviewer/gridprocess/TestGridProcess.java
===================================================================
--- trunk/soft/fudaa-prepro/meshview/src/test/java/org/fudaa/fudaa/meshviewer/gridprocess/TestGridProcess.java 2009-11-12 08:17:36 UTC (rev 5479)
+++ trunk/soft/fudaa-prepro/meshview/src/test/java/org/fudaa/fudaa/meshviewer/gridprocess/TestGridProcess.java 2009-11-12 11:29:18 UTC (rev 5480)
@@ -1,9 +1,8 @@
package org.fudaa.fudaa.meshviewer.gridprocess;
-import java.util.Locale;
-
import javax.swing.JFrame;
+import org.fudaa.ctulu.fileformat.FileFormat;
import org.fudaa.ctulu.gui.CtuluUIDialog;
import org.fudaa.fudaa.commun.impl.FudaaPanelTask;
@@ -20,9 +19,9 @@
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
CtuluUIDialog dialog = new CtuluUIDialog(frame);
dialog.getMainProgression();
+
+ FudaaPanelTask task = new FudaaPanelTask(dialog, new GridProcessTaskModel(new FileFormat[0], null));
- FudaaPanelTask task = new FudaaPanelTask(dialog, new GridProcessTaskModel());
-
task.afficheDialog();
}
}
Modified: trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/telemac/TrTelemacAppliManager.java
===================================================================
--- trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/telemac/TrTelemacAppliManager.java 2009-11-12 08:17:36 UTC (rev 5479)
+++ trunk/soft/fudaa-prepro/ui/src/main/java/org/fudaa/fudaa/tr/telemac/TrTelemacAppliManager.java 2009-11-12 11:29:18 UTC (rev 5480)
@@ -103,7 +103,7 @@
CtuluUIDialog dialog = new CtuluUIDialog(frame);
dialog.getMainProgression();
- FudaaPanelTask task = new FudaaPanelTask(dialog, new GridProcessTaskModel());
+ FudaaPanelTask task = new FudaaPanelTask(dialog, new GridProcessTaskModel(TrFileFormatManager.getAllGridFormat(), _target));
task.afficheDialog();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|