From: <had...@us...> - 2008-09-13 20:38:31
|
Revision: 3921 http://fudaa.svn.sourceforge.net/fudaa/?rev=3921&view=rev Author: hadouxad Date: 2008-09-13 20:38:41 +0000 (Sat, 13 Sep 2008) Log Message: ----------- COrrection bugs - action configurer: delegue toujours a son widgetBordure. - cas special legende: Copier/couper: lors de la copie/couper de legende, n enregistre rien pour eviter le plantage. Correction bug wizard courbes temporelles - l'action ajouter en cliquant sur la ligene de la cellule vide - action supprimer: qui supprime les points saisis - action modifs: en double cliquant sur les cellules (cf setValueAt) - s'il n'y a pas de graphe dispo, l'option cr?\195?\169e un nouveau graphe doit etre coch?\195?\169e et disable ( l'utilisateur n'a pas le choix...) - Bug bizarre lors de la saisie de certains points pour les courbes temporelles... FONCTION AJOUT COURBE SOURCE OK!! - Fonction clic droit sur courbe du graphe FONCTIONNE! - methode TrPostCourbeTreeModel.duplicateWithChooseSrc() - Il fallait initialiser le tableau des y en recuperant la taille du y de son duplicata - utilsier la methode update - GESTION DE TOUS LEs CAS (tentative) - creation courbe REELLE sur nouveau src depuis courbe REELLE ancien source - creation courbe INTERPOLEE sur nouveau src depuis courbe REELLE ancien source - creation courbe REELLE sur nouveau src depuis courbe INTERPOLEE ancien source - creation courbe INTERPOLEE sur nouveau src depuis courbe INTERPOLEE ancien source Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostCourbeTreeModel.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostWizardCourbeTemporelle.java Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostCourbeTreeModel.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostCourbeTreeModel.java 2008-09-13 20:37:51 UTC (rev 3920) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostCourbeTreeModel.java 2008-09-13 20:38:41 UTC (rev 3921) @@ -26,15 +26,19 @@ import org.fudaa.ctulu.CtuluLibArray; import org.fudaa.ctulu.ProgressionInterface; import org.fudaa.ctulu.ProgressionUpdater; +import org.fudaa.ctulu.gis.GISPrecision; import org.fudaa.dodico.h2d.type.H2dVariableType; import org.fudaa.ebli.courbe.EGAxeVertical; import org.fudaa.ebli.courbe.EGCourbe; import org.fudaa.ebli.courbe.EGCourbeChild; import org.fudaa.ebli.courbe.EGGrapheTreeModel; import org.fudaa.ebli.courbe.EGGroup; +import org.fudaa.ebli.geometrie.GrPoint; import org.fudaa.fudaa.commun.impl.FudaaCommonImplementation; import org.fudaa.fudaa.tr.common.TrResource; +import org.fudaa.fudaa.tr.post.TrPostCourbeModel.Node; +import com.memoire.bu.BuDialogChoice; import com.memoire.bu.BuLib; import com.memoire.fu.FuComparator; import com.memoire.fu.FuEmptyArrays; @@ -70,6 +74,8 @@ Set varSupported_; + TrPostProjet projet_; + public Set getVarSupported() { return varSupported_; } @@ -95,7 +101,7 @@ * ] * _timeIdx */, - final H2dVariableType[] _vars) { + final H2dVariableType[] _vars, TrPostProjet _projet) { src_ = _src; varGroup_ = new HashMap(); // tidx_ = _timeIdx; @@ -105,6 +111,7 @@ varSupported_ = new HashSet(Arrays.asList(_vars)); impl_ = _impl; isAllTimeStep_ = true;// tidx_.length == _src.getNbTimeStep(); + projet_ = _projet; } public TrPostCourbeTreeModel(final FudaaCommonImplementation _impl, final TrPostSource _src,/* @@ -115,15 +122,15 @@ * _timeIdx * , */ - final int[] _objIdx, final H2dVariableType[] _vars) { - this(_impl, _src/* , _timeIdx */, _vars); + final int[] _objIdx, final H2dVariableType[] _vars, TrPostProjet _projet) { + this(_impl, _src/* , _timeIdx */, _vars, _projet); objIdx_ = _objIdx; Arrays.sort(objIdx_); } public TrPostCourbeTreeModel(final FudaaCommonImplementation _impl, final TrPostSource _src, final int[] _timeIdx, - final TrPostInterpolatePoint _interpol, final H2dVariableType[] _vars) { - this(_impl, _src/* , _timeIdx */, _vars); + final TrPostInterpolatePoint _interpol, final H2dVariableType[] _vars, TrPostProjet _projet) { + this(_impl, _src/* , _timeIdx */, _vars, _projet); intepolPt_.add(_interpol); } @@ -692,7 +699,147 @@ return isAllTimeStep_; } - // public void updateTimeStep(int[] _idx, ProgressionInterface _prog) { - // } + protected EGCourbeChild duplicateCourbe(final EGCourbeChild _c) { + return null; + } + + String[] formattageDonnees() { + String[] listeSimul = new String[projet_.listeSrc_.size()]; + int cpt = 0; + for (Iterator<TrPostSource> it = projet_.listeSrc_.iterator(); it.hasNext();) { + + TrPostSource src = it.next(); + + // --ajout dans la liste des titres --// + listeSimul[cpt++] = projet_.formatInfoSource(src); + } + + return listeSimul; + } + + /** + * OVERIDE. methode qui demande a l user de choisir sa courbe puis genere une + * copie avec la source en cours. + * + * @param _child + * @return + */ + protected EGCourbeChild duplicateWithChooseSrc(EGCourbeChild _child) { + + + // -- mise en place du chooser des projets sources disponibles --// + + // -- recuperation du source voulu --// + // -- recuperation de la liste des src sous forme de liste --// + String[] values = formattageDonnees(); + + // -- ouverture du chooser --// + BuDialogChoice chooser = new BuDialogChoice(projet_.impl_.getApp(), projet_.impl_.getInformationsSoftware(), + TrResource.getS("Cr\xE9ation d'un calque"), TrResource.getS("S\xE9lectionnez le jeux de donn\xE9es "), values); + + int response = chooser.activate(); + + if (response == 0) { + + int indiceSOURCESelect = chooser.getSelectedIndex(); + + TrPostSource srcChoisie=projet_.getSource(indiceSOURCESelect); + + + EGCourbeChild newCurve=null; + + //-- recuperation du point interpol\xE9 ou non selon le cas --// + if(_child.getModel() instanceof TrPostCourbeModel.Node){ + + // -- CAS COURBE REELLE --// + TrPostCourbeModel.Node modelBase=(Node) _child.getModel(); + H2dVariableType var = modelBase.getVar(); + + // -- verification si le point du model choisi est reel ou interpol\xE9 + // dans la nouvelle source --// + if (srcChoisie.getGrid().contientPoint(src_.getGrid().getPtX(modelBase.ptIdx_), + src_.getGrid().getPtY(modelBase.ptIdx_))) { + + // -- CREATION DE LA COURBE REELE DEPUIS COURBE REELLE --// + newCurve = TrPostCourbeModel.Node.buildCourbeModel(var, modelBase.ptIdx_, modelBase.getTime(), + _child.getParentGroup(), srcChoisie); + } else { + // -- on recupere le point le plus proche pour interpoler --// + GrPoint pointAInterpole=new GrPoint(src_.getGrid().getPtX(modelBase.ptIdx_),src_.getGrid().getPtY(modelBase.ptIdx_),0); + int newPtIdx = TrIsoLayerDefault.sondeSelection(pointAInterpole, srcChoisie.getGrid()); + + if (newPtIdx != -1) { + + TrPostInterpolatePoint interpolatePoint = new TrPostInterpolatePoint(newPtIdx, pointAInterpole.x_, + pointAInterpole.y_, new GISPrecision()); + + // -- CREATION DE LA COURBE INTERPOLEE DEPUIS COURBE REELLE --// + newCurve = TrPostCourbeModel.Interpolated.buildCourbeModel(modelBase.getVar(), interpolatePoint, modelBase + .getTime(), _child.getParentGroup(), srcChoisie); + } + } + + // -- recuperation des y de son duplicata --// + ((TrPostCourbeModel) newCurve.getModel()).setY(new double[modelBase.getY().length]); + + double[] ds = modelBase.getTime(); + for (int i = 0; i < ds.length; i++) { + ((TrPostCourbeModel) newCurve.getModel()).updateY(i, var); + } + + } + else{ + + // -- CAS COURBE INTERPOLEE --// + TrPostCourbeModel.Interpolated modelBase=(TrPostCourbeModel.Interpolated) _child.getModel(); + H2dVariableType var = modelBase.getVar(); + + // -- verification si le point du model choisi est reel ou interpol\xE9 + // dans la nouvelle source --// + if (srcChoisie.getGrid().contientPoint(modelBase.ptIdx_.x_, modelBase.ptIdx_.y_)) { + + // -- recuperation du point interpol\xE9 pour la nouvelle source --// + GrPoint pointInterpol = new GrPoint(modelBase.ptIdx_.x_, modelBase.ptIdx_.y_, 0); + int newPtIdx = TrIsoLayerDefault.sondeSelection(pointInterpol, srcChoisie.getGrid()); + if (newPtIdx != -1) { + // -- CREATION DE LA COURBE REELE DEPUIS COURBE INTERPOLEE --// + newCurve = TrPostCourbeModel.Node.buildCourbeModel(var, newPtIdx, modelBase.getTime(), _child + .getParentGroup(), srcChoisie); + } + } else { + // -- on recupere le point le plus proche pour interpoler --// + GrPoint pointInterpol = new GrPoint(modelBase.ptIdx_.x_, modelBase.ptIdx_.y_, 0); + int newPtIdx = TrIsoLayerDefault.sondeSelection(pointInterpol, srcChoisie.getGrid()); + + if (newPtIdx != -1) { + + TrPostInterpolatePoint interpolatePoint = new TrPostInterpolatePoint(newPtIdx, modelBase.ptIdx_.x_, + modelBase.ptIdx_.y_, new GISPrecision()); + + // -- CREATION DE LA COURBE INTERPOLEE DEPUIS COURBE INTERPOLEE --// + newCurve = TrPostCourbeModel.Interpolated.buildCourbeModel(modelBase.getVar(), interpolatePoint, modelBase + .getTime(), _child.getParentGroup(), srcChoisie); + } + } + + + // -- recuperation des y de son duplicata --// + ((TrPostCourbeModel) newCurve.getModel()).setY(new double[modelBase.getY().length]); + double[] ds = modelBase.getTime(); + for (int i = 0; i < ds.length; i++) { + ((TrPostCourbeModel) newCurve.getModel()).updateY(i, var); + } + + } + newCurve.setTitle(newCurve.getTitle() + " " + + projet_.formatName(projet_.getSource(indiceSOURCESelect).getTitle())); + + + return newCurve; + } + return null; + } + + } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostWizardCourbeTemporelle.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostWizardCourbeTemporelle.java 2008-09-13 20:37:51 UTC (rev 3920) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/TrPostWizardCourbeTemporelle.java 2008-09-13 20:38:41 UTC (rev 3921) @@ -31,7 +31,6 @@ import com.memoire.bu.BuCheckBox; import com.memoire.bu.BuScrollPane; import com.memoire.bu.BuTextField; -import com.memoire.bu.BuValueValidator; import com.memoire.bu.BuWizardTask; import com.memoire.fu.FuLog; @@ -88,8 +87,79 @@ public class ModelListePoints extends AbstractTableModel { - String[] titre_; + // -- variables utilisees pour stocker la saisie de l utilisateur + String xTempCreate = null; + String yTempCreate = null; + public void setValueAt(Object _value, int _rowIndex, int _columnIndex) { + + if (_columnIndex == 0) + return; + + // -- cas edition interne de nouveau point --// + if (ptIdx_ != null && _rowIndex == ptIdx_.length) { + if (_columnIndex == 1) { + xTempCreate = (String) _value; + + } else if (_columnIndex == 2) { + + yTempCreate = (String) _value; + } + + // -- verification si les 2 params sont saisis, on ajoute le point au + // tableau + if (xTempCreate != null && yTempCreate != null) { + + if (!checkAndReplaceSonde(xTempCreate, yTempCreate, this, ptIdx_.length)) { + + projet_.impl_.error("Le point rentr\xE9 n'est pas dans le maillage."); + //-- on reintialise les donnees --// + if (_columnIndex == 1) { + xTempCreate = null; + + } else if (_columnIndex == 2) { + yTempCreate = null; + } + + } else { + + // -- le point est ajout\xE9 auto dans la methode check, on + // repositionne anull les temp --// + xTempCreate = null; + yTempCreate = null; + } + } + + } else { + // cas normal de modif de val --// + if (_columnIndex == 1) { + String val = (String) _value; + // -- on recupere le y et on v\xE9rifie que le point est toujours bon + // --// + String y = (String) getValueAt(_rowIndex, 2); + + if (!checkAndReplaceSonde(xTempCreate, yTempCreate, this, _rowIndex)) { + projet_.impl_.error("Le point rentr\xE9 n'est pas dans le maillage."); + } + + + } else if (_columnIndex == 2) { + + String val = (String) _value; + // -- on recupere le x et on v\xE9rifie que le point est toujours bon + // --// + String x = (String) getValueAt(_rowIndex, 1); + + + + } + + } + + } + + String[] titre_; + public ModelListePoints() { String[] val = { "Point", "X", "Y" }; titre_ = val; @@ -111,12 +181,24 @@ public int getRowCount() { if (ptIdx_ != null) - return ptIdx_.length; + return ptIdx_.length + 1; else return 1; } public Object getValueAt(int _rowIndex, int _columnIndex) { + + // -- cas edition interne de nouveau point --// + if (ptIdx_ != null && _rowIndex == ptIdx_.length) + if (_columnIndex == 1 && xTempCreate != null) + return xTempCreate; + else if (_columnIndex == 2 && yTempCreate != null) + return yTempCreate; + else + return ""; + + + if(_columnIndex==0){ if(ptIdx_!=null) return ptIdx_[_rowIndex]; @@ -150,7 +232,10 @@ } public boolean isCellEditable(int _rowIndex, int _columnIndex) { + if (_columnIndex == 0) return false; + else + return true; } @@ -172,6 +257,11 @@ pt_ = _pt; ptIdx_ = _ptIdx; + // -- si les 2 sont nuls, on initialise la liste des points modifiable --// + if (pt_ == null && ptIdx_ == null) + ptIdx_ = new int[0]; + + // creationNewGraphe_.addActionListener(new ActionListener() { // // public void actionPerformed(ActionEvent _e) { @@ -269,7 +359,8 @@ final JXTable tableau = new JXTable(model); content.add(new BuScrollPane(tableau), BorderLayout.CENTER); if (pt_ == null) { - content.add(new JLabel(TrResource.getS("Choisir parmi les points selectionn\xE9s.")), BorderLayout.NORTH); + content.add(new JLabel(TrResource.getS("Saisir ou modifier des points en cliquant dans le tableau.")), + BorderLayout.NORTH); } else @@ -277,47 +368,58 @@ // -- ajout du jtext pour ajout uniquement d'un point interpol\xE9 --// - if (ptIdx_ == null) { + if (ptIdx_ != null) { JPanel control = new JPanel(new FlowLayout(FlowLayout.CENTER)); - control.add(new JLabel(TrResource.getS("Cr\xE9ez votre point interpol\xE9. x:"))); - tf1_1 = new BuTextField(10); - tf1_1.setValueValidator(BuValueValidator.DOUBLE); - tf1_2 = new BuTextField(10); - tf1_2.setValueValidator(BuValueValidator.DOUBLE); - control.add(tf1_1); - control.add(new JLabel("y:")); - control.add(tf1_2); - JButton valide = new JButton(EbliResource.EBLI.getIcon("crystal_valider")); - valide.addActionListener(new ActionListener() { + control.add(new JLabel(TrResource.getS("Supprimer les points s\xE9lectionn\xE9s:"))); + + JButton supprimer = new JButton("Supprimer", EbliResource.EBLI.getIcon("crystal_supprimer")); + supprimer.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent _e) { - if (!checkAndReplaceSonde(tf1_1.getText(), tf1_2.getText(), model)) { - projet_.getImpl().error(TrResource.getS("Le point rentr\xE9 n'est pas correct")); - } + + int[] listePointToDelete = tableau.getSelectedRows(); + + if (listePointToDelete != null) { + + + boolean selectEmptyRow = false; + for (int i = 0; !selectEmptyRow && i < listePointToDelete.length; i++) + if (listePointToDelete[i] == ptIdx_.length) + selectEmptyRow = true; + + int[] newTab = null; + if (selectEmptyRow) + newTab = new int[ptIdx_.length - listePointToDelete.length + 1]; + else + newTab = new int[ptIdx_.length - listePointToDelete.length]; + + int cpt = 0; + for (int i = 0; i < ptIdx_.length; i++) { + + boolean mustDelete = false; + + for (int k = 0; !mustDelete && k < listePointToDelete.length; k++) + if (listePointToDelete[k] ==i) + mustDelete = true; + + if(!mustDelete) + newTab[cpt++] = ptIdx_[i]; + + + } + + ptIdx_ = newTab; + + model.fireTableDataChanged(); + } + } }); - control.add(valide); + control.add(supprimer); content.add(control, BorderLayout.SOUTH); - } else { - // -- fonction specifique a la liste de points reels: possibilit\xE9de - // degager els points snon selectionner --// - JPanel control = new JPanel(new FlowLayout(FlowLayout.CENTER)); - control.add(new JLabel(TrResource - .getS("Garder uniquement les points choisis (ctrl+ clic pour en choisir plusieurs)"))); - JButton valide = new JButton(EbliResource.EBLI.getIcon("crystal_valider")); - valide.addActionListener(new ActionListener() { + } - public void actionPerformed(ActionEvent _e) { - checkAndReplacePoints(model, tableau.getSelectedRows()); - - } - - }); - control.add(valide); - content.add(control, BorderLayout.SOUTH); - } - return content; } @@ -333,6 +435,11 @@ JPanel bouttonCenter = new JPanel(new FlowLayout(FlowLayout.CENTER)); bouttonCenter.add(creationNewGraphe_); content.add(bouttonCenter, BorderLayout.SOUTH); + if (actionChoixGraphes_.listeGraphesPossibles.size() == 0 && actionChoixGraphes_.listeGraphesChoisis.size() == 0) { + creationNewGraphe_.setSelected(true); + creationNewGraphe_.setEnabled(false); + actionChoixGraphes_.setEnabled(false); + } return content; } } @@ -342,22 +449,38 @@ /** * Methode qui verifie que le nouveau point peut etre une sonde et le remplace - * par l actuelle. + * par l actuel ou alors l ajoute dans le tableau selon l indice. */ - public boolean checkAndReplaceSonde(String xs, String ys, ModelListePoints model) { + public boolean checkAndReplaceSonde(String xs, String ys, ModelListePoints model, int _indiceTableauAmodif) { double x = Double.parseDouble(xs); double y = Double.parseDouble(ys); GrPoint point=new GrPoint( x,y,0); + + + // -- verification que le point peut etre une sonde --// int idxElt = TrIsoLayerDefault.sondeSelection(point, (TrPostModelInterface) calque_.getIsoLayer().getIsoModel()); if (idxElt > -1){ //--on remoplace la sonde actuelle --// pt_ = new TrPostInterpolatePoint(idxElt, x, y, new GISPrecision()); - // -- mise a jour des donnees sur le calque --// - int[] newVal = new int[1]; - newVal[0] = pt_.idxElt_; + + + + if (_indiceTableauAmodif < ptIdx_.length) + this.ptIdx_[_indiceTableauAmodif] = pt_.idxElt_; + else { + // -- il faut reconstruire le tableau avec size +1 en ajoutant le point + int[] newVal = new int[ptIdx_.length + 1]; + for (int i = 0; i < ptIdx_.length; i++) { + newVal[i] = ptIdx_[i]; + FuLog.warning("ptIdx_[" + i + "]=" + newVal[i]); + } + newVal[ptIdx_.length] = pt_.idxElt_; + ptIdx_ = newVal; + + } model.fireTableDataChanged(); return true; } @@ -365,21 +488,8 @@ } - public void checkAndReplacePoints(ModelListePoints model, int[] pointsChoisis) { - - int[] newPtIdx=new int[pointsChoisis.length]; - for (int i = 0; i < pointsChoisis.length; i++) { - newPtIdx[i] = ptIdx_[pointsChoisis[i]]; - } - ptIdx_ = newPtIdx; - // -- mise a jour des donnees sur le calque --// - // ((ZCalqueAffichageDonnees) - // calque_.getCalqueActif()).setSelection(ptIdx_); - // -- mise a joru des donnees sur le model --// - model.fireTableDataChanged(); - - } + private static int cptGraphe = 1; /** * Action de creation d un nouveau widget graphe en live @@ -399,13 +509,13 @@ FuLog.warning("Sonde: " + pt_ + "\n liste points. " + ptIdx_); // -- cas listes de noeuds if (pt_ == null) - model = TrPostCourbeBuilder.build(projet_.getImpl(), calque_.getSourceCalque(), chooserVarTime_ + model = TrPostCourbeBuilder.build(projet_, calque_.getSourceCalque(), chooserVarTime_ .getSelectedTimeStepIdx(), var, ptIdx_, prog); else // -- cas sonde --// if (ptIdx_ == null || ptIdx_.length == 0) model = TrPostCourbeBuilder.build( - projet_.getImpl(), calque_.getSourceCalque(), + projet_, calque_.getSourceCalque(), chooserVarTime_ .getSelectedTimeStepIdx(), var, pt_, prog); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |