From: <had...@us...> - 2008-09-23 18:36:12
|
Revision: 3975 http://fudaa.svn.sourceforge.net/fudaa/?rev=3975&view=rev Author: hadouxad Date: 2008-09-23 18:34:17 +0000 (Tue, 23 Sep 2008) Log Message: ----------- - Sepration des classes pour els format scope: une pour chaque format - tous les algorithmes ecriture/lecture sont ?\195?\169crits et blind?\195?\169s prou tous les formats - r?\195?\169alisation des junit et test unitaires ok pour tous les formats Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/h2d/resource/h2d_en.fr_txt 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/ScopeStructure.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGInteractionSuiviAllOrdonnees.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetControllerGraphe.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostLayoutFille.java Added Paths: ----------- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeGENEFileFormat.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/ScopeSFileFormat.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeTFileFormat.java 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/ScopeWriterSorT.java branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/TestJScopeGENE.java branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/TestJScopeSorT.java branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/exemple.res.post.fzip branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/exemple.scopGENE branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/exemple.scopS branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/exemple.scopT branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/fichier.scopGENE branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/fichier.scopS branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/fichier.scopT branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/scope.scopGENE branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/scope.scopS branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/scope.scopT Removed Paths: ------------- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeFileFormat.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReader.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriter.java branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/TestJScope.java Deleted: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeFileFormat.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeFileFormat.java 2008-09-23 15:17:21 UTC (rev 3974) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeFileFormat.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -1,53 +0,0 @@ -package org.fudaa.dodico.telemac.io; - -import java.io.File; - -import org.fudaa.ctulu.CtuluIOOperationSynthese; -import org.fudaa.ctulu.ProgressionInterface; -import org.fudaa.ctulu.fileformat.FileFormatUnique; -import org.fudaa.ctulu.fileformat.FileReadOperationAbstract; -import org.fudaa.ctulu.fileformat.FileWriteOperationAbstract; -import org.fudaa.dodico.commun.DodicoLib; -import org.fudaa.dodico.fichiers.FileFormatSoftware; - - -/** - * Manager de fichiers au format scope. Utilis\xE9 poru la cr\xE9ation des graphes. - * - * @author Adrien Hadoux - * - */ -public class ScopeFileFormat extends FileFormatUnique { - - static final ScopeFileFormat INSTANCE = new ScopeFileFormat(); - - /** - * @return singleton - */ - public static ScopeFileFormat getInstance() { - return INSTANCE; - } - - private ScopeFileFormat() { - super(1); - extensions_ = new String[] { ScopeKeyWord.TYPE_COURBE_TEMPORELLE, ScopeKeyWord.TYPE_COURBE_SPATIALE, - ScopeKeyWord.TYPE_COURBE_MIXTE }; - id_ = "SCOPE"; - nom_ = "Scope"; - description_ = DodicoLib.getS("Comporte les d\xE9finitions de courbes temporelles et spatiales."); - software_ = FileFormatSoftware.TELEMAC_IS; - } - - public FileReadOperationAbstract createReader() { - return new ScopeReader(this); - } - - public CtuluIOOperationSynthese write(final File _f, final Object _source, final ProgressionInterface _prog) { - return super.write(_f, _source, _prog); - } - - public FileWriteOperationAbstract createWriter() { - return new ScopeWriter(this); - } - -} Added: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeGENEFileFormat.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeGENEFileFormat.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeGENEFileFormat.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -0,0 +1,52 @@ +package org.fudaa.dodico.telemac.io; + +import java.io.File; + +import org.fudaa.ctulu.CtuluIOOperationSynthese; +import org.fudaa.ctulu.ProgressionInterface; +import org.fudaa.ctulu.fileformat.FileFormatUnique; +import org.fudaa.ctulu.fileformat.FileReadOperationAbstract; +import org.fudaa.ctulu.fileformat.FileWriteOperationAbstract; +import org.fudaa.dodico.commun.DodicoLib; +import org.fudaa.dodico.fichiers.FileFormatSoftware; + +/** + * Manager de fichiers au format scope. Utilis\xE9 pour la cr\xE9ation des graphes. au + * format SCOPGENE + * + * @author Adrien Hadoux + * + */ +public class ScopeGENEFileFormat extends FileFormatUnique { + + static final ScopeGENEFileFormat INSTANCE = new ScopeGENEFileFormat(); + + /** + * @return singleton + */ + public static ScopeGENEFileFormat getInstance() { + return INSTANCE; + } + + private ScopeGENEFileFormat() { + super(1); + extensions_ = new String[] { ScopeKeyWord.TYPE_COURBE_MIXTE }; + id_ = "SCOPE"; + nom_ = "Scope"; + description_ = DodicoLib.getS("Comporte les d\xE9finitions de courbes temporelles et spatiales."); + software_ = FileFormatSoftware.TELEMAC_IS; + } + + public FileReadOperationAbstract createReader() { + return new ScopeReaderGene(this); + } + + public CtuluIOOperationSynthese write(final File _f, final Object _source, final ProgressionInterface _prog) { + return super.write(_f, _source, _prog); + } + + public FileWriteOperationAbstract createWriter() { + return new ScopeWriterGENE(this); + } + +} \ No newline at end of file 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-23 15:17:21 UTC (rev 3974) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeKeyWord.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -14,7 +14,9 @@ public final static String TYPE_COURBE_TEMPORELLE = "ScopS"; public final static String TYPE_COURBE_SPATIALE = "ScopT"; public final static String TYPE_COURBE_MIXTE = "SCOPGENE"; + public final static String SYMBOL_VALUE_UNDEFINED = "*"; + public ScopeKeyWord() { } @@ -25,25 +27,47 @@ return version_; } + public boolean isUndefined(String val) { + return SYMBOL_VALUE_UNDEFINED.equals(val); + } + /** * @return BlocCommentaire */ - public String getBlocCommentaire() { + public String getBlocCommentaireSorT() { return blocCommentaireSorT_; } + + public String getBlocCommentaireGENE() { + return blocCommentaireGene_; + } /** * Verifie que lon est pas en presence d un commentaire a la fois pour les - * formats s,t et gene + * formats s et t * * @param _t * @return BlocCommentaire */ - public boolean isBlocCommentaire(final String _t) { - return (blocCommentaireSorT_.equals(_t) || blocCommentaireGene_.equals(_t)); + public boolean isBlocCommentaireSorT(final String _t) { + // return (blocCommentaireSorT_.equals(_t) || blocCommentaireGene_.equals(_t)); + + if(_t==null) + return false; + return _t.startsWith(blocCommentaireSorT_); } + + + public boolean isBlocCommentaireGENE(final String _t) { + // return (blocCommentaireSorT_.equals(_t) || + // blocCommentaireGene_.equals(_t)); + if (_t == null) + return false; + return _t.startsWith(blocCommentaireGene_); + } + /** * retourne la bonen chaine separator en fonction de la valeur de iparam * envoy\xE9e. @@ -56,14 +80,31 @@ case 0: return "TEMPS ="; case 1: - return " X ="; + return "X ="; case 2: - return " Y ="; + return "Y ="; case 3: - return " Z ="; + return "Z ="; } return null; } + public int getScopeGENESeparator(String debutLigne) { + + if(debutLigne.startsWith("TEMPS =")) + return 0; + else + if(debutLigne.startsWith("X =")) + return 1; + else + if(debutLigne.startsWith("Y =")) + return 2; + else + if(debutLigne.startsWith("Z =")) + return 3; + else + return 0; + } + } Deleted: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReader.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReader.java 2008-09-23 15:17:21 UTC (rev 3974) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReader.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -1,301 +0,0 @@ -package org.fudaa.dodico.telemac.io; - -import java.io.EOFException; -import java.io.File; -import java.io.IOException; - -import org.fudaa.ctulu.CtuluActivity; -import org.fudaa.ctulu.CtuluLibFile; -import org.fudaa.ctulu.fileformat.FileFormatVersionInterface; -import org.fudaa.dodico.fortran.FileOpReadCharSimpleAbstract; -import org.fudaa.dodico.h2d.resource.H2dResource; - -/** - * Classe reader de fichier au format scope. Utilise fortranReader - * @author Adrien Hadoux - * - */ -public class ScopeReader extends FileOpReadCharSimpleAbstract implements CtuluActivity { - - - FileFormatVersionInterface v_; - private String name_; - ScopeKeyWord key = new ScopeKeyWord(); - private int nbOctets_; - private String extension_; - public ScopeReader(final FileFormatVersionInterface _v) { - v_ = _v; - } - - - protected void processFile(final File _f) { - name_ = CtuluLibFile.getSansExtension(_f.getName()); - nbOctets_ = (int) _f.length(); - extension_ = CtuluLibFile.getExtension(_f.getName()); - } - - @Override - protected Object internalRead() { - return readZones(); - } - - public void stop() { - } - - - /** - * Lit selon l extension un format gen ou alors s ou t plsu simple a lire. - * - * @return - */ - ScopeStructure readZones() { - - if (ScopeKeyWord.TYPE_COURBE_MIXTE.equals(extension_)) - return readZonesMixte(); - else - return readZonesSorT(); - } - - /** - * - * Retourne une map. La premiere clef indique le type de data (tempo,spatial - * ou mixte, cf var static de ScopeKeyWord) les 3 clef suivantes contiennent - * les titres ensuite chaque paire contient le titre de la variables et ses - * valeurs associ\xE9es sous arraylist de doubles. - * - * @return - */ - ScopeStructure readZonesSorT() { - - if (super.in_ == null) { - analyze_.addError(H2dResource.getS("Flux d'entr\xE9e non trouv\xE9"), 0); - return null; - } - - ScopeStructure.SorT structure = new ScopeStructure.SorT(); - String typeLigne = null; - String ligne = null; - - try { - if ((progress_ != null) && (nbOctets_ > 0)) { - progress_.setProgression(0); - progress_.setDesc("R\xE9cup\xE9ration des titres et nons des variables"); - } - - // -- creation du type de courbe contenu dans les datas --// - structure.type = extension_; - - - // -- on commence a lire a partir de la ligne 3 pour recuperer les variables - int cpt = 0; - do { - in_.readFields(); - typeLigne = in_.stringField(0); - ligne = in_.getLine(); - - if (key.isBlocCommentaire(typeLigne) && cpt < 3) - // titre - structure.addTitle(ligne); - else if (key.isBlocCommentaire(typeLigne)) { - // nom de variable - structure.addVariable(ligne); - } - cpt++; - } while (key.isBlocCommentaire(typeLigne)); - progress_.setProgression(30); - progress_.setDesc("R\xE9cup\xE9ration des donn\xE9es"); - - // -- on lit toutes les valeurs pour une variable jusqu a l a fin de fichier--// - try{ - while(true){ - typeLigne = in_.stringField(0); - if (!key.isBlocCommentaire(typeLigne)) { - // -- on recupere toutes les valeurs de la variable --// - for (int i = 0; i < structure.getNbVariables(); i++) { - double val = in_.doubleField(i); - // ajout dans la map - structure.addValueForVariable(val, i); - } - } - in_.readFields(); - - } - - - }catch(EOFException Exc){ - return structure; - } - - - } catch (IOException e) { - e.printStackTrace(); - return null; - } - - } - - - private ScopeStructure readZonesMixte() { - - if (super.in_ == null) { - analyze_.addError(H2dResource.getS("Flux d'entr\xE9e non trouv\xE9"), 0); - return null; - } - - ScopeStructure.Gene structure = new ScopeStructure.Gene(); - String typeLigne = null; - String ligne = null; - - try { - if ((progress_ != null) && (nbOctets_ > 0)) { - progress_.setProgression(0); - progress_.setDesc("R\xE9cup\xE9ration des titres et nons des variables"); - } - - // -- creation du type de courbe contenu dans les datas --// - structure.type = extension_; - - // --on lit touts les titres tant qu il y a un com --// - - do { - in_.readFields(); - typeLigne = in_.stringField(0); - ligne = in_.getLine(); - // titre - if (key.isBlocCommentaire(typeLigne)) - structure.addTitle(ligne); - - } while (key.isBlocCommentaire(typeLigne)); - - // --on lit le nombre de pas de temps --// - int nbVar = in_.intField(0); - - // -- on lit les params des pas de temps et on init les liste de var - // associees - for(int i=0;i<nbVar;i++){ - in_.readFields(); - - structure.addPasDeTemps(in_.getLine()); - } - progress_.setProgression(30); - - // --on lit le tableau IPARAM --// - in_.readFields(); - final int MODE_ECLATE = in_.intField(0); - final int SEPARATOR = in_.intField(1); - - int indicePasDeTemps = -1; - - in_.readFields(); - // -- on lit toutes les pas de temps --// - try { - while (true) { - - typeLigne = in_.stringField(0); - if (!key.isBlocCommentaire(typeLigne)) { - - if (MODE_ECLATE == 0) { - // -- MODE ECLATE 0 == toutes les valeurs des variabels sont sur - // la meme ligne - - - if (in_.getLine().startsWith(key.getScopeGENESeparator(SEPARATOR))) { - - // -- on est arriv\xE9 a une ligne de pas de temps --// - indicePasDeTemps++; - - in_.readFields(); - - //-- tant qu'on ne revient pas a un nouveau pas de temps on ajoute les var --// - while (!in_.getLine().startsWith(key.getScopeGENESeparator(SEPARATOR))) { - if (!key.isBlocCommentaire(typeLigne)) { - //ce sont des var on les ajoute toutes - int nbFields=in_.getNumberOfFields(); - for (int i = 0; i < nbFields; i++) { - // on alloue la place pour la var - structure.addVariableForPDt("var " + i, indicePasDeTemps); - - //on inscrit la valeur pour la variable du pas de temps correspondant - double value=in_.doubleField(i); - structure.addValueForVariableAtPdt(value, i, indicePasDeTemps); - - } - - - } - // on lit la suite - in_.readFields(); - } - - - } else - in_.readFields(); - - - } else if (MODE_ECLATE == 1) { - // -- MODE ECLATE 1 == toutes les valeurs des variabels sont sur - // la meme ligne - - - if (in_.getLine().startsWith(key.getScopeGENESeparator(SEPARATOR))) { - - // -- on est arriv\xE9 a une ligne de pas de temps --// - indicePasDeTemps++; - - in_.readFields(); - - // -- tant qu'on ne revient pas a un nouveau pas de temps on - // ajoute les var --// - while (!in_.getLine().startsWith(key.getScopeGENESeparator(SEPARATOR))) { - - // -- il faut passer les lignes qui comencent par VARIABLE= ou - // commentaire --// - if (!key.isBlocCommentaire(typeLigne) && !in_.getLine().startsWith("VARIABLE =")) { - - // ce sont des var on les lis ligne par ligne - int indiceVar = 0; - //tant qu on ne revient pas sur une ligne du type VAR= - while (!in_.getLine().startsWith("VARIABLE =")){ - // on alloue la place pour la var - structure.addVariableForPDt("var " + indiceVar, indicePasDeTemps); - - // on inscrit la valeur pour la variable du pas de temps - // correspondant - double value = in_.doubleField(0); - structure.addValueForVariableAtPdt(value, indiceVar, indicePasDeTemps); - indiceVar++; - - //on lit la var suivante - in_.readFields(); - } - - } - else - // on lit la suite - in_.readFields(); - } - - } - - } else - in_.readFields(); - - - } - } - - - - } catch (EOFException Exc) { - return structure; - } - - } catch (IOException e) { - e.printStackTrace(); - return null; - } - - } - - -} Added: 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 (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReaderGene.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -0,0 +1,254 @@ +package org.fudaa.dodico.telemac.io; + +import java.io.EOFException; +import java.io.File; +import java.io.IOException; + +import org.fudaa.ctulu.CtuluActivity; +import org.fudaa.ctulu.CtuluLibFile; +import org.fudaa.ctulu.fileformat.FileFormatVersionInterface; +import org.fudaa.dodico.fortran.FileOpReadCharSimpleAbstract; +import org.fudaa.dodico.h2d.resource.H2dResource; + +/** + * Classe reader de fichier au format scope Gene, evolu\xE9 par rapport a s ou t. + * Utilise fortranReader + * + * @author Adrien Hadoux + * + */ +public class ScopeReaderGene extends FileOpReadCharSimpleAbstract implements CtuluActivity { + + FileFormatVersionInterface v_; + private String name_; + ScopeKeyWord key = new ScopeKeyWord(); + private int nbOctets_; + private String extension_; + + public ScopeReaderGene(final FileFormatVersionInterface _v) { + v_ = _v; + } + + protected void processFile(final File _f) { + name_ = CtuluLibFile.getSansExtension(_f.getName()); + nbOctets_ = (int) _f.length(); + extension_ = CtuluLibFile.getExtension(_f.getName()); + } + + @Override + protected Object internalRead() { + return readStructure(); + } + + public void stop() { + } + + + public void setProgression(int val, String desc) { + if (progress_ != null) { + progress_.setProgression(val); + progress_.setDesc(desc); + } + } + + + + + + /** + * Lit selon l extension un format gen ou alors s ou t plsu simple a lire. + * + * @return + */ + ScopeStructure readStructure() { + + if (super.in_ == null) { + analyze_.addError(H2dResource.getS("Flux d'entr\xE9e non trouv\xE9"), 0); + return null; + } + + ScopeStructure.Gene structure = new ScopeStructure.Gene(); + + + + try { + if ((progress_ != null) && (nbOctets_ > 0)) { + setProgression(0, H2dResource.getS("R\xE9cup\xE9ration des titres et nons des variables")); + } + + // -- creation du type de courbe contenu dans les datas --// + structure.type = extension_; + + // --on lit touts les titres tant qu il y a un com --// + + readHeader(structure); + + + readVariable(structure); + + setProgression(30, H2dResource.getS("R\xE9cup\xE9ration des valeurs")); + + // --on lit le tableau IPARAM --// + in_.readFields(); + final int MODE_ECLATE = in_.intField(0); + final int SEPARATOR = in_.intField(1); + + int indicePasDeTemps = -1; + + in_.readFields(); + // -- on lit toutes les pas de temps --// + try { + while (true) { + + + if (!key.isBlocCommentaireGENE(in_.getLine())) { + + if (MODE_ECLATE == 0) { + + readValuesModeNonEclate(structure, SEPARATOR); + + } else if (MODE_ECLATE == 1) { + + readValuesModeEclate(structure, SEPARATOR); + + } else + in_.readFields(); + } else + in_.readFields(); + } + + } catch (EOFException Exc) { + return structure; + } + + } catch (IOException e) { + e.printStackTrace(); + return null; + } + + } + + + public void readHeader(ScopeStructure.Gene structure) throws IOException { + String ligne = null; + do { + in_.readFields(); + + ligne = in_.getLine(); + // titre + if (key.isBlocCommentaireGENE(ligne)) + structure.addTitle(ligne); + + } while (key.isBlocCommentaireGENE(ligne)); + + } + + public void readVariable(ScopeStructure.Gene structure) throws IOException { + // --on lit le nombre de variables--// + int nbVar = in_.intField(0); + + // -- on lit les params des pas de temps et on init les liste de var + // associees + for (int i = 0; i < nbVar; i++) { + in_.readFields(); + + structure.addVariable(in_.getLine()); + } + } + + + /** + * MODE ECLATE 0 == toutes les valeurs des variabels sont sur la meme ligne + * @param structure + * @param SEPARATOR + * @param indicePasDeTemps + * @throws IOException + */ + public void readValuesModeNonEclate(ScopeStructure.Gene structure, int SEPARATOR) + throws IOException { + if (in_.getLine().startsWith(key.getScopeGENESeparator(SEPARATOR))) { + + // -- 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); + + + in_.readFields(); + + // -- tant qu'on ne revient pas a un nouveau pas de temps on + // ajoute les var --// + while (!in_.getLine().startsWith(key.getScopeGENESeparator(SEPARATOR))) { + if (!key.isBlocCommentaireGENE(in_.getLine())) { + // ce sont des var on les ajoute toutes + int nbFields = in_.getNumberOfFields(); + for (int i = 0; i < nbFields; i++) { + // on inscrit la valeur pour la variable du pas de temps + // correspondant + double value =0; + if (!key.isUndefined(in_.stringField(i))) + value = in_.doubleField(i); + + structure.addValueForVariableAtPdt(value, i, valuePasDetemps); + } + } + // on lit la suite + in_.readFields(); + } + + } else + in_.readFields(); + } + + /** + * MODE ECLATE 1 == toutes les valeurs des variabels sont sur la meme ligne + * @param structure + * @param SEPARATOR + * @param indicePasDeTemps + * @throws IOException + */ + public void readValuesModeEclate(ScopeStructure.Gene structure, int SEPARATOR) + throws IOException { + if (in_.getLine().startsWith(key.getScopeGENESeparator(SEPARATOR))) { + + // -- on est arriv\xE9 a une ligne de pas de temps --// + + String valuePasDetemps = in_.getLine(); + structure.addPasDeTemps(valuePasDetemps); + + in_.readFields(); + + // -- tant qu'on ne revient pas a un nouveau pas de temps on + // ajoute les var --// + while (!in_.getLine().startsWith(key.getScopeGENESeparator(SEPARATOR))) { + + // -- il faut passer les lignes qui comencent par VARIABLE= ou + // commentaire --// + if (!key.isBlocCommentaireGENE(in_.getLine()) && !in_.getLine().startsWith("VARIABLE =")) { + + // ce sont des var on les lis ligne par ligne + int indiceVar = 0; + // tant qu on ne revient pas sur une ligne du type VAR= + while (!in_.getLine().startsWith("VARIABLE =")) { + + + // on inscrit la valeur pour la variable du pas de temps + // correspondant + double value = in_.doubleField(0); + structure.addValueForVariableAtPdt(value, indiceVar, valuePasDetemps); + indiceVar++; + + // on lit la var suivante + in_.readFields(); + } + + } else + // on lit la suite + in_.readFields(); + } + + } + + } + +} Copied: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReaderSorT.java (from rev 3969, branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReader.java) =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReaderSorT.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReaderSorT.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -0,0 +1,149 @@ +package org.fudaa.dodico.telemac.io; + +import java.io.EOFException; +import java.io.File; +import java.io.IOException; + +import org.fudaa.ctulu.CtuluActivity; +import org.fudaa.ctulu.CtuluLibFile; +import org.fudaa.ctulu.fileformat.FileFormatVersionInterface; +import org.fudaa.dodico.fortran.FileOpReadCharSimpleAbstract; +import org.fudaa.dodico.h2d.resource.H2dResource; + +/** + * Classe reader de fichier au format scope. Utilise fortranReader + * @author Adrien Hadoux + * + */ +public class ScopeReaderSorT extends FileOpReadCharSimpleAbstract implements CtuluActivity { + + + FileFormatVersionInterface v_; + private String name_; + ScopeKeyWord key = new ScopeKeyWord(); + private int nbOctets_; + private String extension_; + public ScopeReaderSorT(final FileFormatVersionInterface _v) { + v_ = _v; + } + + + protected void processFile(final File _f) { + name_ = CtuluLibFile.getSansExtension(_f.getName()); + nbOctets_ = (int) _f.length(); + extension_ = CtuluLibFile.getExtension(_f.getName()); + } + + @Override + protected Object internalRead() { + return readStructure(); + } + + public void stop() { + } + + + public void setProgression(int val, String desc) { + if (progress_ != null) { + progress_.setProgression(val); + progress_.setDesc(desc); + } + } + + /** + * + * Retourne une map. La premiere clef indique le type de data (tempo,spatial + * ou mixte, cf var static de ScopeKeyWord) les 3 clef suivantes contiennent + * les titres ensuite chaque paire contient le titre de la variables et ses + * valeurs associ\xE9es sous arraylist de doubles. + * + * @return + */ + ScopeStructure readStructure() { + + + if (super.in_ == null) { + analyze_.addError(H2dResource.getS("Flux d'entr\xE9e non trouv\xE9"), 0); + return null; + } + + ScopeStructure.SorT structure = new ScopeStructure.SorT(); + + String ligne = null; + + try { + if ((progress_ != null) && (nbOctets_ > 0)) { + setProgression(0, "R\xE9cup\xE9ration des titres et nons des variables"); + } + + // -- creation du type de courbe contenu dans les datas --// + structure.type = extension_; + + readHeader(structure); + + + setProgression(30, "R\xE9cup\xE9ration des donn\xE9es"); + + + // -- on lit toutes les valeurs pour une variable jusqu a l a fin de fichier--// + try{ + readData(structure); + + + }catch(EOFException Exc){ + + + return structure; + } + + + } catch (IOException e) { + e.printStackTrace(); + return null; + } + return null; + } + + + + public void readHeader(ScopeStructure.SorT structure) throws IOException { + String ligne = null; + int cpt = 0; + do { + in_.readFields(); + + ligne = in_.getLine(); + + if (key.isBlocCommentaireSorT(ligne) && cpt < 3) + // titre + structure.addTitle(ligne); + else if (key.isBlocCommentaireSorT(ligne)) { + // nom de variable + structure.addVariable(ligne); + } + cpt++; + } while (key.isBlocCommentaireSorT(ligne)); + + } + + + public void readData(ScopeStructure.SorT structure) throws IOException { + + while (true) { + + 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); + // ajout dans la map + structure.addValueForVariable(val, i); + } + } + in_.readFields(); + + } + } + + + +} Property changes on: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeReaderSorT.java ___________________________________________________________________ Added: svn:mergeinfo + Copied: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeSFileFormat.java (from rev 3969, branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeFileFormat.java) =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeSFileFormat.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeSFileFormat.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -0,0 +1,52 @@ +package org.fudaa.dodico.telemac.io; + +import java.io.File; + +import org.fudaa.ctulu.CtuluIOOperationSynthese; +import org.fudaa.ctulu.ProgressionInterface; +import org.fudaa.ctulu.fileformat.FileFormatUnique; +import org.fudaa.ctulu.fileformat.FileReadOperationAbstract; +import org.fudaa.ctulu.fileformat.FileWriteOperationAbstract; +import org.fudaa.dodico.commun.DodicoLib; +import org.fudaa.dodico.fichiers.FileFormatSoftware; + +/** + * Manager de fichiers au format scope. Utilis\xE9 pour la cr\xE9ation des graphes. au + * format ScopS + * + * @author Adrien Hadoux + * + */ +public class ScopeSFileFormat extends FileFormatUnique { + + static final ScopeSFileFormat INSTANCE = new ScopeSFileFormat(); + + /** + * @return singleton + */ + public static ScopeSFileFormat getInstance() { + return INSTANCE; + } + + private ScopeSFileFormat() { + super(1); + extensions_ = new String[] { ScopeKeyWord.TYPE_COURBE_TEMPORELLE }; + id_ = "SCOPE"; + nom_ = "Scope"; + description_ = DodicoLib.getS("Comporte les d\xE9finitions de courbes temporelles et spatiales."); + software_ = FileFormatSoftware.TELEMAC_IS; + } + + public FileReadOperationAbstract createReader() { + return new ScopeReaderSorT(this); + } + + public CtuluIOOperationSynthese write(final File _f, final Object _source, final ProgressionInterface _prog) { + return super.write(_f, _source, _prog); + } + + public FileWriteOperationAbstract createWriter() { + return new ScopeWriterSorT(this); + } + +} Property changes on: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeSFileFormat.java ___________________________________________________________________ Added: svn:mergeinfo + 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-23 15:17:21 UTC (rev 3974) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeStructure.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -2,7 +2,6 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; @@ -14,7 +13,10 @@ */ public abstract class ScopeStructure { + public final static ScopeKeyWord KEY = new ScopeKeyWord(); + public abstract void printResults(); + /** * Structure pour les fichiers s ou t * @@ -35,11 +37,15 @@ } public void addTitle(String ligne) { + ligne = ligne.replace(KEY.getBlocCommentaireSorT(), ""); titles_.add(ligne); } public void addVariable(String ligne) { + + ligne = ligne.replace(KEY.getBlocCommentaireSorT(), ""); + listeVariales_.add(ligne); // on init la liste des valeurs de la variabel correspondante data_.put(ligne, new ArrayList<Double>()); @@ -49,13 +55,61 @@ return listeVariales_.size(); } + public String getVariable(int _i) { + return listeVariales_.get(_i); + } public void addValueForVariable(double value, int indexVariable) { data_.get(listeVariales_.get(indexVariable)).add(value); } + /** + * Retourne le nombre de valeur pour chaque variables + * + * @return + */ + public int getNbValuePerVariables() { + + if (listeVariales_.size() == 0) + return 0; + return data_.get(listeVariales_.get(0)).size(); + } + + /** + * retourne une string qui contient toutes les valeurs a l indice value pour + * toutes les variables + * + * @param indice + * dans les tableaux des variables + * @return + */ + public String getListValuesofAllVariable(int indiceValue) { + String brochetteVal = ""; + + for (int i = 0; i < getNbVariables(); i++) { + if (i > 0) + brochetteVal += " "; + brochetteVal += data_.get(listeVariales_.get(i)).get(indiceValue); + + } + return brochetteVal; } + @Override + public void printResults() { + System.err.print("\n Contenu du fichier scope"); + for(int i=0;i<titles_.size();i++) + System.err.print("\n" + titles_.get(i)); + for(int i=0;i<listeVariales_.size();i++) + System.err.print("\n" + listeVariales_.get(i)); + + for (int i = 0; i < getNbValuePerVariables(); i++) + System.err.print("\n" + getListValuesofAllVariable(i)); + + } + + } + /** * * @author Adrien Hadoux. @@ -66,35 +120,63 @@ */ public static class Gene extends ScopeStructure { + /** + * Map qui donne a chaque pas de temps 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 HashSet<String> listeVariales_ = new HashSet<String>(); + private List<String> listeVariales_ = new ArrayList<String>(); private List<String> titles_ = new ArrayList<String>(); + + public String type = ScopeKeyWord.TYPE_COURBE_MIXTE; public Gene() { + // ajout par defaut des variables x + listeVariales_.add("X"); } public void addTitle(String ligne) { + ligne = ligne.replace(KEY.getBlocCommentaireGENE(), ""); titles_.add(ligne); } + public void addVariable(String ligne) { + ligne = ligne.replace(KEY.getBlocCommentaireGENE(), ""); + listeVariales_.add(ligne); + + + + } + public void addPasDeTemps(String ligne) { + ligne = ligne.replace(KEY.getBlocCommentaireGENE(), ""); + listePasDeTemps.add(ligne); - // on init la liste des valeurs de la variabel correspondante - data_.put(ligne, new ArrayList<ArrayList<Double>>()); + + // on ajoute un enregistrment dans data pour le pas de temps + // correspondant + ArrayList<ArrayList<Double>> listeDuPdt = new ArrayList<ArrayList<Double>>(); + data_.put(ligne, listeDuPdt); + + // --il faut initialiser cette liste du pas de temps en y ajoutant autant + // de listes qu il y a de variables --// + for (int i = 0; i < getNbVariables(); i++) + listeDuPdt.add(new ArrayList<Double>()); + } - - public void addVariableForPDt(String labelVariable, int pdt) { - listeVariales_.add(labelVariable); - getListeVarForPasDeTemps(pdt).add(new ArrayList<Double>()); - - } + // public void addVariableForPDt(String labelVariable, int pdt) { + // labelVariable = labelVariable.replace(KEY.getBlocCommentaireGENE(), ""); + // listeVariales_.add(labelVariable); + // getListeVarForPasDeTemps(pdt).add(new ArrayList<Double>()); + // + // } public int getNbPasDeTemps() { return listePasDeTemps.size(); @@ -105,19 +187,114 @@ return listeVariales_.size(); } + public ArrayList<ArrayList<Double>> getListeVarForPasDeTemps(String pdt) { + return data_.get(pdt); + } + public ArrayList<ArrayList<Double>> getListeVarForPasDeTemps(int pdt) { return data_.get(listePasDeTemps.get(pdt)); } - public ArrayList<Double> getListValueForVariableForPDT(int pdt, int var) { + public ArrayList<Double> getListValueForVariableForPDT(String pdt, int var) { + + return getListeVarForPasDeTemps(pdt).get(var); } - public void addValueForVariableAtPdt(double value, int indexVariable, int indexPasDeTemps) { - getListValueForVariableForPDT(indexPasDeTemps, indexVariable).add(value); + public void addValueForVariableAtPdt(double value, int indexVariable, String valuePasDetemps) { + ArrayList<Double> listeValueOfVar = getListValueForVariableForPDT(valuePasDetemps, indexVariable); + // if (listeValueOfVar == null) + // listeValueOfVar = new ArrayList<Double>(); + + listeValueOfVar.add(value); } + + + /** + * tailel par defaut des donnees pour une variale donn\xE9 pour un pas de temps + * donn\xE9 + * + * @return + */ + // public int getNbValuePerVariablesPerPdt() { + // + // return getListValueForVariableForPDT(listePasDeTemps.get(0), 0).size(); + // } + + /** + * retourne l equivalent d une ligne du fichier qui contient les valeurs + * pour chaque variables pour un pas de temps donn\xE9. + * + * @param pasDetemps + * @return + */ + public String getAllValuesForVariableAndPasDeTemps(String pasDetemps,int indiceValue) { + + String ligneBrochette = ""; + for (int i = 0; i < listeVariales_.size(); i++) { + ArrayList<Double> listeValueOfVar = getListValueForVariableForPDT(pasDetemps, i); + if (i != 0) + ligneBrochette += " "; + ligneBrochette += listeValueOfVar.get(indiceValue); + } + + return ligneBrochette; + } + + + public String getPasDeTemps(int i) { + return listePasDeTemps.get(i); + } + public String getVariable(int i) { + return listeVariales_.get(i); + } + + + public int getNbTitles() { + return titles_.size(); + } + public String getTitle(int i) { + return titles_.get(i); + } + + + @Override + public void printResults() { + // titres + for (int i = 0; i < getNbTitles(); i++) { + System.err.print("\n" + getTitle(i)); + } + // nb variabels - le x + System.err.print("\n" + (getNbVariables() - 1)); + + for (int i = 0; i < getNbVariables(); i++) { + System.err.print("\n" + getVariable(i)); + } + + // tableau de val mode non eclatee + String tableauVal = "0 " + KEY.getScopeGENESeparator(getPasDeTemps(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++) { + // separator pas de temps + System.err.print("\n " + getPasDeTemps(i)); + + int nbValuesForThisPdt = getListeVarForPasDeTemps(i).get(0).size(); + // -- parcours la liste des donnees + for (int k = 0; k < nbValuesForThisPdt; k++) { + + System.err.print("\n" + getAllValuesForVariableAndPasDeTemps(getPasDeTemps(i), k)); + + + } + + } + + } + } Added: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeTFileFormat.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeTFileFormat.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeTFileFormat.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -0,0 +1,52 @@ +package org.fudaa.dodico.telemac.io; + +import java.io.File; + +import org.fudaa.ctulu.CtuluIOOperationSynthese; +import org.fudaa.ctulu.ProgressionInterface; +import org.fudaa.ctulu.fileformat.FileFormatUnique; +import org.fudaa.ctulu.fileformat.FileReadOperationAbstract; +import org.fudaa.ctulu.fileformat.FileWriteOperationAbstract; +import org.fudaa.dodico.commun.DodicoLib; +import org.fudaa.dodico.fichiers.FileFormatSoftware; + +/** + * Manager de fichiers au format scope. Utilis\xE9 pour la cr\xE9ation des graphes. au + * format ScopT + * + * @author Adrien Hadoux + * + */ +public class ScopeTFileFormat extends FileFormatUnique { + + static final ScopeTFileFormat INSTANCE = new ScopeTFileFormat(); + + /** + * @return singleton + */ + public static ScopeTFileFormat getInstance() { + return INSTANCE; + } + + private ScopeTFileFormat() { + super(1); + extensions_ = new String[] { ScopeKeyWord.TYPE_COURBE_SPATIALE }; + id_ = "SCOPE"; + nom_ = "Scope"; + description_ = DodicoLib.getS("Comporte les d\xE9finitions de courbes temporelles et spatiales."); + software_ = FileFormatSoftware.TELEMAC_IS; + } + + public FileReadOperationAbstract createReader() { + return new ScopeReaderSorT(this); + } + + public CtuluIOOperationSynthese write(final File _f, final Object _source, final ProgressionInterface _prog) { + return super.write(_f, _source, _prog); + } + + public FileWriteOperationAbstract createWriter() { + return new ScopeWriterSorT(this); + } + +} \ No newline at end of file Deleted: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriter.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriter.java 2008-09-23 15:17:21 UTC (rev 3974) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriter.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -1,34 +0,0 @@ -package org.fudaa.dodico.telemac.io; - -import org.fudaa.ctulu.CtuluActivity; -import org.fudaa.ctulu.fileformat.FileFormatVersionInterface; -import org.fudaa.dodico.fortran.FileOpWriterCharSimpleAbstract; - -/** - * Classe writer de fichier au format scope. Utilise fortranWriter - * - * @author Adrien Hadoux - * - */ -public class ScopeWriter extends FileOpWriterCharSimpleAbstract implements CtuluActivity { - - boolean stop_; - final FileFormatVersionInterface v_; - - ScopeKeyWord key = new ScopeKeyWord(); - - public ScopeWriter(final FileFormatVersionInterface _v) { - v_ = _v; - - } - - - public void stop() { - stop_ = true; - } - - @Override - protected void internalWrite(Object _o) { - } - -} Added: 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 (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriterGENE.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -0,0 +1,113 @@ +package org.fudaa.dodico.telemac.io; + +import java.io.IOException; + +import org.fudaa.ctulu.CtuluActivity; +import org.fudaa.ctulu.fileformat.FileFormatVersionInterface; +import org.fudaa.dodico.fortran.FileOpWriterCharSimpleAbstract; +import org.fudaa.dodico.h2d.resource.H2dResource; + +/** + * Classe writer de fichier au format scope GENE. Utilise fortranWriter + * + * @author Adrien Hadoux + * + */ +public class ScopeWriterGENE extends FileOpWriterCharSimpleAbstract implements CtuluActivity { + + boolean stop_; + final FileFormatVersionInterface v_; + + ScopeKeyWord key_ = new ScopeKeyWord(); + + public ScopeWriterGENE(final FileFormatVersionInterface _v) { + v_ = _v; + + } + + public void stop() { + stop_ = true; + } + + @Override + protected void internalWrite(Object _o) { + if (_o instanceof ScopeStructure) { + writeStruct((ScopeStructure.Gene) _o); + } else { + donneesInvalides(_o); + } + } + + protected void writeStruct(ScopeStructure.Gene _struct) { + + if (super.out_ == null) { + analyze_.addError(H2dResource.getS("Flux d'entr\xE9e non trouv\xE9"), 0); + return; + } + + // -- ecriture dans le fichier --// + try { + // -- ecriture des lignes titres --// + writeHeader(_struct); + + // -- ecritures des variables --// + writeVariable(_struct); + + // -- ecritures de toutes les valeurs des variables --// + writeData(_struct); + + } catch (final IOException e) { + analyze_.manageException(e); + } + } + + public void setProgression(int val, String desc) { + if (progress_ != null) { + progress_.setProgression(val); + progress_.setDesc(desc); + } + } + + 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)); + } + + } + + protected void writeVariable(ScopeStructure.Gene _struct) throws IOException { + + setProgression(10, H2dResource.getS("Cr\xE9ation des variables")); + // nb variabels - le x + writelnToOut("" + (_struct.getNbVariables() - 1)); + for (int i = 1; i < _struct.getNbVariables(); i++) { + 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"; + writelnToOut(tableauVal); + } + + protected void writeData(ScopeStructure.Gene _struct) throws IOException { + + setProgression(30, H2dResource.getS("Cr\xE9ation des donn\xE9es")); + // pour chaque pas de temps + for (int i = 0; i < _struct.getNbPasDeTemps(); i++) { + // separator pas de temps + writelnToOut(_struct.getPasDeTemps(i)); + + // -- parcours la liste des donnees + int nbValuesForThisPdt = _struct.getListeVarForPasDeTemps(i).get(0).size(); + for (int k = 0; k < nbValuesForThisPdt; k++) { + + writelnToOut(_struct.getAllValuesForVariableAndPasDeTemps(_struct.getPasDeTemps(i), k)); + + } + + } + } + + +} Copied: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriterSorT.java (from rev 3969, branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriter.java) =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriterSorT.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriterSorT.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -0,0 +1,108 @@ +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; +import org.fudaa.dodico.fortran.FileOpWriterCharSimpleAbstract; +import org.fudaa.dodico.h2d.resource.H2dResource; + +/** + * Classe writer de fichier au format scope. Utilise fortranWriter + * + * @author Adrien Hadoux + * + */ +public class ScopeWriterSorT extends FileOpWriterCharSimpleAbstract implements CtuluActivity { + + boolean stop_; + final FileFormatVersionInterface v_; + + ScopeKeyWord key_ = new ScopeKeyWord(); + + public ScopeWriterSorT(final FileFormatVersionInterface _v) { + v_ = _v; + + } + + + public void stop() { + stop_ = true; + } + + @Override + protected void internalWrite(Object _o) { + if (_o instanceof ScopeStructure) { + writeStruct((ScopeStructure.SorT) _o); + } else { + donneesInvalides(_o); + } + } + + /** + * Ecriture de la structure dans un fichier + * + * @param _struct + */ + protected void writeStruct(ScopeStructure.SorT _struct) { + + if (super.out_ == null) { + analyze_.addError(H2dResource.getS("Flux d'entr\xE9e non trouv\xE9"), 0); + return; + } + + // -- ecriture dans le fichier --// + try { + // -- ecriture des 3 premieres lignes titres --// + writeHeader(); + + // -- ecritures des variables --// + writeVariable(_struct); + + // -- ecritures de toutes les valeurs des variables --// + writeData(_struct); + + + } catch (final IOException e) { + analyze_.manageException(e); + } + } + + public void setProgression(int val, String desc) { + if (progress_ != null) { + progress_.setProgression(val); + progress_.setDesc(desc); + } + } + + + protected void writeHeader() throws IOException { + String bc = key_.getBlocCommentaireSorT(); + 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); + } + + protected void writeVariable(ScopeStructure.SorT _struct) throws IOException { + String bc = key_.getBlocCommentaireSorT(); + setProgression(10, H2dResource.getS("Cr\xE9ation des variables")); + + for (int i = 0; i < _struct.getNbVariables(); i++) { + writelnToOut(bc + _struct.getVariable(i) + bc); + } + } + + protected void writeData(ScopeStructure.SorT _struct) throws IOException { + String bc = key_.getBlocCommentaireSorT(); + setProgression(30, H2dResource.getS("Cr\xE9ation des donn\xE9es")); + for (int i = 0; i < _struct.getNbValuePerVariables(); i++) { + writelnToOut(_struct.getListValuesofAllVariable(i)); + } + } + + +} Property changes on: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeWriterSorT.java ___________________________________________________________________ Added: svn:mergeinfo + Deleted: branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/TestJScope.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/TestJScope.java 2008-09-23 15:17:21 UTC (rev 3974) +++ branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/TestJScope.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -1,127 +0,0 @@ -package org.fudaa.dodico.telemac; - -import java.io.File; - -import junit.framework.TestCase; - -import org.fudaa.ctulu.CtuluIOOperationSynthese; -import org.fudaa.ctulu.gis.GISZone; -import org.fudaa.dodico.all.TestIO; -import org.fudaa.dodico.telemac.io.ScopeFileFormat; -import org.fudaa.dodico.telemac.io.SinusxFileFormat; - -public class TestJScope extends TestCase { - /** - * Le fichier de lecture. - */ - String testLectureFic_; - - - - /** - * Constructeur par defaut. - */ - public TestJScope() {} - - /** - * @see junit.framework.TestCase#setUp() - */ - public void setUp() { - testLectureFic_ = "fichier.scopT"; - - } - - /** - * @param _f - * @return Les zones lues - * @throws NumberFormatException - */ - private GISZone lecture(final File _f) { - - final CtuluIOOperationSynthese op = ScopeFileFormat.getInstance().getLastVersionInstance(null).read(_f, null); - final GISZone zone = (GISZone) op.getSource(); -// // assertEquals(zone.getNom(), CtuluLibFile.getSansExtension(_f.getName())); -// final GISZoneCollectionPoint[] pts = zone.getPointCollections(); -// assertEquals(2, pts.length); -// GISZoneCollectionPoint pt1 = pts[0]; -// assertNotNull(pt1); -// assertEquals(pt1.getNumGeometries(), 4); -// GISPointMutable p = new GISPointMutable(); -// double t; -// for (int i = 0; i < pt1.getNumGeometries(); i++) { -// pt1.get(i, p); -// t = i; -// assertEquals(p.getX(), t, delta_); -// assertEquals(p.getY(), t, delta_); -// assertEquals(p.getZ(), t, delta_); -// } -// pt1 = pts[1]; -// assertEquals(pt1.getNumGeometries(), 1); -// pt1.get(0, p); -// assertEquals(p.getX(), 4, delta_); -// assertEquals(p.getY(), 4, delta_); -// assertEquals(p.getZ(), 4, delta_); -// final GISZoneCollectionPolygone[] polygones = zone.getPolygoneCollections(); -// assertNotNull(polygones); -// assertEquals(1, polygones.length); -// assertEquals(polygones[0].getNumGeometries(), 1); -// final GISZoneCollectionPolyligne[] polys = zone.getPolyligneCollections(); -// assertNotNull(polys); -// assertEquals(1, polys.length); -// final GISZoneCollectionPolyligne poly0 = polys[0]; -// assertNotNull(poly0); -// assertEquals(poly0.getNumGeometries(), 2); -// GISPolyligne poly = (GISPolyligne) poly0.getGeometry(0); -// assertEquals(poly.getNumPoints(), 4); -// p = new GISPointMutable(-1d, -1d, -1d); -// for (int i = 0; i < 4; i++) { -// final CoordinateSequence s = poly.getCoordinateSequence(); -// t = (double) i * 5; -// assertEquals(s.getX(i), t, delta_); -// assertEquals(s.getY(i), t, delta_); -// assertEquals(s.getOrdinate(i, 2), t, delta_); -// } -// poly = (GISPolyligne) poly0.getGeometry(1); -// assertEquals(poly.getNumPoints(), 2); -// p = new GISPointMutable(-1, -1, -1); -// for (int i = 0; i < 2; i++) { -// final CoordinateSequence s = poly.getCoordinateSequence(); -// t = (double) i * 100 + 100; -// assertEquals(s.getX(i), t, delta_); -// assertEquals(s.getY(i), t, delta_); -// assertEquals(s.getOrdinate(i, 2), 100, delta_); -// } - return zone; - } - - public void testLectureEcriture() { - File f = null; - try { - final File initFile = getFile(testLectureFic_); - assertNotNull("Le fichier " + testLectureFic_ + " est introuvable", initFile); - assertTrue(initFile.getAbsolutePath() + " n'existe pas !", initFile.exists()); - final GISZone zones = lecture(initFile); - assertNotNull(zones); - f = File.createTempFile("testSinux", ".sx"); - assertNotNull(f); - SinusxFileFormat.getInstance().getLastVersionInstance(null).write(f, zones, null); - lecture(f); - } catch (final Exception _e) { - _e.printStackTrace(); - } finally { - if (f != null) { - f.delete(); - } - } - } - - /** - * @param _f - * @return File - */ - public File getFile(final String _f) { - return TestIO.getFile(getClass(), _f); - } - - -} \ No newline at end of file Added: branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/TestJScopeGENE.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/TestJScopeGENE.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/dodico/test/org/fudaa/dodico/telemac/TestJScopeGENE.java 2008-09-23 18:34:17 UTC (rev 3975) @@ -0,0 +1,106 @@ +package org.fudaa.dodico.telemac; + +import java.io.File; + +import junit.framework.TestCase; + +import org.fudaa.ctulu.CtuluIOOperationSynthese; +import org.fudaa.dodico.all.TestIO; +import org.fudaa.dodico.telemac.io.ScopeGENEFileFormat; +import org.fudaa.dodico.telemac.io.ScopeStructure; + +public class TestJScopeGENE extends TestCase { + /** + * Le fichier de lecture. + */ + String testLectureFic_; + + String[] listeExemplesAtester = { "scope.scopGENE", "exemple.scopGENE" }; + + /** + * Constructeur par defaut. + */ + public TestJScopeGENE() {} + + /** + * @see junit.framework.TestCase#setUp() + */ + public void setUp() { + + + } + + /** + * @param _f + * @return Les zones lues + * @throws NumberFormatException + */ + private ScopeStructure lecture(final File _f) { + + final CtuluIOOperationSynthese op = ScopeGENEFileFormat.getInstance().getLastVersionInstance(null).read(_f, null); + final ScopeStructure struct = (ScopeStructure) op.getSource(); + + return struct; + } + + + private void ecriture(final File _f,ScopeStructure struct) { + + ScopeGENEFileFormat.getInstance().getLastVersionInstance(null).write(_f, struct, null); + + + } + + public void lectureEcriture(int typeFichier) { + File f = null; + try { + final File initFile = getFile(listeExemplesAtester[typeFichier]); + assertNotNull("Le fichier " + listeExemplesAtester[typeFichier] + " est introuvable", initFile); + assertTrue(initFile.getAbsolutePath() + " n'existe pas !", initFile.exists()); + ScopeStructure structureScope = lecture(initFile); + assertNotNull(structureScope); + + // --test tecriture contenu --// + System.err.print("\n\n\n***contenu structure du fichier " + listeExemplesAtester[typeFichier] + "***"); + structureScope.printResults(); + + f = File.createTempFile("scopeGENE", ".scopGENE"); + System.err.print("\n\nemplacement copie: " + f.getAbsolutePath() + "\n\n"); + assertNotNull(f); + ecriture(f, structureScope); + structureScope = lecture(f); + System.err.print("\n\n\n***contenu structure du fichier apres ecriture " + listeExemplesAtester[typeFichier] + + "***"); + structureScope.printResults(); + + } catch (final Exception... [truncated message content] |