From: <de...@us...> - 2009-01-26 22:59:38
|
Revision: 4404 http://fudaa.svn.sourceforge.net/fudaa/?rev=4404&view=rev Author: deniger Date: 2009-01-26 22:59:34 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MVProfileCourbeModel.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostBuilderSuiteCalcul.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostCourbeModel.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/TrPostMinPaletteTableModel.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjet.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSource.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstract.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceComparator.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceComparatorBuilder.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceDefault.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceFromReader.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceOneTimeStep.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceProjected.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderComposite.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderInterface.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderReflux.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderSerafin.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceRubar.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceRubarZFN.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceSerafin.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceTelemac3D.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostUserVariableSaver.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/actions/TrPostActionChooseAndCreateCalque.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/persist/TrPostPersistenceManager.java Added Paths: ----------- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstractFromIdx.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderCommonAbstract.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderFromFileAbstract.java Removed Paths: ------------- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderAbstract.java Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MVProfileCourbeModel.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MVProfileCourbeModel.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MVProfileCourbeModel.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -32,7 +32,7 @@ import org.fudaa.fudaa.tr.post.TrPostCommonImplementation; import org.fudaa.fudaa.tr.post.TrPostProjet; import org.fudaa.fudaa.tr.post.TrPostSource; -import org.fudaa.fudaa.tr.post.TrPostSourceAbstract; +import org.fudaa.fudaa.tr.post.TrPostSourceAbstractFromIdx; import org.fudaa.fudaa.tr.post.TrPostVisuPanel; import org.fudaa.fudaa.tr.post.TrReplayCurvesData; import org.fudaa.fudaa.tr.post.actions.TrPostProfileAction; @@ -151,7 +151,7 @@ if (this.data_ instanceof TrPostSource) { _table.put(TrResource.getS("Type"), "Profil spatial"); TrPostSource src = (TrPostSource) this.data_; - TrPostSourceAbstract.fillWithSourceInfo(_table, src); + TrPostSourceAbstractFromIdx.fillWithSourceInfo(_table, src); if (this.time_ != -1 && this.time_ < src.getNbTimeStep()) pdt += ": " + src.getTime().getTimeListModel().getElementAt(this.time_); } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostBuilderSuiteCalcul.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostBuilderSuiteCalcul.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostBuilderSuiteCalcul.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -1,9 +1,10 @@ package org.fudaa.fudaa.tr.post; +import gnu.trove.TDoubleArrayList; + import java.awt.event.ActionEvent; import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; @@ -14,291 +15,261 @@ import javax.swing.Icon; -import org.fudaa.ctulu.CtuluLibString; -import org.fudaa.ctulu.CtuluVariable; -import org.fudaa.ctulu.collection.CtuluArrayDouble; import org.fudaa.dodico.ef.EfGridInterface; import org.fudaa.dodico.h2d.type.H2dVariableType; -import org.fudaa.ebli.calque.ZEbliCalquesPanel; import org.fudaa.ebli.commun.EbliActionSimple; import org.fudaa.ebli.visuallibrary.EbliNode; import org.fudaa.ebli.visuallibrary.calque.CalqueLegendeWidgetAdapter; -import org.fudaa.fudaa.commun.impl.FudaaCommonImplementation; import org.fudaa.fudaa.tr.common.TrResource; import org.fudaa.fudaa.tr.post.TrPostSourceReaderComposite.CoupleTimeStepData; - - - /** * Builder qui construit les suites de calcul. + * * @author Adrien Hadoux - * */ public class TrPostBuilderSuiteCalcul { + /** + * Action qui r\xE9alise la suite de calcul. + * + * @author Adrien Hadoux + */ + public static class ActionBuildSuite extends EbliActionSimple { - /** - * Action qui r\xE9alise la suite de calcul. - * @author Adrien Hadoux - * - */ - public static class ActionBuildSuite extends EbliActionSimple{ + TrPostSource src_; + TrPostCommonImplementation impl_; + public ActionBuildSuite(TrPostSource src, String _name, Icon _ic, String _ac, TrPostCommonImplementation impl) { + super(_name, _ic, _ac); + // TODO Auto-generated constructor stub + src_ = src; + src_ = src; + impl_ = impl; + } - TrPostSource src_; - TrPostCommonImplementation impl_; - public ActionBuildSuite(TrPostSource src,String _name, Icon _ic, String _ac,TrPostCommonImplementation impl) { - super(_name, _ic, _ac); - // TODO Auto-generated constructor stub - src_= src; - src_=src; - impl_=impl; - } + public void actionPerformed(ActionEvent _e) { + // -- test de comptabilit\xE9 de fichier source --// + if (!isCompatibleSuiteCalcul(src_)) { + impl_.error(TrResource.getS("Le fichier n'est pas valide.")); + return; + } - public void actionPerformed(ActionEvent _e) { + // -- on lance la dialog de choix des fichiers sources --// + final TrPostSource srcChoisie = impl_.getCurrentProject().getChooserMultiSources(-1); + if (srcChoisie == null) { + impl_.error(TrResource.getS(TrResource.getS("Aucune source choisie"))); + return; + } + if (!isCompatibleSuiteCalcul(srcChoisie)) { + impl_.error(TrResource.getS("Le fichier n'est pas valide.")); + return; + } - //-- test de comptabilit\xE9 de fichier source --// - if(!isCompatibleSuiteCalcul(src_)){ - impl_.error(TrResource.getS("Le fichier n'est pas valide.")); - return; - } + List<String> error = new ArrayList<String>(); - //-- on lance la dialog de choix des fichiers sources --// - final TrPostSource srcChoisie = impl_.getCurrentProject().getChooserMultiSources(-1); - if (srcChoisie == null) { - impl_.error(TrResource.getS(TrResource.getS("Aucune source choisie"))); - return; - } + // -- creation de la suite de calcul --// + TrPostSource suiteCalcul = createSuiteCalcul((TrPostSourceFromReader) src_, impl_, + (TrPostSourceFromReader) srcChoisie, error); - if(!isCompatibleSuiteCalcul(srcChoisie)){ - impl_.error(TrResource.getS("Le fichier n'est pas valide.")); - return; - } + if (suiteCalcul == null) { + // -- il se passe des choses \xE9tranges.... --// + String maxiStringLeo = ""; + for (String err : error) + maxiStringLeo += err + "\n"; + impl_.error(maxiStringLeo); + return; + } - List<String> error=new ArrayList<String>(); + // -- on ajoute la nouvelle src r\xE9sultat comme \xE9tant une suite de calcul --// - //-- creation de la suite de calcul --// - TrPostSource suiteCalcul=createSuiteCalcul((TrPostSourceFromReader)src_, impl_, (TrPostSourceFromReader)srcChoisie, error); + impl_.c_.ajouterSource(suiteCalcul); - if(suiteCalcul==null){ - //-- il se passe des choses \xE9tranges.... --// - String maxiStringLeo=""; - for(String err:error) - maxiStringLeo+=err+"\n"; + // -- on cree la vue 2d correspondante --// - impl_.error(maxiStringLeo); - return; - } + TrPostProjet projet = impl_.getCurrentProject(); + TrPostLayoutPanelController controller = impl_.getCurrentLayoutFille().controller_; + final CalqueLegendeWidgetAdapter legendeCalque = new CalqueLegendeWidgetAdapter(controller.getSceneCourante(), + null); + final TrPostVisuPanel pnVisu = new TrPostVisuPanel(projet.getImpl(), projet, legendeCalque, suiteCalcul); + final EbliNode node = controller.addCalque(TrResource.getS("Calque") + + (controller.getSceneCourante().getAllVue2d().size() + 1), pnVisu.getLocation(), pnVisu.getPreferredSize(), + pnVisu, legendeCalque); + // -- ajout de l INFO de la source utilis\xE9e --// + node.getWidget().getController().setDescription("Source: " + projet.formatInfoSource(srcChoisie)); + // -- ajout des infos de cr\xE9ation --// - //-- on ajoute la nouvelle src r\xE9sultat comme \xE9tant une suite de calcul --// + TrPostSourceReaderComposite.fillInfosWithComposite(pnVisu.infosCreation_, + (TrPostSourceReaderComposite) ((TrPostSourceFromReader) suiteCalcul).getReader()); - impl_.c_.ajouterSource(suiteCalcul); + } - - //-- on cree la vue 2d correspondante --// - - TrPostProjet projet=impl_.getCurrentProject(); - TrPostLayoutPanelController controller=impl_.getCurrentLayoutFille().controller_; - final CalqueLegendeWidgetAdapter legendeCalque = new CalqueLegendeWidgetAdapter(controller.getSceneCourante(), null); - final TrPostVisuPanel pnVisu = new TrPostVisuPanel(projet.getImpl(), projet, legendeCalque, suiteCalcul); - final EbliNode node = controller.addCalque(TrResource.getS("Calque") - + (controller.getSceneCourante().getAllVue2d().size() + 1), pnVisu.getLocation(), pnVisu.getPreferredSize(), - pnVisu, legendeCalque); - // -- ajout de l INFO de la source utilis\xE9e --// - node.getWidget().getController().setDescription("Source: " + projet.formatInfoSource(srcChoisie)); + } - // -- ajout des infos de cr\xE9ation --// - - TrPostSourceReaderComposite.fillInfosWithComposite(pnVisu.infosCreation_,(TrPostSourceReaderComposite)((TrPostSourceFromReader)suiteCalcul).getReader()); - - + /** + * R\xE9cup\xE9rer l'interface \xE0 partir du fichier + * + * @param _f + * @param _impl + * @return + */ + public static TrPostSourceFromReader createSourceFromeFile(File _f, TrPostCommonImplementation _impl) { + TrPostSource src = TrPostSourceBuilder.activeSourceAction(_f, _impl, _impl.getMainProgression()); + if (src != null && src instanceof TrPostSourceFromReader) return ((TrPostSourceFromReader) src); + return null; + } - } + public static TrPostSource createSuiteCalcul(File _f, TrPostCommonImplementation _impl, + TrPostSourceFromReader _reader, List<String> error) { + // -- lecture de l'interface \xE0 ajouter --// + TrPostSourceFromReader srcToConcat = createSourceFromeFile(_f, _impl); + return createSuiteCalcul(_reader, _impl, srcToConcat, error); + } + /** + * Algorithme de construction d'une suite de calcul. + * + * @param srcToConcat + * @param _impl + * @param _reader + * @param error + * @return + */ + public static TrPostSource createSuiteCalcul(TrPostSourceFromReader srcToConcat, TrPostCommonImplementation _impl, + TrPostSourceFromReader _reader, List<String> error) { + TrPostSource suiteCalcul = null; + if (srcToConcat == null) { + error.add(TrResource.getS("Le fichier n'est pas valide.")); + return null; + } - } + if (_reader.isRubar() || srcToConcat.isRubar()) { + error.add(TrResource.getS("Format Rubar non g\xE9r\xE9")); + return null; + } + // -- comparaison des grilles --// + EfGridInterface grille = srcToConcat.getGrid(); + if (!grille.isSameStrict(_reader.getGrid(), _impl.getMainProgression(), 0.01)) { + error.add(TrResource.getS("Les grilles ne sont pas identiques")); + return null; + } - /** - * R\xE9cup\xE9rer l'interface \xE0 partir du fichier - * @param _f - * @param _impl - * @return - */ - public static TrPostSourceFromReader createSourceFromeFile(File _f, TrPostCommonImplementation _impl){ - TrPostSource src= TrPostSourceBuilder.activeSourceAction(_f, _impl, _impl.getMainProgression()); - if(src!=null && src instanceof TrPostSourceFromReader) return ((TrPostSourceFromReader)src); - return null; + // -- comparaison des pas de temps d\xE9but et finaux --// + double[] time1 = TrPostSourceFromReader.getTimes(_reader.getReader()); + double[] time2 = TrPostSourceFromReader.getTimes(srcToConcat.getReader()); - } + if (time1[time1.length - 1] != time2[0] && time2[time2.length - 1] != time1[0]) { + error.add(TrResource + .getS("Le dernier pas de temps de l'un doit \xEAtre \xE9quivalent au premier pas de temps de l'autre.")); + return null; + } - public static TrPostSource createSuiteCalcul(File _f, TrPostCommonImplementation _impl, TrPostSourceFromReader _reader,List<String> error){ - //-- lecture de l'interface \xE0 ajouter --// - TrPostSourceFromReader srcToConcat=createSourceFromeFile(_f, _impl); - return createSuiteCalcul(_reader, _impl, srcToConcat, error); - } + // -- recuperation des pas de temps et des variables --// + // double[] timeTotal= new double[time1.length+time2.length-1]; + // if(time1[0]>time2[0]){ + // //-- on permute pour garder l'ordre --// + // double[] temp=time1; + // time1=time2; + // time2=temp; + // } + // for(int i=0;i<time1.length;i++) + // timeTotal[i]=time1[i]; + // for(int i=0;i<time2.length-1;i++) + // timeTotal[time1.length+i]=time2[i+1]; + HashSet<H2dVariableType> listeVar = new HashSet<H2dVariableType>(); + H2dVariableType[] var = null; + for (int i = 0; i < _reader.getAvailableVar().length; i++) + listeVar.add(_reader.getVariable(i)); + for (int i = 0; i < srcToConcat.getAvailableVar().length; i++) + listeVar.add(srcToConcat.getVariable(i)); + var = new H2dVariableType[listeVar.size()]; + int k = 0; + for (H2dVariableType v : listeVar) + var[k++] = v; - /** - * Algorithme de construction d'une suite de calcul. - * @param srcToConcat - * @param _impl - * @param _reader - * @param error - * @return - */ - public static TrPostSource createSuiteCalcul(TrPostSourceFromReader srcToConcat, TrPostCommonImplementation _impl, TrPostSourceFromReader _reader,List<String> error){ - TrPostSource suiteCalcul=null; - if(srcToConcat==null){ - error.add(TrResource.getS("Le fichier n'est pas valide.")); - return null; - } + // var=srcToConcat.variable_; + // -- initialisation de la liste de source --// + List<TrPostSourceReaderInterface> listeSourceInterface_ = new ArrayList<TrPostSourceReaderInterface>(); + // -- on ajoute \xE0 la liste des interfaces l'interface 1 et l'intrface 2 --// + TrPostSourceReaderInterface interface1 = _reader.reader_; + TrPostSourceReaderInterface interface2 = srcToConcat.reader_; - if(_reader.isRubar() || srcToConcat.isRubar()){ - error.add(TrResource.getS("Format Rubar non g\xE9r\xE9")); - return null; - } + // -- attetion au cas particulier: si une interface1 est deja une suite, il faut ajouter toutes ses interfaces --// + if (interface1 instanceof TrPostSourceReaderComposite) listeSourceInterface_ + .addAll(((TrPostSourceReaderComposite) interface1).listeSourceInterface_); + else listeSourceInterface_.add(interface1); - //-- comparaison des grilles --// - EfGridInterface grille=srcToConcat.getGrid(); - if(!grille.isSameStrict(_reader.getGrid(), _impl.getMainProgression(),0.01)){ - error.add(TrResource.getS("Les grilles ne sont pas identiques")); - return null; - } + if (interface2 instanceof TrPostSourceReaderComposite) listeSourceInterface_ + .addAll(((TrPostSourceReaderComposite) interface2).listeSourceInterface_); + else listeSourceInterface_.add(interface2); - //-- comparaison des pas de temps d\xE9but et finaux --// - double[] time1=TrPostSourceFromReader.getTimes(_reader.getReader()); - double[] time2=TrPostSourceFromReader.getTimes(srcToConcat.getReader()); + // -- ajout de tous les fichiers dans la collection --// + final Collection<File> file_ = new HashSet<File>(interface1.getFiles());; + file_.addAll(interface2.getFiles()); - if(time1[time1.length-1]!=time2[0] && time2[time2.length-1]!=time1[0]){ - error.add(TrResource.getS("Le dernier pas de temps de l'un doit \xEAtre \xE9quivalent au premier pas de temps de l'autre.")); - return null; - } + // -- on trie les listes dans l'ordre des timestep --// + Collections.sort(listeSourceInterface_, new ComparateurTrPostSourceReaderInterface()); + // - ajout des correspondances timestep/source avec nouveau timestep --// + Map<Integer, CoupleTimeStepData> mapTimeStep_ = new HashMap<Integer, CoupleTimeStepData>(); + // TODO utilise TDoubleArrayList + TDoubleArrayList times = new TDoubleArrayList(); + // int cpt = 0; + for (TrPostSourceReaderInterface data : listeSourceInterface_) { + for (int i = 0; i < data.getNbTimeStep(); i++) { + // LOGIquement, il faudrait prendre en compte les erreurs d'arrondi + // -- ICI, pour cet algo, on doit degager tout les doublons et ne conserver que des valeurs uniques --// + if (!times.contains(data.getTimeStep(i))) { + // le cpt vaut la taille des times + mapTimeStep_.put(times.size(), new CoupleTimeStepData(data, i)); + times.add(data.getTimeStep(i)); + // cpt++; + } + } + } - //-- recuperation des pas de temps et des variables --// - // double[] timeTotal= new double[time1.length+time2.length-1]; - // if(time1[0]>time2[0]){ - // //-- on permute pour garder l'ordre --// - // double[] temp=time1; - // time1=time2; - // time2=temp; - // } - // for(int i=0;i<time1.length;i++) - // timeTotal[i]=time1[i]; - // for(int i=0;i<time2.length-1;i++) - // timeTotal[time1.length+i]=time2[i+1]; + double[] timeTotal = times.toNativeArray(); + // -- creation de la suite de calcul + TrPostSourceReaderComposite suite = new TrPostSourceReaderComposite(timeTotal, var, mapTimeStep_, + listeSourceInterface_, file_); - HashSet<H2dVariableType> listeVar=new HashSet<H2dVariableType>(); - H2dVariableType[] var=null; - for(int i=0;i<_reader.getAvailableVar().length;i++) - listeVar.add(_reader.getVariable(i)); - for(int i=0;i<srcToConcat.getAvailableVar().length;i++) - listeVar.add(srcToConcat.getVariable(i)); - var=new H2dVariableType[listeVar.size()]; - int k=0; - for(H2dVariableType v:listeVar) - var[k++]=v; + // -- creation du source Reader --// + return new TrPostSourceFromReader(suite, TrResource.getS("Suite de calcul"), grille, _impl); + } + /** + * Methode appelee pour v\xE9rifier que ceci est bien compatible avec la suite de calcul. + * + * @param src + * @return + */ + public static boolean isCompatibleSuiteCalcul(TrPostSource src) { - //var=srcToConcat.variable_; + if (src != null && src instanceof TrPostSourceFromReader) return true; + return false; + } - //-- initialisation de la liste de source --// - List<TrPostSourceReaderInterface> listeSourceInterface_=new ArrayList<TrPostSourceReaderInterface>(); + public static class ComparateurTrPostSourceReaderInterface implements Comparator<TrPostSourceReaderInterface> { - //-- on ajoute \xE0 la liste des interfaces l'interface 1 et l'intrface 2 --// - TrPostSourceReaderInterface interface1=_reader.reader_; - TrPostSourceReaderInterface interface2=srcToConcat.reader_; + public int compare(TrPostSourceReaderInterface o1, TrPostSourceReaderInterface o2) { + // -- on compare selon la valeur des timesteps -- + if (o1.getTimeStep(0) > o2.getTimeStep(0)) return 1; - //-- attetion au cas particulier: si une interface1 est deja une suite, il faut ajouter toutes ses interfaces --// - if(interface1 instanceof TrPostSourceReaderComposite) - listeSourceInterface_.addAll(((TrPostSourceReaderComposite)interface1).listeSourceInterface_); - else - listeSourceInterface_.add(interface1); + if (o1.getTimeStep(0) < o2.getTimeStep(0)) return -1; - if(interface2 instanceof TrPostSourceReaderComposite) - listeSourceInterface_.addAll(((TrPostSourceReaderComposite)interface2).listeSourceInterface_); - else - listeSourceInterface_.add(interface2); + return 0; + } - //-- ajout de tous les fichiers dans la collection --// - final Collection<File> file_=new HashSet<File>(interface1.getFiles());; - file_.addAll(interface2.getFiles()); + } - - //-- on trie les listes dans l'ordre des timestep --// - Collections.sort(listeSourceInterface_,new ComparateurTrPostSourceReaderInterface()); - - //- ajout des correspondances timestep/source avec nouveau timestep --// - Map<Integer, CoupleTimeStepData> mapTimeStep_=new HashMap<Integer, CoupleTimeStepData>(); - ArrayList<Double> times=new ArrayList<Double>(); - int cpt=0; - for(TrPostSourceReaderInterface data:listeSourceInterface_){ - for(int i=0;i<data.getNbTimeStep();i++){ - - //-- ICI, pour cet algo, on doit degager tout les doublons et ne conserver que des valeurs uniques --// - if(!times.contains(data.getTimeStep(i))){ - mapTimeStep_.put(cpt,new CoupleTimeStepData(data,i)); - times.add(data.getTimeStep(i)); - cpt++; - } - } - } - - double[] timeTotal=new double[times.size()]; - for(int i=0;i<times.size();i++) - timeTotal[i]=times.get(i); - - //-- creation de la suite de calcul - TrPostSourceReaderComposite suite=null; - - suite=new TrPostSourceReaderComposite(timeTotal,var,mapTimeStep_,listeSourceInterface_,file_); - - //-- creation du source Reader --// - suiteCalcul=new TrPostSourceFromReader(suite,TrResource.getS("Suite de calcul"),grille,_impl); - - return suiteCalcul; - } - - - /** - * Methode appelee pour v\xE9rifier que ceci est bien compatible avec la suite de calcul. - * @param src - * @return - */ - public static boolean isCompatibleSuiteCalcul(TrPostSource src){ - - if(src!=null && src instanceof TrPostSourceFromReader) - return true; - return false; - } - - public static class ComparateurTrPostSourceReaderInterface implements Comparator<TrPostSourceReaderInterface>{ - - @Override - public int compare(TrPostSourceReaderInterface o1, - TrPostSourceReaderInterface o2) { - - //-- on compare selon la valeur des timesteps -- - if(o1.getTimeStep(0)>o2.getTimeStep(0)) - return 1; - - if(o1.getTimeStep(0)<o2.getTimeStep(0)) - return -1; - - - return 0; - } - - } - } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostCourbeModel.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostCourbeModel.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostCourbeModel.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -401,7 +401,7 @@ public void fillWithInfo(InfoData _table, CtuluListSelectionInterface _selectedPt) { if(EbliWidget.AMELIO_LOT_VISIBLE){ _table.put(TrResource.getS("Type"),"Evolution temporelle"); - TrPostSourceAbstract.fillWithSourceInfo(_table, source_); + TrPostSourceAbstractFromIdx.fillWithSourceInfo(_table, source_); _table.put(TrResource.getS("Titre Fichier r\xE9sultat"),this.source_.getTitle()); _table.put(TrResource.getS("Infos Point initial"),this.getInfosPoint()); _table.put(TrResource.getS("Variable"),this.getVar().getName()+" en "+this.getVar().getCommonUnitString()); Modified: 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/TrPostLayoutPanelController.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostLayoutPanelController.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -328,19 +328,19 @@ // -- ajout du rectangle --// final EbliNodeDefault nodeFleche = new EbliNodeDefault(); nodeFleche.setTitle("Fleche simple"); - //nodeFleche.setCreator(new EbliWidgetCreatorShape(new ShapeCreatorFlecheSimple())); - + // nodeFleche.setCreator(new EbliWidgetCreatorShape(new ShapeCreatorFlecheSimple())); + nodeFleche.setCreator(new EbliWidgetCreatorArrowEditor(new EbliEditorArrow())); - + nodeFleche.setPreferedSize(new Dimension(200, 150)); nodeFleche.setPreferedLocation(new Point(350, 125)); // ajout du node au layout addNode(nodeFleche); - //nodeFleche.getWidget().repaint(); - //((EbliWidgetArrowEditor)nodeFleche.getWidget()).editor_.creationFlecheClassique(); - + // nodeFleche.getWidget().repaint(); + // ((EbliWidgetArrowEditor)nodeFleche.getWidget()).editor_.creationFlecheClassique(); + return nodeFleche; } @@ -432,8 +432,8 @@ }); // -- palette fleche simple--// - _l.add(new EbliActionSimple(EbliResource.EBLI.getString("Editeur Fleche"), - EbliResource.EBLI.getToolIcon("crystal_bu_link"), "WIDGETFLECHESIMPLE") { + _l.add(new EbliActionSimple(EbliResource.EBLI.getString("Editeur Fleche"), EbliResource.EBLI + .getToolIcon("crystal_bu_link"), "WIDGETFLECHESIMPLE") { @Override public void actionPerformed(final ActionEvent _evt) { addFlecheSimple(); Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostMinPaletteTableModel.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostMinPaletteTableModel.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostMinPaletteTableModel.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -24,9 +24,9 @@ H2dVariableType[] vs_; boolean[] activated_; Double[] value_; - TrPostSourceAbstract s_; + TrPostSource s_; - TrPostMinPaletteTableModel(final TrPostSourceAbstract _s) { + TrPostMinPaletteTableModel(final TrPostSource _s) { s_ = _s; vs_ = _s.getVarToDefinedMinPalette(); activated_ = _s.getMinPaletteActived(vs_); Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjet.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjet.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostProjet.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -9,6 +9,7 @@ import java.awt.Component; import java.awt.Dimension; +import java.awt.EventQueue; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -400,7 +401,7 @@ } } - + public TrPostSource findSource(final String _file) { return findSource(new File(_file)); } @@ -432,9 +433,9 @@ private boolean isOpenedIn(Collection<File> files, TrPostSource _in) { if (_in == null) return false; - boolean sourceGetAllFiles=true; + boolean sourceGetAllFiles = true; for (File file : files) { - if (!_in.isOpened(file)) sourceGetAllFiles=false;; + if (!_in.isOpened(file)) sourceGetAllFiles = false;; } return sourceGetAllFiles; @@ -609,9 +610,9 @@ ic, TrPostProjet.this)); menuSimul.addSeparator(); - - - listSousMenus.add(menuSimul.addMenuItem(new TrPostBuilderSuiteCalcul.ActionBuildSuite(_src,TrResource.getS("Suite de calcul"),EbliResource.EBLI.getIcon(""),"SUITECALCUL",impl_))); + + listSousMenus.add(menuSimul.addMenuItem(new TrPostBuilderSuiteCalcul.ActionBuildSuite(_src, TrResource + .getS("Suite de calcul"), EbliResource.EBLI.getIcon(""), "SUITECALCUL", impl_))); listSousMenus.add(menuSimul.addMenuItem(TrResource.getS("Comparer..."), "COMPARE", ic, TrPostProjet.this)); listSousMenus.get(listSousMenus.size() - 1).setToolTipText( TrResource.getS("Comparer les r\xE9sultats avec ceux d'un autre projet")); @@ -890,7 +891,7 @@ // -- ajout des infos de cr\xE9ation --// // TODO centralise tout cela \xFC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - TrPostSourceAbstract.fillWithSourceInfo(CtuluLibString.EMPTY_STRING, pnVisu.infosCreation_, projection); + TrPostSourceAbstractFromIdx.fillWithSourceInfo(CtuluLibString.EMPTY_STRING, pnVisu.infosCreation_, projection); pnVisu.infosCreation_.put(ZEbliCalquesPanel.TITRE_FIC, projection.getTitle()); // creation de l internalframe qui contient le panel de visu @@ -1168,11 +1169,13 @@ } // -- lancement du thread d'ouverture du layout avec els widgets calque - new CtuluTaskOperationGUI(impl_, TrResource.getS("Ouverture vue 2D...")) { + // TODO pourquoi faire un thread pour des operation graphiques !!!!!!!!!!!!!!!!!!!!!!!! + // new CtuluTaskOperationGUI(impl_, TrResource.getS("Ouverture vue 2D...")) { - @Override - public void act() { + Runnable r = new Runnable() { + public void run() { + // -- si il y a deja une source de pr\xE9charg\xE9e --// if (listeSrc_.size() > 0) { final TrPostLayoutFille filleLayout = new TrPostLayoutFille(TrPostProjet.this); @@ -1185,7 +1188,7 @@ // -- ajout des infos de cr\xE9ation --// // TODO Adrien centralise tout cela !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // c'est la source qui doit donner ces info: modifier TrPostSource ! - TrPostSourceAbstract.fillWithSourceInfo(CtuluLibString.EMPTY_STRING, pnVisu.infosCreation_, source); + TrPostSourceAbstractFromIdx.fillWithSourceInfo(CtuluLibString.EMPTY_STRING, pnVisu.infosCreation_, source); // -- ajout du visuPanel au layout --// final Point location = pnVisu.getLocation(); @@ -1206,9 +1209,11 @@ // -- creation du menu POST de base --// setMenuPost(); + changedMainFrameState(); } - }.start(Thread.MAX_PRIORITY); - changedMainFrameState(); + }; + EventQueue.invokeLater(r); + } public void changedMainFrameState() { Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSource.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSource.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSource.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -49,12 +49,10 @@ */ public interface TrPostSource extends EfGridData, FudaaSavable { - public String getId(); - + public void setId(String id); - - + public void activate(); EfGridDataInterpolator getInterpolator(); @@ -70,11 +68,11 @@ void buildDefaultVarUpdateLists(); -// TrPostInspectorReader createWatcher(TrPostProjet _proj, boolean _auto); + // TrPostInspectorReader createWatcher(TrPostProjet _proj, boolean _auto); -// boolean isInspectable(); + // boolean isInspectable(); -// void setInspected(boolean _b); + // void setInspected(boolean _b); boolean isInspected(); @@ -302,8 +300,6 @@ void updateUserValue(final H2dVariableTypeCreated _old, final H2dVariableTypeCreated _new, final TrPostDataCreated _newData, final CtuluCommandContainer _cmd); - - /** * @param _analyze permet d'initialise la base temporaire. */ @@ -312,4 +308,28 @@ void addSpecificItemInMainMenu(final BuMenu _m, TrPostCommonImplementation _impl); TrPostVisuPanel buildVisuPanel(TrPostProjet _parent, BCalqueLegende _legende); + + /** + * @return + */ + H2dVariableType[] getVarToDefinedMinPalette(); + + /** + * @param _v + * @return + */ + boolean[] getMinPaletteActived(H2dVariableType[] _v); + + /** + * @param _v + * @return + */ + double[] getMinPaletteValues(H2dVariableType[] _v); + + /** + * @param _v + * @param _actived + * @param _d + */ + void setDefaultPaletteMinPalette(H2dVariableType[] _v, boolean[] _actived, double[] _d); } \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstract.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstract.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstract.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -7,9 +7,6 @@ */ package org.fudaa.fudaa.tr.post; -import gnu.trove.TObjectIntHashMap; -import gnu.trove.TObjectIntIterator; - import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -92,11 +89,15 @@ */ public abstract class TrPostSourceAbstract implements TrPostSource { + public boolean isRubar() { + return false; + } + public TrPostVisuPanel buildVisuPanel(final TrPostProjet _parent, final BCalqueLegende _legende) { return new TrPostVisuPanel(_parent.getImpl(), _parent, _legende, this); } - - public static Collection<File> getFiles(File _file){ + + public static Collection<File> getFiles(File _file) { return Collections.unmodifiableCollection(Arrays.asList(_file)); } @@ -207,8 +208,6 @@ TrPostDataInfoDoc info_; - TObjectIntHashMap initVarIdx_; - protected boolean inspected_; EfGridDataInterpolator interpolator_; @@ -238,6 +237,8 @@ InterpolationVectorContainer vectors_; + Collection<H2dVariableType> initVar_; + protected TrPostSourceAbstract(final String _titre, final EfGridInterface _g, final double[] _time, final H2dVariableType[] _v, final CtuluUI _impl) { title_ = _titre; @@ -248,6 +249,7 @@ time_.setTimeSteps(_time); g_ = _g; impl_ = _impl; + setInitVar(_v); } @@ -256,9 +258,9 @@ protected final void addFroud(final Map _l) { if (getInitDataIndex("FROUDE") != null) { return; } // les variables h,u et v doivent etre d\xE9finies - if ((getInitDataIndex(H2dVariableType.HAUTEUR_EAU) >= 0 || _l.containsKey(H2dVariableType.HAUTEUR_EAU)) - && (getInitDataIndex(H2dVariableType.VITESSE_U) >= 0 || _l.containsKey(H2dVariableType.VITESSE_U)) - && (getInitDataIndex(H2dVariableType.VITESSE_V) >= 0 || _l.containsKey(H2dVariableType.VITESSE_V))) { + if ((isInitVar(H2dVariableType.HAUTEUR_EAU) || _l.containsKey(H2dVariableType.HAUTEUR_EAU)) + && (isInitVar(H2dVariableType.VITESSE_U) || _l.containsKey(H2dVariableType.VITESSE_U)) + && (isInitVar(H2dVariableType.VITESSE_V) || _l.containsKey(H2dVariableType.VITESSE_V))) { final H2dVariableTypeCreated c = H2dVariableType.createTempVar(H2dResource.getS("Nombre de Froude"), "froude", shortNameCreateVar_); _l.put(c, new TrPostDataCreatedFroud(this)); @@ -271,28 +273,27 @@ * * @param _map */ - final void addInitData(final TObjectIntHashMap _map) { - if (_map == null || _map.size() == 0) { return; } - if (initVarIdx_ == null) { - initVarIdx_ = new TObjectIntHashMap(_map.size()); - } - final TObjectIntIterator it = _map.iterator(); - final Set l = new HashSet(_map.size()); - for (int i = _map.size(); i-- > 0;) { - it.advance(); - final Object var = it.key(); - if (!initVarIdx_.containsKey(var)) { - l.add(var); - initVarIdx_.put(var, it.value()); - } - } - // pas de modif - if (l.size() == 0) { return; } - buildDefaultVectors(); - updateVarList(); - fireFlecheListModelChanged(); - } - + // final void addInitData(final TObjectIntHashMap _map) { + // if (_map == null || _map.size() == 0) { return; } + // if (initVarIdx_ == null) { + // initVarIdx_ = new TObjectIntHashMap(_map.size()); + // } + // final TObjectIntIterator it = _map.iterator(); + // final Set l = new HashSet(_map.size()); + // for (int i = _map.size(); i-- > 0;) { + // it.advance(); + // final Object var = it.key(); + // if (!initVarIdx_.containsKey(var)) { + // l.add(var); + // initVarIdx_.put(var, it.value()); + // } + // } + // // pas de modif + // if (l.size() == 0) { return; } + // buildDefaultVectors(); + // updateVarList(); + // fireFlecheListModelChanged(); + // } protected void addOtherVariables(final Map _l, final Map _fleche) { addFroud(_l); } @@ -384,52 +385,42 @@ final Map nameFleche = new HashMap(); varCreateData_ = new HashMap(); // par defaut vitesse et debit - int idx = getInitDataIndex(H2dVariableType.VITESSE_U); - if (idx >= 0) { - final int idxY = getInitDataIndex(H2dVariableType.VITESSE_V); - if (idxY >= 0) { + if (isInitVar(H2dVariableType.VITESSE_U)) { + if (isInitVar(H2dVariableType.VITESSE_V)) { final TrPostFlecheContent vec = createSimpleVecteurContent(H2dVariableType.VITESSE, H2dVariableType.VITESSE_U, H2dVariableType.VITESSE_V, isRubar()); nameFleche.put(H2dVariableType.VITESSE, vec); - if (getInitDataIndex(H2dVariableType.VITESSE) < 0) { + if (!isInitVar(H2dVariableType.VITESSE)) { varCreateData_.put(H2dVariableType.VITESSE, vec); } } } - idx = getInitDataIndex(H2dVariableType.DEBIT_X); - if (idx >= 0) { - final int idxY = getInitDataIndex(H2dVariableType.DEBIT_Y); - if (idxY >= 0) { + if (isInitVar(H2dVariableType.DEBIT_X)) { + if (isInitVar(H2dVariableType.DEBIT_Y)) { final TrPostFlecheContent vec = createSimpleVecteurContent(H2dVariableType.DEBIT, H2dVariableType.DEBIT_X, H2dVariableType.DEBIT_Y, isRubar()); nameFleche.put(H2dVariableType.DEBIT, vec); - if (getInitDataIndex(H2dVariableType.DEBIT) < 0) { + if (!isInitVar(H2dVariableType.DEBIT)) { varCreateData_.put(H2dVariableType.DEBIT, vec); } } } - idx = getInitDataIndex(H2dVariableType.COTE_EAU); - final int idxBath = getInitDataIndex(H2dVariableType.BATHYMETRIE); - final int idxH = getInitDataIndex(H2dVariableType.HAUTEUR_EAU); - if (idx < 0) { - if (idxBath >= 0 && idxH >= 0) { + if (!isInitVar(H2dVariableType.COTE_EAU)) { + if (isInitVar(H2dVariableType.BATHYMETRIE) && isInitVar(H2dVariableType.HAUTEUR_EAU)) { varCreateData_.put(H2dVariableType.COTE_EAU, new TrPostDataCreatedPlus(this, H2dVariableType.BATHYMETRIE, H2dVariableType.HAUTEUR_EAU)); } } // sinon on cree la hauteur d'eau - else if (idxH < 0 && idxBath >= 0) { + else if (!isInitVar(H2dVariableType.HAUTEUR_EAU) && isInitVar(H2dVariableType.BATHYMETRIE)) { varCreateData_.put(H2dVariableType.HAUTEUR_EAU, new TrPostDataCreatedMoins(this, H2dVariableType.COTE_EAU, H2dVariableType.BATHYMETRIE)); } - if (initVarIdx_ != null) { - final TObjectIntIterator it = initVarIdx_.iterator(); - for (int i = initVarIdx_.size(); i-- > 0;) { - it.advance(); - // int idxInit = it.value(); - final H2dVariableType vi = (H2dVariableType) it.key(); + Collection<H2dVariableType> vars = getInitVar(); + if (vars != null) { + for (H2dVariableType vi : vars) { final String name = vi.getName(); if (name.endsWith("X") && vi != H2dVariableType.DEBIT_X && vi != H2dVariableType.SXX) { final H2dVariableType idxY = getInitDataIndex(name.substring(0, name.length() - 1) + 'Y'); @@ -498,8 +489,7 @@ } } - protected TrPostDataMinMaxGlobalItem computeMinMax(final H2dVariableType _variable, - final ProgressionInterface _prog) { + protected TrPostDataMinMaxGlobalItem computeMinMax(final H2dVariableType _variable, final ProgressionInterface _prog) { final ProgressionUpdater up = createUpdaterForMinMax(_variable); final TrPostExtremVisitor visitor = new TrPostExtremVisitor(isRubar() ? getGrid().getEltNb() : getGrid().getPtsNb()); for (int i = getNbTimeStep() - 1; i >= 0; i--) { @@ -534,6 +524,10 @@ return up; } + protected Collection<H2dVariableType> getInitVar() { + return initVar_; + } + protected final InterpolationVectorContainer createVectorInterpolation() { if (vectors_ == null) { vectors_ = new InterpolationVectorContainer(); @@ -669,18 +663,15 @@ public EfData getData(final H2dVariableType _variable, final int _timeStep) { if (_timeStep < 0) { return null; } - final int init = getInitDataIndex(_variable); - if (init >= 0) { return getInitData(init, _timeStep); } + if (isInitVar(_variable)) return getInitData(_variable, _timeStep); if (isCreatedVar(_variable)) { return ((TrPostDataCreated) varCreateData_.get(_variable)).getDataFor(_timeStep); } if (isUserCreatedVar(_variable)) { return ((TrPostDataCreated) varUserCreateData_.get(_variable)) .getDataFor(_timeStep); } return null; } - public double getData(final H2dVariableType _variable, final int _timeStep, final int _idxPt) - throws IOException { - final int init = getInitDataIndex(_variable); - if (init >= 0) { return getInitData(init, _timeStep, _idxPt); } + public double getData(final H2dVariableType _variable, final int _timeStep, final int _idxPt) throws IOException { + if (isInitVar(_variable)) return getInitData(_variable, _timeStep, _idxPt); if (isCreatedVar(_variable)) { return ((TrPostDataCreated) varCreateData_.get(_variable)).getValue(_timeStep, _idxPt); } if (isUserCreatedVar(_variable)) { return ((TrPostDataCreated) varUserCreateData_.get(_variable)).getValue( @@ -850,21 +841,24 @@ return g_; } - public abstract EfData getInitData(int _varIdx, int _timeIdx); + public abstract EfData getInitData(H2dVariableType _varIdx, int _timeIdx); - public abstract double getInitData(int _varIdx, int _timeIdx, int _ptIdx) throws IOException; + public abstract double getInitData(H2dVariableType _varIdx, int _timeIdx, int _ptIdx) throws IOException; - protected final int getInitDataIndex(final H2dVariableType _t) { - if (initVarIdx_ != null && _t != null && initVarIdx_.contains(_t)) { return initVarIdx_.get(_t); } - return -1; + protected final boolean isInitVar(final H2dVariableType _t) { + return getInitVar().contains(_t); } + // protected final int getInitDataIndex(final H2dVariableType _t) { + // if (initVarIdx_ != null && _t != null && initVarIdx_.contains(_t)) { return initVarIdx_.get(_t); } + // return -1; + // } + protected final H2dVariableType getInitDataIndex(final String _varName) { - if (initVarIdx_ != null) { - final TObjectIntIterator it = initVarIdx_.iterator(); - for (int i = initVarIdx_.size(); i-- > 0;) { - it.advance(); - if (((H2dVariableType) it.key()).getName().equals(_varName)) { return (H2dVariableType) it.key(); } + Collection<H2dVariableType> vars = getInitVar(); + if (vars != null) { + for (H2dVariableType variableType : vars) { + if (variableType.getName().equals(_varName)) { return variableType; } } } return null; @@ -989,15 +983,6 @@ return variable_.length; } - public final H2dVariableType getVariableWithInitIdx(final int _idx) { - final TObjectIntIterator it = initVarIdx_.iterator(); - for (int i = initVarIdx_.size(); i-- > 0;) { - it.advance(); - if (it.value() == _idx) { return (H2dVariableType) it.key(); } - } - return null; - } - /** * @return un model representant les pas de temps */ @@ -1091,9 +1076,7 @@ } public final boolean isDefined(final H2dVariableType _variable) { - final int init = getInitDataIndex(_variable); - if (init >= 0) { return true; } - return isCreatedVar(_variable) || isUserCreatedVar(_variable); + return isInitVar(_variable) || isCreatedVar(_variable) || isUserCreatedVar(_variable); } public final boolean isElementVar(final CtuluVariable _idxVar) { @@ -1156,8 +1139,8 @@ return -1; } - public boolean openDatas(final ProgressionInterface _int, final CtuluAnalyze _analyze, - final ObjectContainer _db, final CtuluUI _ui) { + public boolean openDatas(final ProgressionInterface _int, final CtuluAnalyze _analyze, final ObjectContainer _db, + final CtuluUI _ui) { if (_db == null) { return false; } if (tmpContainer_ != null) { FuLog.error("the database is already opened", new Throwable()); @@ -1327,17 +1310,12 @@ } } - protected final void setInitVar(final H2dVariableType[] _v) { + protected void setInitVar(final H2dVariableType[] _v) { + initVar_ = Collections.unmodifiableCollection(Arrays.asList(_v)); variable_ = _v; if (variable_ == null) { variable_ = new H2dVariableType[0]; } - if (variable_.length > 0) { - initVarIdx_ = new TObjectIntHashMap(variable_.length); - for (int i = variable_.length - 1; i >= 0; i--) { - initVarIdx_.put(variable_[i], i); - } - } } @@ -1400,7 +1378,7 @@ } protected void updateVarList() { - final Set r = initVarIdx_ == null ? new HashSet() : new HashSet(Arrays.asList(initVarIdx_.keys())); + final Set r = initVar_ == null ? new HashSet() : new HashSet(initVar_); if (FuLog.isDebug()) { FuLog.debug("nb var creee auto " + varCreateData_.size()); } @@ -1442,32 +1420,33 @@ idx++; } } - public static void fillWithSourceInfo(String _pref,Map _table, TrPostSource src) { - + + public static void fillWithSourceInfo(String _pref, Map _table, TrPostSource src) { + Collection<File> files = src.getFiles(); int idx = 1; - String pref=_pref==null?CtuluLibString.EMPTY_STRING:_pref; + String pref = _pref == null ? CtuluLibString.EMPTY_STRING : _pref; for (File file : files) { String suffixe = files.size() > 1 ? CtuluLibString.getEspaceString(idx) : CtuluLibString.EMPTY_STRING; - _table.put(pref+TrResource.getS("Fichier r\xE9sultat") + suffixe, file.getName()); - _table.put(pref+TrResource.getS("Chemin complet") + suffixe, file.getAbsolutePath()); - _table.put(pref+TrResource.getS("Titre Fichier r\xE9sultat") + suffixe, src.getTitle()); + _table.put(pref + TrResource.getS("Fichier r\xE9sultat") + suffixe, file.getName()); + _table.put(pref + TrResource.getS("Chemin complet") + suffixe, file.getAbsolutePath()); + _table.put(pref + TrResource.getS("Titre Fichier r\xE9sultat") + suffixe, src.getTitle()); idx++; } } - - public static void fillWithSourceInfo(String _pref,Map _table, TrPostSourceReaderInterface src) { - - Collection<File> files = src.getFiles(); - int idx = 1; - String pref=_pref==null?CtuluLibString.EMPTY_STRING:_pref; - for (File file : files) { - String suffixe = files.size() > 1 ? CtuluLibString.getEspaceString(idx) : CtuluLibString.EMPTY_STRING; - _table.put(pref+TrResource.getS("Fichier r\xE9sultat") + suffixe, file.getName()); - _table.put(pref+TrResource.getS("Chemin complet") + suffixe, file.getAbsolutePath()); - // _table.put(pref+TrResource.getS("Titre Fichier r\xE9sultat") + suffixe, s); - idx++; - } - } - + + public static void fillWithSourceInfo(String _pref, Map _table, TrPostSourceReaderInterface src) { + + Collection<File> files = src.getFiles(); + int idx = 1; + String pref = _pref == null ? CtuluLibString.EMPTY_STRING : _pref; + for (File file : files) { + String suffixe = files.size() > 1 ? CtuluLibString.getEspaceString(idx) : CtuluLibString.EMPTY_STRING; + _table.put(pref + TrResource.getS("Fichier r\xE9sultat") + suffixe, file.getName()); + _table.put(pref + TrResource.getS("Chemin complet") + suffixe, file.getAbsolutePath()); + // _table.put(pref+TrResource.getS("Titre Fichier r\xE9sultat") + suffixe, s); + idx++; + } + } + } \ No newline at end of file Copied: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstractFromIdx.java (from rev 4403, branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstract.java) =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstractFromIdx.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceAbstractFromIdx.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -0,0 +1,82 @@ +/* + * @creation 24 mars 2004 + * @modification $Date: 2007-06-28 09:28:18 $ + * @license GNU General Public License 2 + * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail de...@fu... + */ +package org.fudaa.fudaa.tr.post; + +import gnu.trove.TObjectIntHashMap; +import gnu.trove.TObjectIntIterator; + +import java.io.IOException; + +import org.fudaa.ctulu.CtuluUI; +import org.fudaa.dodico.ef.EfData; +import org.fudaa.dodico.ef.EfGridInterface; +import org.fudaa.dodico.h2d.type.H2dVariableType; + +/** + * @author Fred Deniger + * @version $Id: TrPostSourceAbstract.java,v 1.52 2007-06-28 09:28:18 deniger Exp $ + */ +public abstract class TrPostSourceAbstractFromIdx extends TrPostSourceAbstract { + + TObjectIntHashMap initVarIdx_; + + protected TrPostSourceAbstractFromIdx(final String _titre, final EfGridInterface _g, final double[] _time, + final H2dVariableType[] _v, final CtuluUI _impl) { + super(_titre, _g, _time, _v, _impl); + setInitVar(_v); + } + + public void activate() {} + + + + public abstract EfData getInitData(int _varIdx, int _timeIdx); + + public abstract double getInitData(int _varIdx, int _timeIdx, int _ptIdx) throws IOException; + + protected final int getInitDataIndex(final H2dVariableType _t) { + if (initVarIdx_ != null && _t != null && initVarIdx_.contains(_t)) { return initVarIdx_.get(_t); } + return -1; + } + + protected final void setInitVar(final H2dVariableType[] _v) { + super.setInitVar(_v); + if (variable_.length > 0) { + initVarIdx_ = new TObjectIntHashMap(variable_.length); + for (int i = variable_.length - 1; i >= 0; i--) { + initVarIdx_.put(variable_[i], i); + } + } + + } + + public final H2dVariableType getVariableWithInitIdx(final int _idx) { + final TObjectIntIterator it = initVarIdx_.iterator(); + for (int i = initVarIdx_.size(); i-- > 0;) { + it.advance(); + if (it.value() == _idx) { return (H2dVariableType) it.key(); } + } + return null; + } + + @Override + public double getInitData(H2dVariableType _varIdx, int _timeIdx, int _ptIdx) throws IOException { + final int init = getInitDataIndex(_varIdx); + if (init >= 0) { return getInitData(init, _timeIdx, _ptIdx); } + return 0; + } + + @Override + public EfData getInitData(H2dVariableType _varIdx, int _timeIdx) { + final int init = getInitDataIndex(_varIdx); + if (init >= 0) { return getInitData(init, _timeIdx); } + return null; + } + + +} \ No newline at end of file Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceComparator.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceComparator.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceComparator.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -37,7 +37,7 @@ * @author Fred Deniger * @version $Id: TrPostSourceComparator.java,v 1.12 2007-06-05 09:01:14 deniger Exp $ */ -public final class TrPostSourceComparator extends TrPostSourceAbstract { +public final class TrPostSourceComparator extends TrPostSourceAbstractFromIdx { private H2dVariableType[] srcVariable_; Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceComparatorBuilder.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceComparatorBuilder.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceComparatorBuilder.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -187,10 +187,10 @@ // -- ajout des infos de cr\xE9ation --// String pref = TrResource.getS("Source") + " "; infosCreation_.put(pref + ZEbliCalquesPanel.TITRE_FIC, src.getTitle()); - TrPostSourceAbstract.fillWithSourceInfo(pref, infosCreation_, src); + TrPostSourceAbstractFromIdx.fillWithSourceInfo(pref, infosCreation_, src); pref = TrResource.getS("Projet\xE9") + " "; infosCreation_.put(pref + ZEbliCalquesPanel.TITRE_FIC, proj.getTitle()); - TrPostSourceAbstract.fillWithSourceInfo(pref, infosCreation_, proj); + TrPostSourceAbstractFromIdx.fillWithSourceInfo(pref, infosCreation_, proj); if (isOnImpGrid) infosCreation_.put(ZEbliCalquesPanel.MAILLAGE_FIC, proj.getTitle()); else infosCreation_.put(ZEbliCalquesPanel.MAILLAGE_FIC, src.getTitle()); Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceDefault.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceDefault.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceDefault.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -20,7 +20,7 @@ * @author Fred Deniger * @version $Id: TrPostSourceDefault.java,v 1.16 2006-10-27 10:24:42 deniger Exp $ */ -public final class TrPostSourceDefault extends TrPostSourceAbstract { +public final class TrPostSourceDefault extends TrPostSourceAbstractFromIdx { private final EfData[][] datas_; Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceFromReader.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceFromReader.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceFromReader.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -18,7 +18,7 @@ /** * @author deniger */ -public class TrPostSourceFromReader extends TrPostSourceAbstract { +public class TrPostSourceFromReader extends TrPostSourceAbstract{ TrPostSourceReaderInterface reader_; @@ -54,24 +54,6 @@ - @Override - public EfData getInitData(int _varIdx, int _timeIdx) { - return reader_.getInitData(_varIdx, _timeIdx); - } - - @Override - public double getInitData(int _varIdx, int _timeIdx, int _ptIdx) throws IOException { - return reader_.getInitData(_varIdx, _timeIdx, _ptIdx); - } - -// public TrPostInspectorReader createWatcher(TrPostProjet _proj, boolean _auto) { -// return reader_.createWatcher(_proj, _auto); -// } - - public boolean isRubar() { - return false; - } - public Collection<File> getFiles() { return reader_.getFiles(); } @@ -90,4 +72,19 @@ reader_ = _reader; } + @Override + public EfData getInitData(H2dVariableType _varIdx, int _timeIdx) { + return reader_.getInitData(_varIdx, _timeIdx); + } + + @Override + public double getInitData(H2dVariableType _varIdx, int _timeIdx, int _ptIdx) throws IOException { + return reader_.getInitData(_varIdx, _timeIdx, _ptIdx); + } + + + public boolean isRubar() { + return false; + } + } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceOneTimeStep.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceOneTimeStep.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceOneTimeStep.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -21,7 +21,7 @@ * @author fred deniger * @version $Id: TrPostSourceOneTimeStep.java,v 1.4 2007-06-05 09:01:14 deniger Exp $ */ -public class TrPostSourceOneTimeStep extends TrPostSourceAbstract { +public class TrPostSourceOneTimeStep extends TrPostSourceAbstractFromIdx { final int timeStep_; final TrPostSource init_; Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceProjected.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceProjected.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceProjected.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -42,7 +42,7 @@ * @author Fred Deniger * @version $Id: TrPostSourceProjected.java,v 1.14 2007-06-28 09:28:18 deniger Exp $ */ -public class TrPostSourceProjected extends TrPostSourceAbstract { +public class TrPostSourceProjected extends TrPostSourceAbstractFromIdx { final boolean destIsRubar_; Deleted: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderAbstract.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderAbstract.java 2009-01-26 18:36:56 UTC (rev 4403) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostSourceReaderAbstract.java 2009-01-26 22:59:34 UTC (rev 4404) @@ -1,74 +0,0 @@ -/** - * @creation 24 mars 2004 - * @modification $Date: 2007-05-04 14:01:52 $ - * @license GNU General Public License 2 - * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne - * @mail de...@fu... - */ -package org.fudaa.fudaa.tr.post; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.fudaa.dodico.ef.EfData; -import org.fudaa.dodico.ef.EfDataNode; -import org.fudaa.dodico.h2d.type.H2dVariableType; -import org.fudaa.dodico.telemac.io.SerafinNewReaderInfo; - -import com.memoire.fu.FuLog; - -/** - * @author Fred Deniger - * @version $Id: TrPostSourceSerafin.java,v 1.15 2007-05-04 14:01:52 deniger Exp $ - */ -public abstract class TrPostSourceReaderAbstract implements TrPostSourceReaderInterface { - - Collection<File> file_; - final double[] times_; - final List<H2dVariableType> initVar_; - - protected TrPostSourceReaderAbstract(final File _file, final double[] _time, H2dVariableType[] _initVar) { - file_ = Collections.unmodifiableCollection(Arrays.asList(_file)); - times_ = _time; - initVar_ = Collections.unmodifiableList(Arrays.asList(_initVar)); - } - - protected TrPostSourceReaderAbstract(Collection<File> _file, final double[] _time, H2dVariableType[] _initVar) { - file_ = _file; - times_ = _time; - initVar_ = Collections.unmo... [truncated message content] |