From: <had...@us...> - 2008-10-02 18:33:00
|
Revision: 4025 http://fudaa.svn.sourceforge.net/fudaa/?rev=4025&view=rev Author: hadouxad Date: 2008-10-02 18:32:19 +0000 (Thu, 02 Oct 2008) Log Message: ----------- - d?\195?\169but de l'algodes lignes de courant - l'interface de choix des donn?\195?\169es pour les lignes de courant - mise en place du target pour les importations de courbes, il ne reste plus qu'a instancier les les treemodel qui vont bien. - cr?\195?\169ation de toutes les interfaces pour les import scopGENE et scop s, t, tout est en place C'est du lourd avec choix pour scopgene du type de graphe (cardlayout pour gerer les plusieurs cas...) Tout est fait jusque a la cr?\195?\169ation des ?\195?\169volutions regulieres pour le scopGene, tout est g?\195?\169r?\195?\169; spatial, temporel, corr?\195?\169l?\195?\169 Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReaderGene.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeStructure.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriterGENE.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeImporterScope.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeWizardImportScope.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaWriterScopeGENE.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/common/tr_en.fr_txt branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostDialogCubature.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostLayoutPanelController.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostWizardImportScope.java Added Paths: ----------- branches/Prepro-0.92-SNAPSHOT/ebli/classes/ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/common/TrPostActionLigneCourants.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrComputeCurrentLine.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostDialogCurrentLine.java Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReaderGene.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReaderGene.java 2008-10-02 16:17:18 UTC (rev 4024) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReaderGene.java 2008-10-02 18:32:19 UTC (rev 4025) @@ -172,7 +172,7 @@ // -- on est arriv\xE9 a une ligne de pas de temps, on ajoute le pas de temps // dans la structure --// String valuePasDetemps = in_.getLine(); - structure.addPasDeTemps(valuePasDetemps); + structure.addSeparator(valuePasDetemps); in_.readFields(); @@ -191,7 +191,7 @@ value = in_.doubleField(i); - structure.addValueForVariableAtPdt(value, i, valuePasDetemps); + structure.addValueForVariableAtSeparator(value, i, valuePasDetemps); } } // on lit la suite @@ -216,7 +216,7 @@ // -- on est arriv\xE9 a une ligne de pas de temps --// String valuePasDetemps = in_.getLine(); - structure.addPasDeTemps(valuePasDetemps); + structure.addSeparator(valuePasDetemps); in_.readFields(); @@ -237,7 +237,7 @@ // on inscrit la valeur pour la variable du pas de temps // correspondant double value = in_.doubleField(0); - structure.addValueForVariableAtPdt(value, indiceVar, valuePasDetemps); + structure.addValueForVariableAtSeparator(value, indiceVar, valuePasDetemps); indiceVar++; // on lit la var suivante Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeStructure.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeStructure.java 2008-10-02 16:17:18 UTC (rev 4024) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeStructure.java 2008-10-02 18:32:19 UTC (rev 4025) @@ -19,6 +19,8 @@ public abstract void printResults(); + public abstract EvolutionReguliere[] returnEvolReguliere(); + /** * Structure pour les fichiers s ou t Par convention les x sont les premieres * variables. @@ -183,8 +185,8 @@ double[] tabY = new double[listeY.size()]; for (int j = 0; j < listeX.size(); j++) { - tabX[i] = listeX.get(i); - tabY[i] = listeY.get(i); + tabX[j] = listeX.get(j); + tabY[j] = listeY.get(j); } @@ -266,12 +268,12 @@ public static class Gene extends ScopeStructure { /** - * Map qui donne a chaque pas de temps sa liste de valeurs pour chaque + * Map qui donne a chaque separator sa liste de valeurs pour chaque * variables. */ private Map<String, ArrayList<ArrayList<Double>>> data_ = new HashMap<String, ArrayList<ArrayList<Double>>>(); - private List<String> listePasDeTemps = new ArrayList<String>(); + private List<String> listeSeparator = new ArrayList<String>(); private List<String> listeVariales_ = new ArrayList<String>(); @@ -298,7 +300,7 @@ - public List<Double> getAllX(String pdt) { + public ArrayList<Double> getAllX(String pdt) { return data_.get(pdt).get(0); } @@ -316,6 +318,27 @@ getAllX(pdt).add(x); } + + public double getXMax(){ + double max=getX(0,listeSeparator.get(0)); + + for(int j=0;j<listeSeparator.size();j++) + for(int i=1;i<getAllX(listeSeparator.get(j)).size();i++) + if(max<getX(i,listeSeparator.get(j))) + max=getX(i,listeSeparator.get(j)); + return max; + } + + public double getXMin(){ + double min=getX(0,listeSeparator.get(0)); + + for(int j=0;j<listeSeparator.size();j++) + for(int i=1;i<getAllX(listeSeparator.get(j)).size();i++) + if(min>getX(i,listeSeparator.get(j))) + min=getX(i,listeSeparator.get(j)); + return min; + } + /** * Methode qui insert le x dans les variables que si il n'existe pas deja. * @@ -331,10 +354,10 @@ - public void addPasDeTemps(String ligne) { + public void addSeparator(String ligne) { ligne = ligne.replace(KEY.getBlocCommentaireGENE(), ""); - listePasDeTemps.add(ligne); + listeSeparator.add(ligne); // on ajoute un enregistrment dans data pour le pas de temps // correspondant @@ -355,8 +378,8 @@ // // } - public int getNbPasDeTemps() { - return listePasDeTemps.size(); + public int getNbSeparator() { + return listeSeparator.size(); } @@ -364,23 +387,23 @@ return listeVariales_.size(); } - public ArrayList<ArrayList<Double>> getListeVarForPasDeTemps(String pdt) { + public ArrayList<ArrayList<Double>> getListeVarForSeparator(String pdt) { return data_.get(pdt); } - public ArrayList<ArrayList<Double>> getListeVarForPasDeTemps(int pdt) { - return data_.get(listePasDeTemps.get(pdt)); + public ArrayList<ArrayList<Double>> getListeVarForSeparator(int pdt) { + return data_.get(listeSeparator.get(pdt)); } - public ArrayList<Double> getListValueForVariableForPDT(String pdt, int var) { + public ArrayList<Double> getListValueForVariableForSeparator(String separator, int var) { - return getListeVarForPasDeTemps(pdt).get(var); + return getListeVarForSeparator(separator).get(var); } - public void addValueForVariableAtPdt(double value, int indexVariable, String valuePasDetemps) { - ArrayList<Double> listeValueOfVar = getListValueForVariableForPDT(valuePasDetemps, indexVariable); + public void addValueForVariableAtSeparator(double value, int indexVariable, String nameSeparator) { + ArrayList<Double> listeValueOfVar = getListValueForVariableForSeparator(nameSeparator, indexVariable); // if (listeValueOfVar == null) // listeValueOfVar = new ArrayList<Double>(); @@ -403,14 +426,14 @@ * retourne l equivalent d une ligne du fichier qui contient les valeurs * pour chaque variables pour un pas de temps donn\xE9. * - * @param pasDetemps + * @param separator * @return */ - public String getAllValuesForVariableAndPasDeTemps(String pasDetemps,int indiceValue) { + public String getAllValuesForVariableAndSeparator(String separator,int indiceValue) { String ligneBrochette = ""; for (int i = 0; i < listeVariales_.size(); i++) { - ArrayList<Double> listeValueOfVar = getListValueForVariableForPDT(pasDetemps, i); + ArrayList<Double> listeValueOfVar = getListValueForVariableForSeparator(separator, i); if (i != 0) ligneBrochette += " "; if (listeValueOfVar.get(indiceValue) != KEY.VALUE_UNDEFINED) @@ -423,8 +446,8 @@ } - public String getPasDeTemps(int i) { - return listePasDeTemps.get(i); + public String getSeparator(int i) { + return listeSeparator.get(i); } public String getVariable(int i) { return listeVariales_.get(i); @@ -441,26 +464,26 @@ public EvolutionReguliere[] returnEvolReguliere() { - EvolutionReguliere[] evolReg = new EvolutionReguliere[getNbPasDeTemps() * getNbVariables()]; + EvolutionReguliere[] evolReg = new EvolutionReguliere[getNbSeparator() * getNbVariables()]; // -- on parcours tous les pas de temps --// - for (int h = 0; h < getNbPasDeTemps(); h++) { + for (int h = 0; h < getNbSeparator(); h++) { - String pdt = getPasDeTemps(h); + String pdt = getSeparator(h); - // -- on parcours toutes les variables --// - for (int i = 0; i < getNbVariables(); i++) { + // -- on parcours toutes les variables et non les x --// + for (int i = 1; i < getNbVariables(); i++) { String nomVar = getVariable(i); List<Double> listeX = getAllX(pdt); - List<Double> listeY = getListValueForVariableForPDT(pdt, i); + List<Double> listeY = getListValueForVariableForSeparator(pdt, i); double[] tabX = new double[listeX.size()]; double[] tabY = new double[listeY.size()]; for (int j = 0; j < listeX.size(); j++) { - tabX[i] = listeX.get(i); - tabY[i] = listeY.get(i); + tabX[j] = listeX.get(j); + tabY[j] = listeY.get(j); } @@ -472,6 +495,190 @@ return evolReg; } + /** + * A utiliser poru transformer scopgen en evol temporelles. + * On cree une courbe par variables, et on prend les points de tous les separaor pou les former. + * @return + */ + public EvolutionReguliere[] returnEvolRegulierePourTemporelles() { + EvolutionReguliere[] evolReg = new EvolutionReguliere[getNbVariables()]; + + + // -- on parcours toutes les variables et non les x, on a une seule variable --// + for (int i = 1; i < getNbVariables(); i++) { + String nomVar = getVariable(i); + + List<Double> listeTOTALX =new ArrayList<Double>(); + List<Double> listeTOTALY = new ArrayList<Double>(); + + for(int k=0;k<getNbSeparator();k++){ + + //on recupere les x de ce separator + List<Double> listX=getListValueForVariableForSeparator(getSeparator(k), 0); + //on recupere les y de la variable de la courbe + List<Double> listY=getListValueForVariableForSeparator(getSeparator(k), i); + + //on ajoute tout cela au x et y totaux + listeTOTALX.addAll(listX); + listeTOTALY.addAll(listY); + + + } + + //creation de l evol reguliere + double[] tabX = new double[listeTOTALX.size()]; + double[] tabY = new double[listeTOTALX.size()]; + for (int j = 0; j < listeTOTALX.size(); j++) { + tabX[j] = listeTOTALX.get(j); + tabY[j] = listeTOTALY.get(j); + } + evolReg[i] = new EvolutionReguliere(tabX, tabY, false); + evolReg[i].setNom("courbe de " + nomVar); + + + } + + return evolReg; + } + + /** + * Methode reservee pour les correlations, on genere une courbe a la fois. + *les x seront la variable du separator specifi\xE9 + *les Y idem + * @return + */ + public EvolutionReguliere[] returnEvolReguliereCorrelation(int varX,int varY,int separatorX,int separatorY){ + EvolutionReguliere[] evolReg = new EvolutionReguliere[1]; + + List<Double> listeX=getListValueForVariableForSeparator(getSeparator(separatorX), varX+1); + List<Double> listeY=getListValueForVariableForSeparator(getSeparator(separatorY), varY+1); + + double[] tabX = new double[listeX.size()]; + double[] tabY = new double[listeY.size()]; + + for (int j = 0; j < listeX.size(); j++) { + tabX[j] = listeX.get(j); + tabY[j] = listeY.get(j); + + } + + evolReg[0] = new EvolutionReguliere(tabX, tabY, false); + evolReg[0].setNom("courbe corr\xE9l\xE9e X="+getVariable(varX+1)+"/Y="+getVariable(varY+1)); + + + return evolReg; + } + + + /** + * Methode qui reduit la structure en ne conservant que les separator de debut et de fin. + * la liste des variables dont les indices doivents etre incr\xE9ment\xE9s car pas de x. + * et ne garder que le x choisi et interpoler les valeur de facon lin\xE9aire. + * @param debSeparator + * @param finSeparator + * @param listVariables + * @param xchoosen + */ + public void restreindreStructure(int debSeparator,int finSeparator,int[] listVariables, double xchoosen){ + + //on reduit les separator a la liste voulue + restreindreStructure(debSeparator, finSeparator); + + //on reduit les variables + restreindreStructure(listVariables); + + //on interpole pour le x choisi + restreindreStructure(xchoosen); + + printResults(); + } + + public void restreindreStructure(int debSeparator,int finSeparator){ + Map<String, ArrayList<ArrayList<Double>>> newdata_ = new HashMap<String, ArrayList<ArrayList<Double>>>(); + List<String> newlisteSeparator = new ArrayList<String>(); + + + // on ajoute les separator de la plage + for(int i=0;i<getNbSeparator();i++){ + if(i>=debSeparator && i<=finSeparator){ + String newSepa= getSeparator(i); + newlisteSeparator.add(newSepa); + newdata_.put(newSepa, getListeVarForSeparator(i)); + } + } + listeSeparator=newlisteSeparator; + data_=newdata_; + + } + + public void restreindreStructure(int[] listVariables){ + Map<String, ArrayList<ArrayList<Double>>> newdata_ = new HashMap<String, ArrayList<ArrayList<Double>>>(); + List<String> newlisteVariables = new ArrayList<String>(); + + //on ajoute par defaut les x + newlisteVariables.add(getVariable(0)); + + + + //on ajout les news variabels + for(int j=0;j<listVariables.length;j++) + newlisteVariables.add(getVariable(listVariables[j]+1)); + + // on ajoute uniquement les datas de ces variables + for(int i=0;i<getNbSeparator();i++){ + + ArrayList<ArrayList<Double>> newVariablePerValidator=new ArrayList<ArrayList<Double>>(); + + //on ajoute tout dabord tous les x + newVariablePerValidator.add(getAllX(getSeparator(i))); + + for(int j=0;j<listVariables.length;j++){ + //il faut incrementer de 1 car pas de X pris en compte pour les choix de var or ici c est l'elt 0 + int selectedVar=listVariables[j]+1; + newVariablePerValidator.add(getListValueForVariableForSeparator(getSeparator(i), selectedVar)); + + + } + newdata_.put(getSeparator(i), newVariablePerValidator); + + } + listeVariales_=newlisteVariables; + data_=newdata_; + + } + + public void restreindreStructure(double xchoosen){ + + for(int i=0;i<getNbSeparator();i++){ + + ArrayList<Double> listeX=getAllX(getSeparator(i)); + + int indiceProche=0; + double xProche=listeX.get(0); + //etape 1 on recherche le x le plus proche du xchoosen + for(int k=1;k<listeX.size();k++){ + double test=listeX.get(k); + if(Math.abs(test-xchoosen)<Math.abs(xProche-xchoosen)){ + xProche=test; + indiceProche=k; + } + } + + //on ne conserve dans chaque liste des variables que la valeur correspondante au xProche + for(int j=0;j<getNbVariables();j++){ + + ArrayList<Double> listeValueVar=getListValueForVariableForSeparator(getSeparator(i), j); + double conservVar=listeValueVar.get(indiceProche); + for(int h=0;h<listeValueVar.size();) + listeValueVar.remove(h); + listeValueVar.add(conservVar); + + + } + } + + } + @Override public void printResults() { // titres @@ -486,19 +693,19 @@ } // tableau de val mode non eclatee - String tableauVal = "0 " + KEY.getScopeGENESeparator(getPasDeTemps(0)) + " 0 0 0 0 0 0 0 0"; + String tableauVal = "0 " + KEY.getScopeGENESeparator(getSeparator(0)) + " 0 0 0 0 0 0 0 0"; System.err.print("\n" + tableauVal); // pour chaque pas de temps - for (int i = 0; i < listePasDeTemps.size(); i++) { + for (int i = 0; i < listeSeparator.size(); i++) { // separator pas de temps - System.err.print("\n " + getPasDeTemps(i)); + System.err.print("\n " + getSeparator(i)); - int nbValuesForThisPdt = getListeVarForPasDeTemps(i).get(0).size(); + int nbValuesForThisPdt = getListeVarForSeparator(i).get(0).size(); // -- parcours la liste des donnees for (int k = 0; k < nbValuesForThisPdt; k++) { - System.err.print("\n" + getAllValuesForVariableAndPasDeTemps(getPasDeTemps(i), k)); + System.err.print("\n" + getAllValuesForVariableAndSeparator(getSeparator(i), k)); } Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriterGENE.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriterGENE.java 2008-10-02 16:17:18 UTC (rev 4024) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriterGENE.java 2008-10-02 18:32:19 UTC (rev 4025) @@ -1,6 +1,8 @@ package org.fudaa.dodico.telemac.io; import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Calendar; import org.fudaa.ctulu.CtuluActivity; import org.fudaa.ctulu.fileformat.FileFormatVersionInterface; @@ -69,11 +71,12 @@ } protected void writeHeader(ScopeStructure.Gene _struct) throws IOException { - String bc = key_.getBlocCommentaireGENE(); - setProgression(0, H2dResource.getS("Cr\xE9ation des en-t\xEAtes") + bc); - for (int i = 0; i < _struct.getNbTitles(); i++) { - writelnToOut(bc + _struct.getTitle(i)); - } + String bc = key_.getBlocCommentaireGENE(); + setProgression(0, H2dResource.getS("Cr\xE9ation des en-t\xEAtes") + bc); + writelnToOut(bc + H2dResource.getS("Fichier g\xE9n\xE9r\xE9 par Fudaa") + bc); + final String date = new SimpleDateFormat("yyyy-M-d k:mm:ss").format(Calendar.getInstance().getTime()); + writelnToOut(bc + "Version " + key_.getVersion() + " - Date " + date + bc); + writelnToOut(bc); } @@ -86,7 +89,7 @@ writelnToOut(_struct.getVariable(i)); } // tableau de val mode non eclatee - String tableauVal = "0 " + key_.getScopeGENESeparator(_struct.getPasDeTemps(0)) + " 0 0 0 0 0 0 0 0"; + String tableauVal = "0 " + key_.getScopeGENESeparator(_struct.getSeparator(0)) + " 0 0 0 0 0 0 0 0"; writelnToOut(tableauVal); } @@ -94,15 +97,15 @@ setProgression(30, H2dResource.getS("Cr\xE9ation des donn\xE9es")); // pour chaque pas de temps - for (int i = 0; i < _struct.getNbPasDeTemps(); i++) { + for (int i = 0; i < _struct.getNbSeparator(); i++) { // separator pas de temps - writelnToOut(_struct.getPasDeTemps(i)); + writelnToOut(_struct.getSeparator(i)); // -- parcours la liste des donnees - int nbValuesForThisPdt = _struct.getListeVarForPasDeTemps(i).get(0).size(); + int nbValuesForThisPdt = _struct.getListeVarForSeparator(i).get(0).size(); for (int k = 0; k < nbValuesForThisPdt; k++) { - writelnToOut(_struct.getAllValuesForVariableAndPasDeTemps(_struct.getPasDeTemps(i), k)); + writelnToOut(_struct.getAllValuesForVariableAndSeparator(_struct.getSeparator(i), k)); } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeImporterScope.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeImporterScope.java 2008-10-02 16:17:18 UTC (rev 4024) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeImporterScope.java 2008-10-02 18:32:19 UTC (rev 4025) @@ -4,6 +4,7 @@ import org.fudaa.ctulu.CtuluCommandManager; import org.fudaa.ctulu.ProgressionInterface; +import org.fudaa.dodico.mesure.EvolutionReguliere; import org.fudaa.dodico.telemac.io.ScopeStructure; import org.fudaa.ebli.commun.EbliActionSimple; import org.fudaa.ebli.courbe.EGCourbeChild; @@ -32,18 +33,26 @@ */ - public static EGGraphe createGrapheTemporel(ScopeStructure.SorT data_,ProgressionInterface prog){ + public static void createGraphe(FudaaCourbeImporter.Target target,ScopeStructure _data, CtuluCommandManager _mng,ProgressionInterface _prog){ - return createGrapheSpatialGraphe(data_, prog); + createGraphe(target,_data.returnEvolReguliere(), _mng, _prog); } + public static void createGraphe(FudaaCourbeImporter.Target target,EvolutionReguliere[] _data, CtuluCommandManager _mng,ProgressionInterface _prog){ + + + target.importCourbes(_data, _mng, _prog); + } + + + /** * genere un graphe spatial * @param data_ * @return */ - public static EGGraphe createGrapheSpatialGraphe(ScopeStructure.SorT data_,ProgressionInterface prog){ + public static void createGrapheSpatialGrapheOLD(FudaaCourbeImporter.Target target,ScopeStructure.SorT data_,ProgressionInterface prog){ EGGrapheTreeModel model=new EGGrapheTreeModel(); double[] tabX=new double[data_.getAllX().size()]; @@ -74,20 +83,7 @@ EGGraphe graphe=new EGGraphe(model); - return graphe; - } - - -public static EGGraphe createGrapheSpatialGENE(ScopeStructure.Gene data_,ProgressionInterface prog){ - - return null; } - -public static EGGraphe createGrapheTemporelGENE(ScopeStructure.Gene data_,ProgressionInterface prog){ - - - return null; } -} Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeWizardImportScope.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeWizardImportScope.java 2008-10-02 16:17:18 UTC (rev 4024) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeWizardImportScope.java 2008-10-02 18:32:19 UTC (rev 4025) @@ -1,20 +1,28 @@ package org.fudaa.fudaa.commun.courbe; import java.awt.BorderLayout; +import java.awt.CardLayout; import java.awt.FlowLayout; +import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import javax.swing.AbstractAction; +import javax.swing.AbstractListModel; import javax.swing.BorderFactory; +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JTextField; +import javax.swing.ListSelectionModel; import javax.swing.filechooser.FileFilter; import org.fudaa.ctulu.CtuluCommandManager; @@ -28,6 +36,7 @@ import org.fudaa.ctulu.gui.CtuluLibSwing; import org.fudaa.ctulu.gui.CtuluTaskOperationGUI; import org.fudaa.dodico.mesure.EvolutionFileFormat; +import org.fudaa.dodico.mesure.EvolutionReguliere; import org.fudaa.dodico.reflux.io.CLTransitoireFileFormat; import org.fudaa.dodico.reflux.io.CrbFileFormat; import org.fudaa.dodico.rubar.io.RubarCLIFileFormat; @@ -44,12 +53,14 @@ import org.fudaa.fudaa.commun.courbe.FudaaCourbeImporterScope; import org.fudaa.fudaa.commun.impl.FudaaCommonImplementation; import org.fudaa.fudaa.commun.impl.FudaaGuiLib; +import org.fudaa.fudaa.ressource.FudaaResource; import org.fudaa.fudaa.tr.common.TrResource; import com.memoire.bu.BuButton; import com.memoire.bu.BuButtonPanel; import com.memoire.bu.BuCharValidator; import com.memoire.bu.BuFileFilter; +import com.memoire.bu.BuIcon; import com.memoire.bu.BuResource; import com.memoire.bu.BuStringValidator; import com.memoire.bu.BuTextField; @@ -69,7 +80,7 @@ //donnees haut niveau FudaaCommonImplementation impl_; - + FudaaCourbeImporter.Target target_; /** * type de fomat: * 0 => scops @@ -93,17 +104,19 @@ BuTextField plageFin_=new BuTextField(5); double xMin; double xMax; - JList listVariables_; + JList listVariablesST_; public static class ImportAction extends EbliActionSimple { final FudaaCommonImplementation ui_; - public ImportAction(final FudaaCommonImplementation _ui) { + FudaaCourbeImporter.Target target_; + public ImportAction(final FudaaCommonImplementation _ui,FudaaCourbeImporter.Target target) { super(BuResource.BU.getString("Importer au format scope"), BuResource.BU.getIcon("IMPORTER"), "IMPORTER"); - ui_ = _ui; + ui_ = _ui; + target_=target; } public void actionPerformed(final ActionEvent _e) { - FudaaCourbeWizardImportScope wizard=new FudaaCourbeWizardImportScope(ui_); + FudaaCourbeWizardImportScope wizard=new FudaaCourbeWizardImportScope(ui_,target_); BuWizardDialog DialogWizard = new BuWizardDialog(ui_.getFrame(), wizard); // --affichage du wizard --// DialogWizard.setSize(600, 500); @@ -113,7 +126,7 @@ } - public FudaaCourbeWizardImportScope(FudaaCommonImplementation impl) { + public FudaaCourbeWizardImportScope(FudaaCommonImplementation impl,FudaaCourbeImporter.Target target) { super(); impl_=impl; @@ -301,10 +314,10 @@ for(int i=1;i<dataST().getNbVariables();i++) listeVar[i-1]=dataST().getVariable(i); - listVariables_=new JList(listeVar); - listVariables_.setSelectedIndex(0); - content.add(listVariables_,BorderLayout.CENTER); - listVariables_.setBorder(BorderFactory.createTitledBorder(TrResource.getS("S\xE9lection des variables"))); + listVariablesST_=new JList(listeVar); + listVariablesST_.setSelectedIndex(0); + content.add(listVariablesST_,BorderLayout.CENTER); + listVariablesST_.setBorder(BorderFactory.createTitledBorder(TrResource.getS("S\xE9lection des variables"))); plageDeb_.setCharValidator(BuCharValidator.FLOAT); plageDeb_.setStringValidator(BuStringValidator.FLOAT); @@ -331,14 +344,216 @@ } + + JComboBox comBoChoixTypeGraphe_=new JComboBox(new String[]{TrResource.getS("Profil Spatial"),TrResource.getS("Evolution temporelle"),TrResource.getS("Corr\xE9lation")}); + JList listSeparator_,listSeparatorDebPlage_,listSeparatorFinPlage_, listSeparatorCorrel1_,listSeparatorCorrel2_; + JList listVariablesGENE_,listVariablesGENE2_,listVariablesGENECorrlX_,listVariablesGENECorrlY_; + CardLayout layoutParamGene=new CardLayout(); + BuTextField fieldX=new BuTextField(10); /** + * Liste des couples a importer. + * Ces couples utilisent la classe coupleVarSepartor + */ + JList listCoupleSpatiauxGENE_; + DefaultListModel modelCoupleSpatiauxGENE_; + public class CoupleVarSepartor{ + String nomVar,nomSeparator; + ArrayList<Double> listX; + ArrayList<Double> listY; + public CoupleVarSepartor(String nomVar, String nomSeparator, + ArrayList<Double> listX, ArrayList<Double> listY) { + this.nomVar = nomVar; + this.nomSeparator = nomSeparator; + this.listX = listX; + this.listY = listY; + } + @Override + public String toString() { + // TODO Auto-generated method stub + return "("+nomVar+"/"+nomSeparator+")"; + } + + public EvolutionReguliere transform(boolean _time){ + double[] tabX = new double[listX.size()]; + double[] tabY = new double[listY.size()]; + for (int j = 0; j < listX.size(); j++) { + tabX[j] = listX.get(j); + tabY[j] = listY.get(j); + } + EvolutionReguliere evol=new EvolutionReguliere(tabX, tabY,_time); + evol.setNom(nomVar+" "+nomSeparator); + return evol; + } + + } + + /** * Creation du panel scopGene pour choisir ses parametres * @return */ JPanel buildPanelScopeGENE(){ + final JPanel content=new JPanel(new BorderLayout()); + content.add(comBoChoixTypeGraphe_,BorderLayout.NORTH); + final JPanel container=new JPanel(layoutParamGene); + content.add(container,BorderLayout.CENTER); + comBoChoixTypeGraphe_.setAction(new AbstractAction(){ + public void actionPerformed(ActionEvent arg0) { + String val=(String) comBoChoixTypeGraphe_.getSelectedItem(); + layoutParamGene.show(container, val); + //layoutParamGene.next(container); +// content.revalidate(); +// container.revalidate(); + + } + }); + + //-- ACHTUNG!!! DANS LES SPEC ON VEUT POUVOIR SAISIR DES COUPLES SEPARATOR/VARIABLES --// + //-- creation de la liste des variables --// + String[] listeVar=new String[dataG().getNbVariables()-1]; + //on ne prends pas les x + for(int i=1;i<dataG().getNbVariables();i++) + listeVar[i-1]=dataG().getVariable(i); + listVariablesGENE_=new JList(listeVar); + listVariablesGENE_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listVariablesGENE_.setBorder(BorderFactory.createTitledBorder(TrResource.getS("S\xE9lection des variables"))); - return null; + //-- creation de la liste des separators --// + listeVar=new String[dataG().getNbSeparator()]; + //on ne prends pas les x + for(int i=0;i<dataG().getNbSeparator();i++) + listeVar[i]=dataG().getSeparator(i); + listSeparator_=new JList(listeVar); + listSeparator_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listSeparator_.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Valeurs num\xE9riques du s\xE9parateur de bloc"))); + + + //-- panel reserv\xE9 aux profils spatiaux --// + JPanel paramProfils=new JPanel(new BorderLayout()); + container.add(paramProfils, TrResource.getS("Profil Spatial")); + JPanel choixVar=new JPanel(new GridLayout(1,2)); + choixVar.add(listVariablesGENE_); + choixVar.add(listSeparator_); + paramProfils.add(choixVar,BorderLayout.NORTH); + //--panel du milieu: liste de couples VAR/SEPARATOR --// + modelCoupleSpatiauxGENE_=new DefaultListModel(); + listCoupleSpatiauxGENE_=new JList(modelCoupleSpatiauxGENE_); + listCoupleSpatiauxGENE_.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Liste des couples variable/separateur"))); + paramProfils.add(listCoupleSpatiauxGENE_,BorderLayout.CENTER); + //-- boutons du bas d'ajout/supression dans la liste --// + BuButton ajouter=new BuButton(FudaaResource.FUDAA.getIcon("crystal_ajouter"), TrResource.getS("Ajouter")); + ajouter.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e) { + if(listSeparator_.getSelectedIndex()==-1) + impl_.error(TrResource.getS("Il faut choisir une valeur num\xE9rique de s\xE9parateur.")); + else if(listVariablesGENE_.getSelectedIndex()==-1) + impl_.error(TrResource.getS("Il faut choisir une variable.")); + else{ + //-- creation du couple choisi en recherchant les bonnes donn\xE9es dans la structure --// + int indiceVarChoisie=listVariablesGENE_.getSelectedIndex()+1; + String varChoisie=dataG().getVariable(indiceVarChoisie); + String separatorChoisi=dataG().getSeparator(listSeparator_.getSelectedIndex()); + CoupleVarSepartor newCouple=new CoupleVarSepartor(varChoisie,separatorChoisi,dataG().getAllX(separatorChoisi),dataG().getListValueForVariableForSeparator(separatorChoisi,indiceVarChoisie)); + modelCoupleSpatiauxGENE_.addElement(newCouple); + } + } + + }); + BuButton supprimer=new BuButton(FudaaResource.FUDAA.getIcon("crystal_enlever"), TrResource.getS("Enlever")); + supprimer.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e) { + if(listCoupleSpatiauxGENE_.getSelectedIndex()==-1) + impl_.error(TrResource.getS("Il faut choisir une valeur du couple \xE0 supprimer")); + + else{ + modelCoupleSpatiauxGENE_.remove(listCoupleSpatiauxGENE_.getSelectedIndex()); + } + } + + }); + //ajout des boutons + JPanel panelActions=new JPanel(new FlowLayout()); + panelActions.add(ajouter); + panelActions.add(supprimer); + paramProfils.add(panelActions, BorderLayout.SOUTH); + + //-- panel reserv\xE9 aux courbes temporelles --// + JPanel paramTempo=new JPanel(new BorderLayout()); + container.add(paramTempo, TrResource.getS("Evolution temporelle")); + listeVar=new String[dataG().getNbVariables()-1]; + for(int i=1;i<dataG().getNbVariables();i++) + listeVar[i-1]=dataG().getVariable(i); + listVariablesGENE2_=new JList(listeVar); + listVariablesGENE2_.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + listVariablesGENE2_.setBorder(BorderFactory.createTitledBorder(TrResource.getS("S\xE9lection des variables"))); + listeVar=new String[dataG().getNbSeparator()]; + for(int i=0;i<dataG().getNbSeparator();i++) + listeVar[i]=dataG().getSeparator(i); + listSeparatorDebPlage_=new JList(listeVar); + listSeparatorDebPlage_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listSeparatorDebPlage_.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Plage d\xE9part du s\xE9parateur de bloc"))); + listSeparatorDebPlage_.setSelectedIndex(0); + listSeparatorFinPlage_=new JList(listeVar); + listSeparatorFinPlage_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listSeparatorFinPlage_.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Plage fin du s\xE9parateur de bloc"))); + listSeparatorFinPlage_.setSelectedIndex(listSeparatorDebPlage_.getModel().getSize()-1); + + JPanel listData=new JPanel(new GridLayout(1,2)); + JPanel listData2=new JPanel(new GridLayout(2,1)); + listData.add(listVariablesGENE2_); + listData.add(listData2); + listData2.add(listSeparatorDebPlage_); + listData2.add(listSeparatorFinPlage_); + paramTempo.add(listData,BorderLayout.CENTER); + + //textField contenant le x choisi + xMax=dataG().getXMax(); + xMin=dataG().getXMin(); + JPanel panelInfo=new JPanel(); + panelInfo.add(new JLabel(TrResource.getS("Veuillez saisir le X:") +xMin+"<=X<="+xMax)); + fieldX.setCharValidator(BuCharValidator.FLOAT); + fieldX.setStringValidator(BuStringValidator.FLOAT); + fieldX.setValueValidator(BuValueValidator.FLOAT); + panelInfo.add(fieldX); + paramTempo.add(panelInfo,BorderLayout.SOUTH); + fieldX.setText(""+((xMax+xMin)/2)); + + + + //-- panel reserv\xE9s au corr\xE9lations --// + JPanel paramCorrel=new JPanel(new GridLayout(2,2)); + container.add(paramCorrel, TrResource.getS("Corr\xE9lation")); + + listeVar=new String[dataG().getNbVariables()-1]; + for(int i=1;i<dataG().getNbVariables();i++) + listeVar[i-1]=dataG().getVariable(i); + listVariablesGENECorrlX_=new JList(listeVar); + listVariablesGENECorrlX_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listVariablesGENECorrlX_.setBorder(BorderFactory.createTitledBorder(TrResource.getS("S\xE9lection la variable pour l'axe X"))); + listVariablesGENECorrlY_=new JList(listeVar); + listVariablesGENECorrlY_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listVariablesGENECorrlY_.setBorder(BorderFactory.createTitledBorder(TrResource.getS("S\xE9lection la variable pour l'axe Y"))); + + + listeVar=new String[dataG().getNbSeparator()]; + for(int i=0;i<dataG().getNbSeparator();i++) + listeVar[i]=dataG().getSeparator(i); + listSeparatorCorrel1_=new JList(listeVar); + listSeparatorCorrel1_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listSeparatorCorrel1_.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Plage associ\xE9e \xE0 la variable X"))); + listSeparatorCorrel1_.setSelectedIndex(0); + + listSeparatorCorrel2_=new JList(listeVar); + listSeparatorCorrel2_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listSeparatorCorrel2_.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Plage associ\xE9e \xE0 la variable Y"))); + listSeparatorCorrel2_.setSelectedIndex(0); + + paramCorrel.add(listVariablesGENECorrlX_); + paramCorrel.add(listSeparatorCorrel1_); + paramCorrel.add(listVariablesGENECorrlY_); + paramCorrel.add(listSeparatorCorrel2_); + + return content; } JPanel buildPanelParametresImportation(){ @@ -403,27 +618,57 @@ impl_.setMainMessage(CtuluLib.getS("Structure modification")); prog.setProgression(10); prog.setDesc(CtuluLib.getS("Structure modification")); - if(typeFormat_<=1) - dataST().restreindreStructure(listVariables_.getSelectedIndices(),Double.parseDouble(plageDeb_.getText()),Double.parseDouble(plageFin_.getText())); - - + if(typeFormat_<=1){ + dataST().restreindreStructure(listVariablesST_.getSelectedIndices(),Double.parseDouble(plageDeb_.getText()),Double.parseDouble(plageFin_.getText())); impl_.setMainProgression(30); impl_.setMainMessage(CtuluLib.getS("Cr\xE9ation du graphe")); - // creation du graphe - switch(typeFormat_){ - case 0: - //cas s - result_=FudaaCourbeImporterScope.createGrapheSpatialGraphe(dataST(),prog);break; - case 1: - //cas scopT - result_=FudaaCourbeImporterScope.createGrapheTemporel(dataST(),prog);break; - case 2: - //cas scopGENE - result_=FudaaCourbeImporterScope.createGrapheTemporelGENE(dataG(),prog);break; - } - - //-- mise en forme du resultata g\xE9n\xE9r\xE9 --// - createGraphImported(result_); + FudaaCourbeImporterScope.createGraphe(target_, data_, null, prog); + } + else{ + //-- format scopeGen, selon le type de format g\xE9n\xE9r\xE9--// + if(comBoChoixTypeGraphe_.getSelectedIndex()==0){ + //profil spatial, on recupere la liste des couples solutions + EvolutionReguliere[] tabEvol=new EvolutionReguliere[modelCoupleSpatiauxGENE_.getSize()]; + for(int i=0;i<modelCoupleSpatiauxGENE_.getSize();i++) + tabEvol[i]=((CoupleVarSepartor) modelCoupleSpatiauxGENE_.getElementAt(i)).transform(false); + + impl_.setMainProgression(30); + impl_.setMainMessage(CtuluLib.getS("Cr\xE9ation du graphe")); + FudaaCourbeImporterScope.createGraphe(target_, tabEvol, null, prog); + }else + if(comBoChoixTypeGraphe_.getSelectedIndex()==1){ + //profil spatial + int debSeparator=listSeparatorDebPlage_.getSelectedIndex(); + int finSeparator=listSeparatorFinPlage_.getSelectedIndex(); + int[] selectedVariables= listVariablesGENE2_.getSelectedIndices(); + double xchoosen=Double.parseDouble(fieldX.getText()); + dataG().restreindreStructure(debSeparator,finSeparator,selectedVariables,xchoosen); + + impl_.setMainProgression(30); + impl_.setMainMessage(CtuluLib.getS("Cr\xE9ation du graphe")); + //on cree les evol reguliere SPECIFIQUES pour ces courbes. + FudaaCourbeImporterScope.createGraphe(target_, dataG().returnEvolRegulierePourTemporelles(), null, prog); + + }else{ + //correlation + impl_.setMainProgression(30); + impl_.setMainMessage(CtuluLib.getS("Cr\xE9ation du graphe")); + //on cree les evol reguliere SPECIFIQUES pour ces courbes. + int varX=listVariablesGENECorrlX_.getSelectedIndex(); + int varY=listVariablesGENECorrlY_.getSelectedIndex(); + + int plageX=listSeparatorCorrel1_.getSelectedIndex(); + int plageY=listSeparatorCorrel2_.getSelectedIndex(); + + FudaaCourbeImporterScope.createGraphe(target_, dataG().returnEvolReguliereCorrelation(varX,varY,plageX,plageY), null, prog); + + + } + + } + + //-- mise en forme du resultata g\xE9n\xE9r\xE9 --// + createGraphImported(); } }.start(); } @@ -433,7 +678,7 @@ * Methode a surcharger. * Appel\xE9e a la toute fin, gere le resultat */ - public void createGraphImported(EGGraphe grapheGenere){ + public void createGraphImported(){ //placer le graphe ou vous voulez... } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaWriterScopeGENE.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaWriterScopeGENE.java 2008-10-02 16:17:18 UTC (rev 4024) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaWriterScopeGENE.java 2008-10-02 18:32:19 UTC (rev 4025) @@ -2,6 +2,7 @@ import java.io.File; import java.io.IOException; +import java.util.ArrayList; import jxl.write.WriteException; @@ -65,8 +66,8 @@ EGCourbe[] listeChoixUser = data.getCourbes(); //-- on ajoute un pas de temps qui decrit le graphe --// - String keyPDt="contenu graphe"; - structure_.addPasDeTemps(keyPDt); + String keyPDt="X=contenu graphe"; + structure_.addSeparator(keyPDt); @@ -107,6 +108,8 @@ if (!hasAlreadyRegistered) { hasAlreadyRegistered = true; structure_.addVariable(groupe.getTitle()); + //ACHTUNG IL FAUT AJOUTER CETTE LISTE QUI PERMETTRA AU VARIABLE D INITIALISER LEUR DATA. + structure_.getListeVarForSeparator(keyPDt).add(new ArrayList<Double>()); } // --ajout des valeurs pour chaque X--/ @@ -129,10 +132,10 @@ // -- si le x existe dans la courbe alors on inscrit son y // correspondant pour la bonne variable--// if (xExistForCourbe) - structure_.addValueForVariableAtPdt(courbe.getModel().getY(emplacementYcorrespondant), structure_.getNbVariables()-1, keyPDt); + structure_.addValueForVariableAtSeparator(courbe.getModel().getY(emplacementYcorrespondant), structure_.getNbVariables()-1, keyPDt); else // -- on enregistre une valeure foireuse. - structure_.addValueForVariableAtPdt(ScopeKeyWord.VALUE_UNDEFINED, structure_.getNbVariables()-1, keyPDt); + structure_.addValueForVariableAtSeparator(ScopeKeyWord.VALUE_UNDEFINED, structure_.getNbVariables()-1, keyPDt); } } Added: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/common/TrPostActionLigneCourants.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/common/TrPostActionLigneCourants.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/common/TrPostActionLigneCourants.java 2008-10-02 18:32:19 UTC (rev 4025) @@ -0,0 +1,36 @@ +package org.fudaa.fudaa.tr.common; + +import java.awt.event.ActionEvent; + +import org.fudaa.ebli.commun.EbliActionSimple; +import org.fudaa.fudaa.meshviewer.MvResource; +import org.fudaa.fudaa.meshviewer.profile.MvProfileTreeModel; +import org.fudaa.fudaa.tr.post.TrPostCommonImplementation; +import org.fudaa.fudaa.tr.post.TrPostDialogBilan; +import org.fudaa.fudaa.tr.post.TrPostDialogCurrentLine; +import org.fudaa.fudaa.tr.post.TrPostProjet; +import org.fudaa.fudaa.tr.post.TrPostVisuPanel; + +public class TrPostActionLigneCourants extends EbliActionSimple { + + // final MvProfileTarget src_; + TrPostProjet projet_; + + + public TrPostActionLigneCourants(TrPostProjet projet) { + super(MvResource.getS("Calcul des bilans"), MvResource.MV.getIcon("profile"), "BILAN"); + projet_=projet; + + } + + + + public void actionPerformed(final ActionEvent _e) { + // -- creation du wizard depusi le calque --// + + new TrPostDialogCurrentLine(projet_,projet_.getImpl()); + } + + + + } Added: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrComputeCurrentLine.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrComputeCurrentLine.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrComputeCurrentLine.java 2008-10-02 18:32:19 UTC (rev 4025) @@ -0,0 +1,198 @@ +package org.fudaa.fudaa.tr.post; + +import java.awt.Point; +import java.util.ArrayList; + +import org.fudaa.ctulu.ProgressionInterface; +import org.fudaa.dodico.ef.EfData; +import org.fudaa.dodico.ef.EfGridData; +import org.fudaa.dodico.ef.EfGridInterface; +import org.fudaa.dodico.ef.EfNeighborMesh; +import org.fudaa.dodico.ef.interpolation.EfGridDataInterpolator; +import org.fudaa.dodico.ef.interpolation.EfInterpolator; +import org.fudaa.dodico.ef.operation.EfIndexVisitorNearestElt; +import org.fudaa.dodico.ef.operation.EfIndexVisitorNearestNode; +import org.fudaa.dodico.ef.operation.EfLineIntersection; +import org.fudaa.dodico.ef.operation.EfLineIntersectionParent; +import org.fudaa.dodico.h2d.type.H2dVariableType; +import org.fudaa.ebli.geometrie.GrPoint; +import org.fudaa.ebli.geometrie.GrPolygone; +import org.fudaa.fudaa.tr.common.TrResource; + + +/** + * Algorithme de Calcul les lignes de courants + * @author Adrien Hadoux + * + */ +public class TrComputeCurrentLine implements EfLineIntersectionParent{ + + +/** + * data + */ +final TrPostSource data_; + +/** + * pour interpoler les valeur + */ +final EfInterpolator interpolator_; + +ProgressionInterface prog_; + +/** + * Liste des intersections r\xE9sultats + */ +ArrayList<EfLineIntersection> listeIntersection_=null; + + +public TrComputeCurrentLine(TrPostSource data_) { + super(); + this.data_ = data_; + this.interpolator_ = data_.getInterpolator(); +} + +public void progression(String desc, int completionRate){ + if(prog_==null) + return; + prog_.setDesc(TrResource.getS(desc)); + prog_.setProgression(5); + +} +/** + * Methode appel\xE9e par l'interface de calcul des lignes de courant. + * @param init point de depart + * @param dureeIntegration duree totale de l'integration en secondes + * @param indicePdt indice du pas de temps + * @param finesse coefficient de finesse double + * @param variable la variable a utiliser + * @param prog l'interface de progression, peut etre null + * @return + */ +public ArrayList<EfLineIntersection> computeLine(GrPoint init, double dureeIntegration, int indicePdt,double finesse ,H2dVariableType variable, ProgressionInterface prog){ + prog_=prog; + //on init le temps total avec l'indice du pas de temps fourni au depart + double tempsTotal=data_.getTimeStep(indicePdt); + double oldTempsTotal; + boolean inactif=false; + + + + + while(!inactif && tempsTotal<=dureeIntegration){ + oldTempsTotal=tempsTotal; + + //etape 1 \xE9l\xE9ment englobant de init + progression("Recherche \xE9l\xE9ment englobant",5); + int eltEnglob=elementEnglobant(init); + if(eltEnglob !=-1){ + //creation de la premiere intersection + EfLineIntersection.ItemMesh intersection=new EfLineIntersection.ItemMesh(eltEnglob,init.x_,init.y_); + //recup des datas + EfData dataX=data_.getData(variable, indicePdt); + double vx=intersection.getDistanceFrom(init.x_, init.y_); + double vy=intersection.getValueBadInterpolation(dataX); + + //calcul des distances avec son voisinage + EfNeighborMesh voisinage=EfNeighborMesh.compute(data_.getGrid(), prog_); + double distanceMaxEntrePoints=0; + int[] listeEltVoisins=null; + int voisinChoisi=0; + //cas sur un noeud + if(intersection.isNodeIntersection()){ + int nbVoisins=voisinage.getNbNeighborMeshes(eltEnglob); + listeEltVoisins=new int[nbVoisins]; + for(int i=0;i<nbVoisins;i++){ + //On calcule la distance avec lequel de ces points??? + listeEltVoisins[i] =voisinage.getNeighborMesh(eltEnglob, i); + } + + }else { + //comment faire en fudaa pour les autres cas??? + } + + //calcul de la distance max + if(listeEltVoisins!=null && listeEltVoisins.length>0) + voisinChoisi=listeEltVoisins[0]; + for(int i=0;i<listeEltVoisins.length;i++){ + int eltVoisin=listeEltVoisins[i]; + // comment je fais pour avoir les coordonn\xE9es x et y du point eltVoisin??? + double x=0 ;//a remplacer par les coordonn\xE9es de eltVoisin + double y=0; + double distance=Math.sqrt((init.x_-x)*(init.x_-x) + (init.y_-y)*(init.y_-y) ); + if(distanceMaxEntrePoints>distance){ + + //ACHTUNG!! VERIFIER QUE LE t+ deltaT<dureeIntegration si on choisit cette distance + if(vy!=0 && (tempsTotal+ distance/vy<=dureeIntegration)){ + distanceMaxEntrePoints=distance; + voisinChoisi=eltVoisin; + } + } + } + + //on calcul le nouveau temps total + if(vy !=0) + tempsTotal+=distanceMaxEntrePoints/vy; + + + + + + + + } + //on verifie que l'on n'est pas inactif + if(oldTempsTotal==tempsTotal) + inactif=true; + } + + return listeIntersection_; +} + + + + +/** + * Recherche l'\xE9l\xE9lment englobant pour un point donn\xE9 + * @param _prReel + * @param grid + * @return + */ +public int elementEnglobant(final GrPoint _prReel) { + EfGridInterface grid=data_.getGrid(); + if (grid.getIndex() != null) { + final EfIndexVisitorNearestElt visitor = new EfIndexVisitorNearestElt(grid, _prReel.x_, _prReel.y_, 0); + grid.getIndex().query(EfIndexVisitorNearestNode.getEnvelope(_prReel.x_, _prReel.y_, 0), visitor); + return visitor.isIn() ? visitor.getSelected() : -1; + } + else + return -1; + } + +@Override +public void buildNeighbor(ProgressionInterface _prog) { + // TODO Auto-generated method stub + +} + +@Override +public EfGridInterface getGrid() { + // TODO Auto-generated method stub + return data_.getGrid(); +} + +@Override +public EfGridDataInterpolator getGridData() { + // TODO Auto-generated method stub + return null; +} + +@Override +public EfNeighborMesh getNeighbor() { + // TODO Auto-generated method stub + return null; +} + + + +} Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostDialogCubature.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostDialogCubature.java 2008-10-02 16:17:18 UTC (rev 4024) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostDialogCubature.java 2008-10-02 18:32:19 UTC (rev 4025) @@ -343,7 +343,7 @@ } public String getTitle() { - return TrResource.getS("Bilans"); + return TrResource.getS("Cubatures"); } Added: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostDialogCurrentLine.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostDialogCurrentLine.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostDialogCurrentLine.java 2008-10-02 18:32:19 UTC (rev 4025) @@ -0,0 +1,392 @@ +package org.fudaa.fudaa.tr.post; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.ArrayList; + +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTree; +import javax.swing.ListModel; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.DefaultTableModel; + +import org.fudaa.ctulu.CtuluAnalyze; +import org.fudaa.ctulu.CtuluLib; +import org.fudaa.ctulu.CtuluListSelection; +import org.fudaa.ctulu.ProgressionInterface; +import org.fudaa.ctulu.gui.CtuluLibSwing; +import org.fudaa.ctulu.gui.CtuluTaskOperationGUI; +import org.fudaa.dodico.ef.EfComputeVolumeSeuil; +import org.fudaa.dodico.ef.EfData; +import org.fudaa.dodico.ef.EfDataIntegrale; +import org.fudaa.dodico.ef.EfFilter; +import org.fudaa.dodico.ef.EfFilterSelectedElement; +import org.fudaa.dodico.h2d.type.H2dVariableType; +import org.fudaa.ebli.calque.ZCalqueLigneBrisee; +import org.fudaa.ebli.calque.find.CalqueFindCourbeTreeModel; +import org.fudaa.ebli.commun.EbliSelectionMode; +import org.fudaa.ebli.geometrie.GrPoint; +import org.fudaa.ebli.ressource.EbliResource; +import org.fudaa.fudaa.commun.FudaaLib; +import org.fudaa.fudaa.meshviewer.layer.MvElementLayer; +import org.fudaa.fudaa.meshviewer.profile.MvProfileTreeModel; +import org.fudaa.fudaa.tr.common.TrResource; + +import com.memoire.bu.BuCharValidator; +import com.memoire.bu.BuStringValidator; +import com.memoire.bu.BuTextField; +import com.memoire.bu.BuValueValidator; +import com.vividsolutions.jts.geom.LinearRing; + +public class TrPostDialogCurrentLine { +/** + * booleen qui indique si le wizard a \xE9t\xE9t lanc\xE9 depuis un calque + */ + + +ArrayList<TrPostSource> source_; +TrPostCommonImplementation impl_; +TrComputeCurrentLine algoCalcul_; + +// donnees graphiques +JDialog dialog_; + +// variables et pdt +private JPanel panelVariables_; +ListModel modelVariables_; +JList listVar_; +ListModel modelPdt_; +JList listPdt_; + +// finesse et duree et point +private JPanel panelSeuil_; +BuTextField finesse_ = new BuTextField(5); +BuTextField duree_ = new BuTextField(5); +BuTextField x_ = new BuTextField(5); +BuTextField y_ = new BuTextField(5); + +// results +JPanel panelResults_; +JLabel results_; +JButton ajouter_ = new JButton("Valider", EbliResource.EBLI.getIcon("crystal_valider")); +DefaultTableModel modelResult_; + +/** + * Constructeur reserv\xE9 au calques + * + * @param _builderParams + * @param _calque + * @param _modelGraphe + * @param _panelVariables + * @param _source + */ +public TrPostDialogCurrentLine(TrPostProjet projet,TrPostCommonImplementation impl) { + impl_ = impl; + source_ = projet.listeSrc_; + modelVariables_ = source_.get(0).getNewVarListModel(); + modelPdt_ = source_.get(0).getNewTimeListModel(); + + // -- construction de la dialog --// + buildDialog(); +} + + + + + + + +private JPanel buildresults() { + JPanel conteneur = new JPanel(new BorderLayout()); + + JPanel content = new JPanel(new FlowLayout(FlowLayout.CENTER)); + + results_ = new JLabel(""); + content.add(ajouter_); + // content.add(new JLabel(TrResource.getS("R\xE9sultat:"))); + content.add(results_); + + conteneur.setBorder(BorderFactory.createTitledBorder(TrResource.getS("R\xE9sultats"))); + + // -- action relatives aux resultats --// + ajouter_.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent _e) { + if (controleDataOk()) { + computeResults(); + } + } + + }); + + modelResult_ = new DefaultTableModel(); + + JTable tableauRes = new JTable(modelResult_); + conteneur.add(tableauRes.getTableHeader(), BorderLayout.NORTH); + conteneur.add(tableauRes, BorderLayout.CENTER); + conteneur.add(content, BorderLayout.SOUTH); + return conteneur; +} + +public boolean controleDataOk() { + + + if (finesse_.getText().equals("")) { + impl_.error(TrResource.getS("La finesse doit \xEAtre d\xE9fini par un r\xE9el ")); + return false; + } + if (duree_.getText().equals("")) { + impl_.error(TrResource.getS("La dur\xE9e doit \xEAtre d\xE9fini par un r\xE9el en secondes ")); + return false; + } + if (x_.getText().equals("")) { + impl_.error(TrResource.getS("Le point doit etre form\xE9 de 2 r\xE9els ")); + return false; + } + if (y_.getText().equals("")) { + impl_.error(TrResource.getS("Le point doit etre form\xE9 de 2 r\xE9els ")); + return false; + } + if (listVar_.getSelectedIndex() == -1) { + impl_.error(TrResource.getS("Il faut choisir une variable")); + return false; + } + if (listPdt_.getSelectedIndex() == -1) { + impl_.error(TrResource.getS("Il faut choisir un pas de temps")); + return false; + } + return true; +} + +/** + * retourne la variable selectionnee + * + * @return + */ +protected H2dVariableType getSelectedVariable() { + + return (H2dVariableType) modelVariables_.getElementAt(listVar_.getSelectedIndex()); +} + +/** + * retourne l indice du pas de temps. + * + * @return + */ +protected int getSelectedTimeStep() { + return listPdt_.getSelectedIndex(); +} + +JList listeSources_; +DefaultListModel modelSources_; +private JPanel buildSources() { + JPanel conteneur = new JPanel(new BorderLayout()); + JPanel content = new JPanel(new GridLayout(1, 2)); + modelSources_=new DefaultListModel(); + for(TrPostSource source:source_) + modelSources_.addElement(source.getFile().getPath()); + listeSources_ = new JList(modelSources_); + listeSources_.setSelectedIndex(0); + listeSources_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + content.add(new JScrollPane(listeSources_)); + content.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Choix du source"))); + conteneur.add(content, BorderLayout.CENTER); + + listeSources_.addListSelectionListener(new ListSelectionListener(){ + + @Override + public void valueChanged(ListSelectionEvent e) { + //reconstruction des models de var et de pdt + if(listeSources_.getSelectedIndex()!=-1){ + modelVariables_ = source_.get(listeSources_.getSelectedIndex()).getNewVarListModel(); + modelPdt_ = source_.get(listeSources_.getSelectedIndex()).getNewTimeListModel(); + listPdt_.setModel(modelPdt_); + listVar_.setModel(modelVariables_); + } + } + + }); + + return content; + } + + +private JPanel buildVariables() { + JPanel conteneur = new JPanel(new BorderLayout()); + JPanel content = new JPanel(new GridLayout(1, 2)); + listVar_ = new JList(modelVariables_); + listVar_.setSelectedIndex(0); + listPdt_ = new JList(modelPdt_); + listPdt_.setSelectedIndex(0); + listVar_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + listPdt_.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + content.add(new JScrollPane(listVar_)); + content.add(new JScrollPane(listPdt_)); + content.setBorder(BorderFactory.createTitledBorder(TrResource.getS("Choix des variables et pas de temps"))); + conteneur.add(content, BorderLayout.CENTER); + conteneur.add(new JLabel(TrResource.getS("Veuillez s\xE9lectionner la variable et pas de temps")), BorderLayout.NORTH); + return content; +} + + +private JPanel buildParams() { + finesse_.setCharValidator(BuCharValidator.FLOAT); + finesse_.setStringVa... [truncated message content] |