From: <had...@us...> - 2009-01-16 08:19:32
|
Revision: 4370 http://fudaa.svn.sourceforge.net/fudaa/?rev=4370&view=rev Author: hadouxad Date: 2009-01-16 08:19:27 +0000 (Fri, 16 Jan 2009) Log Message: ----------- Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MVProfileCourbeModel.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-16 08:16:33 UTC (rev 4369) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/meshviewer/profile/MVProfileCourbeModel.java 2009-01-16 08:19:27 UTC (rev 4370) @@ -1,252 +1,395 @@ -/* - * @creation 21 nov. 06 - * @modification $Date: 2007-06-13 12:58:09 $ - * @license GNU General Public License 2 - * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne - * @mail de...@fu... - */ -package org.fudaa.fudaa.meshviewer.profile; - -import java.util.Map; - -import gnu.trove.TDoubleArrayList; - -import org.fudaa.ctulu.CtuluCommandContainer; -import org.fudaa.ctulu.CtuluListSelectionInterface; -import org.fudaa.ctulu.CtuluRange; -import org.fudaa.ctulu.CtuluVariable; -import org.fudaa.ctulu.ProgressionInterface; -import org.fudaa.dodico.ef.EfGridData; -import org.fudaa.dodico.ef.operation.EfLineIntersectionsResultsBuilder; -import org.fudaa.dodico.ef.operation.EfLineIntersectionsResultsI; -import org.fudaa.ebli.palette.BPaletteInfo.InfoData; - -/** - * @author fred deniger - * @version $Id: MVProfileCourbeModel.java,v 1.10 2007-06-13 12:58:09 deniger Exp $ - */ -public class MVProfileCourbeModel implements MvProfileCourbeModelInterface { - - private int time_; - final EfGridData data_; - EfLineIntersectionsResultsI res_; - EfLineIntersectionsResultsBuilder builder_; - String title_; - - CtuluVariable variable_; - - final TDoubleArrayList y_; - - double yMax_; - - double yMin_; - - private MVProfileCourbeModel(final CtuluVariable _variable, final EfGridData _data, - final EfLineIntersectionsResultsI _res, final int _timeStep, final double[] _y, - final EfLineIntersectionsResultsBuilder _builder) { - super(); - variable_ = _variable; - data_ = _data; - res_ = _res; - title_ = _variable.toString(); - time_ = _timeStep; - builder_ = _builder; - y_ = new TDoubleArrayList(_y); - } - - public MVProfileCourbeModel(final CtuluVariable _variable, final EfGridData _data, final int _timeStep, - final EfLineIntersectionsResultsBuilder _builder, final ProgressionInterface _prog) { - super(); - variable_ = _variable; - data_ = _data; - title_ = _variable.toString(); - time_ = _timeStep; - builder_ = _builder; - if (builder_ != null) res_ = builder_.createResults(_timeStep, _prog); - y_ = new TDoubleArrayList(res_.getNbIntersect()); - computeY(_prog); - } - - public boolean addValue(final double _x, final double _y, final CtuluCommandContainer _cmd) { - return false; - } - - public boolean addValue(final double[] _x, final double[] _y, final CtuluCommandContainer _cmd) { - return false; - } - - public final void computeY(final ProgressionInterface _prog) { - final CtuluRange range = new CtuluRange(); - res_ = builder_.createResults(time_, _prog); - y_.ensureCapacity(res_.getNbIntersect()); - y_.resetQuick(); - for (int i = 0; i < res_.getNbIntersect(); i++) { - double val = 0; - if (res_.getIntersect(i).isRealIntersection()) { - val = res_.getIntersect(i).getValue(variable_, time_); - range.expandTo(val); - } - y_.add(val); - } - if (range.isNill()) { - yMax_ = 0; - yMin_ = 0; - } else { - yMax_ = range.getMax(); - yMin_ = range.getMin(); - } - } - - public boolean deplace(final int[] _selectIdx, final double _deltaX, final double _deltaY, - final CtuluCommandContainer _cmd) { - return false; - } - - public MVProfileCourbeModel duplicate() { - final MVProfileCourbeModel res = new MVProfileCourbeModel(variable_, data_, res_, time_, y_.toNativeArray(), - builder_); - res.yMax_ = yMax_; - res.yMin_ = yMin_; - return res; - } - - public void fillWithInfo(final InfoData _table, final CtuluListSelectionInterface _selectedPt) {} - - public int getActiveTimeIdx() { - return 0; - } - - public int getNbValues() { - return res_.getNbIntersect(); - } - - public EfLineIntersectionsResultsI getRes() { - return res_; - } - - public int getTime() { - return time_; - } - - public String getTitle() { - return title_; - } - - public CtuluVariable getVariable() { - return variable_; - } - - public double getX(final int _idx) { - return res_.getDistFromDeb(_idx); - } - - public double getXMax() { - return res_.getDistFromDeb(getNbValues() - 1); - } - - public double getXMin() { - return 0; - } - - public double getY(final int _idx) { - return y_.getQuick(_idx); - } - - public double getYMax() { - return yMax_; - } - - public double getYMin() { - return yMin_; - } - - public boolean isActiveTimeEnable() { - return false; - } - - public boolean isDuplicatable() { - return true; - } - - public boolean isModifiable() { - return false; - } - - public boolean isPointDrawn(final int _i) { - return res_.getIntersect(_i).isRealIntersection(); - } - - public boolean isRemovable() { - return false; - } - - public boolean isSegmentDrawn(final int _i) { - return res_.isSegmentIn(_i); - } - - public boolean isTitleModifiable() { - return true; - } - - public boolean isVisibleLong() { - return false; - } - - public boolean isXModifiable() { - return false; - } - - public boolean removeValue(final int _i, final CtuluCommandContainer _cmd) { - return false; - } - - public boolean removeValue(final int[] _i, final CtuluCommandContainer _cmd) { - return false; - } - - public void reupdateY() { - computeY(null); - - } - - public void setRes(final EfLineIntersectionsResultsBuilder _builder, final ProgressionInterface _prog) { - builder_ = _builder; - computeY(_prog); - } - - public void setTime(final int _time) { - if (time_ != _time && _time >= 0) { - time_ = _time; - computeY(null); - } - } - - public boolean setTitle(final String _newName) { - title_ = _newName; - return true; - } - - public boolean setValue(final int _i, final double _x, final double _y, final CtuluCommandContainer _cmd) { - return false; - } - - public boolean setValues(final int[] _idx, final double[] _x, final double[] _y, final CtuluCommandContainer _cmd) { - return false; - } - - public void setVariable(final CtuluVariable _variable, final boolean _contentChanged) { - variable_ = _variable; - if (_contentChanged && data_.isDefined(_variable)) { - computeY(null); - } - } - - public Object getPersistSpecificDatas() { - return null; - } - - public void setPersistSpecificDatas(Object data, Map infos) { - - } - -} +/* + * @creation 21 nov. 06 + * @modification $Date: 2007-06-13 12:58:09 $ + * @license GNU General Public License 2 + * @copyright (c)1998-2001 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail de...@fu... + */ +package org.fudaa.fudaa.meshviewer.profile; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.swing.JComboBox; + +import gnu.trove.TDoubleArrayList; + +import org.fudaa.ctulu.CtuluCommandContainer; +import org.fudaa.ctulu.CtuluListSelectionInterface; +import org.fudaa.ctulu.CtuluRange; +import org.fudaa.ctulu.CtuluVariable; +import org.fudaa.ctulu.ProgressionInterface; +import org.fudaa.dodico.ef.EfGridData; +import org.fudaa.dodico.ef.operation.EfLineIntersectionsResultsBuilder; +import org.fudaa.dodico.ef.operation.EfLineIntersectionsResultsI; +import org.fudaa.dodico.h2d.type.H2dVariableType; +import org.fudaa.ebli.calque.BCalqueLegende; +import org.fudaa.ebli.palette.BPaletteInfo.InfoData; +import org.fudaa.ebli.visuallibrary.EbliWidget; +import org.fudaa.fudaa.tr.common.TrResource; +import org.fudaa.fudaa.tr.post.TrPostProjet; +import org.fudaa.fudaa.tr.post.TrPostSource; +import org.fudaa.fudaa.tr.post.TrPostVisuPanel; +import org.fudaa.fudaa.tr.post.actions.TrPostProfileAction; + +import com.vividsolutions.jts.geom.LineString; + +/** + * @author fred deniger + * @version $Id: MVProfileCourbeModel.java,v 1.10 2007-06-13 12:58:09 deniger Exp $ + */ +public class MVProfileCourbeModel implements MvProfileCourbeModelInterface { + + private int time_; + EfGridData data_; + EfLineIntersectionsResultsI res_; + EfLineIntersectionsResultsBuilder builder_; + String title_; + + CtuluVariable variable_; + + TDoubleArrayList y_; + + double yMax_; + + double yMin_; + + private MVProfileCourbeModel(final CtuluVariable _variable, final EfGridData _data, + final EfLineIntersectionsResultsI _res, final int _timeStep, final double[] _y, + final EfLineIntersectionsResultsBuilder _builder) { + super(); + variable_ = _variable; + data_ = _data; + res_ = _res; + title_ = _variable.toString(); + time_ = _timeStep; + builder_ = _builder; + y_ = new TDoubleArrayList(_y); + } + + public MVProfileCourbeModel(final CtuluVariable _variable, final EfGridData _data, final int _timeStep, + final EfLineIntersectionsResultsBuilder _builder, final ProgressionInterface _prog) { + super(); + variable_ = _variable; + data_ = _data; + title_ = _variable.toString(); + time_ = _timeStep; + builder_ = _builder; + if (builder_ != null) res_ = builder_.createResults(_timeStep, _prog); + y_ = new TDoubleArrayList(res_.getNbIntersect()); + computeY(_prog); + } + + /** + * ACHTUNG: Constructeur uniquement utilis\xE9 pour la persistance des donn\xE9es. + */ + public MVProfileCourbeModel(){ + super(); + } + + public boolean addValue(final double _x, final double _y, final CtuluCommandContainer _cmd) { + return false; + } + + public boolean addValue(final double[] _x, final double[] _y, final CtuluCommandContainer _cmd) { + return false; + } + + /** + * Recalcule les y en fonction des informations fournises. + * @param _prog + */ + public final void computeY(final ProgressionInterface _prog) { + final CtuluRange range = new CtuluRange(); + res_ = builder_.createResults(time_, _prog); + + if(y_==null) + y_=new TDoubleArrayList(); + + y_.ensureCapacity(res_.getNbIntersect()); + y_.resetQuick(); + for (int i = 0; i < res_.getNbIntersect(); i++) { + double val = 0; + if (res_.getIntersect(i).isRealIntersection()) { + val = res_.getIntersect(i).getValue(variable_, time_); + range.expandTo(val); + } + y_.add(val); + } + if (range.isNill()) { + yMax_ = 0; + yMin_ = 0; + } else { + yMax_ = range.getMax(); + yMin_ = range.getMin(); + } + } + + public boolean deplace(final int[] _selectIdx, final double _deltaX, final double _deltaY, + final CtuluCommandContainer _cmd) { + return false; + } + + public MVProfileCourbeModel duplicate() { + final MVProfileCourbeModel res = new MVProfileCourbeModel(variable_, data_, res_, time_, y_.toNativeArray(), + builder_); + res.yMax_ = yMax_; + res.yMin_ = yMin_; + return res; + } + + public void fillWithInfo(InfoData _table, CtuluListSelectionInterface _selectedPt) { + if(EbliWidget.AMELIO_LOT_VISIBLE){ + String pdt="N\xB0"+this.time_; + if(this.data_ instanceof TrPostSource){ + TrPostSource src=(TrPostSource)this.data_; + _table.put(TrResource.getS("Type"),"Profil spatial"); + _table.put(TrResource.getS("Fichier r\xE9sultat"),src.getFile().getName()); + _table.put(TrResource.getS("Chemin complet"),src.getFile().getAbsolutePath()); + _table.put(TrResource.getS("Titre Fichier r\xE9sultat"),src.getTitle()); + if(this.time_!=-1 && this.time_<src.getNbTimeStep()) + pdt+=": "+src.getTimeStep(this.time_); + } + if(this.variable_!=null) + _table.put(TrResource.getS("Variable"),this.variable_.getName()+" en "+this.variable_.getCommonUnit()); + _table.put(TrResource.getS("Pas de temps "),pdt); + + LineString polyligne=builder_.getInitLine_(); + if(polyligne!=null){ + _table.put(TrResource.getS("Polyligne, nb pts"),""+polyligne.getNumPoints()); + _table.put(TrResource.getS("Point d\xE9but"),"("+polyligne.getCoordinateN(0).x+";"+polyligne.getCoordinateN(0).y+")"); + _table.put(TrResource.getS("Point fin"),"("+polyligne.getCoordinateN(polyligne.getNumPoints()-1).x+";"+polyligne.getCoordinateN(polyligne.getNumPoints()-1).y+")"); + + } + + + } + } + + public int getActiveTimeIdx() { + return 0; + } + + public int getNbValues() { + return res_.getNbIntersect(); + } + + public EfLineIntersectionsResultsI getRes() { + return res_; + } + + public int getTime() { + return time_; + } + + public String getTitle() { + return title_; + } + + public CtuluVariable getVariable() { + return variable_; + } + + public double getX(final int _idx) { + return res_.getDistFromDeb(_idx); + } + + public double getXMax() { + return res_.getDistFromDeb(getNbValues() - 1); + } + + public double getXMin() { + return 0; + } + + public double getY(final int _idx) { + return y_.getQuick(_idx); + } + + public double getYMax() { + return yMax_; + } + + public double getYMin() { + return yMin_; + } + + public boolean isActiveTimeEnable() { + return false; + } + + public boolean isDuplicatable() { + return true; + } + + public boolean isModifiable() { + return false; + } + + public boolean isPointDrawn(final int _i) { + return res_.getIntersect(_i).isRealIntersection(); + } + + public boolean isRemovable() { + return false; + } + + public boolean isSegmentDrawn(final int _i) { + return res_.isSegmentIn(_i); + } + + public boolean isTitleModifiable() { + return true; + } + + public boolean isVisibleLong() { + return false; + } + + public boolean isXModifiable() { + return false; + } + + public boolean removeValue(final int _i, final CtuluCommandContainer _cmd) { + return false; + } + + public boolean removeValue(final int[] _i, final CtuluCommandContainer _cmd) { + return false; + } + + public void reupdateY() { + computeY(null); + + } + + public void setRes(final EfLineIntersectionsResultsBuilder _builder, final ProgressionInterface _prog) { + builder_ = _builder; + computeY(_prog); + } + + public void setTime(final int _time) { + if (time_ != _time && _time >= 0) { + time_ = _time; + computeY(null); + } + } + + public boolean setTitle(final String _newName) { + title_ = _newName; + return true; + } + + public boolean setValue(final int _i, final double _x, final double _y, final CtuluCommandContainer _cmd) { + return false; + } + + public boolean setValues(final int[] _idx, final double[] _x, final double[] _y, final CtuluCommandContainer _cmd) { + return false; + } + + public void setVariable(final CtuluVariable _variable, final boolean _contentChanged) { + variable_ = _variable; + if (_contentChanged && data_.isDefined(_variable)) { + computeY(null); + } + } + + + + + + public Object getPersistSpecificDatas() { + //-- retourne le quatuor point, pdt,variable et fichier source + ArrayList<Object> listeData=new ArrayList<Object>(); + //listeData.add(this.); + + //-- ajout du pas de temps --// + listeData.add(new Integer(time_)); + + //-- ajout de la variable --// + listeData.add(this.variable_.getID()); + + //-- ajout de la polyligne --// + listeData.add(builder_.getInitLine_()); + + //-- ajout des datas --// + if(data_ instanceof TrPostSource){ + listeData.add(((TrPostSource)data_).getId()); + } + + + return listeData; + } + + + public void setPersistSpecificDatas(Object data, Map infos) { + + if(data ==null || !(data instanceof ArrayList))return; + ArrayList<Object> liste=(ArrayList<Object>)data; + + TrPostProjet projet = (TrPostProjet) infos.get("TrPostProjet"); + TrPostSource src = null; + //-- etape 1: le pas de temps --// + this.time_=(Integer) liste.get(0); + + //-- etape 2 la variable --// + String idVar=(String)liste.get(1); + H2dVariableType var=null;//(H2dVariableType) liste.get(1); + + + + + + //-- etape 3: la polyligne --// + LineString polyligne=(LineString) liste.get(2); + + // -- etape 4: recherche du source qui contient le path donn\xE9 --// + if (projet != null && liste.size()>=4){ + String idSource=(String) liste.get(3); + src = projet.findSourceById(idSource); + if(src!=null) + this.data_=src; + else{ + ((List<String>) infos.get("errorMsg")) + .add("Erreur, la frame graphe ne trouve pas le fichier r\xE9sultat qui correspond \xE0 l'ID " + idVar); + return; + } + } + else{ + ((List<String>) infos.get("errorMsg")) + .add("Erreur, la frame graphe ne trouve pas le fichier r\xE9sultat qui correspond \xE0 l'ID " + idVar); + return; + } + //-- recherche dans les sources de la variable par id --// + for(int i=0;i<src.getAvailableVar().length;i++) + if(src.getAvailableVar()[i].getID().equals(idVar)) + var=src.getAvailableVar()[i]; + + if(var!=null) + this.variable_=var; + else{ + ((List<String>) infos.get("errorMsg")) + .add("Erreur, la frame graphe ne trouve pas la variable qui correspond \xE0 l'ID " + idVar); + return; + } + + //-- on rejoue les donn\xE9es: --// + //-- creation du resultBuilder: --// + TrPostVisuPanel panelUtilise=new TrPostVisuPanel(projet.impl_,projet,new BCalqueLegende(),src); + MvProfileTarget target=new TrPostProfileAction.ProfileAdapter(src,projet); + MvProfileBuilder builder=new MvProfileBuilderFromLine(target,projet.impl_,polyligne,panelUtilise,new MvProfileCoteTester()); + + //-- intersectionResultI --// + this.res_=builder.getDefaultRes(this.variable_, projet.impl_.getMainProgression()); + + //-- EfLineIntersectionsResultsBuilder --// + this.builder_=new EfLineIntersectionsResultsBuilder(polyligne,this.res_,new MvProfileCoteTester()); + + //-- rejouer les donn\xE9es --// + this.computeY(projet.impl_.getMainProgression()); + } + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |