From: <had...@us...> - 2008-09-26 15:21:15
|
Revision: 3992 http://fudaa.svn.sourceforge.net/fudaa/?rev=3992&view=rev Author: hadouxad Date: 2008-09-26 15:21:04 +0000 (Fri, 26 Sep 2008) Log Message: ----------- exportation scopeS, scopeGen Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeKeyWord.java 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/ScopeReaderSorT.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeStructure.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeImporter.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaWriterScopeS.java Added Paths: ----------- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaWriterScopeGENE.java Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeKeyWord.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeKeyWord.java 2008-09-26 13:19:23 UTC (rev 3991) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeKeyWord.java 2008-09-26 15:21:04 UTC (rev 3992) @@ -15,8 +15,8 @@ public final static String TYPE_COURBE_SPATIALE = "ScopT"; public final static String TYPE_COURBE_MIXTE = "SCOPGENE"; public final static String SYMBOL_VALUE_UNDEFINED = "*"; + public final static long VALUE_UNDEFINED = 9999999; - public ScopeKeyWord() { } 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-09-26 13:19:23 UTC (rev 3991) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReaderGene.java 2008-09-26 15:21:04 UTC (rev 3992) @@ -185,10 +185,11 @@ for (int i = 0; i < nbFields; i++) { // on inscrit la valeur pour la variable du pas de temps // correspondant - double value =0; + double value = key.VALUE_UNDEFINED; if (!key.isUndefined(in_.stringField(i))) value = in_.doubleField(i); - + + structure.addValueForVariableAtPdt(value, i, valuePasDetemps); } } Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReaderSorT.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReaderSorT.java 2008-09-26 13:19:23 UTC (rev 3991) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReaderSorT.java 2008-09-26 15:21:04 UTC (rev 3992) @@ -134,9 +134,11 @@ if (!key.isBlocCommentaireSorT(in_.getLine())) { // -- on recupere toutes les valeurs de la variable --// for (int i = 0; i < structure.getNbVariables(); i++) { - double val = in_.doubleField(i); + double value = key.VALUE_UNDEFINED; + if (!key.isUndefined(in_.stringField(i))) + value = in_.doubleField(i); // ajout dans la map - structure.addValueForVariable(val, i); + structure.addValueForVariable(value, i); } } in_.readFields(); 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-09-26 13:19:23 UTC (rev 3991) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeStructure.java 2008-09-26 15:21:04 UTC (rev 3992) @@ -84,6 +84,23 @@ public double getX(int i) { return getAllX().get(i); } + + + private void insertX(double x) { + getAllX().add(x); + } + /** + * Methode qui insert le x dans les variables que si il n'existe pas deja. + * + * @param x + */ + public void insertNewX(double x) { + + for (int i = 0; i < getAllX().size(); i++) + if (x == getX(i)) + return; + insertX(x); + } /** * Retourne le nombre de valeur pour chaque variables @@ -111,8 +128,11 @@ for (int i = 0; i < getNbVariables(); i++) { if (i > 0) brochetteVal += " "; + if (data_.get(listeVariales_.get(i)).get(indiceValue) != KEY.VALUE_UNDEFINED) brochetteVal += data_.get(listeVariales_.get(i)).get(indiceValue); - + else + brochetteVal += KEY.SYMBOL_VALUE_UNDEFINED; + } return brochetteVal; } @@ -171,11 +191,43 @@ public void addVariable(String ligne) { ligne = ligne.replace(KEY.getBlocCommentaireGENE(), ""); listeVariales_.add(ligne); - - - + } + + + + public List<Double> getAllX(String pdt) { + return data_.get(pdt).get(0); } + + /** + * retourne un x sp\xE9cifi\xE9. + * + * @param i + * @return + */ + public double getX(int i, String pdt) { + return getAllX(pdt).get(i); + } + + private void insertX(double x, String pdt) { + getAllX(pdt).add(x); + } + + /** + * Methode qui insert le x dans les variables que si il n'existe pas deja. + * + * @param x + */ + public void insertNewX(double x, String pdt) { + + for (int i = 0; i < getAllX(pdt).size(); i++) + if (x == getX(i, pdt)) + return; + insertX(x, pdt); + } + + public void addPasDeTemps(String ligne) { ligne = ligne.replace(KEY.getBlocCommentaireGENE(), ""); @@ -258,7 +310,10 @@ ArrayList<Double> listeValueOfVar = getListValueForVariableForPDT(pasDetemps, i); if (i != 0) ligneBrochette += " "; + if (listeValueOfVar.get(indiceValue) != KEY.VALUE_UNDEFINED) ligneBrochette += listeValueOfVar.get(indiceValue); + else + ligneBrochette += KEY.SYMBOL_VALUE_UNDEFINED; } return ligneBrochette; Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeImporter.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeImporter.java 2008-09-26 13:19:23 UTC (rev 3991) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaCourbeImporter.java 2008-09-26 15:21:04 UTC (rev 3992) @@ -29,8 +29,8 @@ import org.fudaa.ctulu.gui.CtuluLibSwing; import org.fudaa.ctulu.gui.CtuluTableCsvWriter; import org.fudaa.ctulu.gui.CtuluTableExcelWriter; +import org.fudaa.ctulu.gui.CtuluTaskOperationGUI; import org.fudaa.ctulu.gui.CtuluWriter; -import org.fudaa.ctulu.gui.CtuluTaskOperationGUI; import org.fudaa.dodico.mesure.EvolutionFileFormat; import org.fudaa.dodico.mesure.EvolutionFileFormatVersion; import org.fudaa.dodico.mesure.EvolutionReguliereInterface; @@ -215,7 +215,7 @@ // --ajout des formats scope --// liste.add(new FudaaWriterScopeS()); - + liste.add(new FudaaWriterScopeGENE()); return liste; } Added: 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 (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaWriterScopeGENE.java 2008-09-26 15:21:04 UTC (rev 3992) @@ -0,0 +1,160 @@ +package org.fudaa.fudaa.commun.courbe; + +import java.io.File; +import java.io.IOException; + +import jxl.write.WriteException; + +import org.fudaa.ctulu.ProgressionInterface; +import org.fudaa.ctulu.gui.CtuluTableModelInterface; +import org.fudaa.ctulu.gui.CtuluWriter; +import org.fudaa.dodico.telemac.io.ScopeGENEFileFormat; +import org.fudaa.dodico.telemac.io.ScopeKeyWord; +import org.fudaa.dodico.telemac.io.ScopeStructure; +import org.fudaa.ebli.courbe.EGAxeHorizontal; +import org.fudaa.ebli.courbe.EGCourbe; +import org.fudaa.ebli.courbe.EGCourbeChild; +import org.fudaa.ebli.courbe.EGExportData; +import org.fudaa.ebli.courbe.EGGraphe; +import org.fudaa.ebli.courbe.EGGroup; +import org.fudaa.ebli.courbe.EGObject; + +import com.memoire.bu.BuFileFilter; + +/** + * Writer, passe de la structure Eggraphe a la structure scopeGENE. + * + * @author Adrien Hadoux + * + */ +public class FudaaWriterScopeGENE implements CtuluWriter { + + ScopeGENEFileFormat format_; + File destination_; + ScopeStructure.Gene structure_; + String extension_ = ".scopGENE"; + BuFileFilter filter_; + + + public FudaaWriterScopeGENE(){ + format_ = ScopeGENEFileFormat.getInstance(); + filter_ = format_.createFileFilter(); + + } + + public BuFileFilter getFilter() { + return filter_; + } + + public String getMostPopularExtension() { + return extension_; + } + + public void setFile(File _f) { + destination_ = _f; + + } + + public void setModel(CtuluTableModelInterface _model) { + + structure_ = new ScopeStructure.Gene(); + + //-- data qui contient les courbes choisies --// + EGExportData data = (EGExportData) _model; + EGGraphe graphe_ = data.getGraphe(); + EGCourbe[] listeChoixUser = data.getCourbes(); + + //-- on ajoute un pas de temps qui decrit le graphe --// + String keyPDt="contenu graphe"; + structure_.addPasDeTemps(keyPDt); + + + + //--on ajoute tous les x donn\xE9s de la courbe= UNION DE TOUTES LES COURBES--// + final EGAxeHorizontal h = graphe_.getTransformer().getXAxe(); + for (int i = listeChoixUser.length - 1; i >= 0; i--) { + final EGCourbe c = listeChoixUser[i]; + for (int j = c.getModel().getNbValues() - 1; j >= 0; j--) { + final double x = c.getModel().getX(j); + // if ( (h.containsPoint(x))) { + // -- on ajoute le x pour les variables x si il n existe pas deja --// + structure_.insertNewX(x,keyPDt); + // } + } + } + + //-- ON INSERE LES Y CORRESPONDANTS POUR CHAQUE VARIABLES--// + for (int i = 0; i < graphe_.getModel().getNbEGObject(); i++) { + final EGObject ci = graphe_.getModel().getEGObject(i); + if (ci instanceof EGGroup) { + EGGroup groupe = (EGGroup) ci; + + boolean hasAlreadyRegistered=false; + + + for (int k = 0; k < groupe.getChildCount(); k++) { + EGCourbeChild courbe = groupe.getCourbeAt(k); + + boolean selected = false; + for (int j = 0; !selected && j < listeChoixUser.length; j++) + if (listeChoixUser[j] == courbe) + selected = true; + + if (selected) { + + // -- il y a au moins une courbe selectionnee pour la variable, on + // va donc enregistrer la variable dans la structure + if (!hasAlreadyRegistered) { + hasAlreadyRegistered = true; + structure_.addVariable(groupe.getTitle()); + } + + // --ajout des valeurs pour chaque X--/ + for (int g = 0; g < structure_.getAllX(keyPDt).size(); g++) { + //-- on ajoute la valeur interpol\xE9e pour les x pr\xE9cemment saisis --// + double x = structure_.getX(g,keyPDt); + + //-- on v\xE9rifie que le x existe pour la courbe actuelle --// + boolean xExistForCourbe = false; + int emplacementYcorrespondant = -1; + for (int l = 0; !xExistForCourbe && l < courbe.getModel().getNbValues(); l++) { + if (courbe.getModel().getX(l) == x) { + xExistForCourbe = true; + emplacementYcorrespondant = l; + } + } + + //double yInterpole = courbe.interpol(x); + + // -- 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); + else + // -- on enregistre une valeure foireuse. + structure_.addValueForVariableAtPdt(ScopeKeyWord.VALUE_UNDEFINED, structure_.getNbVariables()-1, keyPDt); + } + + } + } + + + + } + + } + + + + } + + public void write(ProgressionInterface _p) throws IOException, WriteException { + format_.getLastVersionInstance(null).write(destination_, structure_, null); + + } + + public boolean allowFormatData() { + return false; + } + +} Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaWriterScopeS.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaWriterScopeS.java 2008-09-26 13:19:23 UTC (rev 3991) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/commun/courbe/FudaaWriterScopeS.java 2008-09-26 15:21:04 UTC (rev 3992) @@ -8,6 +8,7 @@ import org.fudaa.ctulu.ProgressionInterface; import org.fudaa.ctulu.gui.CtuluTableModelInterface; import org.fudaa.ctulu.gui.CtuluWriter; +import org.fudaa.dodico.telemac.io.ScopeKeyWord; import org.fudaa.dodico.telemac.io.ScopeSFileFormat; import org.fudaa.dodico.telemac.io.ScopeStructure; import org.fudaa.ebli.courbe.EGAxeHorizontal; @@ -20,6 +21,13 @@ import com.memoire.bu.BuFileFilter; + +/** + * Writer, passe de la structure Eggraphe a la structure scopeS. + * + * @author Adrien Hadoux + * + */ public class FudaaWriterScopeS implements CtuluWriter { ScopeSFileFormat format_; @@ -48,55 +56,190 @@ } + public void setModel(CtuluTableModelInterface _model) { + setModelVersionInterpoleY(_model); + } + + /** + * Cette version recupere l'union des X de toutes les courebs pour chaque + * variable du graphe. Ecrit le y du x si x appartient a la courbe sinon ecrit + * la valeur interpol\xE9e de x + * + * @param _model + */ + public void setModelVersionInterpoleY(CtuluTableModelInterface _model) { + + structure_ = new ScopeStructure.SorT(); + + // -- data qui contient les courbes choisies --// + EGExportData data = (EGExportData) _model; + EGGraphe graphe_ = data.getGraphe(); + EGCourbe[] listeChoixUser = data.getCourbes(); + + // -- on ajoute la var des x, debut de chaque ligne de valeurs --// + structure_.addVariable("X"); + + // --on ajoute tous les x donn\xE9s de la courbe= UNION DE TOUTES LES + // COURBES--// + final EGAxeHorizontal h = graphe_.getTransformer().getXAxe(); + for (int i = listeChoixUser.length - 1; i >= 0; i--) { + final EGCourbe c = listeChoixUser[i]; + for (int j = c.getModel().getNbValues() - 1; j >= 0; j--) { + final double x = c.getModel().getX(j); + // if ( (h.containsPoint(x))) { + // -- on ajoute le x pour les variables x si il n existe pas deja --// + structure_.insertNewX(x); + // } + } + } + + // -- ON INSERE LES Y CORRESPONDANTS POUR CHAQUE VARIABLES--// + for (int i = 0; i < graphe_.getModel().getNbEGObject(); i++) { + final EGObject ci = graphe_.getModel().getEGObject(i); + if (ci instanceof EGGroup) { + EGGroup groupe = (EGGroup) ci; + + boolean hasAlreadyRegistered = false; + + for (int k = 0; k < groupe.getChildCount(); k++) { + EGCourbeChild courbe = groupe.getCourbeAt(k); + + boolean selected = false; + for (int j = 0; !selected && j < listeChoixUser.length; j++) + if (listeChoixUser[j] == courbe) + selected = true; + + if (selected) { + + // -- il y a au moins une courbe selectionnee pour la variable, on + // va donc enregistrer la variable dans la structure + if (!hasAlreadyRegistered) { + hasAlreadyRegistered = true; + structure_.addVariable(groupe.getTitle()); + } + + // --ajout des valeurs pour chaque X--/ + for (int g = 0; g < structure_.getAllX().size(); g++) { + // -- on ajoute la valeur interpol\xE9e pour les x pr\xE9cemment saisis + // --// + double x = structure_.getX(g); + + // -- on v\xE9rifie que le x existe pour la courbe actuelle --// + // boolean xExistForCourbe = false; + // int emplacementYcorrespondant = -1; + // for (int l = 0; !xExistForCourbe && l < + // courbe.getModel().getNbValues(); l++) { + // if (courbe.getModel().getX(l) == x) { + // xExistForCourbe = true; + // emplacementYcorrespondant = l; + // } + // } + + double yInterpole = courbe.interpol(x); + + // -- si le x existe dans la courbe alors on inscrit son y + // correspondant pour la bonne variable--// + + structure_.addValueForVariable(yInterpole, structure_ + .getNbVariables() - 1); + + } + + } + } + + } + + } + + } + + + /** + * Cette version recupere l'union des X de toutes les courebs pour chaque + * variable du graphe. Ecrit le y du x que si x de l'union appartient a la courbe + * + * @param _model + */ + public void setModelVersionUnionXcoubesY(CtuluTableModelInterface _model) { + structure_ = new ScopeStructure.SorT(); //-- data qui contient les courbes choisies --// EGExportData data = (EGExportData) _model; EGGraphe graphe_ = data.getGraphe(); - EGCourbe[] liste=data.getCourbes(); + EGCourbe[] listeChoixUser = data.getCourbes(); //-- on ajoute la var des x, debut de chaque ligne de valeurs --// structure_.addVariable("X"); - //--on ajoute tous les x donn\xE9s de la courbe--// + - + //--on ajoute tous les x donn\xE9s de la courbe= UNION DE TOUTES LES COURBES--// final EGAxeHorizontal h = graphe_.getTransformer().getXAxe(); - for (int i = liste.length - 1; i >= 0; i--) { - final EGCourbe c = liste[i]; + for (int i = listeChoixUser.length - 1; i >= 0; i--) { + final EGCourbe c = listeChoixUser[i]; for (int j = c.getModel().getNbValues() - 1; j >= 0; j--) { final double x = c.getModel().getX(j); - if ( (h.containsPoint(x))) { - //-- on ajoute le x pour les variables x --// - structure_.addValueForVariable(x,0); - } + // if ( (h.containsPoint(x))) { + // -- on ajoute le x pour les variables x si il n existe pas deja --// + structure_.insertNewX(x); + // } } } - + //-- ON INSERE LES Y CORRESPONDANTS POUR CHAQUE VARIABLES--// for (int i = 0; i < graphe_.getModel().getNbEGObject(); i++) { final EGObject ci = graphe_.getModel().getEGObject(i); if (ci instanceof EGGroup) { EGGroup groupe = (EGGroup) ci; - structure_.addVariable(groupe.getTitle()); + boolean hasAlreadyRegistered = false; + for (int k = 0; k < groupe.getChildCount(); k++) { EGCourbeChild courbe = groupe.getCourbeAt(k); boolean selected = false; - for (int j = 0; !selected && j < liste.length; j++) - if (liste[j] == courbe) + for (int j = 0; !selected && j < listeChoixUser.length; j++) + if (listeChoixUser[j] == courbe) selected = true; if (selected) { + + // -- il y a au moins une courbe selectionnee pour la variable, on + // va donc enregistrer la variable dans la structure + if (!hasAlreadyRegistered) { + hasAlreadyRegistered = true; + structure_.addVariable(groupe.getTitle()); + } + // --ajout des valeurs pour chaque X--/ for (int g = 0; g < structure_.getAllX().size(); g++) { //-- on ajoute la valeur interpol\xE9e pour les x pr\xE9cemment saisis --// double x = structure_.getX(g); - double yInterpole = courbe.interpol(x); - structure_.addValueForVariable(yInterpole, structure_.getNbVariables() - 1); + + //-- on v\xE9rifie que le x existe pour la courbe actuelle --// + boolean xExistForCourbe = false; + int emplacementYcorrespondant = -1; + for (int l = 0; !xExistForCourbe && l < courbe.getModel().getNbValues(); l++) { + if (courbe.getModel().getX(l) == x) { + xExistForCourbe = true; + emplacementYcorrespondant = l; + } + } + + //double yInterpole = courbe.interpol(x); + + // -- si le x existe dans la courbe alors on inscrit son y + // correspondant pour la bonne variable--// + if (xExistForCourbe) + structure_.addValueForVariable(courbe.getModel().getY(emplacementYcorrespondant), structure_ + .getNbVariables() - 1); + else + // -- on enregistre une valeure foireuse. + structure_.addValueForVariable(ScopeKeyWord.VALUE_UNDEFINED, structure_.getNbVariables() - 1); } } @@ -112,13 +255,16 @@ } + + + public void write(ProgressionInterface _p) throws IOException, WriteException { format_.getLastVersionInstance(null).write(destination_, structure_, null); } public boolean allowFormatData() { - return true; + return false; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |