From: <emm...@us...> - 2008-12-18 10:59:30
|
Revision: 4306 http://fudaa.svn.sourceforge.net/fudaa/?rev=4306&view=rev Author: emmanuel_martin Date: 2008-12-18 10:59:27 +0000 (Thu, 18 Dec 2008) Log Message: ----------- Ajout de l'undo/redo dans le modeleur1d. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/Controller1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometry.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/MdlFille1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueCourbe.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueTableau.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/testModeleur1d/TestDataGeometryAdapter.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/Controller1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/Controller1d.java 2008-12-17 17:44:49 UTC (rev 4305) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/Controller1d.java 2008-12-18 10:59:27 UTC (rev 4306) @@ -20,6 +20,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import org.fudaa.ctulu.CtuluCommandManager; import org.fudaa.ctulu.CtuluListSelectionEvent; import org.fudaa.ctulu.CtuluListSelectionListener; import org.fudaa.ctulu.gis.GISAttributeConstants; @@ -67,6 +68,8 @@ private DataGeometryAdapter dataGeomAdapter_; /** Formater */ private EbliFormatterInterface formater_=new EbliFormatter(); + /** Le commande manager pour le undo/redo */ + private CtuluCommandManager mng_; public Controller1d(MdlImplementation _appli, MdlFille1d _frame1d){ if(_appli==null||_frame1d==null) @@ -74,6 +77,7 @@ appli_=_appli; frame1d_=_frame1d; frame1d_.addInternalFrameListener(this); + mng_=new CtuluCommandManager(); vueBief_=new VueBief(appli_, this); vueBief_.getScene().addSelectionListener(this); treeModel_=vueBief_.getArbreCalqueModel(); @@ -109,6 +113,10 @@ return formater_; } + public CtuluCommandManager getCommandManager(){ + return mng_; + } + // Gestion de l'affichage des erreurs. \\ public void showError(String _message){ Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometry.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometry.java 2008-12-17 17:44:49 UTC (rev 4305) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometry.java 2008-12-18 10:59:27 UTC (rev 4306) @@ -7,6 +7,8 @@ */ package org.fudaa.fudaa.modeleur.modeleur1d; +import org.fudaa.ctulu.CtuluCommandContainer; + /** * Une interface permettant d'acc\xE9der aux informations manipul\xE9es par les * widgets tableau et courbe. @@ -53,14 +55,14 @@ * Pour les autres points, le point 2D est d\xE9plac\xE9 sur son axe en concervant * la longeur globale. */ - public void setCurv(int _idxPoint, double _value) throws DataGeometryException; + public void setCurv(int _idxPoint, double _value, CtuluCommandContainer _cmd) throws DataGeometryException; /** Enregistre la valeur de z du point indiqu\xE9 en param\xE8tre. */ - public void setZ(int _idxPoint, double _value); + public void setZ(int _idxPoint, double _value, CtuluCommandContainer _cmd); /** Enregistre l'abcisse curviligne et la valeur de z du point indiqu\xE9 en param\xE8tre. */ - public void setValues(int _idxPoint, double _valueCurv, double _valueZ) throws DataGeometryException; + public void setValues(int _idxPoint, double _valueCurv, double _valueZ, CtuluCommandContainer _cmd) throws DataGeometryException; /** Supprime le point indiqu\xE9 en param\xE8tre. */ - public void remove(int _idxPoint) throws DataGeometryException; + public void remove(int _idxPoint, CtuluCommandContainer _cmd) throws DataGeometryException; } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryAdapter.java 2008-12-17 17:44:49 UTC (rev 4305) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryAdapter.java 2008-12-18 10:59:27 UTC (rev 4306) @@ -10,7 +10,11 @@ import java.util.ArrayList; import java.util.List; +import org.fudaa.ctulu.CtuluCommand; +import org.fudaa.ctulu.CtuluCommandComposite; +import org.fudaa.ctulu.CtuluCommandContainer; import org.fudaa.ctulu.CtuluListSelection; +import org.fudaa.ctulu.CtuluNamedCommand; import org.fudaa.ctulu.collection.CtuluCollection; import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISGeometryFactory; @@ -33,6 +37,62 @@ */ public class DataGeometryAdapter implements DataGeometry { + /** + * Un command container pour le undo/redo. + * Fonctionnement : + * Deux \xE9l\xE9ments sont \xE0 prendre en compte lors du undo/redo : + * 1) Il peut \xEAtre n\xE9c\xE9ssaire de mettre a jour le z et/ou le curv. + * 2) Le undo/redo peut \xEAtre d\xE9clanch\xE9 alors que le DataGeometryAdapter g\xE9re actuellement une autre g\xE9om\xE9try. + * Pour g\xE9rer ces deux cas : + * 1) Deux booleans sont pris par le constructeur indiquant si il faut mettre \xE0 jour les valeurs de z et/ou de curv. + * 2) La zone et l'index de la g\xE9om\xE9trie g\xE9r\xE9 au moment de l'action sont m\xE9moris\xE9s pour g\xE9rer le cas 2. Dans le cas + * o\xF9 un autre g\xE9om\xE9trie est g\xE9r\xE9e au moment du undo/redo aucun update n'est d\xE9clanch\xE9. + * Ainsi m\xEAme si la g\xE9om\xE9trie selectionn\xE9 change plein de fois, revient sur la selection pr\xE9c\xE9dente etc...La mise \xE0 + * jour visuelle se fera correctement. + * Information suppl\xE9mentaire : pour fonctionner correctement le CtuluCommandContainer prit en param\xE8tre contenant + * le undo/redo ne doit pas d\xE9pendre de DataGeometryAdapter mais seulement de la zone. + */ + protected class DGCommandUndoRedo implements CtuluCommand, CtuluNamedCommand { + private CtuluCommand cmd_; + private boolean updateZ_; + private boolean updateCurv_; + private GISZoneCollectionLigneBrisee oldZone_; + private int oldIdxGeom_; + + public DGCommandUndoRedo(CtuluCommand _cmd, boolean _updateZ, boolean _updateCurv){ + cmd_=_cmd; + updateZ_=_updateZ; + updateCurv_=_updateCurv; + oldZone_=zone_; + oldIdxGeom_=idxGeom_; + } + + private void updateIfNeeded(){ + if(oldZone_==zone_&&oldIdxGeom_==idxGeom_) { + if(updateZ_) updateCacheZ(); + if(updateCurv_) updateCacheCurv(); + fireDataGeometryChanged(); + } + } + + public void redo() { + cmd_.redo(); + updateIfNeeded(); + } + + public void undo() { + cmd_.undo(); + updateIfNeeded(); + } + + public String getName() { + if(cmd_ instanceof CtuluNamedCommand) + return ((CtuluNamedCommand) cmd_).getName(); + else + return null; + } + } + private GISZoneCollectionLigneBrisee zone_; private int idxGeom_; private CtuluCollection z_; @@ -50,6 +110,46 @@ } /** + * Met \xE0 jour les valeurs zMin et zMax. + * Si z_ est null, zMin et zMax sont mises \xE0 -1. + */ + protected void updateCacheZ(){ + if(z_!=null) { + idxZMax_=0; + idxZMin_=0; + for (int i=1; i<z_.getSize(); i++) { + double val=(Double)z_.getObjectValueAt(i); + if (val>(Double)z_.getObjectValueAt(idxZMax_)) + idxZMax_=i; + else if (val<(Double)z_.getObjectValueAt(idxZMin_)) + idxZMin_=i; + } + } + else { + idxZMax_=-1; + idxZMin_=-1; + } + } + + /** + * Met \xE0 jour les valeurs curv_. + * Si curv_ ou zone_ sont null, rien n'est fait. + */ + protected void updateCacheCurv(){ + if(curv_!=null&&zone_!=null) { + CoordinateSequence seq=((GISCoordinateSequenceContainerInterface)zone_.getGeometry(idxGeom_)).getCoordinateSequence(); + curv_.clear(); + double curvPre=0; + curv_.add((double)0); + for (int i=1; i<seq.size(); i++) { + double partialCurv=Math.sqrt(Math.pow(seq.getX(i)-seq.getX(i-1), 2)+Math.pow(seq.getY(i)-seq.getY(i-1), 2)); + curvPre=curvPre+partialCurv; + curv_.add(curvPre); + } + } + } + + /** * Permet de choisir la g\xE9om\xE9trie sur lequel l'instance va travailler. * Hypoth\xE8se importante : les points de la g\xE9om\xE9tries sont correctement * ordonn\xE9s (les points sont ordonn\xE9s en ordre croissant de leur abscisse @@ -80,25 +180,10 @@ for (int i=1; i<seq.size(); i++) if (seq.getX(i-1)==seq.getX(i)&&seq.getY(i-1)==seq.getY(i)) throw new DataGeometryException(FudaaLib.getS("Au moins deux points dans le profil sont confondus.")); - // Calcul des acbscisses curvilignes => hypoth\xE8se d'ordonnancement - // correcte des points \\ - double curvPre=0; - curv_.add((double)0); - for (int i=1; i<seq.size(); i++) { - double partialCurv=Math.sqrt(Math.pow(seq.getX(i)-seq.getX(i-1), 2)+Math.pow(seq.getY(i)-seq.getY(i-1), 2)); - curvPre=curvPre+partialCurv; - curv_.add(curvPre); - } + // Calcul des acbscisses curvilignes => hypoth\xE8se d'ordonnancement correcte des points \\ + updateCacheCurv(); // Remplissage du cache Z \\ - idxZMax_=0; - idxZMin_=0; - for (int i=1; i<z_.getSize(); i++) { - double val=(Double)z_.getObjectValueAt(i); - if (val>(Double)z_.getObjectValueAt(idxZMax_)) - idxZMax_=i; - else if (val<(Double)z_.getObjectValueAt(idxZMin_)) - idxZMin_=i; - } + updateCacheZ(); // Verifie que le profil donn\xE9 ne poss\xE8de pas des axes qui se coupent entre eux \\ for(int i=1;i<seq.size();i++){ @@ -212,7 +297,7 @@ return ((Double)z_.getObjectValueAt(_idxPoint)).doubleValue(); } - public void setCurv(int _idxPoint, double _value) throws DataGeometryException { + public void setCurv(int _idxPoint, double _value, CtuluCommandContainer _cmd) throws DataGeometryException { if(curv_==null||_idxPoint<0||_idxPoint>=curv_.size()) // Si curv_!=null alors z et index_ ont des valeurs coh\xE9rentes throw new IllegalArgumentException("Cet index n'existe pas."); // Extraction des coordonn\xE9es de la g\xE9om\xE9trie pour pouvoir les modifier par la suite @@ -324,6 +409,13 @@ * abscisses curvilignes de chacun des points. * Pour y parvenir le nouveau coefficient directeur des axes est calcul\xE9 et appliqu\xE9 au rapport de * l'abcisse curviligne avec l'abscisse du point extr\xE9mit\xE9 de l'axe. + * + * Derni\xE8re petite note pour la fin, le cas dit 'simple' pr\xE9c\xE9dent + * (d\xE9placement d'un point qui n'est pas un point de rupture) n'est qu'un + * cas particulier de la r\xE9solution ci dessus (la solution de l'\xE9quation + * du second degr\xE9 serait unique). On pourrait donc l'enlever, je pense que + * s\xE9parer ces deux cas ne fait pas de mal pour une \xE9ventuelle relecture + * et/ou modification de ce code. */ // Application de la m\xE9thode d\xE9crite ci dessus \\ @@ -460,29 +552,29 @@ } } } - + CtuluCommandComposite cmd=new CtuluCommandComposite("Changement abs. curviligne"); // Enregistrement des nouvelles coordonn\xE9es \\ - zone_.setCoordinateSequence(idxGeom_, GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create(coords), null); + zone_.setCoordinateSequence(idxGeom_, GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create(coords), cmd); + // Gestion du undo/redo \\ + if(_cmd!=null) + _cmd.addCmd(new DGCommandUndoRedo(cmd, false, true)); // Notification des changements de valeurs fireDataGeometryChanged(); } - public void setZ(int _idxPoint, double _value) { + public void setZ(int _idxPoint, double _value, CtuluCommandContainer _cmd) { if (z_==null||_idxPoint<0||_idxPoint>=z_.getSize()) throw new IllegalArgumentException("Cet index n'existe pas."); - z_.setObject(_idxPoint, _value, null); + + CtuluCommandComposite cmd=new CtuluCommandComposite("Changement abs. curviligne"); + // Mise \xE0 jour du z \\ + z_.setObject(_idxPoint, _value, cmd); + // Gestion du undo/redo \\ + if(_cmd!=null) + _cmd.addCmd(new DGCommandUndoRedo(cmd, true, false)); // Mise \xE0 jour de idxZMin_ et idxZMax_ - if (_idxPoint==idxZMax_||_idxPoint==idxZMin_) { - idxZMax_=0; - idxZMin_=0; - for (int i=1; i<z_.getSize(); i++) { - double val=(Double)z_.getObjectValueAt(i); - if (val>(Double)z_.getObjectValueAt(idxZMax_)) - idxZMax_=i; - else if (val<(Double)z_.getObjectValueAt(idxZMin_)) - idxZMin_=i; - } - } + if (_idxPoint==idxZMax_||_idxPoint==idxZMin_) + updateCacheZ(); else if (_value>(Double)z_.getObjectValueAt(idxZMax_)) idxZMax_=_idxPoint; else if (_value<(Double)z_.getObjectValueAt(idxZMin_)) @@ -518,18 +610,25 @@ return (Double) z_.getObjectValueAt(idxZMin_); } - public void setValues(int _idxPoint, double _valueCurv, double _valueZ) throws DataGeometryException{ - setZ(_idxPoint, _valueZ); - setCurv(_idxPoint, _valueCurv); + public void setValues(int _idxPoint, double _valueCurv, double _valueZ, CtuluCommandContainer _cmd) throws DataGeometryException{ + CtuluCommandComposite cmd=new CtuluCommandComposite(FudaaLib.getS("D\xE9placement d'un point")); + setZ(_idxPoint, _valueZ, cmd); + setCurv(_idxPoint, _valueCurv, cmd); + if(_cmd!=null) + _cmd.addCmd(cmd.getSimplify()); } - public void remove(int _idxPoint) throws DataGeometryException { + public void remove(int _idxPoint, CtuluCommandContainer _cmd) throws DataGeometryException { if(zone_==null||z_==null||curv_==null||_idxPoint<0||_idxPoint>=curv_.size()) throw new IllegalArgumentException("Cet index n'existe pas."); if(curv_.size()==2) throw new DataGeometryException("On ne peut pas enlever un point quand il n'en reste que deux."); + CtuluCommandComposite cmd=new CtuluCommandComposite("Changement abs. curviligne"); // Suppression du point dans la zone - zone_.removeAtomics(idxGeom_, new CtuluListSelection(new int[]{_idxPoint}), null, null); + zone_.removeAtomics(idxGeom_, new CtuluListSelection(new int[]{_idxPoint}), null, cmd); + // Gestion du undo/redo \\ + if(_cmd!=null) + _cmd.addCmd(new DGCommandUndoRedo(cmd, true, true)); z_=(CtuluCollection)zone_.getValue(zone_.getIndiceOf(zone_.getAttributeIsZ()), idxGeom_); // Mise \xE0 jour des informations curvilignes \\ if (_idxPoint==0) { @@ -553,17 +652,8 @@ // Si _idxPoint est le dernier curv_.remove(curv_.size()-1); // Mise \xE0 jour de idxZMin_ et idxZMax_ - if (_idxPoint==idxZMax_||_idxPoint==idxZMin_) { - idxZMax_=0; - idxZMin_=0; - for (int i=1; i<z_.getSize(); i++) { - double val=(Double)z_.getObjectValueAt(i); - if (val>(Double)z_.getObjectValueAt(idxZMax_)) - idxZMax_=i; - else if (val<(Double)z_.getObjectValueAt(idxZMin_)) - idxZMin_=i; - } - } + if (_idxPoint==idxZMax_||_idxPoint==idxZMin_) + updateCacheZ(); fireDataGeometryChanged(); } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/MdlFille1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/MdlFille1d.java 2008-12-17 17:44:49 UTC (rev 4305) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/MdlFille1d.java 2008-12-18 10:59:27 UTC (rev 4306) @@ -14,6 +14,8 @@ import javax.swing.JComponent; import javax.swing.JSplitPane; +import org.fudaa.ctulu.CtuluCommandManager; +import org.fudaa.ctulu.CtuluUndoRedoInterface; import org.fudaa.ctulu.gui.CtuluFilleWithComponent; import org.fudaa.ebli.calque.BArbreCalque; import org.fudaa.ebli.impression.EbliFilleImprimable; @@ -22,6 +24,7 @@ import org.fudaa.fudaa.sig.FSigResource; import com.memoire.bu.BuBorderLayout; +import com.memoire.bu.BuUndoRedoInterface; /** * La fenetre interne vue 2D des donn\xE9es du modeleur. Elle construit le composant arbre de @@ -33,7 +36,7 @@ * @author Emmanuel Martin * @version $Id$ */ -public class MdlFille1d extends EbliFilleImprimable implements CtuluFilleWithComponent { +public class MdlFille1d extends EbliFilleImprimable implements BuUndoRedoInterface, CtuluFilleWithComponent, CtuluUndoRedoInterface { /** Le controller 1d */ private Controller1d controller_; @@ -104,4 +107,22 @@ public JComponent[] getSpecificTools() { return controller_.getToolsActions(); } + + public void redo() { + controller_.getCommandManager().redo(); + } + + public void undo() { + controller_.getCommandManager().undo(); + } + + public void clearCmd(CtuluCommandManager _source) { + } + + public CtuluCommandManager getCmdMng() { + return controller_.getCommandManager(); + } + + public void setActive(boolean _active) { + } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueCourbe.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueCourbe.java 2008-12-17 17:44:49 UTC (rev 4305) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueCourbe.java 2008-12-18 10:59:27 UTC (rev 4306) @@ -19,6 +19,7 @@ import javax.swing.Action; import javax.swing.JComponent; +import org.fudaa.ctulu.CtuluCommandComposite; import org.fudaa.ctulu.CtuluCommandContainer; import org.fudaa.ctulu.CtuluLib; import org.fudaa.ctulu.CtuluListSelectionInterface; @@ -47,6 +48,14 @@ * Cette vue permet la modification et le visionnage d'un profil (pr\xE9alablement * selectionn\xE9 dans la vue du bief). * + * Element important a propos de l'implementation de l'undo/redo : + * une gestion de l'undo/redo est d\xE9j\xE0 pr\xE9sente dans le framework de courbe, + * mais il n'est pas utilis\xE9 pour g\xE9rer l'undo/redo. La raison est qu'il permet + * d'annuler trop d'action (notamment l'ajout de courbe) ce qui peut provoquer + * des comportements incoh\xE9rent dans l'application. C'est pour cette raison que + * tous les undo/redo passent \xE0 la place par le gestionnaire undo/redo du + * controller1d. + * * @author Emmanuel MARTIN * @version $Id$ */ @@ -94,13 +103,18 @@ public boolean deplace(int[] idx, double _deltax, double _deltay, CtuluCommandContainer _cmd) { Arrays.sort(idx); + CtuluCommandComposite cmd=new CtuluCommandComposite(FudaaLib.getS("D\xE9placement d'un ou plusieurs points")); // Selon le sens de d\xE9placement, il faut commencer par le d\xE9but ou la fin du tableau if(_deltax<0) for(int index:idx) - setValue(index, getX(index)+_deltax, getY(index)+_deltay, _cmd); + setValue(index, getX(index)+_deltax, getY(index)+_deltay, cmd); else for(int i=idx.length-1;i>=0;i--) - setValue(idx[i], getX(idx[i])+_deltax, getY(idx[i])+_deltay, _cmd); + setValue(idx[i], getX(idx[i])+_deltax, getY(idx[i])+_deltay, cmd); + if(controller_.getCommandManager()!=null) + // Pour une explication sur l'utilisation de controller_ a la place de + // _cmd voir l'entete de la classe. + controller_.getCommandManager().addCmd(cmd.getSimplify()); return true; } @@ -169,7 +183,9 @@ public boolean removeValue(int _i, CtuluCommandContainer _cmd) { try { - data_.remove(_i); + // Pour une explication sur l'utilisation de controller_ a la place de + // _cmd voir l'entete de la classe. + data_.remove(_i, controller_.getCommandManager()); return true; } catch (DataGeometryException _exc) { @@ -193,7 +209,9 @@ public boolean setValue(int _i, double _x, double _y, CtuluCommandContainer _cmd) { controller_.clearError(); try { - data_.setValues(_i, _x, _y); + // Pour une explication sur l'utilisation de controller_ a la place de + // _cmd voir l'entete de la classe. + data_.setValues(_i, _x, _y, controller_.getCommandManager()); return true; } catch (DataGeometryException _exc) { @@ -203,8 +221,13 @@ } public boolean setValues(int[] _idx, double[] _x, double[] _y, CtuluCommandContainer _cmd) { + CtuluCommandComposite cmd=new CtuluCommandComposite(FudaaLib.getS("D\xE9placement d'un ou plusieurs points")); for(int index: _idx) - setValue(index, _x[index], _y[index], _cmd); + setValue(index, _x[index], _y[index], cmd); + if(controller_.getCommandManager()!=null) + // Pour une explication sur l'utilisation de controller_ a la place de + // _cmd voir l'entete de la classe. + controller_.getCommandManager().addCmd(cmd.getSimplify()); return true; } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueTableau.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueTableau.java 2008-12-17 17:44:49 UTC (rev 4305) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueTableau.java 2008-12-18 10:59:27 UTC (rev 4306) @@ -85,13 +85,13 @@ controller_.clearError(); if(columnIndex==0) try { - data_.setCurv(rowIndex, (Double) value); + data_.setCurv(rowIndex, (Double) value, controller_.getCommandManager()); } catch (DataGeometryException _exc) { controller_.showError(_exc.getMessage()); } else - data_.setZ(rowIndex, (Double) value); + data_.setZ(rowIndex, (Double) value, controller_.getCommandManager()); } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/testModeleur1d/TestDataGeometryAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/testModeleur1d/TestDataGeometryAdapter.java 2008-12-17 17:44:49 UTC (rev 4305) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/testModeleur1d/TestDataGeometryAdapter.java 2008-12-18 10:59:27 UTC (rev 4306) @@ -23,7 +23,7 @@ /** * Test pour DataGeometryAdapter. * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public class TestDataGeometryAdapter extends TestCase { @@ -565,46 +565,46 @@ // Cas limits geomAdapter_.setData(null, -1); try{ - geomAdapter_.setCurv(0, 0); + geomAdapter_.setCurv(0, 0, null); fail(); } catch(IllegalArgumentException _exc) {} try{ - geomAdapter_.setCurv(-1, 0); + geomAdapter_.setCurv(-1, 0, null); fail(); } catch(IllegalArgumentException _exc) {} geomAdapter_.setData(zone1_, 0); try{ - geomAdapter_.setCurv(-1, 0); + geomAdapter_.setCurv(-1, 0, null); fail(); } catch(IllegalArgumentException _exc) {} try{ - geomAdapter_.setCurv(zone1_.getGeometry(0).getNumPoints(), 0); + geomAdapter_.setCurv(zone1_.getGeometry(0).getNumPoints(), 0, null); fail(); } catch(IllegalArgumentException _exc) {} try{ - geomAdapter_.setCurv(zone1_.getGeometry(0).getNumPoints()+1, 0); + geomAdapter_.setCurv(zone1_.getGeometry(0).getNumPoints()+1, 0, null); fail(); } catch(IllegalArgumentException _exc) {} // Une abcisse curviligne peut \xEAtre donn\xE9 pour le premier point, seulement pour lui geomAdapter_.setData(zone5_, 0); try{ - geomAdapter_.setCurv(0, -1); + geomAdapter_.setCurv(0, -1, null); } catch(Exception exc){ fail(); } try{ - geomAdapter_.setCurv(1, -1); + geomAdapter_.setCurv(1, -1, null); fail(); } catch(DataGeometryException exc){} try{ - geomAdapter_.setCurv(geomAdapter_.getNbPoint()-1, -1); + geomAdapter_.setCurv(geomAdapter_.getNbPoint()-1, -1, null); fail(); } catch(DataGeometryException exc){} @@ -612,29 +612,29 @@ // Test sur le d\xE9placement d'un point au del\xE0 d'un autre ou au niveau d'un autre geomAdapter_.setData(zone5_, 0); try{ - geomAdapter_.setCurv(0, Math.sqrt(10*10+5*5)+1); + geomAdapter_.setCurv(0, Math.sqrt(10*10+5*5)+1, null); fail(); } catch(DataGeometryException exc){} try{ - geomAdapter_.setCurv(1, 0); + geomAdapter_.setCurv(1, 0, null); fail(); } catch(DataGeometryException exc){} geomAdapter_.setData(zone5_, 6); try{ - geomAdapter_.setCurv(2, geomAdapter_.getCurv(1)-0.1); + geomAdapter_.setCurv(2, geomAdapter_.getCurv(1)-0.1, null); fail(); } catch(DataGeometryException exc){} geomAdapter_.setData(zone5_, 11); try{ // Tentative de se placer sur un point de rupture - geomAdapter_.setCurv(3, geomAdapter_.getCurv(2)); + geomAdapter_.setCurv(3, geomAdapter_.getCurv(2), null); fail(); } catch(DataGeometryException exc){} try{ // Tentative d'un point de rupture de d\xE9pacer un point adjacent - geomAdapter_.setCurv(2, geomAdapter_.getCurv(3)+1); + geomAdapter_.setCurv(2, geomAdapter_.getCurv(3)+1, null); fail(); } catch(DataGeometryException exc){} @@ -643,7 +643,7 @@ // Cas g\xE9n\xE9ral, d\xE9placement d\xE9but geomAdapter_.setData(zone5_, 0); double curvOld=geomAdapter_.getCurv(1); - geomAdapter_.setCurv(0, Math.sqrt(5*5+2.5*2.5)); + geomAdapter_.setCurv(0, Math.sqrt(5*5+2.5*2.5), null); assertEquals(curvOld-Math.sqrt(5*5+2.5*2.5), geomAdapter_.getCurv(1), tolerance); assertEquals(5, zone5_.getGeometry(0).getCoordinates()[0].x, tolerance); assertEquals(2.5, zone5_.getGeometry(0).getCoordinates()[0].y, tolerance); @@ -651,7 +651,7 @@ // Cas g\xE9n\xE9ral, d\xE9placement fin avec point de ruptures geomAdapter_.setData(zone5_, 16); curvOld=geomAdapter_.getCurv(9); - geomAdapter_.setCurv(9, geomAdapter_.getCurv(8)+Math.sqrt((10/4.-10/16.)*(10/4.-10/16.)+(-5/4.+5/16.)*(-5/4.+5/16.))); + geomAdapter_.setCurv(9, geomAdapter_.getCurv(8)+Math.sqrt((10/4.-10/16.)*(10/4.-10/16.)+(-5/4.+5/16.)*(-5/4.+5/16.)), null); assertEquals(geomAdapter_.getCurv(8)+Math.sqrt((10/4.-10/16.)*(10/4.-10/16.)+(-5/4.+5/16.)*(-5/4.+5/16.)), geomAdapter_.getCurv(9), tolerance); assertEquals(10/16., zone5_.getGeometry(16).getCoordinates()[9].x, tolerance); assertEquals(-5/16., zone5_.getGeometry(16).getCoordinates()[9].y, tolerance); @@ -659,7 +659,7 @@ // Cas particulier parall\xE8le \xE0 l'axe des x geomAdapter_.setData(zone5_, 1); curvOld=geomAdapter_.getCurv(1); - geomAdapter_.setCurv(0, -5); + geomAdapter_.setCurv(0, -5, null); assertEquals(curvOld+5, geomAdapter_.getCurv(1), tolerance); assertEquals(0, zone5_.getGeometry(1).getCoordinates()[0].x, tolerance); assertEquals(10, zone5_.getGeometry(1).getCoordinates()[0].y, tolerance); @@ -667,7 +667,7 @@ // Cas particulier parall\xE8le \xE0 l'axe des y geomAdapter_.setData(zone5_, 8); curvOld=geomAdapter_.getCurv(2); - geomAdapter_.setCurv(0, -5); + geomAdapter_.setCurv(0, -5, null); assertEquals(curvOld+5, geomAdapter_.getCurv(2), tolerance); assertEquals(-9.1, zone5_.getGeometry(8).getCoordinates()[0].x, tolerance); assertEquals(93, zone5_.getGeometry(8).getCoordinates()[0].y, tolerance); @@ -677,7 +677,7 @@ geomAdapter_.setData(zone5_, 4); curvOld=geomAdapter_.getCurv(1); double curvOld2=geomAdapter_.getCurv(2); - geomAdapter_.setCurv(1, geomAdapter_.getCurv(1)-5); + geomAdapter_.setCurv(1, geomAdapter_.getCurv(1)-5, null); assertEquals(curvOld-5, geomAdapter_.getCurv(1), tolerance); assertEquals(curvOld2, geomAdapter_.getCurv(2), tolerance); assertEquals(15, zone5_.getGeometry(4).getCoordinates()[1].x, tolerance); @@ -687,7 +687,7 @@ geomAdapter_.setData(zone5_, 15); curvOld=geomAdapter_.getCurv(3); curvOld2=geomAdapter_.getCurv(1); - geomAdapter_.setCurv(3, geomAdapter_.getCurv(3)-2); + geomAdapter_.setCurv(3, geomAdapter_.getCurv(3)-2, null); assertEquals(curvOld-2, geomAdapter_.getCurv(3), tolerance); assertEquals(curvOld2, geomAdapter_.getCurv(1), tolerance); assertEquals(10, zone5_.getGeometry(15).getCoordinates()[3].x, tolerance); @@ -700,7 +700,7 @@ double[] absCurv=new double[6]; for(int i=0;i<6;i++) absCurv[i]=geomAdapter_.getCurv(i); - geomAdapter_.setCurv(2,geomAdapter_.getCurv(2)-2); + geomAdapter_.setCurv(2,geomAdapter_.getCurv(2)-2, null); absCurv[2]=absCurv[2]-2; // R\xE9instancier un nouvel adapter va verifier si il n'y a pas de nouveaux points de ruptures qui sont apparux ou qu'il y ai pas des axes qui se croisent DataGeometryAdapter testAdapter=null; @@ -717,7 +717,7 @@ setUp(); // Test sur les coordonn\xE9es g\xE9n\xE9r\xE9es geomAdapter_.setData(zone1_, 0); - geomAdapter_.setCurv(1, 5); + geomAdapter_.setCurv(1, 5, null); assertEquals(5.0, geomAdapter_.getCurv(1), tolerance); Coordinate p=((GISPolyligne)zone1_.getGeometry(0)).getCoordinateSequence().getCoordinate(1); assertEquals(3.1013705223595296, p.x, tolerance); @@ -726,24 +726,24 @@ public void testSetZ() throws IllegalArgumentException, DataGeometryException { geomAdapter_.setData(zone0_, 0); - geomAdapter_.setZ(0, 20); + geomAdapter_.setZ(0, 20, null); assertEquals(20, geomAdapter_.getZ(0), tolerance); - geomAdapter_.setZ(2, -2); + geomAdapter_.setZ(2, -2, null); assertEquals(-2, geomAdapter_.getZ(2), tolerance); // Cas limits try{ - geomAdapter_.setZ(-11, -2); + geomAdapter_.setZ(-11, -2, null); fail(); }catch(IllegalArgumentException _exc){} try { - geomAdapter_.setZ(1000, -2); + geomAdapter_.setZ(1000, -2, null); fail(); } catch (IllegalArgumentException _exc){} // Cas limits geomAdapter_.setData(null, -1); try { - geomAdapter_.setZ(0, 10); + geomAdapter_.setZ(0, 10, null); fail(); } catch(IllegalArgumentException _exc){} @@ -768,9 +768,9 @@ assertEquals(10, geomAdapter_.getZMax(), tolerance); geomAdapter_.setData(zone1_, 0); assertEquals(0, geomAdapter_.getZMax(), tolerance); - geomAdapter_.setZ(0, 20); + geomAdapter_.setZ(0, 20, null); assertEquals(20, geomAdapter_.getZMax(), tolerance); - geomAdapter_.setZ(0, -5); + geomAdapter_.setZ(0, -5, null); assertEquals(0, geomAdapter_.getZMax(), tolerance); } @@ -779,9 +779,9 @@ assertEquals(-20, geomAdapter_.getZMin(), tolerance); geomAdapter_.setData(zone1_, 0); assertEquals(0, geomAdapter_.getZMin(), tolerance); - geomAdapter_.setZ(0, -20); + geomAdapter_.setZ(0, -20, null); assertEquals(-20, geomAdapter_.getZMin(), tolerance); - geomAdapter_.setZ(0, 10); + geomAdapter_.setZ(0, 10, null); assertEquals(0, geomAdapter_.getZMin(), tolerance); } @@ -791,7 +791,7 @@ double[] absCurv=new double[6]; for(int i=0;i<6;i++) absCurv[i]=geomAdapter_.getCurv(i); - geomAdapter_.setValues(2,geomAdapter_.getCurv(2)-2, 60); + geomAdapter_.setValues(2,geomAdapter_.getCurv(2)-2, 60, null); assertEquals(60, geomAdapter_.getZ(2), tolerance); absCurv[2]=absCurv[2]-2; // R\xE9instancier un nouvel adapter va verifier si il n'y a pas de nouveaux points de ruptures qui sont apparux ou qu'il y ai pas des axes qui se croisent @@ -811,14 +811,14 @@ public void testRemove() throws IllegalArgumentException, DataGeometryException { // Un cas g\xE9n\xE9ral geomAdapter_.setData(zone0_, 0); - geomAdapter_.remove(0); + geomAdapter_.remove(0, null); assertEquals(2, geomAdapter_.getNbPoint()); assertEquals(-20, geomAdapter_.getZ(0), tolerance); assertEquals(0, geomAdapter_.getCurv(0), tolerance); assertEquals(Math.sqrt((50+10)*(50+10)+(10+20)*(10+20)), geomAdapter_.getCurv(1), tolerance); // On ne peut pas descendre en dessous de 2 points try { - geomAdapter_.remove(0); + geomAdapter_.remove(0, null); fail(); } catch(DataGeometryException _exc){ @@ -827,15 +827,15 @@ // Cas limits geomAdapter_.setData(null, -1); try { - geomAdapter_.remove(0); + geomAdapter_.remove(0, null); fail(); } catch(IllegalArgumentException _exc){} // Un cas g\xE9n\xE9ral geomAdapter_.setData(zone3_, 1); - geomAdapter_.remove(4); - geomAdapter_.remove(2); - geomAdapter_.remove(1); + geomAdapter_.remove(4, null); + geomAdapter_.remove(2, null); + geomAdapter_.remove(1, null); assertEquals(2, geomAdapter_.getNbPoint()); assertEquals(0, geomAdapter_.getZ(0), tolerance); assertEquals(0, geomAdapter_.getCurv(0), tolerance); @@ -861,13 +861,13 @@ assertTrue(listener.callNewGeom); listener.callNewGeom=false; // Test dataGeometryChanged - geomAdapter_.setZ(0, 10); + geomAdapter_.setZ(0, 10, null); assertTrue(listener.callChanged); listener.callChanged=false; - geomAdapter_.setCurv(1, (geomAdapter_.getCurv(2)-geomAdapter_.getCurv(0))/2); + geomAdapter_.setCurv(1, (geomAdapter_.getCurv(2)-geomAdapter_.getCurv(0))/2, null); assertTrue(listener.callChanged); listener.callChanged=false; - geomAdapter_.setValues(0, 0, 20); + geomAdapter_.setValues(0, 0, 20, null); assertTrue(listener.callChanged); listener.callChanged=false; try { @@ -896,13 +896,13 @@ assertFalse(listener.callNewGeom); listener.callNewGeom=false; // Test dataGeometryChanged - geomAdapter_.setZ(0, 10); + geomAdapter_.setZ(0, 10, null); assertFalse(listener.callChanged); listener.callChanged=false; - geomAdapter_.setCurv(1, (geomAdapter_.getCurv(2)-geomAdapter_.getCurv(0))/2); + geomAdapter_.setCurv(1, (geomAdapter_.getCurv(2)-geomAdapter_.getCurv(0))/2, null); assertFalse(listener.callChanged); listener.callChanged=false; - geomAdapter_.setValues(0, 0, 20); + geomAdapter_.setValues(0, 0, 20, null); assertFalse(listener.callChanged); listener.callChanged=false; try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <emm...@us...> - 2008-12-17 17:44:56
|
Revision: 4305 http://fudaa.svn.sourceforge.net/fudaa/?rev=4305&view=rev Author: emmanuel_martin Date: 2008-12-17 17:44:49 +0000 (Wed, 17 Dec 2008) Log Message: ----------- modeleur1d : tous les points d'un profil sont d?\195?\169pla?\195?\167ables. Test unitaire couvrant DataGeometryAdapter. quelques autres modifications mineures. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/Controller1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometry.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueCourbe.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueTableau.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/testModeleur1d/ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/testModeleur1d/TestDataGeometryAdapter.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/Controller1d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/Controller1d.java 2008-12-15 16:28:55 UTC (rev 4304) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/Controller1d.java 2008-12-17 17:44:49 UTC (rev 4305) @@ -69,20 +69,27 @@ private EbliFormatterInterface formater_=new EbliFormatter(); public Controller1d(MdlImplementation _appli, MdlFille1d _frame1d){ + if(_appli==null||_frame1d==null) + throw new IllegalArgumentException("Les param\xE8tres ne doivent pas \xEAtre null."); appli_=_appli; frame1d_=_frame1d; frame1d_.addInternalFrameListener(this); vueBief_=new VueBief(appli_, this); vueBief_.getScene().addSelectionListener(this); treeModel_=vueBief_.getArbreCalqueModel(); - dataGeomAdapter_=new DataGeometryAdapter(this, null, -1); + try { + dataGeomAdapter_=new DataGeometryAdapter(null, -1); + } + catch (DataGeometryException _exc) { + _exc.printStackTrace(); + } vueTableau_=new VueTableau(this, dataGeomAdapter_); vueTableau_.addSelectionListener(this); vueCourbe_=new VueCourbe(this, dataGeomAdapter_); vueCourbe_.addSelectionListener(this); vueError_=new BuLabel(); vueError_.setForeground(Color.RED); - vueError_.setText(""); + clearError(); } public VueBief getVueBief(){ @@ -105,11 +112,13 @@ // Gestion de l'affichage des erreurs. \\ public void showError(String _message){ + if(_message==null||_message.length()==0) + clearError(); vueError_.setText(_message); } public void clearError(){ - vueError_.setText(null); + vueError_.setText(" "); } // Gestion de l'arbre \\ @@ -184,8 +193,8 @@ int sceneIdSelected=scene.getSelectionHelper().getUniqueSelectedIdx(); boolean ok=true; // Indique si tout s'est bien pass\xE9. if (sceneIdSelected==-1) - // Aucune selection - dataGeomAdapter_.setData(null, -1); + try {dataGeomAdapter_.setData(null, -1);} + catch (DataGeometryException _exc) {_exc.printStackTrace();} else { int idSelected=scene.sceneId2LayerId(sceneIdSelected); // Extraction des diff\xE9rentes informations n\xE9c\xE9ssaires au changement de @@ -198,8 +207,8 @@ try { dataGeomAdapter_.setData(zone, idSelected); } - catch (IllegalArgumentException _exp) { - showError(_exp.getMessage()); + catch (DataGeometryException _exc) { + showError(_exc.getMessage()); } } else Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometry.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometry.java 2008-12-15 16:28:55 UTC (rev 4304) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometry.java 2008-12-17 17:44:49 UTC (rev 4305) @@ -12,7 +12,7 @@ * widgets tableau et courbe. * * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public interface DataGeometry { @@ -43,15 +43,24 @@ /** Retourne la valeur minimal de z. */ public double getZMin(); - /** Enregistre l'abcisse curviligne du point indiqu\xE9 en param\xE8tre. */ - public void setCurv(int _idxPoint, double _value); + /** + * Enregistre l'abcisse curviligne du point indiqu\xE9 en param\xE8tre. + * Ce changement d'abscisse curviligne fonctionne sur tout les points. + * Si un points extr\xE9mit\xE9 est chang\xE9, le point 2D est d\xE9plac\xE9 sur son axe, + * la longueur globale n'est pas concerv\xE9e dans l'op\xE9ration. + * Si c'est un point de rupture le point 2D est d\xE9plac\xE9 de telle mani\xE8re + * que la longueur globale soit concerv\xE9e. + * Pour les autres points, le point 2D est d\xE9plac\xE9 sur son axe en concervant + * la longeur globale. + */ + public void setCurv(int _idxPoint, double _value) throws DataGeometryException; /** Enregistre la valeur de z du point indiqu\xE9 en param\xE8tre. */ public void setZ(int _idxPoint, double _value); /** Enregistre l'abcisse curviligne et la valeur de z du point indiqu\xE9 en param\xE8tre. */ - public void setValues(int _idxPoint, double _valueCurv, double _valueZ); + public void setValues(int _idxPoint, double _valueCurv, double _valueZ) throws DataGeometryException; /** Supprime le point indiqu\xE9 en param\xE8tre. */ - public void remove(int _idxPoint); + public void remove(int _idxPoint) throws DataGeometryException; } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryAdapter.java 2008-12-15 16:28:55 UTC (rev 4304) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryAdapter.java 2008-12-17 17:44:49 UTC (rev 4305) @@ -10,15 +10,18 @@ import java.util.ArrayList; import java.util.List; +import org.fudaa.ctulu.CtuluListSelection; import org.fudaa.ctulu.collection.CtuluCollection; import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; import org.fudaa.ctulu.gis.GISGeometryFactory; +import org.fudaa.ctulu.gis.GISPolyligne; import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; import org.fudaa.fudaa.commun.FudaaLib; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.Geometry; /** * Cette classe permet d'adapter une GISZoneCollection en un model manipulable @@ -28,9 +31,8 @@ * @author Emmanuel MARTIN * @version $Id$ */ -class DataGeometryAdapter implements DataGeometry { - /** Le controller, pour afficher des messages d'erreur. */ - private Controller1d controller_; +public class DataGeometryAdapter implements DataGeometry { + private GISZoneCollectionLigneBrisee zone_; private int idxGeom_; private CtuluCollection z_; @@ -43,10 +45,7 @@ int idxRupture1_; int idxRupture2_; - public DataGeometryAdapter(Controller1d _controller, GISZoneCollectionLigneBrisee _zone, int _idxGeom) throws IllegalArgumentException { - if(_controller==null) - throw new IllegalArgumentException("Controller1d ne doit pas \xEAtre null."); - controller_=_controller; + public DataGeometryAdapter(GISZoneCollectionLigneBrisee _zone, int _idxGeom) throws IllegalArgumentException, DataGeometryException { setData(_zone, _idxGeom); } @@ -58,8 +57,9 @@ * * @param _zone la zone contenant la g\xE9om\xE9trie * @param _idxGeom l'indice de la g\xE9om\xE9trie dans _zone + * @throws DataGeometryException */ - public void setData(GISZoneCollectionLigneBrisee _zone, int _idxGeom) throws IllegalArgumentException { + public void setData(GISZoneCollectionLigneBrisee _zone, int _idxGeom) throws IllegalArgumentException, DataGeometryException { if (_zone==null&&_idxGeom==-1) { zone_=null; idxGeom_=-1; @@ -75,11 +75,11 @@ CoordinateSequence seq=((GISCoordinateSequenceContainerInterface)zone_.getGeometry(idxGeom_)).getCoordinateSequence(); // Verifie qu'on a bien au minimum deux points. \\ if (seq.size()<2) - throw new IllegalArgumentException(FudaaLib.getS("Le profil doit avoir au minimum deux points.")); + throw new DataGeometryException(FudaaLib.getS("Le profil doit avoir au minimum deux points.")); // Verifie que deux points cons\xE9cutifs ne sont pas confondus. \\ for (int i=1; i<seq.size(); i++) if (seq.getX(i-1)==seq.getX(i)&&seq.getY(i-1)==seq.getY(i)) - throw new IllegalArgumentException(FudaaLib.getS("Au moins deux points dans le profil sont confondus.")); + throw new DataGeometryException(FudaaLib.getS("Au moins deux points dans le profil sont confondus.")); // Calcul des acbscisses curvilignes => hypoth\xE8se d'ordonnancement // correcte des points \\ double curvPre=0; @@ -99,6 +99,23 @@ else if (val<(Double)z_.getObjectValueAt(idxZMin_)) idxZMin_=i; } + + // Verifie que le profil donn\xE9 ne poss\xE8de pas des axes qui se coupent entre eux \\ + for(int i=1;i<seq.size();i++){ + Geometry mainAxe=GISGeometryFactory.INSTANCE.createLineString(new Coordinate[]{seq.getCoordinate(i-1), seq.getCoordinate(i)}); + boolean ok=true; + // Un seul point d'intersection avec l'axe qui suit + if(i+1<seq.size()&&mainAxe.intersection(GISGeometryFactory.INSTANCE.createLineString(new Coordinate[]{seq.getCoordinate(i), seq.getCoordinate(i+1)})).getNumPoints()>1) + ok=false; + // Aucun point d'intersectin avec les axes qui suivent + int j=i; + while(ok&&++j+1<seq.size()) + ok=!mainAxe.intersects(GISGeometryFactory.INSTANCE.createLineString(new Coordinate[]{seq.getCoordinate(j), seq.getCoordinate(j+1)})); + // Traitement d'une \xE9ventuelle intersection + if(!ok) + throw new DataGeometryException(FudaaLib.getS("Le profil se coupe lui m\xEAme. Il n'est donc pas valide.")); + } + // / D\xE9termination des points de ruptures et verification qu'il y en a // au maximun deux. \\\ idxRupture1_=-1; @@ -144,14 +161,14 @@ else if (idxRupture2_==-1) idxRupture2_=idx-1; else - throw new IllegalArgumentException(FudaaLib.getS("Il y a plus que deux ruptures dans le profil.")); + throw new DataGeometryException(FudaaLib.getS("Il y a plus que deux ruptures dans le profil.")); } // Pr\xE9paration de l'it\xE9ration suivante coefDirecteur=newCoefDirecteur; coefDirX=newCoefDirX; } } - catch(IllegalArgumentException _exp) { + catch(DataGeometryException _exp) { // Remise dans un \xE9tat coh\xE9rent zone_=null; idxGeom_=-1; @@ -184,105 +201,293 @@ } public double getCurv(int _idxPoint) { - if(curv_==null) - return 0; - else - return curv_.get(_idxPoint); + if(curv_==null||_idxPoint<0||_idxPoint>=curv_.size()) + throw new IllegalArgumentException("Cet index n'existe pas."); + return curv_.get(_idxPoint); } public double getZ(int _idxPoint) { - if (z_==null) - return 0; - else - return ((Double)z_.getObjectValueAt(_idxPoint)).doubleValue(); + if (z_==null||_idxPoint<0||_idxPoint>=z_.getSize()) + throw new IllegalArgumentException("Cet index n'existe pas."); + return ((Double)z_.getObjectValueAt(_idxPoint)).doubleValue(); } - - public void setCurv(int _idxPoint, double _value) { - controller_.clearError(); - if(curv_==null) - return; + + public void setCurv(int _idxPoint, double _value) throws DataGeometryException { + if(curv_==null||_idxPoint<0||_idxPoint>=curv_.size()) // Si curv_!=null alors z et index_ ont des valeurs coh\xE9rentes + throw new IllegalArgumentException("Cet index n'existe pas."); + // Extraction des coordonn\xE9es de la g\xE9om\xE9trie pour pouvoir les modifier par la suite CoordinateSequence seq=((GISCoordinateSequenceContainerInterface)zone_.getGeometry(idxGeom_)).getCoordinateSequence(); Coordinate[] coords=seq.toCoordinateArray(); - if(_idxPoint==0||_idxPoint==seq.size()-1){ - controller_.showError(FudaaLib.getS("Le changement d'abscisse curviligne des extr\xE9mit\xE9s n'est pas g\xE9r\xE9 pour l'instant.")); - return; + // Les nouvelles valeurs du points \xE0 d\xE9placer + double newX; + double newY; + // Delta pour savoir si des doubles sont \xE9gaux + double tolerance=0.000001; + + // Verifie que le point reste encadr\xE9 par le(s) m\xEAme(s) point(s) + if((_idxPoint==0&&_value>=curv_.get(1))||(_idxPoint==seq.size()-1&&_value<=curv_.get(seq.size()-2))||(_idxPoint!=0&&_idxPoint!=seq.size()-1&&(_value<=curv_.get(_idxPoint-1)||_value>=curv_.get(_idxPoint+1)))) + throw new DataGeometryException(FudaaLib.getS("Il est interdit de d\xE9placer un point au dela des points l'encadrant.")); + + // Cas o\xF9 l'index n'est pas sur un point de rupture \\ + if (_idxPoint!=idxRupture1_&&_idxPoint!=idxRupture2_) { + // Le point reste encadr\xE9 par les deux m\xEAme points => le signe de xa-xb et + // de ya-yb ne change pas + // D\xE9termination des deux index \xE0 utiliser + int idx1; + int idx2; + double valCurv; + if (_idxPoint>0) { // Le premier point n'est pas selectionn\xE9 + idx1=_idxPoint-1; + idx2=_idxPoint; + valCurv=_value-curv_.get(idx1); + } + else { + idx1=_idxPoint+1; + idx2=_idxPoint; + valCurv=Math.abs(_value-curv_.get(idx1)); + } + // Calcul des nouvelles coordonn\xE9es + if (Math.abs(seq.getX(idx2)-seq.getX(idx1))>tolerance) { + // Extraction du signe de xa-xb + double sign=Math.signum(seq.getX(idx2)-seq.getX(idx1)); + double coefDirecteur=(seq.getY(idx2)-seq.getY(idx1))/(seq.getX(idx2)-seq.getX(idx1)); + newX=seq.getX(idx1)+sign*valCurv/Math.sqrt(1+coefDirecteur*coefDirecteur); + newY=seq.getY(idx1)+coefDirecteur*(newX-seq.getX(idx1)); + } + else { // Cas du bout de profil vertical + // Extraction du signe de ya-yb + double sign=Math.signum(seq.getY(idx2)-seq.getY(idx1)); + newX=seq.getX(idx1); + newY=seq.getY(idx1)+sign*valCurv; + } + coords[_idxPoint].x=newX; + coords[_idxPoint].y=newY; + // Mise a jour de la table des valeurs curvilignes + if (_idxPoint==0) + for (int i=1; i<curv_.size(); i++) + curv_.set(i, curv_.get(i)-_value); + else + curv_.set(_idxPoint, _value); } - if(_value<0) - return; - // Cas o\xF9 l'index n'est pas sur un point de rupture \\ - if(_idxPoint!=idxRupture1_&&_idxPoint!=idxRupture2_){ - // Cas o\xF9 le point reste encadr\xE9 par les deux m\xEAme points (noralement toujours le cas) => le signe de xa-xb et de ya-yb ne change pas - if((_idxPoint==0||_value>curv_.get(_idxPoint-1))&&(_idxPoint==curv_.size()-1||_value<curv_.get(_idxPoint+1))){ - // D\xE9termination des deux index \xE0 utiliser - int idx1; - int idx2; - double valCurv; - if(_idxPoint>0){ // On a pas selectionn\xE9 le premier point - idx1=_idxPoint-1; - idx2=_idxPoint; - valCurv=_value-curv_.get(idx1); + + // Cas complexe : l'index est sur un point de rupture \\ + else { + /* + * Abstract : + * Pour trouver le point restectant la concervation de labcisse curviligne, est + * utilis\xE9 par la suite une m\xE9thode d'intersection de deux cercles. + * - Soient A, B, C, trois points non confondus. Soit la polyligne A, C, B. + * On veut construire C' tq cruv(C')=c et que curv(B) reste constant. + * Donc : + * dist(AC)+dist(CB)=dist(AC')+dist(C'B) + * Ce probl\xE8me peut se r\xE9duire \xE0 la recherche de l'intersection de deux cercles : + * C1=cercle(centre=A, rayon=c-curv(A)) avec C2=cercle(centre=B, rayon=curv(B)-c) + * + * Cas 1 : ya-yb != 0: + * La r\xE9solution de ce probl\xE8me donne l'\xE9quation : + * x\xB2[M\xB2+1] + x[2yaM-2NM-2xa] + xa\xB2+ya\xB2+N\xB2-rayonC1\xB2-2yaN=0 + * avec N=(rayonC2\xB2-rayonC1\xB2-xb\xB2+xa\xB2-yb\xB2+ya\xB2)/(2(ya-yb)) + * et M=(xa-xb)/(ya-yb) + * C'est une \xE9quation du second degr\xE9. + * Pour la r\xE9solution de l'\xE9quation, nous nommerons : + * equA=[M\xB2+1] + * equB=[2yaM-2NM-2xa] + * equC=xa\xB2+ya\xB2+N\xB2-rayonC1\xB2-2yaN + * La r\xE9solution de l'\xE9quation r\xE9sultante donne deux solutions (c1' et c2'). + * Pour trouver celle qui nous interesse (si elle existe) la contrainte suivante doit \xEAtre v\xE9rifi\xE9e : + * vecteurNorm\xE9(C, Proj(C, AB)) = vecteurNorm\xE9(CX', Proj(CX', AB)) + * A noter que Proj(C1', AB)=Proj(C2', AB) de plus pour simplifier cette r\xE9solution sera faite sur z=0. + * + * Cas 2 : ya-yb = 0 et xa-xb != 0: + * La r\xE9solution de ce prol\xE8me donne l'\xE9quation : + * y\xB2-2yay+xa+K\xB2-2xaK-rayonC1\xB2=0 + * avec K=(rayonC2\xB2-rayonC1\xB2-xb\xB2+xa\xB2)/(2*(xa-xb)) + * # k est \xE9galement la valeur de x des deux solutions potentielles + * C'est un \xE9quation du second degr\xE9. + * Pour la r\xE9solution de l'aquation, nous nommerons : + * equA=1 + * equB=2ya + * equC=K\xB2-2xaK-rayonC1\xB2 + * La r\xE9solution de l'\xE9quation r\xE9sultante donne deux solutions (c1' et c2'). + * Pour trouver celle qui nous interesse (si elle existe) la contrainte suivante doit \xEAtre v\xE9rifi\xE9e : + * vecteurNorm\xE9(C, Proj(C, AB)) = vecteurNorm\xE9(CX', Proj(CX', AB)) + * A noter que Proj(C1', AB)=Proj(C2', AB) de plus pour simplifier cette r\xE9solution sera faite sur z=0. + * + * Cas 3 : ya-yb = 0 et xa-xb=0: + * quel qu'en soit le r\xE9sultat, c'est incoh\xE9rent pour notre contexte. + * + * De plus on verifie que le r\xE9sultat ne provoque pas de croisement avec les autres axes + * du profil. + * + * Une fois ce point trouv\xE9, on va \xE9galement d\xE9placer tous les points des deux axes adjacents, + * pour que le profil concerve sa forme g\xE9n\xE9rale. Ce r\xE9aligement se faire en concervant les + * abscisses curvilignes de chacun des points. + * Pour y parvenir le nouveau coefficient directeur des axes est calcul\xE9 et appliqu\xE9 au rapport de + * l'abcisse curviligne avec l'abscisse du point extr\xE9mit\xE9 de l'axe. + */ + + // Application de la m\xE9thode d\xE9crite ci dessus \\ + + // Valuation des variables d'entr\xE9es n\xE9c\xE9ssaires + final int idxPtdeb=_idxPoint==idxRupture1_?0:idxRupture1_; + final int idxPtFin=_idxPoint==idxRupture2_||idxRupture2_==-1?seq.size()-1:idxRupture2_; + final Coordinate a=seq.getCoordinate(idxPtdeb); + final Coordinate b=seq.getCoordinate(idxPtFin); + final Coordinate c=seq.getCoordinate(_idxPoint); + final double rayonC1=_value-curv_.get(idxPtdeb); + final double rayonC2=curv_.get(idxPtFin)-_value; + // Solutions + double x1; + double y1; + double x2; + double y2; + // Cas 1 + if(Math.abs(a.y-b.y)>tolerance){ + // Variables interm\xE9diaires + double n=(rayonC2*rayonC2-rayonC1*rayonC1-b.x*b.x+a.x*a.x-b.y*b.y+a.y*a.y)/(2*(a.y-b.y)); + double m=(a.x-b.x)/(a.y-b.y); + double equA=m*m+1; + double equB=2*(a.y*m-n*m-a.x); + double equC=a.x*a.x+a.y*a.y+n*n-rayonC1*rayonC1-2*a.y*n; + // Variables de r\xE9solution + double deltaTmp=equB*equB-4*equA*equC; + if(deltaTmp<0) + throw new DataGeometryException(FudaaLib.getS("Ce d\xE9placement n'est pas possible sans violer la contrainte de constance de la longueur du profil.")); + double delta=Math.sqrt(equB*equB-4*equA*equC); + x1=(-equB+delta)/(2*equA); + y1=n-x1*m; + x2=(-equB-delta)/(2*equA); + y2=n-x2*m; + } + // Cas 2 + else if(Math.abs(a.x-b.x)>tolerance){ + // Variables interm\xE9diaires + double k=(rayonC2*rayonC2-rayonC1*rayonC1-b.x*b.x+a.x*a.x)/(2*(a.x-b.x)); + double equA=1; + double equB=2*a.y; + double equC=k*k-2*a.x*k-rayonC1*rayonC1; + // Variables de r\xE9solution + double deltaTmp=equB*equB-4*equA*equC; + if(deltaTmp<0) + throw new DataGeometryException(FudaaLib.getS("Ce d\xE9placement n'est pas possible sans violer la contrainte de constance de la longueur du profil.")); + double delta=Math.sqrt(equB*equB-4*equA*equC); + y1=(-equB+delta)/(2*equA); + x1=k; + y2=(-equB-delta)/(2*equA); + x2=k; + } + // Cas 3 + else + throw new DataGeometryException(FudaaLib.getS("Ce d\xE9placement n'est pas valide. Ce cas ne devrait jamais arriver. CSI_1")); + // Recherche du r\xE9sultat nous interessant dans ce cas ci + Coordinate aZ0=new Coordinate(a.x, a.y, 0); + Coordinate bZ0=new Coordinate(b.x, b.y, 0); + Coordinate cZ0=new Coordinate(c.x, c.y, 0); + Coordinate vecReference=vec(cZ0, proj(cZ0, aZ0, bZ0)); + Coordinate cProj=proj(new Coordinate(x1, y1, 0), aZ0, bZ0); + assert(egal(cProj, proj(new Coordinate(x2, y2, 0), aZ0, bZ0), 0.0001, false)); + if(egal(vecReference, vec(new Coordinate(x1, y1, 0), cProj), 0.0001, true)){ + newX=x1; + newY=y1; + } + else if(egal(vecReference, vec(new Coordinate(x2, y2, 0), cProj), 0.0001, true)) { + newX=x2; + newY=y2; + } + else + throw new DataGeometryException(FudaaLib.getS("Ce d\xE9placement n'est pas valide. Ce cas ne devrait jamais arriver. CSI_2")); + + // Verifie que le point trouv\xE9 ne coupe pas un autre axe du profil \\ + boolean noCut=true; + Coordinate newP=new Coordinate(newX, newY); + GISPolyligne axe1=GISGeometryFactory.INSTANCE.createLineString(new Coordinate[]{a, newP}); + GISPolyligne axe2=GISGeometryFactory.INSTANCE.createLineString(new Coordinate[]{newP, b}); + if(idxPtdeb>0) { + /* + * Test de croisement entre les deux axes modifi\xE9s et l'axe avant. l'axe + * a, newP a normalement un point d'intersectino (a). + */ + GISPolyligne axeTest=GISGeometryFactory.INSTANCE.createLineString(new Coordinate[]{coords[0], coords[idxPtdeb]}); + noCut=axe1.intersection(axeTest).getNumPoints()==1; + noCut=noCut&&!axe2.intersects(axeTest); + } + if(idxPtFin<seq.size()-1) { + /* + * Test de croisement entre les deux axes modifi\xE9s et l'axe avant. l'axe + * newP, b a normalement un point d'intersectino (b). + */ + GISPolyligne axeTest=GISGeometryFactory.INSTANCE.createLineString(new Coordinate[]{coords[idxPtFin], coords[coords.length-1]}); + noCut=noCut&&axe2.intersection(axeTest).getNumPoints()==1; + noCut=noCut&&!axe1.intersects(axeTest); + } + // Traitement de l'\xE9ventuelle d\xE9tection d'un croisement + if(!noCut) + throw new DataGeometryException(FudaaLib.getS("Ce d\xE9placement est impossible sans obtenir un profil dont des axes se coupent.")); + // Enregistrement du nouveau point C' et de la nouvelle valeur curviligne + coords[_idxPoint].x=newX; + coords[_idxPoint].y=newY; + // Mise a jour de la table des valeurs curvilignes + curv_.set(_idxPoint, _value); + + // R\xE9alignement des points des axes adjacents \\ + for(int inc=0;inc<2;inc++){ + // D\xE9termination des points de d\xE9but et de fin d'axe + int idxDeb; + int idxFin; + if(inc==0) { // premi\xE8re it\xE9ration, axe : debut, C' + idxDeb=_idxPoint==idxRupture1_?0:idxRupture1_; + idxFin=_idxPoint; } - else { - idx1=_idxPoint+1; - idx2=_idxPoint; - valCurv=Math.abs(_value-curv_.get(idx1)); + else { // seconde it\xE9ration, axe : C', fin + idxDeb=_idxPoint; + idxFin=_idxPoint==idxRupture2_||idxRupture2_==-1 ? seq.size()-1:idxRupture2_; } - // Calcul des nouvelles coordonn\xE9es - if (seq.getX(idx2)!=seq.getX(idx1)) { - // Extraction du signe de xa-xb - double sign=Math.signum(seq.getX(idx2)-seq.getX(idx1)); - double coefDirecteur=(seq.getY(idx2)-seq.getY(idx1))/(seq.getX(idx2)-seq.getX(idx1)); - double newX=seq.getX(idx1)+sign*valCurv/Math.sqrt(1+coefDirecteur*coefDirecteur); - double newY=seq.getY(idx1)+coefDirecteur*(newX-seq.getX(idx1)); - coords[_idxPoint].x=newX; - coords[_idxPoint].y=newY; + // R\xE9alignement sur l'axe + if (Math.abs(coords[idxFin].x-coords[idxDeb].x)>tolerance) { + double sign=Math.signum(coords[idxFin].x-coords[idxDeb].x); + double newCoefDirecteur=(coords[idxFin].y-coords[idxDeb].y)/(coords[idxFin].x-coords[idxDeb].x); + for(int i=idxDeb+1;i<idxFin;i++){ + coords[i].x=coords[idxDeb].x+sign*(curv_.get(i)-curv_.get(idxDeb))/Math.sqrt(1+newCoefDirecteur*newCoefDirecteur); + coords[i].y=coords[idxDeb].y+newCoefDirecteur*(coords[i].x-coords[idxDeb].x); + } } else { // Cas du bout de profil vertical - // Extraction du signe de ya-yb - double sign=Math.signum(seq.getY(idx2)-seq.getY(idx1)); - double newY=seq.getY(idx1)+sign*(valCurv-curv_.get(idx1)); - coords[_idxPoint].y=newY; + double sign=Math.signum(coords[idxFin].y-coords[idxDeb].y); + for(int i=idxDeb+1;i<idxFin;i++){ + coords[i].x=coords[idxDeb].x; + coords[i].y=coords[idxDeb].y+sign*(curv_.get(i)-curv_.get(idxDeb)); + } } - zone_.setCoordinateSequence(idxGeom_, GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create(coords), null); - // Mise a jour de la table des valeurs curvilignes - if (_idxPoint!=0) - curv_.set(_idxPoint, _value); - else - for (int i=1; i<curv_.size(); i++) - curv_.set(i, curv_.get(i)-_value); - fireDataGeometryChanged(); } - // Cas o\xF9 il y a d\xE9pacement d'un autre point => le signe de xa-xb va potentiellement chang\xE9 => cas interdit - else - controller_.showError(FudaaLib.getS("Il est interdit de d\xE9placer un point au dela des points l'encadrant.")); } - else - // Cas complexe : l'index est sur un point de rupture \\ - // TODO : d\xE9placement sur l'\xE9llipse avec verification de non croisement des axes du profil - controller_.showError(FudaaLib.getS("Le changement d'abscisse curviligne des points de ruptures n'est pas g\xE9r\xE9 pour l'instant.")); + + // Enregistrement des nouvelles coordonn\xE9es \\ + zone_.setCoordinateSequence(idxGeom_, GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create(coords), null); + // Notification des changements de valeurs + fireDataGeometryChanged(); } public void setZ(int _idxPoint, double _value) { - if (z_!=null) { - z_.setObject(_idxPoint, _value, null); - // Mise \xE0 jour de idxZMin_ et idxZMax_ - if (_idxPoint==idxZMax_||_idxPoint==idxZMin_) { - idxZMax_=0; - idxZMin_=0; - for (int i=1; i<z_.getSize(); i++) { - double val=(Double)z_.getObjectValueAt(i); - if (val>(Double)z_.getObjectValueAt(idxZMax_)) - idxZMax_=i; - else if (val<(Double)z_.getObjectValueAt(idxZMin_)) - idxZMin_=i; - } + if (z_==null||_idxPoint<0||_idxPoint>=z_.getSize()) + throw new IllegalArgumentException("Cet index n'existe pas."); + z_.setObject(_idxPoint, _value, null); + // Mise \xE0 jour de idxZMin_ et idxZMax_ + if (_idxPoint==idxZMax_||_idxPoint==idxZMin_) { + idxZMax_=0; + idxZMin_=0; + for (int i=1; i<z_.getSize(); i++) { + double val=(Double)z_.getObjectValueAt(i); + if (val>(Double)z_.getObjectValueAt(idxZMax_)) + idxZMax_=i; + else if (val<(Double)z_.getObjectValueAt(idxZMin_)) + idxZMin_=i; } - else if (_value>(Double)z_.getObjectValueAt(idxZMax_)) - idxZMax_=_idxPoint; - else if (_value<(Double)z_.getObjectValueAt(idxZMin_)) - idxZMin_=_idxPoint; - fireDataGeometryChanged(); } + else if (_value>(Double)z_.getObjectValueAt(idxZMax_)) + idxZMax_=_idxPoint; + else if (_value<(Double)z_.getObjectValueAt(idxZMin_)) + idxZMin_=_idxPoint; + fireDataGeometryChanged(); } public double getCurvMax() { @@ -296,7 +501,7 @@ if(curv_==null) return 0; else - return curv_.get(0); + return curv_.get(0); // toujours 0 de toute fa\xE7on } public double getZMax() { @@ -313,57 +518,68 @@ return (Double) z_.getObjectValueAt(idxZMin_); } - public void setValues(int _idxPoint, double _valueCurv, double _valueZ){ + public void setValues(int _idxPoint, double _valueCurv, double _valueZ) throws DataGeometryException{ setZ(_idxPoint, _valueZ); setCurv(_idxPoint, _valueCurv); } - public void remove(int _idxPoint){ - if(zone_==null||z_==null||curv_==null) - return; - if(_idxPoint>=0&&_idxPoint<z_.getSize()){ - // Suppression du point dans la zone + public void remove(int _idxPoint) throws DataGeometryException { + if(zone_==null||z_==null||curv_==null||_idxPoint<0||_idxPoint>=curv_.size()) + throw new IllegalArgumentException("Cet index n'existe pas."); + if(curv_.size()==2) + throw new DataGeometryException("On ne peut pas enlever un point quand il n'en reste que deux."); + // Suppression du point dans la zone + zone_.removeAtomics(idxGeom_, new CtuluListSelection(new int[]{_idxPoint}), null, null); + z_=(CtuluCollection)zone_.getValue(zone_.getIndiceOf(zone_.getAttributeIsZ()), idxGeom_); + // Mise \xE0 jour des informations curvilignes \\ + if (_idxPoint==0) { + // Si _idxPoint est le premier point + curv_.remove(0); + for (int i=curv_.size()-1; i>=0; i--) + curv_.set(i, curv_.get(i)-curv_.get(0)); + } + else if (_idxPoint>0&&_idxPoint<curv_.size()-1) { + // Cas g\xE9n\xE9ral si _idxPoint est entre le premier et le dernier + // Attention curv_ contient toujours _idxPoint contrairement \xE0 seq CoordinateSequence seq=((GISCoordinateSequenceContainerInterface)zone_.getGeometry(idxGeom_)).getCoordinateSequence(); - Coordinate[] points=new Coordinate[seq.size()-1]; - for(int i=0;i<_idxPoint;i++) - points[i]=seq.getCoordinate(i); - for(int i=_idxPoint+1;i<seq.size();i++) - points[i]=seq.getCoordinate(i); - zone_.setGeometry(idxGeom_, GISGeometryFactory.INSTANCE.createGeometry(zone_.getGeometry(idxGeom_).getClass(), - GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create(points)), null); - // Mise \xE0 jour des informations curvilignes \\ - if(_idxPoint==0){ - // Si _idxPoint est le premier point - curv_.remove(0); - for(int i=curv_.size();i>=0;i--) - curv_.set(i, curv_.get(i)-curv_.get(0)); + double delta=curv_.get(_idxPoint-1)-curv_.get(_idxPoint+1) + +Math.sqrt(Math.pow(seq.getCoordinate(_idxPoint-1).x-seq.getCoordinate(_idxPoint).x, 2) + +Math.pow(seq.getCoordinate(_idxPoint-1).y-seq.getCoordinate(_idxPoint).y, 2)); + curv_.remove(_idxPoint); + for (int i=_idxPoint; i<curv_.size(); i++) + curv_.set(i, curv_.get(i)+delta); + } + else + // Si _idxPoint est le dernier + curv_.remove(curv_.size()-1); + // Mise \xE0 jour de idxZMin_ et idxZMax_ + if (_idxPoint==idxZMax_||_idxPoint==idxZMin_) { + idxZMax_=0; + idxZMin_=0; + for (int i=1; i<z_.getSize(); i++) { + double val=(Double)z_.getObjectValueAt(i); + if (val>(Double)z_.getObjectValueAt(idxZMax_)) + idxZMax_=i; + else if (val<(Double)z_.getObjectValueAt(idxZMin_)) + idxZMin_=i; } - else if (_idxPoint>0&&_idxPoint<curv_.size()-1) { - // Cas g\xE9n\xE9ral si _idxPoint est entre le premier et le dernier - // Attention 'curv_' contient encore _idxPoint alors que 'points' ne le - // contient plus - double delta=-curv_.get(_idxPoint)-curv_.get(_idxPoint+1) - +Math.sqrt(Math.pow(points[_idxPoint-1].x-points[_idxPoint].x, 2) - +Math.pow(points[_idxPoint-1].y-points[_idxPoint].y, 2)); - curv_.remove(_idxPoint); - for(int i=_idxPoint;i<curv_.size();i++) - curv_.set(i, curv_.get(i)+delta); - } - else - // Si _idxPoint est le dernier - curv_.remove(curv_.size()-1); } + fireDataGeometryChanged(); } /** List de listener. */ List<DataGeometryListener> listeners_=new ArrayList<DataGeometryListener>(); public void addDataGeometryListener(DataGeometryListener _listener) { + if(_listener==null) + throw new IllegalArgumentException("_listener doit \xEAtre non null"); if(!listeners_.contains(_listener)) listeners_.add(_listener); } public void removeDataGeometryListener(DataGeometryListener _listener) { + if(_listener==null) + throw new IllegalArgumentException("_listener doit \xEAtre non null"); if(listeners_.contains(_listener)) listeners_.remove(_listener); } @@ -377,4 +593,55 @@ for(DataGeometryListener listener:listeners_) listener.dataGeometryNewGeom(); } + + // Quelques fonctions m\xE9th\xE9matiques \\ + + /** + * retourne le vecteur _a, _b sous forme de Coordinate. + */ + private Coordinate vec(Coordinate _a, Coordinate _b){ + return new Coordinate(_b.x-_a.x, _b.y-_a.y, _b.z-_a.z); + } + + /** + * Retourne la projection de _a sur la droite _b_c. + * Attention : Il s'agit bien d'une projection sur une + * droite et non un segment de droite : le r\xE9sultat + * peut \xEAtre en dehors de [_b, _c] + */ + private Coordinate proj(Coordinate _a, Coordinate _b, Coordinate _c){ + Coordinate vBC=vec(_b, _c); + Coordinate vBA=vec(_b, _a); + double normeBC=Math.sqrt(vBC.x*vBC.x+vBC.y*vBC.y+vBC.z*vBC.z); + double produitScalaireBCBA=vBC.x*vBA.x+vBC.y*vBA.y+vBC.z*vBA.z; + double rapportSurBC=produitScalaireBCBA/(normeBC*normeBC); + return new Coordinate(vBC.x*rapportSurBC+_b.x, vBC.y*rapportSurBC+_b.y, vBC.z*rapportSurBC+_b.z); + } + + /** + * Normalise le vecteur pass\xE9 en param\xE8tre. + */ + private Coordinate normalisation(Coordinate _a){ + double normeA=Math.sqrt(_a.x*_a.x+_a.y*_a.y+_a.z*_a.z); + _a.x=_a.x/normeA; + _a.y=_a.y/normeA; + _a.z=_a.z/normeA; + return _a; + } + + /** + * Compars les deux vecteurs avec la tol\xE9rance donn\xE9e. + * Le dernier param\xE8tre indique si un normalisation des + * deux vecteurs doit \xEAtre faite avec la comparaison. + * Les vecteurs ne sont pas modif\xE9s dans l'op\xE9ration. + */ + private boolean egal(Coordinate _a, Coordinate _b, double _tolerance, boolean _normalisation) { + if(_normalisation){ + normalisation(_a); + normalisation(_b); + } + Coordinate diff=vec(_a, _b); + return Math.abs(diff.x)<_tolerance&&Math.abs(diff.y)<_tolerance&&Math.abs(diff.z)<_tolerance; + } + } Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java 2008-12-17 17:44:49 UTC (rev 4305) @@ -0,0 +1,23 @@ +/* + * @creation 16 d\xE9c. 2008 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.fudaa.modeleur.modeleur1d; + +/** + * Exception lev\xE9e par les classes impl\xE9mentant DataGeometry pour indiqu\xE9 une + * impossibilit\xE9 dans le traitement demand\xE9. Un message d'erreur renseigne sur + * le probl\xE8me. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class DataGeometryException extends Exception { + + public DataGeometryException(String _message) { + super(_message); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueCourbe.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueCourbe.java 2008-12-15 16:28:55 UTC (rev 4304) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueCourbe.java 2008-12-17 17:44:49 UTC (rev 4305) @@ -139,11 +139,7 @@ return data_.getZMin(); } - /* (non-Javadoc) - * @see org.fudaa.ebli.courbe.EGModel#isDuplicatable() - */ public boolean isDuplicatable() { - // TODO Auto-generated method stub return false; } @@ -172,8 +168,14 @@ } public boolean removeValue(int _i, CtuluCommandContainer _cmd) { - data_.remove(_i); - return true; + try { + data_.remove(_i); + return true; + } + catch (DataGeometryException _exc) { + controller_.showError(_exc.getMessage()); + return false; + } } /* (non-Javadoc) @@ -189,8 +191,15 @@ } public boolean setValue(int _i, double _x, double _y, CtuluCommandContainer _cmd) { - data_.setValues(_i, _x, _y); - return true; + controller_.clearError(); + try { + data_.setValues(_i, _x, _y); + return true; + } + catch (DataGeometryException _exc) { + controller_.showError(_exc.getMessage()); + return false; + } } public boolean setValues(int[] _idx, double[] _x, double[] _y, CtuluCommandContainer _cmd) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueTableau.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueTableau.java 2008-12-15 16:28:55 UTC (rev 4304) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueTableau.java 2008-12-17 17:44:49 UTC (rev 4305) @@ -82,15 +82,20 @@ } public void setValueAt(Object value, int rowIndex, int columnIndex) { + controller_.clearError(); if(columnIndex==0) - data_.setCurv(rowIndex, (Double) value); + try { + data_.setCurv(rowIndex, (Double) value); + } + catch (DataGeometryException _exc) { + controller_.showError(_exc.getMessage()); + } else data_.setZ(rowIndex, (Double) value); } } /** Le controller de la fen\xEAtre 1d. */ - @SuppressWarnings("unused") private Controller1d controller_; /** La vue du tableau. */ private JTable table_; Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/testModeleur1d/TestDataGeometryAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/testModeleur1d/TestDataGeometryAdapter.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/testModeleur1d/TestDataGeometryAdapter.java 2008-12-17 17:44:49 UTC (rev 4305) @@ -0,0 +1,914 @@ +/* + * @creation 16 d\xE9c. 2008 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package testModeleur1d; + +import junit.framework.TestCase; + +import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISAttributeInterface; +import org.fudaa.ctulu.gis.GISGeometryFactory; +import org.fudaa.ctulu.gis.GISPolyligne; +import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; +import org.fudaa.fudaa.modeleur.modeleur1d.DataGeometryAdapter; +import org.fudaa.fudaa.modeleur.modeleur1d.DataGeometryException; +import org.fudaa.fudaa.modeleur.modeleur1d.DataGeometryListener; + +import com.vividsolutions.jts.geom.Coordinate; + +/** + * Test pour DataGeometryAdapter. + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class TestDataGeometryAdapter extends TestCase { + + /** Tolerance pour les comparaisons de doubles. */ + private double tolerance=0.000001; + private DataGeometryAdapter geomAdapter_; + private GISZoneCollectionLigneBrisee zone0_; + private GISZoneCollectionLigneBrisee zone1_; + private GISZoneCollectionLigneBrisee zone3_; + private GISZoneCollectionLigneBrisee zone4_; + private GISZoneCollectionLigneBrisee zone5_; + private GISZoneCollectionLigneBrisee zone6_; + + /* + * (non-Javadoc) + * + * @see junit.framework.TestCase#setUp() + */ + @Override + protected void setUp() throws Exception { + super.setUp(); + geomAdapter_=new DataGeometryAdapter(null, -1); + // Zone6_ \\ + // Attribut z non d\xE9fini + zone6_=new GISZoneCollectionLigneBrisee(); + zone6_.setAttributes(new GISAttributeInterface[]{GISAttributeConstants.BATHY}, null); + zone6_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(-10, -20, -20), + new Coordinate(50, 10, 10)}), null, null); + // Zone0_ \\ + // Quelconque + zone0_=new GISZoneCollectionLigneBrisee(); + zone0_.setAttributes(new GISAttributeInterface[]{GISAttributeConstants.BATHY}, null); + zone0_.setAttributeIsZ(GISAttributeConstants.BATHY); + zone0_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(-10, -20, -20), + new Coordinate(50, 10, 10)}), null, null); + // Zone1_ \\ + // Quelconque + zone1_=new GISZoneCollectionLigneBrisee(); + zone1_.setAttributes(new GISAttributeInterface[]{GISAttributeConstants.BATHY}, null); + zone1_.setAttributeIsZ(GISAttributeConstants.BATHY); + zone1_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory() + .create( + new Coordinate[]{new Coordinate(8, 6, 0), new Coordinate(5.052590034554651, 6.559262456806686, 0), + new Coordinate(3, 2, 0)}), null, null); + // Zone3_ \\ + // Quelconque + zone3_=new GISZoneCollectionLigneBrisee(); + zone3_.setAttributes(new GISAttributeInterface[]{GISAttributeConstants.BATHY}, null); + zone3_.setAttributeIsZ(GISAttributeConstants.BATHY); + zone3_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(-10, -20, -20), new Coordinate(50, 10, 10), + new Coordinate(30, 5, 5), new Coordinate(10, 0, 0)}), null, null); + zone3_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(5, 0, 0), new Coordinate(-15, -20, -20), new Coordinate(55, 10, 10), + new Coordinate(35, 5, -20), new Coordinate(15, 0, -20)}), null, null); + // zone4_ \\ + zone4_=new GISZoneCollectionLigneBrisee(); + zone4_.setAttributes(new GISAttributeInterface[]{GISAttributeConstants.BATHY}, null); + zone4_.setAttributeIsZ(GISAttributeConstants.BATHY); + // 0 : Points confondus + zone4_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(-10, -20, -20), new Coordinate(-10, -20, -20), + new Coordinate(-20, -40, -40), new Coordinate(-30, -60, -60)}), null, null); + // 1 : nb ruptures > 2 + zone4_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(10, 20, 5), new Coordinate(11, 100, 8), new Coordinate(41, 5, 9), new Coordinate(41, 0, 8)}), null, null); + // 2 : nb ruptures = 1 + zone4_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(11, 100, 8), new Coordinate(12, 101, 10), new Coordinate(13, 102, -5)}), null, null); + // 3 : nb ruptures = 0 + zone4_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(10, 20, 5), new Coordinate(20, 40, 8)}), null, null); + // 4 : nb ruptures = 2 + zone4_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(10, 10, 0), new Coordinate(20, 10, 5), new Coordinate(20, 20, 8), new Coordinate(25, 20, 8), new Coordinate(30, 20, 8)}), null, null); + // 5 : axes crois\xE9s + zone4_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(10, 10, 0), new Coordinate(20, 10, 5), new Coordinate(20, 20, 8), new Coordinate(10, 5, 8)}), null, null); + // Zone5_ \\ + zone5_=new GISZoneCollectionLigneBrisee(); + zone5_.setAttributes(new GISAttributeInterface[]{GISAttributeConstants.BATHY}, null); + zone5_.setAttributeIsZ(GISAttributeConstants.BATHY); + // 0 : 2 points align\xE9s (cas g\xE9n\xE9ral) + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(10, 5, -4)}), null, null); + // 1 : 2 points align\xE9s parall\xE8le \xE0 l'axe des X + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(5, 10, 3), new Coordinate(20, 10, -7)}), null, null); + // 2 : 2 points align\xE9s parall\xE8le \xE0 l'axe des Y + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(5, 0, 0), new Coordinate(5, 10, 88)}), null, null); + // 3 : 3 points align\xE9s (cas g\xE9n\xE9ral) + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, -2), new Coordinate(11, 5, 7), new Coordinate(16.5, 7.5, 0)}), null, null); + // 4 : 3 points align\xE9s parall\xE8le \xE0 l'axe des X + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(-5, 10, 3), new Coordinate(20, 10, 6), new Coordinate(20.4, 10, 2)}), null, null); + // 5 : 3 points align\xE9s parall\xE8le \xE0 l'axe des Y + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(-5, 10, 8), new Coordinate(-5, -2, -2), new Coordinate(-5, -50, 50)}), null, null); + // 6 : 4 points align\xE9s (cas g\xE9n\xE9ral) + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(1, 1, 0), new Coordinate(2, 1, 3), new Coordinate(8, 5, -9), new Coordinate(40, 25, 99)}), null, null); + // 7 : 4 points align\xE9s parall\xE8le \xE0 l'axe des X + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(1, 2.56, -2), new Coordinate(10, 2.56, 0), new Coordinate(99, 2.56, 84), new Coordinate(100.5, 2.56, 100)}), null, null); + // 8 : 4 points align\xE9s parall\xE8le \xE0 l'axe des Y + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(-9.1, 88, 0), new Coordinate(-9.1, 50, 8), new Coordinate(-9.1, 0, -87), new Coordinate(-9.1, -10, -10)}), null, null); + // 9 : 3 points avec un point de rupture + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(10, 5, 2), new Coordinate(10, -5, 9)}), null, null); + // 10 : 4 points avec un point de rupture (deux points sur le premier axe) + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, -2), new Coordinate(11, 5, 7), new Coordinate(16.5, 7.5, 0), new Coordinate(50, 60, 70)}), null, null); + // 11 : 5 points avec un point de rupture (deux points sur chaque axe) + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, -2), new Coordinate(11, 5, 7), new Coordinate(16.5, 7.5, 0), new Coordinate(33, 3.75, 9), new Coordinate(11, 1.25, 9)}), null, null); + // 12 : 4 points avec deux points de ruptures + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(10, 5, 2), new Coordinate(10, -5, 9), new Coordinate(20, 0, 0)}), null, null); + // 13 : 5 points avec deux points de ruptures (deux points sur le premier axe) + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(5, 2.5, 88), new Coordinate(10, 5, 2), new Coordinate(10, -5, 9), new Coordinate(20, 0, 0)}), null, null); + // 14 : 6 points avec deux points de ruptures (deux points sur les deux premiers axes) + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(5, 2.5, 88), new Coordinate(10, 5, 2), new Coordinate(10, 0, 44), new Coordinate(10, -5, 9), new Coordinate(20, 0, 0)}), null, null); + // 15 : 7 points avec deux points de ruptures (deux points sur chacun des axes) + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(5, 2.5, 88), new Coordinate(10, 5, 2), new Coordinate(10, 0, 44), new Coordinate(10, -5, 9), new Coordinate(15, -2.5, 2), new Coordinate(20, 0, 0)}), null, null); + // 16 : 10 points avec deux points de ruptures (trois points sur chacun des axes) + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(0, 0, 0), new Coordinate(2.5, 1.25, 44), new Coordinate(5, 2.5, 88), new Coordinate(10, 5, 2), new Coordinate(10, 0, 44), new Coordinate(10, -2, 0), new Coordinate(10, -5, 9), new Coordinate(10/2., -5/2., 2), new Coordinate(10/4., -5/4., 0), new Coordinate(10/8., -5/8., 0)}), null, null); + // 17 : 3 points avec un point de rupture et le premier et le dernier points sont sur le m\xEAme axe des y + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(5, 5, -9), new Coordinate(10, 10, 0), new Coordinate(5, 20, 0)}), null, null); + // 18 : 3 points avec un point de rupture et le premier et le dernier points sont sur le m\xEAme axe des x + zone5_.addPolyligne(GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create( + new Coordinate[]{new Coordinate(5, 5, -9), new Coordinate(10, 10, 0), new Coordinate(20, 5, 0)}), null, null); + } + + public void testDataGeometryAdapter() throws IllegalArgumentException, DataGeometryException { + // Points confondus + try { + new DataGeometryAdapter(zone4_, 0); + fail(); + } + catch (IllegalArgumentException _exc) { + fail(); + } + catch (DataGeometryException _exc) {} + // nb points > 2 + try { + new DataGeometryAdapter(zone4_, 1); + fail(); + } + catch (IllegalArgumentException _exc) { + fail(); + } + catch (DataGeometryException _exc) {} + // nb ruptures = 1 + try { + new DataGeometryAdapter(zone4_, 2); + } + catch (IllegalArgumentException _exc) { + fail(); + } + catch (DataGeometryException _exc) { + fail(); + } + // nb ruptures = 0 + try { + new DataGeometryAdapter(zone4_, 3); + } + catch (IllegalArgumentException _exc) { + fail(); + } + catch (DataGeometryException _exc) { + fail(); + } + // nb ruptures = 2 + try { + new DataGeometryAdapter(zone4_, 4); + } + catch (IllegalArgumentException _exc) { + fail(); + } + catch (DataGeometryException _exc) { + fail(); + } + // axes crois\xE9s + try { + new DataGeometryAdapter(zone4_, 5); + fail(); + } + catch (IllegalArgumentException _exc) { + fail(); + } + catch (DataGeometryException _exc) { + } + // aguments invalide + geomAdapter_=new DataGeometryAdapter(null, -1); + assertNull(geomAdapter_.getGISZoneCollection()); + assertEquals(-1, geomAdapter_.getIdxGeom()); + // aguments invalide + try { + geomAdapter_=new DataGeometryAdapter(null, 0); + fail(); + } + catch (IllegalArgumentException _exc) { + assertNull(geomAdapter_.getGISZoneCollection()); + assertEquals(-1, geomAdapter_.getIdxGeom()); + } + catch (DataGeometryException _exc) { + fail(); + } + // aguments invalide + try { + geomAdapter_=new DataGeometryAdapter(null, 1); + fail(); + } + catch (IllegalArgumentException _exc) { + assertNull(geomAdapter_.getGISZoneCollection()); + assertEquals(-1, geomAdapter_.getIdxGeom()); + } + catch (DataGeometryException _exc) { + fail(); + } + // aguments invalide + try { + geomAdapter_=new DataGeometryAdapter(zone4_, -1); + fail(); + } + catch (IllegalArgumentException _exc) { + assertNull(geomAdapter_.getGISZoneCollection()); + assertEquals(-1, geomAdapter_.getIdxGeom()); + } + catch (DataGeometryException _exc) { + fail(); + } + // aguments invalide + try { + geomAdapter_=new DataGeometryAdapter(zone4_, -10); + fail(); + } + catch (IllegalArgumentException _exc) { + assertNull(geomAdapter_.getGISZoneCollection()); + assertEquals(-1, geomAdapter_.getIdxGeom()); + } + catch (DataGeometryException _exc) { + fail(); + } + // aguments invalide + try { + geomAdapter_=new DataGeometryAdapter(zone4_, zone4_.getNbGeometries()); + fail(); + } + catch (IllegalArgumentException _exc) { + assertNull(geomAdapter_.getGISZoneCollection()); + assertEquals(-1, geomAdapter_.getIdxGeom()); + } + catch (DataGeometryException _exc) { + fail(); + } + // aguments invalide + try { + geomAdapter_=new DataGeometryAdapter(zone4_, zone4_.getNbGeometries()+1); + fail(); + } + catch (IllegalArgumentException _exc) { + assertNull(geomAdapter_.getGISZoneCollection()); + assertEquals(-1, geomAdapter_.getIdxGeom()); + } + catch (DataGeometryException _exc) { + fail(); + } + // aguments valide + try { + new DataGeometryAdapter(zone3_, zone3_.getNbGeometries()-1); + } + catch (IllegalArgumentException _exc) { + fail(); + } + catch (DataGeometryException _exc) { + fail(); + } + } + + public void testSetData() throws IllegalArgumentException, DataGeometryException { + // Zone sans attribut Z d\xE9fini + try{ + geomAdapter_.setData(zone6_, 0); + } + catch (DataGeometryException _exc) { + fail(); + } + catch(IllegalArgumentException _exc){} + // Points confondus + try { + new DataGeometryAdapter(zone4_, 0); + fail(); + } + catch (IllegalArgumentException _exc) { + fail(); + } + catch (DataGeometryException _exc) {} + // nb points > 2 + try { + new DataGeometryAdapter(zone4_, 1); + fail(); + } + catch (IllegalArgumentException _exc) { + fail(); + } + catch (DataGeometryException _exc) {} + // nb ruptures = 1 + try { + new DataGeometryAdapter(zone4_, 2); + } + catch (IllegalArgumentException _exc) { + fail(); + } + catch (DataGeometryException _exc) { + fail(); + } + // nb ruptures = 0 + try { + new DataGeometryAdapter(zone4_, 3); + } + catch (IllegalArgumentException _exc) { + fail(); + } + catch (DataGeometryException _exc) { + fail(); + } + // nb ruptures = 2 + try { + new DataGeometryAdapter(zone4_, 4); + } + catch (IllegalArgumentException _exc) { + fail(); + } + catch (DataGeometryException _exc) { + fail(); + } + // axes crois\xE9s + try { + new DataGeometryAdapter(zone4_, 5); + fail(); + } + catch (IllegalArgumentException _exc) { + fail(); + } + catch (DataGeometryException _exc) { + } + // aguments invalide + geomAdapter_=new DataGeometryAdapter(null, -1); + assertNull(geomAdapter_.getGISZoneCollection()); + assertEquals(-1, geomAdapter_.getIdxGeom()); + // aguments invalide + try { + geomAdapter_=new DataGeometryAdapter(null, 0); + fail(); + } + catch (IllegalArgumentException _exc) { + assertNull(geomAdapter_.getGISZoneCollection()); + assertEquals(-1, geomAdapter_.getIdxGeom()); + } + catch (DataGeometryException _exc) { + fail(); + } + // aguments invalide + try { + geomAdapter_=new DataGeometryAdapter(null, 1); + fail(); + } + catch (IllegalArgumentException _exc) { + assertNull(geomAdapter_.getGISZoneCollection()); + assertEquals(-1, geomAdapter_.getIdxGeom()); + } + catch (DataGeometryException _exc) { + fail(); + } + // aguments invalide + try { + geomAdapter_=new DataGeometryAdapter(zone4_, -1); + fail(); + } + catch (IllegalArgumentException _exc) { + assertNull(geomAdapter_.getGISZoneCollection()); + assertEquals(-1, geomAdapter_.getIdxGeom()); + } + catch (DataGeometryException _exc) { + fail(); + } + // aguments invalide + try { + geomAdapter_=new DataGeometryAdapter(zone4_, -10); + fail(); + } + catch (IllegalArgumentException _exc) { + assertNull(geomAdapter_.getGISZoneCollection()); + assertEquals(-1, geomAdapter_.getIdxGeom()); + } + catch (DataGeometryException _exc) { + fail(); + } + // aguments invalide + try { + geomAdapter_=new DataGeometryAdapter(zone4_, zone4_.getNbGeometries()); + fail(); + } + catch (IllegalArgumentException _exc) { + assertNull(geomAdapter_.getGISZoneCollection()); + assertEquals(-1, geomAdapter_.getIdxGeom()); + } + catch (DataGeometryException _exc) { + fail(); + } + // aguments invalide + try { + geomAdapter_=new DataGeometryAdapter(zone4_, zone4_.getNbGeometries()+1); + fail(); + } + ... [truncated message content] |
From: <emm...@us...> - 2009-02-12 17:10:09
|
Revision: 4459 http://fudaa.svn.sourceforge.net/fudaa/?rev=4459&view=rev Author: emmanuel_martin Date: 2009-02-12 17:10:04 +0000 (Thu, 12 Feb 2009) Log Message: ----------- Impl?\195?\169mentation partielle de la tache #178 (suite) Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/Bief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/BiefSet.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ProfilContainerAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/testModeleur1d/TestProfilContainerAdapter.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/BiefImporterFromModels.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/BiefsImporterFromModeleur2d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/CancelException.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsBief1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueImportation.java Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/BiefImporterFromModels.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/BiefImporterFromModels.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/BiefImporterFromModels.java 2009-02-12 17:10:04 UTC (rev 4459) @@ -0,0 +1,574 @@ +/* + * @creation 11 f\xE9vr. 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.fudaa.modeleur.modeleur1d.controller; + +import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISAttributeInterface; +import org.fudaa.ctulu.gis.GISAttributeModel; +import org.fudaa.ctulu.gis.GISAttributeModelDoubleArray; +import org.fudaa.ctulu.gis.GISAttributeModelDoubleInterface; +import org.fudaa.ctulu.gis.GISAttributeModelIntegerList; +import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; +import org.fudaa.ctulu.gis.GISCoordinateSequenceFactory; +import org.fudaa.ctulu.gis.GISLib; +import org.fudaa.ctulu.gis.GISPolyligne; +import org.fudaa.ctulu.gis.GISReprojectInterpolateur1DDouble; +import org.fudaa.ctulu.gis.GISZoneCollection; +import org.fudaa.ctulu.gis.GISZoneCollectionGeometry; +import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; +import org.fudaa.ebli.calque.ZModeleLigneBrisee; +import org.fudaa.fudaa.commun.FudaaLib; +import org.fudaa.fudaa.modeleur.layer.MdlModel1dAxe; +import org.fudaa.fudaa.modeleur.layer.MdlModel1dBank; +import org.fudaa.fudaa.modeleur.layer.MdlModel1dLimiteStockage; +import org.fudaa.fudaa.modeleur.layer.MdlModel2dConstraintLine; +import org.fudaa.fudaa.modeleur.layer.MdlModel2dDirectionLine; +import org.fudaa.fudaa.modeleur.layer.MdlModel2dProfile; +import org.fudaa.fudaa.modeleur.modeleur1d.model.Bief; +import org.fudaa.fudaa.modeleur.modeleur1d.model.UtilsBief1d; +import org.fudaa.fudaa.modeleur.modeleur1d.model.UtilsProfil1d; +import org.fudaa.fudaa.modeleur.modeleur1d.view.VueImportation; + +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.Geometry; + +/** + * Import un bief a partir d'un tableau de modeles. + * + * Cette classe est dans les controlleurs car elle peut instancier une vue pour + * demander \xE0 l'utilisateur certaines informations suppl\xE9mentaires. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class BiefImporterFromModels { + + /** Le tableau de mod\xE8le tel que donn\xE9 \xE0 la construction de l'instance. */ + private ZModeleLigneBrisee[] models_; + // Les mod\xE8les en fonction de le contenu. Se sont les m\xEAmes que dans models_. + private ZModeleLigneBrisee axeHydraulique_; + private ZModeleLigneBrisee profils_; + private ZModeleLigneBrisee rives_; + private ZModeleLigneBrisee limitesStockages_; + private ZModeleLigneBrisee lignesDirectrices_; + private ZModeleLigneBrisee lignesContraints_; + + public BiefImporterFromModels(ZModeleLigneBrisee[] _models) { + if (_models==null) + throw new IllegalArgumentException(FudaaLib.getS("_models ne peut pas \xEAtre null.")); + models_=_models; + } + + /** + * @return le bief r\xE9sultant des mod\xE8les. + * @throws CancelException + */ + public Bief getBief() throws CancelException { + buildBief(); + Bief bief=new Bief(axeHydraulique_, lignesContraints_, lignesDirectrices_, limitesStockages_, profils_, rives_); + bief.enableSynchroniser(); + return bief; + } + + /** + * Construit les mod\xE8les. + * @throws CancelException + */ + private void buildBief() throws CancelException { + testAndValuateModels(); + // Valuation des attributs sp\xE9cifiques au 1d pour les profils \\ + GISZoneCollection zone=profils_.getGeomData(); + UtilsBief1d.normalizeProfilAttributes(zone); + normalizePKData(); + + int idxAttRiveGauche=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); + int idxAttRiveDroite=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); + int idxAttlsGauche=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); + int idxAttlsDroite=zone.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); + int idxAttLignesDirectrices=zone.getIndiceOf(GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); + + UtilsBief1d.orderProfils(profils_, -1, null); + // Normalise le sens du profil \\ + for (int k=0; k<profils_.getNombre(); k++) { + Geometry profil=zone.getGeometry(k); + CoordinateSequence seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); + // Normalisation du sens (gauche/droite) du profil \\ + Coordinate interAxeProfil=seqProfil.getCoordinate(seqProfil.size()/2); + // Cr\xE9ation du vecteur contenant le sens de l'axe hydraulique + Coordinate vAxeH=null; + boolean noReorientation=false; + if (k>0) { + CoordinateSequence profilPrevious=zone.getCoordinateSequence(k-1); + Coordinate pointProfilPrevious=profilPrevious.getCoordinate(profilPrevious.size()/2); + vAxeH=new Coordinate(interAxeProfil.x-pointProfilPrevious.x, interAxeProfil.y-pointProfilPrevious.y, 0); + } + else if (k<profils_.getNombre()-1) { + CoordinateSequence profilPrevious=zone.getCoordinateSequence(k+1); + Coordinate pointProfilPrevious=profilPrevious.getCoordinate(profilPrevious.size()/2); + vAxeH=new Coordinate(pointProfilPrevious.x-interAxeProfil.x, pointProfilPrevious.y-interAxeProfil.y, 0); + } + else { + if (axeHydraulique_.getNombre()>0) { + Geometry axeHydraulique=(Geometry)axeHydraulique_.getObject(0); + CoordinateSequence seqAxeHydraulique=((GISCoordinateSequenceContainerInterface)axeHydraulique).getCoordinateSequence(); + // Normalisation du sens (gauche/droite) du profil \\ + Coordinate interAxeProfil2=profil.intersection(axeHydraulique).getCoordinate(); + // Cr\xE9ation du vecteur contenant le sens de l'axe hydraulique + int idxPrevious=UtilsProfil1d.getPreviousIndex(seqAxeHydraulique, interAxeProfil2); + int idxNext=UtilsProfil1d.getNextIndex(seqAxeHydraulique, interAxeProfil2); + if (idxPrevious!=-1) + vAxeH=new Coordinate(interAxeProfil2.x-seqAxeHydraulique.getCoordinate(idxPrevious).x, interAxeProfil2.y + -seqAxeHydraulique.getCoordinate(idxPrevious).y, 0); + else + vAxeH=new Coordinate(seqAxeHydraulique.getCoordinate(idxNext).x-interAxeProfil2.x, seqAxeHydraulique + .getCoordinate(idxNext).y + -interAxeProfil2.y, 0); + } + else + // Pas de r\xE9orientatin du profil dans ce cas l\xE0. + noReorientation=true; + } + // Cr\xE9ation du vecteur contenant le sens du profil + if (!noReorientation) { + Coordinate vProfilH; + int idxPrevious=UtilsProfil1d.getPreviousIndex(seqProfil, interAxeProfil); + int idxNext=UtilsProfil1d.getNextIndex(seqProfil, interAxeProfil); + if (idxPrevious!=-1) + vProfilH=new Coordinate(interAxeProfil.x-seqProfil.getCoordinate(idxPrevious).x, interAxeProfil.y + -seqProfil.getCoordinate(idxPrevious).y, 0); + else + vProfilH=new Coordinate(seqProfil.getCoordinate(idxNext).x-interAxeProfil.x, seqProfil.getCoordinate(idxNext).y + -interAxeProfil.y, 0); + // Inversion du sens du profil si besoin + double produitVectorielCoordZ=vAxeH.x*vProfilH.y-vAxeH.y*vProfilH.x; + if (produitVectorielCoordZ>0) { + inverseProfil(k); + profil=(Geometry)profils_.getGeomData().getGeometry(k); + seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); + } + } + } + // Cr\xE9ation des nouveaux points sur les profils \\ + for (int k=0; k<profils_.getNombre(); k++) { + // Ajout des points au profil si n\xE9c\xE9ssaire pour les intersections \\ + // Lignes de contraintes + for (int l=0; l<lignesContraints_.getNombre(); l++) + createPointIfNeededKeepZ(k, l, lignesContraints_); + // Rives + for (int l=0; l<rives_.getNombre(); l++) + createPointIfNeeded(k, (GISPolyligne)rives_.getObject(l)); + // Limites de stockages + for (int l=0; l<limitesStockages_.getNombre(); l++) + createPointIfNeeded(k, (GISPolyligne)limitesStockages_.getObject(l)); + // Lignes directrices + for (int l=0; l<lignesDirectrices_.getNombre(); l++) + createPointIfNeeded(k, (GISPolyligne)lignesDirectrices_.getObject(l)); + } + // Valuation des attributs simple d'intersection (rives et limites) \\ + for (int k=0; k<profils_.getNombre(); k++) { + CoordinateSequence seqProfil=zone.getCoordinateSequence(k); + double abscisseCurvIntersectionAxe; + if (axeHydraulique_.getNombre()>0) + abscisseCurvIntersectionAxe=UtilsProfil1d.abscisseCurviligne(seqProfil, axeHydraulique_.getGeomData() + .getCoordinateSequence(0)); + else + abscisseCurvIntersectionAxe=UtilsProfil1d.abscisseCurviligne(seqProfil, seqProfil.getCoordinate(seqProfil.size()-1))/2; + // Valuation des attributs avec les index des points des intersections \\ + // Rives + zone.setAttributValue(idxAttRiveGauche, k, 0, null); + zone.setAttributValue(idxAttRiveDroite, k, seqProfil.size()-1, null); + for (int l=0; l<rives_.getNombre(); l++) + valuateProfilIntersection(k, (Geometry)rives_.getObject(l), idxAttRiveGauche, idxAttRiveDroite, abscisseCurvIntersectionAxe); + // D\xE9tection des croisements zones de stockages droite et gauche \\ + // Limites de stockages + zone.setAttributValue(idxAttlsGauche, k, 0, null); + zone.setAttributValue(idxAttlsDroite, k, seqProfil.size()-1, null); + for (int l=0; l<limitesStockages_.getNombre(); l++) + valuateProfilIntersection(k, (Geometry)limitesStockages_.getObject(l), idxAttlsGauche, idxAttlsDroite, + abscisseCurvIntersectionAxe); + } + // Valuation des attributs composites d'intersection (lignes directrices) \\ + // Lignes directrices \\ + valuateProfilIntersection(idxAttLignesDirectrices); + + // Valuation des attributs sp\xE9cifique au 1d pour l'axe hydraulique \\ + UtilsBief1d.normalizeAxeHydrauliqueAttributes(axeHydraulique_.getGeomData()); + } + + /** + * Normalise les informations PK. + * @throws CancelException si l'imortation est annul\xE9e. + */ + private void normalizePKData() throws CancelException { + GISZoneCollection zone=profils_.getGeomData(); + int idxAttCommentaireHydraulique=zone.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO); + // Vrai si les PK existes. + boolean attrIsCorrectlyValued=false; + // Vrai si les PK existe et correspond \xE0 l'axe hydraulique si il existe. + boolean attrMatchWithAxeHydraulique=false; + boolean presenceAxeHydraulique=axeHydraulique_.getNombre()>0; + if (idxAttCommentaireHydraulique!=-1) { + attrIsCorrectlyValued=true; + if(presenceAxeHydraulique) + attrMatchWithAxeHydraulique=true; + int i=-1; + while (attrIsCorrectlyValued&&++i<profils_.getNombre()) { + // V\xE9rification de la pr\xE9sence des donn\xE9es PK \\ + String CommHydrauValue=(String)profils_.getGeomData().getValue(idxAttCommentaireHydraulique, i); + attrIsCorrectlyValued=GISLib.isHydroCommentValued(CommHydrauValue, "PK"); + // V\xE9rification de la coh\xE9rence avec l'axe hydraulique \\ + if (presenceAxeHydraulique) { + double hydraoCommValue=GISLib.getHydroCommentDouble(CommHydrauValue, "PK"); + double absCurvValue=UtilsProfil1d.abscisseCurviligne(axeHydraulique_.getGeomData().getCoordinateSequence(0), profils_ + .getGeomData().getCoordinateSequence(i)); + if (absCurvValue==-1) + throw new IllegalArgumentException(FudaaLib + .getS("Au moins un des profils coupe plusieurs fois ou jamais l'axe hydraulique.")); + attrMatchWithAxeHydraulique=attrIsCorrectlyValued&&attrMatchWithAxeHydraulique + &&Math.abs(hydraoCommValue-absCurvValue)<0.0001; + } + } + } + if (idxAttCommentaireHydraulique==-1) + // Ajout de l'attribut COMMENTAIRE_HYDRO + if (idxAttCommentaireHydraulique==-1) { + GISAttributeInterface[] atts=new GISAttributeInterface[zone.getNbAttributes()+1]; + for (int k=0; k<zone.getNbAttributes(); k++) + atts[k]=zone.getAttribute(k); + atts[atts.length-1]=GISAttributeConstants.COMMENTAIRE_HYDRO; + zone.setAttributes(atts, null); + } + if (!attrIsCorrectlyValued) { + // Valuation de l'attribut, a partir de l'axe hydrau si il existe, 0 + // sinon. + idxAttCommentaireHydraulique=zone.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO); + for (int k=0; k<zone.getNumGeometries(); k++) { + String comm=(String)profils_.getGeomData().getValue(idxAttCommentaireHydraulique, k); + if (!GISLib.isHydroCommentValued(comm, "PK")) + if (presenceAxeHydraulique) { + // Valuation avec le croisement avec l'axe hydraulique + double abscurv=UtilsProfil1d.abscisseCurviligne(axeHydraulique_.getGeomData().getCoordinateSequence(0), profils_ + .getGeomData().getCoordinateSequence(k)); + zone.setAttributValue(idxAttCommentaireHydraulique, k, GISLib.setHydroCommentDouble(comm, abscurv, "PK"), null); + } + else + // Valuation avec 0 + zone.setAttributValue(idxAttCommentaireHydraulique, k, GISLib.setHydroCommentDouble(comm, 0, "PK"), null); + } + attrMatchWithAxeHydraulique=true; + } + if (!attrMatchWithAxeHydraulique&&presenceAxeHydraulique) { + VueImportation vImport=new VueImportation(); + if (!vImport.run()) + throw new CancelException(FudaaLib.getS("L'importation a \xE9t\xE9 annul\xE9.")); + if (vImport.axeHydrauChosen()) { + // Ecrasement des anciennes valeurs de PK \\ + idxAttCommentaireHydraulique=zone.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO); + for (int k=0; k<zone.getNumGeometries(); k++) { + String comm=(String)profils_.getGeomData().getValue(idxAttCommentaireHydraulique, k); + // Valuation avec le croisement avec l'axe hydraulique + double abscurv=UtilsProfil1d.abscisseCurviligne(axeHydraulique_.getGeomData().getCoordinateSequence(0), profils_ + .getGeomData().getCoordinateSequence(k)); + zone.setAttributValue(idxAttCommentaireHydraulique, k, GISLib.setHydroCommentDouble(comm, abscurv, "PK"), null); + } + } + else { + // Destruction de l'axe hydraulique \\ + int[] idxAH=new int[axeHydraulique_.getNombre()]; + for (int i=0; i<idxAH.length; i++) + idxAH[i]=i; + axeHydraulique_.getGeomData().removeGeometries(idxAH, null); + } + } + } + + /** + * Value les attributs priv\xE9s a partir du tableau de ZModeleLigneBrisee. + * + * @param _models + */ + private void testAndValuateModels() { + for (int i=0; i<models_.length; i++) { + if (models_[i]==null) + throw new IllegalArgumentException(FudaaLib.getS("Erreur programmation : _models ne doit pas contenir de valeurs null")); + if (models_[i].getGeomData()==null) + throw new IllegalArgumentException(FudaaLib.getS("Erreur programmation : Certain model n'ont pas de GSIZoneCollection.")); + if (!(models_[i].getGeomData() instanceof GISZoneCollectionLigneBrisee)) + throw new IllegalArgumentException(FudaaLib + .getS("Erreur programmation : Toutes les GISZone doivent \xEAtre des GISZoneCollectionLigneBrisee.")); + String nature=(String)models_[i].getGeomData().getFixedAttributValue(GISAttributeConstants.NATURE); + if (nature==null) + throw new IllegalArgumentException(FudaaLib.getS("Un des modeles ne contient pas l'attribut NATURE.")); + if (nature==GISAttributeConstants.ATT_NATURE_AH) + if (axeHydraulique_!=null) + throw new IllegalArgumentException(FudaaLib.getS("Plusieurs models d'axe hydrauliques sont donn\xE9es.")); + else + axeHydraulique_=models_[i]; + else if (nature==GISAttributeConstants.ATT_NATURE_LD) + if (lignesDirectrices_!=null) + throw new IllegalArgumentException(FudaaLib.getS("Plusieurs models de lignes directrices sont donn\xE9es.")); + else + lignesDirectrices_=models_[i]; + else if (nature==GISAttributeConstants.ATT_NATURE_LS) + if (limitesStockages_!=null) + throw new IllegalArgumentException(FudaaLib.getS("Plusieurs models de limites de stockage sont donn\xE9es.")); + else if (models_[i].getGeomData().getNbGeometries()>2) + throw new IllegalArgumentException(FudaaLib.getS("Il ne peut pas y avoir plus de 2 limites de stockages.")); + else + limitesStockages_=models_[i]; + else if (nature==GISAttributeConstants.ATT_NATURE_PF) + if (profils_!=null) + throw new IllegalArgumentException(FudaaLib.getS("Plusieurs models de profils sont donn\xE9es.")); + else + profils_=models_[i]; + else if (nature==GISAttributeConstants.ATT_NATURE_RV) + if (rives_!=null) + throw new IllegalArgumentException(FudaaLib.getS("Plusieurs models de rives sont donn\xE9es.")); + else if (models_[i].getGeomData().getNbGeometries()>2) + throw new IllegalArgumentException(FudaaLib.getS("Il ne peut pas y avoir plus de 2 rives.")); + else + rives_=models_[i]; + else if (nature==GISAttributeConstants.ATT_NATURE_LC) + if (lignesContraints_!=null) + throw new IllegalArgumentException(FudaaLib.getS("Plusieurs models de lignes de contraintes sont donn\xE9es.")); + else + lignesContraints_=models_[i]; + } + // Remplissage des models vides par des ZModeles vides + if (axeHydraulique_==null) + axeHydraulique_=new MdlModel1dAxe(null); + if (profils_==null) + profils_=new MdlModel2dProfile(null, null); + if (rives_==null) + rives_=new MdlModel1dBank(null, null); + if (limitesStockages_==null) + limitesStockages_=new MdlModel1dLimiteStockage(null, null); + if (lignesDirectrices_==null) + lignesDirectrices_=new MdlModel2dDirectionLine(null, null); + if (lignesContraints_==null) + lignesContraints_=new MdlModel2dConstraintLine(null, null); + } + + /** + * Inverse le sens du profil dont l'index est pass\xE9 en param\xE8tre. + */ + private void inverseProfil(int _idxProfil) { + GISZoneCollection zone=profils_.getGeomData(); + Coordinate[] coords=((Geometry)zone.getGeometry(_idxProfil)).getCoordinates(); + for (int l=0; l<coords.length/2; l++) { + // Inversion des coordonn\xE9es + Coordinate tmp=coords[l]; + coords[l]=coords[coords.length-1-l]; + coords[coords.length-1-l]=tmp; + // Inversion des attributs atomiques + for (int i=0; i<zone.getNbAttributes(); i++) + if (zone.getAttribute(i).isAtomicValue()) { + GISAttributeModel model=(GISAttributeModel)zone.getDataModel(i).getObjectValueAt(_idxProfil); + Object valueTmp=model.getObjectValueAt(l); + model.setObject(l, model.getObjectValueAt(coords.length-1-l), null); + model.setObject(l, valueTmp, null); + } + } + zone.setCoordinateSequence(_idxProfil, new GISCoordinateSequenceFactory().create(coords), null); + } + + /** + * Valuation des attributs *gauche et *droite des profils. + * + * @param _idxProfil + * l'index du profil concern\xE9. + * @param _ligne + * la ligne qui est sens\xE9 crois\xE9 le profil. + * @param _idxAttrGauche + * l'index de l'attribut gauche o\xF9 sera mit l'information en cas de + * croisement \xE0 gauche. + * @param _idxAttrDroite + * l'index de l'attribut gauche o\xF9 sera mit l'information en cas de + * croisement \xE0 droite. + * @param _absCurvAxeHydrau + * la valeur de l'abscisse curviligne de l'axe hydrau sur le profil. + */ + private void valuateProfilIntersection(int _idxProfil, Geometry _ligne, int _idxAttrGauche, int _idxAttrDroite, + double _absCurvAxeHydrau) { + Geometry inter=_ligne.intersection((Geometry)profils_.getObject(_idxProfil)); + if (inter.getNumPoints()==1) { + Coordinate coord=inter.getCoordinate(); + int idxIntersection=UtilsProfil1d.getIndex(profils_.getGeomData().getCoordinateSequence(_idxProfil), coord); + if (_absCurvAxeHydrau<UtilsProfil1d.abscisseCurviligne(profils_.getGeomData().getCoordinateSequence(_idxProfil), coord)) + profils_.getGeomData().setAttributValue(_idxAttrDroite, _idxProfil, idxIntersection, null); + else + profils_.getGeomData().setAttributValue(_idxAttrGauche, _idxProfil, idxIntersection, null); + } + } + + /** + * Valuation des attributs composites des profils, c'est \xE0 dire des attributs + * contenant plusieurs informations d'intersection sous forme d'une liste. + * + * @param _idxAttr + * l'index de l'attribut o\xF9 sera stock\xE9 les intersections + */ + private void valuateProfilIntersection(int _idxAttr) { + // Cr\xE9ation des listes + for (int k=0; k<profils_.getNombre(); k++) { + GISAttributeModelIntegerList attrModel=new GISAttributeModelIntegerList(0, + GISAttributeConstants.INTERSECTIONS_LIGNES_DIRECTRICES); + attrModel.setListener(profils_.getGeomData()); + profils_.getGeomData().setAttributValue(_idxAttr, k, attrModel, null); + } + // Valuation de l'attribut + int k=0; + int[] lstIntersectionTmp=new int[profils_.getNombre()]; + while (k<lignesDirectrices_.getNombre()) { + Geometry ligneD=(Geometry)lignesDirectrices_.getObject(k); + // Recherche des croisements avec les profils + for (int l=0; l<profils_.getNombre(); l++) { + Geometry profil=profils_.getGeomData().getGeometry(l); + CoordinateSequence seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); + Geometry inter=((Geometry)profils_.getObject(l)).intersection(ligneD); + if (inter.getNumPoints()==0) + lstIntersectionTmp[l]=-1; + else + lstIntersectionTmp[l]=UtilsProfil1d.getIndex(seqProfil, inter.getCoordinate()); + } + // Test si au moins un croisement existe + boolean ok=false; + int m=-1; + while (!ok&&++m<lstIntersectionTmp.length) + ok=lstIntersectionTmp[m]!=-1; + if (!ok) + // Suppression de la ligne directrice qui est inutile et pas + // incr\xE9mentation de k + lignesDirectrices_.getGeomData().removeGeometries(new int[]{k}, null); + else { + for (int l=0; l<profils_.getNombre(); l++) { + // R\xE9cup\xE9ration de la liste contenant les index + GISAttributeModelIntegerList lst=(GISAttributeModelIntegerList)profils_.getGeomData().getValue(_idxAttr, l); + if (lstIntersectionTmp[l]!=-1) + // Enregistrement de l'index + lst.add(lstIntersectionTmp[l]); + else { + // Place le permier ou le dernier index \\ + // Recherche d'un point avant + int idxTest=l; + while (idxTest>=0&&lstIntersectionTmp[idxTest]==-1) + idxTest--; + if (idxTest<0) { + // Recherche d'un point apr\xE8s + idxTest=l; + while (idxTest<lstIntersectionTmp.length&&lstIntersectionTmp[idxTest]==-1) + idxTest++; + } + // Extraction d'informations sur le profils et l'axe hydraulique + Geometry profil=profils_.getGeomData().getGeometry(idxTest); + CoordinateSequence seqProfil=((GISCoordinateSequenceContainerInterface)profil).getCoordinateSequence(); + int idxAxe; + if (axeHydraulique_.getNombre()==0) + idxAxe=seqProfil.size()/2; + else { + Coordinate intersection=profil.intersection((Geometry)axeHydraulique_.getObject(0)).getCoordinate(); + idxAxe=UtilsProfil1d.getPreviousIndex(seqProfil, intersection); + if (idxAxe==-1) + idxAxe=0; + } + // Enregistrement de l'index + if (lstIntersectionTmp[idxTest]<=idxAxe) + lst.add(0); + else + lst.add(profils_.getGeomData().getCoordinateSequence(l).size()-1); + } + } + k++; + } + } + } + + /** + * Cr\xE9e un point \xE0 l'intersection du profil indiqu\xE9 par _idxProfil et de + * _ligne. + */ + private void createPointIfNeeded(int _idxProfil, GISPolyligne _ligne) { + Geometry inter=_ligne.intersection((Geometry)profils_.getObject(_idxProfil)); + CoordinateSequence seq=profils_.getGeomData().getCoordinateSequence(_idxProfil); + if (inter.getNumPoints()==1) { + Coordinate coord=inter.getCoordinate(); + int previousIdx=UtilsProfil1d.getPreviousIndex(seq, coord); + int nextIdx=UtilsProfil1d.getNextIndex(seq, coord); + // Le point n'appartient pas au profil ou La coordonn\xE9e correspond d\xE9j\xE0 \xE0 + // un point + if (previousIdx!=-2&&nextIdx!=-2&&previousIdx+1!=nextIdx-1&&nextIdx!=-1&&previousIdx!=-1) + // La coordonn\xE9e correspond \xE0 aucun point connu + ((GISZoneCollectionGeometry)profils_.getGeomData()).addAtomic(_idxProfil, previousIdx, coord.x, coord.y, null); + } + } + + /** + * Cr\xE9e un point \xE0 l'intersection du profil indiqu\xE9 par _idxProfil et de + * _ligne. Le z du point cr\xE9e prendra la valeur z du point correspondant dans + * _ligne (interpol\xE9 si n\xE9c\xE9ssaire). + */ + private void createPointIfNeededKeepZ(int _idxProfil, int _idxLigne, ZModeleLigneBrisee _modelLigne) { + GISZoneCollection zoneLigne=_modelLigne.getGeomData(); + GISZoneCollection zoneProfil=profils_.getGeomData(); + GISPolyligne ligne=(GISPolyligne)zoneLigne.getGeometry(_idxLigne); + GISPolyligne profil=(GISPolyligne)zoneProfil.getGeometry(_idxProfil); + CoordinateSequence seqLigne=zoneLigne.getCoordinateSequence(_idxLigne); + CoordinateSequence seqProfil=zoneProfil.getCoordinateSequence(_idxProfil); + Geometry intersection=ligne.intersection(profil); + if (intersection.getNumPoints()==1) { + Coordinate coordIntersection=intersection.getCoordinate(); + int previousIdx=UtilsProfil1d.getPreviousIndex(seqProfil, coordIntersection); + int nextIdx=UtilsProfil1d.getNextIndex(seqProfil, coordIntersection); + // Le point n'appartient pas au profil ou La coordonn\xE9e correspond d\xE9j\xE0 \xE0 + // un point + if (previousIdx!=-2&&nextIdx!=-2&&previousIdx+1!=nextIdx-1&&nextIdx!=-1&&previousIdx!=-1) { + // La coordonn\xE9e correspond \xE0 aucun point connu + ((GISZoneCollectionGeometry)zoneProfil).addAtomic(_idxProfil, previousIdx, coordIntersection.x, coordIntersection.y, null); + seqProfil=zoneProfil.getCoordinateSequence(_idxProfil); + } + // Valuation du z par la valeur de la ligne si _zLigne \xE0 vrai + if (zoneLigne.getAttributeIsZ()!=null) { + int idxPProfil=UtilsProfil1d.getIndex(seqProfil, coordIntersection); + int idxPLigne=UtilsProfil1d.getIndex(seqLigne, coordIntersection); + GISAttributeModel modelZLigne=zoneLigne.getModel(zoneLigne.getAttributeIsZ()); + double z; + // Si l'attribut est global + if (!zoneLigne.getAttributeIsZ().isAtomicValue()) + z=(Double)modelZLigne.getObjectValueAt(_idxLigne); + // Le point existe dans la ligne + else if (idxPLigne!=-1) + z=(Double)((GISAttributeModel)modelZLigne.getObjectValueAt(_idxLigne)).getObjectValueAt(idxPLigne); + // Le point n'existe pas => interpole une valeur + else { + // Extraction des index pr\xE9c\xE9dent et suivant \\ + int idxPrevious=UtilsProfil1d.getPreviousIndex(seqLigne, coordIntersection); + if (idxPrevious==-1) + idxPrevious=0; + Coordinate previous=seqLigne.getCoordinate(idxPrevious); + int idxNext=UtilsProfil1d.getNextIndex(seqLigne, coordIntersection); + if (idxNext==-1) + idxNext=seqLigne.size()-1; + Coordinate next=seqLigne.getCoordinate(UtilsProfil1d.getNextIndex(seqLigne, coordIntersection)); + // Cr\xE9ation d'un model temporaire contenant les z \\ + double valZ1=(Double)((GISAttributeModel)modelZLigne.getObjectValueAt(_idxLigne)).getObjectValueAt(idxPrevious); + double valZ2=(Double)((GISAttributeModel)modelZLigne.getObjectValueAt(_idxLigne)).getObjectValueAt(idxNext); + GISAttributeModelDoubleInterface zModel=new GISAttributeModelDoubleArray(new double[]{valZ1, valZ2}, zoneLigne + .getAttributeIsZ()); + // Interpolation \\ + GISCoordinateSequenceFactory factory=new GISCoordinateSequenceFactory(); + z=new GISReprojectInterpolateur1DDouble(factory.create(new Coordinate[]{previous, next}), factory + .create(new Coordinate[]{previous, new Coordinate(coordIntersection.x, coordIntersection.y, 0), next}), zModel) + .interpol(1); + } + ((GISAttributeModel)zoneProfil.getModel(zoneProfil.getAttributeIsZ()).getObjectValueAt(_idxProfil)).setObject(idxPProfil, + z, null); + } + } + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/BiefImporterFromModels.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/BiefsImporterFromModeleur2d.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/BiefsImporterFromModeleur2d.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/BiefsImporterFromModeleur2d.java 2009-02-12 17:10:04 UTC (rev 4459) @@ -0,0 +1,117 @@ +/* + * @creation 11 f\xE9vr. 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.fudaa.modeleur.modeleur1d.controller; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.fudaa.ebli.calque.BCalque; +import org.fudaa.ebli.calque.ZModeleLigneBrisee; +import org.fudaa.fudaa.commun.FudaaLib; +import org.fudaa.fudaa.modeleur.modeleur1d.model.Bief; +import org.fudaa.fudaa.sig.layer.FSigLayerLineEditable; + +/** + * Cette classe s'occupe de g\xE9rer l'importation de donn\xE9es depuis le modeleur 2d + * vers le modeleur 1d. Cette importation peut-\xEAtre faite bief par bief. Une + * hypoth\xE8se est prise dans cette classe : le calque pass\xE9 en param\xE8tre, de m\xEAme + * pour tous ses fils, ne sont pas modifi\xE9s \xE0 l'ext\xE9rieur de cette classe + * pendant toute la dur\xE9e de sa vie. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class BiefsImporterFromModeleur2d { + + /** La racine de l'arbre du 2d contenant les biefs 2d. */ + private BCalque rootCalque_; + /** La liste de nom. */ + private Map<String, Integer> names_=new HashMap<String, Integer>(); + + /** + * + * @param _rootCalque + * @param _impl peut \xEAtre null. + */ + public BiefsImporterFromModeleur2d(BCalque _rootCalque) { + if (_rootCalque==null) + throw new IllegalArgumentException(FudaaLib.getS("_rootCalque ne doit pas \xEAtre null.")); + rootCalque_=_rootCalque; + // G\xE9n\xE9ration des noms \\ + /* + * Les noms g\xE9n\xE9r\xE9s ne sont pas n\xE9c\xE9ssairement les noms donn\xE9es dans le 2d. + * La diff\xE9rence apparait quand plusieurs biefs porte le m\xEAme nom. Dans ce + * cas le nom prend la forme : nuero#nom. + */ + BCalque[] calques=rootCalque_.getCalques(); + // Extraction pour chacun des calques de son titre \\ + for (int i=0; i<calques.length; i++) + if(names_.containsKey(calques[i].getTitle())) { + // Ajout d'un num\xE9ro \xE0 la fin du nom du calque \\ + int j=2; + while(names_.containsKey(calques[i].getTitle()+" #"+j+"#")) + j++; + names_.put(calques[i].getTitle()+" #"+j+"#", i); + } + else + // Ajout simple du nom \\ + names_.put(calques[i].getTitle(), i); + } + + /** + * Les noms retourn\xE9s ne sont pas n\xE9c\xE9ssairement les noms donn\xE9es dans le 2d. + * La diff\xE9rence apparait quand plusieurs biefs porte le m\xEAme nom. Dans ce cas + * le nom prend la forme : nuero#nom. + * + * @return un tableau de String contenant les noms des biefs importables. + */ + public String[] getBiefsNames() { + return names_.keySet().toArray(new String[0]); + } + + /** + * Import le bief d\xE9fini par _name. + * + * @param _name + * le nom du bief \xE0 importer + * @return le bief construit. + * @throws CancelException + * @throws IllegalArgumentException + * si _name ne correspond \xE0 aucun bief. + */ + public Bief importBief(String _name) throws CancelException { + if (!names_.containsKey(_name)) + throw new IllegalArgumentException(FudaaLib.getS(_name+" ne correspond a aucun bief.")); + // Extraction des modeles du bief selectionn\xE9. \\ + List<ZModeleLigneBrisee> modelsBief=new ArrayList<ZModeleLigneBrisee>(); + // Iteration sur chaque calque + BCalque[] sousCalques=rootCalque_.getCalques()[names_.get(_name)].getCalques(); + for (int j=0; j<sousCalques.length; j++) + if (sousCalques[j] instanceof FSigLayerLineEditable) + modelsBief.add(((FSigLayerLineEditable)sousCalques[j]).getModele()); + // Importation du bief \\ + return new BiefImporterFromModels(modelsBief.toArray(new ZModeleLigneBrisee[0])).getBief(); + } + + /** + * Importe tous les biefs disponibles. + * @return Map<String:NomDuBief, Bief:leBief> + */ + public Map<String, Bief> importAllBiefs() { + String[] names=getBiefsNames(); + Map<String, Bief> result=new HashMap<String, Bief>(); + for(String name: names) + try { + result.put(name, importBief(name)); + } + catch (CancelException _exc) { } + return result; + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/BiefsImporterFromModeleur2d.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/CancelException.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/CancelException.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/CancelException.java 2009-02-12 17:10:04 UTC (rev 4459) @@ -0,0 +1,19 @@ +/* + * @creation 12 f\xE9vr. 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.fudaa.modeleur.modeleur1d.controller; + +/** + * Exception lev\xE9e quand quelque chose est annul\xE9 par l'utilisateur. + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class CancelException extends Exception { + public CancelException(String _message) { + super(_message); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/CancelException.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java 2009-02-11 13:54:26 UTC (rev 4458) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ControllerBief.java 2009-02-12 17:10:04 UTC (rev 4459) @@ -7,10 +7,9 @@ */ package org.fudaa.fudaa.modeleur.modeleur1d.controller; -import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; -import java.util.List; +import java.util.Map; import javax.swing.DefaultListSelectionModel; import javax.swing.event.ListSelectionListener; @@ -25,18 +24,17 @@ import org.fudaa.ctulu.gis.GISPolyligne; import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ebli.calque.BCalque; -import org.fudaa.ebli.calque.ZModeleLigneBrisee; import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; import org.fudaa.fudaa.commun.FudaaLib; import org.fudaa.fudaa.modeleur.modeleur1d.model.Bief; import org.fudaa.fudaa.modeleur.modeleur1d.model.BiefContainer; import org.fudaa.fudaa.modeleur.modeleur1d.model.BiefContainerAdapter; import org.fudaa.fudaa.modeleur.modeleur1d.model.BiefSet; +import org.fudaa.fudaa.modeleur.modeleur1d.model.UtilsBief1d; import org.fudaa.fudaa.modeleur.modeleur1d.model.UtilsProfil1d; import org.fudaa.fudaa.modeleur.modeleur1d.view.VueBief; import org.fudaa.fudaa.modeleur.modeleur1d.view.VueFusionBief; import org.fudaa.fudaa.modeleur.modeleur1d.view.VueModuleGestionBief; -import org.fudaa.fudaa.sig.layer.FSigLayerLineEditable; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateSequence; @@ -97,7 +95,7 @@ * l'indice pass\xE9 en param\xE8tre (-1 si inutilis\xE9). */ public int orderProfils(int _idx, CtuluCommandContainer _cmd) { - return biefSet_.getBief(biefSelectionModel_.getSelectedName()).orderProfils(_idx, _cmd); + return UtilsBief1d.orderProfils(biefSet_.getBief(biefSelectionModel_.getSelectedName()).profils_, _idx, _cmd); } /** @@ -108,36 +106,16 @@ return; int selectedValue=biefSelectionModel_.getMinSelectionIndex(); // Suppression des biefs pr\xE9c\xE9dents - String[] names=biefSet_.getBiefNames(); - for(int i=0;i<names.length;i++) - biefSet_.removeBief(names[i], null); - BCalque[] calques=_rootCalque.getCalques(); - // It\xE9ration du chaque bief - StringBuilder errors=new StringBuilder(); - for (int i=0; i<calques.length; i++) { - BCalque calqueBief=calques[i]; - List<ZModeleLigneBrisee> modelsDuFutureBief=new ArrayList<ZModeleLigneBrisee>(); - // Iteration sur chaque calque - BCalque[] sousCalques=calqueBief.getCalques(); - for (int j=0; j<sousCalques.length; j++) - if (sousCalques[j] instanceof FSigLayerLineEditable) - modelsDuFutureBief.add(((FSigLayerLineEditable)sousCalques[j]).getModele()); - // Ajout du bief - try { - biefSet_.addBief(calqueBief.getTitle(), modelsDuFutureBief.toArray(new ZModeleLigneBrisee[0]), null); - } - catch (IllegalArgumentException _exp) { - errors.append(FudaaLib.getS("Bief \"")+calqueBief.getTitle()+"\" : "+_exp.getMessage()+"\n"); - } - } + biefSet_.removeAllBiefs(null); + // Importation + Map<String, Bief> biefs=new BiefsImporterFromModeleur2d(_rootCalque).importAllBiefs(); + for(Map.Entry<String, Bief> entry:biefs.entrySet()) + biefSet_.addBief(entry.getKey(), entry.getValue(), null); // Ajout d'une selection if(biefSet_.getNbBief()>selectedValue&&selectedValue!=-1) biefSelectionModel_.addSelectionInterval(selectedValue, selectedValue); else if(biefSet_.getNbBief()>0&&selectedValue==-1) biefSelectionModel_.addSelectionInterval(0, 0); - // Traitement des erreurs - if(errors.length()>0) - throw new IllegalArgumentException(errors.toString()); } /** @@ -225,211 +203,226 @@ * Fusion de deux biefs. */ public void fusionnerBiefs(int _idxBief1, int _idxBief2){ - // D\xE9termine quel bief est le premier et lequel est le second (curvilignement parlant) - double bief1BaseCurv=0; - double bief2BaseCurv=0; - { // Bloque r\xE9duisant artificiellement la port\xE9 des variables + try { + // D\xE9termine quel bief est le premier et lequel est le second + // (curvilignement parlant) + double bief1BaseCurv=0; + double bief2BaseCurv=0; + { // Bloque r\xE9duisant artificiellement la port\xE9 des variables + String name1=biefSet_.getBiefName(_idxBief1); + String name2=biefSet_.getBiefName(_idxBief2); + Bief bief1=biefSet_.getBief(name1); + Bief bief2=biefSet_.getBief(name2); + + // Verifications + if (bief1==null||bief2==null) + throw new IllegalArgumentException(FudaaLib.getS("Au moins un des index ne correspond pas \xE0 un bief.")); + if (bief1.lignesDirectrices_.getNombre()!=bief2.lignesDirectrices_.getNombre()) + throw new IllegalArgumentException(FudaaLib + .getS("Il doit y avoir le m\xEAme nombre de lignes directrices dans les deux biefs.")); + if (bief1.axeHydraulique_.getNombre()!=bief2.axeHydraulique_.getNombre()) + throw new IllegalArgumentException(FudaaLib.getS("Les deux biefs doivent avoir la m\xEAme pr\xE9sence d'axe hydraulique.")); + + GISZoneCollection zoneAxeHydrau1=bief1.axeHydraulique_.getGeomData(); + if (zoneAxeHydrau1.getNumGeometries()>0) + bief1BaseCurv=(Double)zoneAxeHydrau1.getValue(zoneAxeHydrau1.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE), 0); + GISZoneCollection zoneAxeHydrau2=bief2.axeHydraulique_.getGeomData(); + if (zoneAxeHydrau2.getNumGeometries()>0) + bief2BaseCurv=(Double)zoneAxeHydrau2.getValue(zoneAxeHydrau2.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE), 0); + + // Inversion des biefs si n\xE9c\xE9ssaire + if (bief1BaseCurv>bief2BaseCurv) { + int idxTmp=_idxBief1; + _idxBief1=_idxBief2; + _idxBief2=idxTmp; + double valTmp=bief1BaseCurv; + bief1BaseCurv=bief2BaseCurv; + bief2BaseCurv=valTmp; + } + } + { // Bloque r\xE9duisant artificiellement la port\xE9 des variables + String name1=biefSet_.getBiefName(_idxBief1); + String name2=biefSet_.getBiefName(_idxBief2); + double bief1MaxCurvBrut; + double bief2MaxCurvBrut; + if (biefSet_.getBief(name1).axeHydraulique_.getGeomData().getNumGeometries()>0) { + CoordinateSequence seqAxe1=biefSet_.getBief(name1).axeHydraulique_.getGeomData().getCoordinateSequence(0); + bief1MaxCurvBrut=UtilsProfil1d.abscisseCurviligne(seqAxe1, seqAxe1.getCoordinate(seqAxe1.size()-1)); + CoordinateSequence seqAxe2=biefSet_.getBief(name2).axeHydraulique_.getGeomData().getCoordinateSequence(0); + bief2MaxCurvBrut=UtilsProfil1d.abscisseCurviligne(seqAxe2, seqAxe2.getCoordinate(seqAxe2.size()-1)); + } + else { + GISZoneCollection zone1=biefSet_.getBief(name1).profils_.getGeomData(); + bief1MaxCurvBrut=Double.parseDouble(((String)zone1.getValue(zone1.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO), + zone1.getNumGeometries()-1)).substring(3)); + GISZoneCollection zone2=biefSet_.getBief(name2).profils_.getGeomData(); + bief2MaxCurvBrut=Double.parseDouble(((String)zone2.getValue(zone2.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO), + zone2.getNumGeometries()-1)).substring(3)); + } + + if (bief1BaseCurv+bief1MaxCurvBrut>bief2BaseCurv) { + VueFusionBief vueFusionBief=new VueFusionBief(controller1d_.getFormater(), name1, bief1BaseCurv, bief1MaxCurvBrut, name2, + bief2BaseCurv, bief2MaxCurvBrut); + if (!vueFusionBief.run()) + return; + bief1BaseCurv=vueFusionBief.getAbsCurvAxe1(); + bief2BaseCurv=vueFusionBief.getAbsCurvAxe2(); + } + + // Inversion des biefs si n\xE9c\xE9ssaire + if (bief1BaseCurv>bief2BaseCurv) { + int idxTmp=_idxBief1; + _idxBief1=_idxBief2; + _idxBief2=idxTmp; + double valTmp=bief1BaseCurv; + bief1BaseCurv=bief2BaseCurv; + bief2BaseCurv=valTmp; + } + } + String name1=biefSet_.getBiefName(_idxBief1); String name2=biefSet_.getBiefName(_idxBief2); Bief bief1=biefSet_.getBief(name1); Bief bief2=biefSet_.getBief(name2); - - // Verifications - if(bief1==null||bief2==null) - throw new IllegalArgumentException(FudaaLib.getS("Au moins un des index ne correspond pas \xE0 un bief.")); - if(bief1.lignesDirectrices_.getNombre()!=bief2.lignesDirectrices_.getNombre()) - throw new IllegalArgumentException(FudaaLib.getS("Il doit y avoir le m\xEAme nombre de lignes directrices dans les deux biefs.")); - if(bief1.axeHydraulique_.getNombre()!=bief2.axeHydraulique_.getNombre()) - throw new IllegalArgumentException(FudaaLib.getS("Les deux biefs doivent avoir la m\xEAme pr\xE9sence d'axe hydraulique.")); - + // Extraction/Cr\xE9ation des axes hydrauliques GISZoneCollection zoneAxeHydrau1=bief1.axeHydraulique_.getGeomData(); - if(zoneAxeHydrau1.getNumGeometries()>0) - bief1BaseCurv=(Double)zoneAxeHydrau1.getValue(zoneAxeHydrau1.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE), 0); GISZoneCollection zoneAxeHydrau2=bief2.axeHydraulique_.getGeomData(); - if(zoneAxeHydrau2.getNumGeometries()>0) - bief2BaseCurv=(Double)zoneAxeHydrau2.getValue(zoneAxeHydrau2.getIndiceOf(GISAttributeConstants.CURVILIGNE_DECALAGE), 0); - - // Inversion des biefs si n\xE9c\xE9ssaire - if (bief1BaseCurv>bief2BaseCurv) { - int idxTmp=_idxBief1; - _idxBief1=_idxBief2; - _idxBief2=idxTmp; - double valTmp=bief1BaseCurv; - bief1BaseCurv=bief2BaseCurv; - bief2BaseCurv=valTmp; + CoordinateSequence seqAxeHydraulique1; + CoordinateSequence seqAxeHydraulique2; + boolean fakeAH=false; + if (zoneAxeHydrau1.getNbGeometries()==0) { + fakeAH=true; + // Construction d'un faux axe hydraulique + if (bief1.profils_.getNombre()>=2) { + CoordinateSequence prof1=bief1.profils_.getGeomData().getCoordinateSequence(0); + CoordinateSequence prof2=bief1.profils_.getGeomData().getCoordinateSequence(bief1.profils_.getNombre()-1); + seqAxeHydraulique1=new GISCoordinateSequenceFactory().create(new Coordinate[]{prof1.getCoordinate(prof1.size()/2), + prof2.getCoordinate(prof2.size()/2)}); + } + else if (bief1.profils_.getNombre()==1) { + CoordinateSequence prof1=bief1.profils_.getGeomData().getCoordinateSequence(0); + Coordinate coord1=prof1.getCoordinate(prof1.size()/2); + Coordinate coord2=new Coordinate(coord1.x-10, coord1.y-1, 0); + seqAxeHydraulique1=new GISCoordinateSequenceFactory().create(new Coordinate[]{coord1, coord2}); + } + else + return; + if (bief2.profils_.getNombre()>=2) { + CoordinateSequence prof1=bief2.profils_.getGeomData().getCoordinateSequence(0); + CoordinateSequence prof2=bief2.profils_.getGeomData().getCoordinateSequence(bief2.profils_.getNombre()-1); + seqAxeHydraulique2=new GISCoordinateSequenceFactory().create(new Coordinate[]{prof1.getCoordinate(prof1.size()/2), + prof2.getCoordinate(prof2.size()/2)}); + } + else if (bief2.profils_.getNombre()==1) { + CoordinateSequence prof1=bief2.profils_.getGeomData().getCoordinateSequence(0); + Coordinate coord1=prof1.getCoordinate(prof1.size()/2); + Coordinate coord2=new Coordinate(coord1.x-10, coord1.y-1, 0); + seqAxeHydraulique2=new GISCoordinateSequenceFactory().create(new Coordinate[]{coord1, coord2}); + } + else + return; } - } - { // Bloque r\xE9duisant artificiellement la port\xE9 des variables - String name1=biefSet_.getBiefName(_idxBief1); - String name2=biefSet_.getBiefName(_idxBief2); - double bief1MaxCurvBrut; - double bief2MaxCurvBrut; - if(biefSet_.getBief(name1).axeHydraulique_.getGeomData().getNumGeometries()>0) { - CoordinateSequence seqAxe1=biefSet_.getBief(name1).axeHydraulique_.getGeomData().getCoordinateSequence(0); - bief1MaxCurvBrut=UtilsProfil1d.abscisseCurviligne(seqAxe1, seqAxe1.getCoordinate(seqAxe1.size()-1)); - CoordinateSequence seqAxe2=biefSet_.getBief(name2).axeHydraulique_.getGeomData().getCoordinateSequence(0); - bief2MaxCurvBrut=UtilsProfil1d.abscisseCurviligne(seqAxe2, seqAxe2.getCoordinate(seqAxe2.size()-1)); - } else { - GISZoneCollection zone1=biefSet_.getBief(name1).profils_.getGeomData(); - bief1MaxCurvBrut=Double.parseDouble(((String) zone1.getValue(zone1.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO), zone1.getNumGeometries()-1)).substring(3)); - GISZoneCollection zone2=biefSet_.getBief(name2).profils_.getGeomData(); - bief2MaxCurvBrut=Double.parseDouble(((String) zone2.getValue(zone2.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO), zone2.getNumGeometries()-1)).substring(3)); + seqAxeHydraulique1=zoneAxeHydrau1.getCoordinateSequence(0); + seqAxeHydraulique2=zoneAxeHydrau2.getCoordinateSequence(0); } - - if(bief1BaseCurv+bief1MaxCurvBrut>bief2BaseCurv) { - VueFusionBief vueFusionBief=new VueFusionBief(controller1d_.getFormater(), name1, bief1BaseCurv, bief1MaxCurvBrut, name2, bief2BaseCurv, bief2MaxCurvBrut); - if(!vueFusionBief.run()) - return; - bief1BaseCurv=vueFusionBief.getAbsCurvAxe1(); - bief2BaseCurv=vueFusionBief.getAbsCurvAxe2(); + + Coordinate debutAxe2=UtilsProfil1d.getCoordinateXY(seqAxeHydraulique1, bief2BaseCurv-bief1BaseCurv); + Coordinate move=UtilsProfil1d.vec(seqAxeHydraulique2.getCoordinate(0), debutAxe2); + + // Construction du nouveau bief + Bief newBief=new Bief(); + String biefName=name1+"_"+name2; + int k=1; + while (biefSet_.getBief(biefName)!=null) + biefName=name1+"_"+name2+"#"+Integer.toString(++k); + // Racourcis + GISZoneCollection zoneAxeHydraulique=newBief.axeHydraulique_.getGeomData(); + GISZoneCollection zoneProfils=newBief.profils_.getGeomData(); + GISZoneCollection bief1ZoneProfil=bief1.profils_.getGeomData(); + GISZoneCollection bief2ZoneProfil=bief2.profils_.getGeomData(); + + // Ajout de g\xE9om\xE9tries au nouveau bief \\ + // Ajout des profils des biefs d'origines + int idxAttrComm=zoneProfils.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO); + for (int i=0; i<bief1.profils_.getNombre(); i++) { + int idxGeom=zoneProfils.addGeometry(bief1ZoneProfil.getGeometry(i), UtilsProfil1d.getData(i, bief1ZoneProfil), null); + if (fakeAH) { + // Dans le cas de l'utilisation de l'attribut CommentaireHydro, on + // r\xE9percute le changement de baseCurv sur les valeurs de l'attribut + String comm=(String)zoneProfils.getValue(idxAttrComm, idxGeom); + double newPK=GISLib.getHydroCommentDouble(comm, "PK")+bief1BaseCurv; + String newValue=GISLib.setHydroCommentDouble(comm, newPK, "PK"); + zoneProfils.setAttributValue(idxAttrComm, idxGeom, newValue, null); + } } - - // Inversion des biefs si n\xE9c\xE9ssaire - if (bief1BaseCurv>bief2BaseCurv) { - int idxTmp=_idxBief1; - _idxBief1=_idxBief2; - _idxBief2=idxTmp; - double valTmp=bief1BaseCurv; - bief1BaseCurv=bief2BaseCurv; - bief2BaseCurv=valTmp; + for (int i=0; i<bief2.profils_.getNombre(); i++) { + int idxGeom=zoneProfils.addGeometry(bief2ZoneProfil.getGeometry(i), UtilsProfil1d.getData(i, bief2ZoneProfil), null); + if (fakeAH) { + // Dans le cas de l'utilisation de l'attribut CommentaireHydro, on + // r\xE9percute le changement de baseCurv sur les valeurs de l'attribut + String comm=(String)zoneProfils.getValue(idxAttrComm, idxGeom); + double newPK=GISLib.getHydroCommentDouble(comm, "PK")+bief2BaseCurv; + String newValue=GISLib.setHydroCommentDouble(comm, newPK, "PK"); + zoneProfils.setAttributValue(idxAttrComm, idxGeom, newValue, null); + } } - } - - String name1=biefSet_.getBiefName(_idxBief1); - String name2=biefSet_.getBiefName(_idxBief2); - Bief bief1=biefSet_.getBief(name1); - Bief bief2=biefSet_.getBief(name2); - // Extraction/Cr\xE9ation des axes hydrauliques - GISZoneCollection zoneAxeHydrau1=bief1.axeHydraulique_.getGeomData(); - GISZoneCollection zoneAxeHydrau2=bief2.axeHydraulique_.getGeomData(); - CoordinateSequence seqAxeHydraulique1; - CoordinateSequence seqAxeHydraulique2; - boolean fakeAH=false; - if(zoneAxeHydrau1.getNbGeometries()==0) { - fakeAH=true; - // Construction d'un faux axe hydraulique - if(bief1.profils_.getNombre()>=2) { - CoordinateSequence prof1=bief1.profils_.getGeomData().getCoordinateSequence(0); - CoordinateSequence prof2=bief1.profils_.getGeomData().getCoordinateSequence(bief1.profils_.getNombre()-1); - seqAxeHydraulique1=new GISCoordinateSequenceFactory().create(new Coordinate[]{prof1.getCoordinate(prof1.size()/2), prof2.getCoordinate(prof2.size()/2)}); + // Ajout de l'axe hydraulique du second bief (utile pour la translation) + if (!fakeAH) + zoneAxeHydraulique.addGeometry(zoneAxeHydrau2.getGeometry(0), UtilsProfil1d.getData(0, zoneAxeHydrau2), null); + + // Translation du second bief \\ + // Cr\xE9ation d'une selection contenant le second axe hydraulique + if (!fakeAH) { + BitSet bs=new BitSet(1); + bs.set(0); + CtuluListSelection selection=new CtuluListSelection(bs); + // Application de la translation sur le second axe hydraulique + ((ZModeleLigneBriseeEditable)newBief.axeHydraulique_).moveGlobal(selection, move.x, move.y, 0, null); } - else if(bief1.profils_.getNombre()==1) { - CoordinateSequence prof1=bief1.profils_.getGeomData().getCoordinateSequence(0); - Coordinate coord1=prof1.getCoordinate(prof1.size()/2); - Coordinate coord2=new Coordinate(coord1.x-10, coord1.y-1, 0); - seqAxeHydraulique1=new GISCoordinateSequenceFactory().create(new Coordinate[]{coord1, coord2}); - } - else - return; - if(bief2.profils_.getNombre()>=2) { - CoordinateSequence prof1=bief2.profils_.getGeomData().getCoordinateSequence(0); - CoordinateSequence prof2=bief2.profils_.getGeomData().getCoordinateSequence(bief2.profils_.getNombre()-1); - seqAxeHydraulique2=new GISCoordinateSequenceFactory().create(new Coordinate[]{prof1.getCoordinate(prof1.size()/2), prof2.getCoordinate(prof2.size()/2)}); - } - else if(bief2.profils_.getNombre()==1) { - CoordinateSequence prof1=bief2.profils_.getGeomData().getCoordinateSequence(0); - Coordinate coord1=prof1.getCoordinate(prof1.size()/2); - Coordinate coord2=new Coordinate(coord1.x-10, coord1.y-1, 0); - seqAxeHydraulique2=new GISCoordinateSequenceFactory().create(new Coordinate[]{coord1, coord2}); - } - else - return; - } - else { - seqAxeHydraulique1=zoneAxeHydrau1.getCoordinateSequence(0); - seqAxeHydraulique2=zoneAxeHydrau2.getCoordinateSequence(0); - } - - Coordinate debutAxe2=UtilsProfil1d.getCoordinateXY(seqAxeHydraulique1, bief2BaseCurv-bief1BaseCurv); - Coordinate move=UtilsProfil1d.vec(seqAxeHydraulique2.getCoordinate(0), debutAxe2); - - // Construction du nouveau bief - Bief newBief=new Bief(); - String biefName=name1+"_"+name2; - int k=1; - while(biefSet_.getBief(biefName)!=null) - biefName=name1+"_"+name2+"#"+Integer.toString(++k); - // Racourcis - GISZoneCollection zoneAxeHydraulique=newBief.axeHydraulique_.getGeomData(); - GISZoneCollection zoneProfils=newBief.profils_.getGeomData(); - GISZoneCollection bief1ZoneProfil=bief1.profils_.getGeomData(); - GISZoneCollection bief2ZoneProfil=bief2.profils_.getGeomData(); - - // Ajout de g\xE9om\xE9tries au nouveau bief \\ - // Ajout des profils des biefs d'origines - int idxAttrComm=zoneProfils.getIndiceOf(GISAttributeConstants.COMMENTAIRE_HYDRO); - for(int i=0;i<bief1.profils_.getNombre();i++) { - int idxGeom=zoneProfils.addGeometry(bief1ZoneProfil.getGeometry(i), UtilsProfil1d.getData(i, bief1ZoneProfil), null); - if (fakeAH) { - // Dans le cas de l'utilisation de l'attribut CommentaireHydro, on - // r\xE9percute le changement de baseCurv sur les valeurs de l'attribut - String comm=(String)zoneProfils.getValue(idxAttrComm, idxGeom); - double newPK=GISLib.getHydroCommentDouble(comm, "PK")+bief1BaseCurv; - String newValue=GISLib.setHydroCommentDouble(comm, newPK, "PK"); - zoneProfils.setAttributValue(idxAttrComm, i, newValue, null); - } - } - for(int i=0;i<bief2.profils_.getNombre();i++) { - int idxGeom=zoneProfils.addGeometry(bief2ZoneProfil.getGeometry(i), UtilsProfil1d.getData(i, bief2ZoneProfil), null); - if (fakeAH) { - // Dans le cas de l'utilisation de l'attribut CommentaireHydro, on - // r\xE9percute le changement de baseCurv sur les valeurs de l'attribut - String comm=(String)zoneProfils.getValue(idxAttrComm, idxGeom); - double newPK=GISLib.getHydroCommentDouble(comm, "PK")+bief1BaseCurv; - String newValue=GISLib.setHydroCommentDouble(comm, newPK, "PK"); - zoneProfils.setAttributValue(idxAttrComm, i, newValue, null); - } - } - // Ajout de l'axe hydraulique du second bief (utile pour la translation) - if(!fakeAH) - zoneAxeHydraulique.addGeometry(zoneAxeHydrau2.getGeometry(0), Utils... [truncated message content] |
From: <bma...@us...> - 2009-06-10 20:59:21
|
Revision: 4868 http://fudaa.svn.sourceforge.net/fudaa/?rev=4868&view=rev Author: bmarchan Date: 2009-06-10 20:59:11 +0000 (Wed, 10 Jun 2009) Log Message: ----------- BugFix sur r?\195?\169ordonnancement X ou Y + test Junit sur Model2dLine Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlSceneEditor.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/SceneOrganizePointAction.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/org/fudaa/fudaa/modeleur/layer/ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/org/fudaa/fudaa/modeleur/layer/TestJModel2dLine.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlSceneEditor.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlSceneEditor.java 2009-06-10 20:53:17 UTC (rev 4867) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlSceneEditor.java 2009-06-10 20:59:11 UTC (rev 4868) @@ -10,7 +10,6 @@ import gnu.trove.TIntArrayList; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -24,7 +23,6 @@ import org.fudaa.ctulu.gis.GISAttributeInterface; import org.fudaa.ctulu.gis.GISAttributeModelDoubleArray; import org.fudaa.ctulu.gis.GISCoordinateSequenceContainerInterface; -import org.fudaa.ctulu.gis.GISCoordinateSequenceFactory; import org.fudaa.ctulu.gis.GISDataModel; import org.fudaa.ctulu.gis.GISDataModelFilterAdapter; import org.fudaa.ctulu.gis.GISDataModelMultiAdapter; @@ -410,60 +408,23 @@ /** * Sort the points of selected polylignes. This sorting is done on the - * _criterion. It can be 'x' or 'y'. + * _icoord. + * @param _icoord 0: x, 1: y. */ - public void organizePoint(String _criterion) { - /** This class contain needed data to sort points. */ - class DataPoint implements Comparable<DataPoint>{ - public Coordinate c; - private String criterion_; - public DataPoint(Coordinate coord, String _criterion) { - if(!_criterion.equals("x")&&!_criterion.equals("y")) - throw new IllegalArgumentException(FudaaLib.getS("Le crit\xE8re n'a pas \xE9t\xE9 reconnu.")); - criterion_=_criterion; - c=coord; - } - /** M\xE9thode pour utiliser les alorithmes de tris fournis par java. */ - public int compareTo(DataPoint o) { - if(criterion_.equals("x")) - return compareX(o); - else - return compareY(o); - } - public int compareX(DataPoint o) { - if (c.x<o.c.x) return -1; - else if (c.x==o.c.x) return 0; - else return 1; - } - public int compareY(DataPoint o) { - if (c.y<o.c.y) return -1; - else if (c.y==o.c.y) return 0; - else return 1; - } - } - CtuluCommandComposite cmd=new CtuluCommandComposite(FudaaLib.getS("R\xE9organisation de la g\xE9om\xE9trie")); - int[] geoms=getScene().getSelectionHelper().getSelectedIndexes(); - for (int i=0; i<geoms.length; i++) { + public void organizePoint(int _icoord) { + CtuluCommandComposite cmp=new CtuluCommandComposite(FudaaLib.getS("R\xE9organisation de la g\xE9om\xE9trie")); + int[] idxScenes=getScene().getSelectionHelper().getSelectedIndexes(); + for (int i=0; i<idxScenes.length; i++) { // Data retrieval - int idxGeom=getScene().sceneId2LayerId(geoms[i]); - ZCalqueAffichageDonneesInterface calque=getScene().getLayerForId(geoms[i]); - if (calque.modeleDonnees() instanceof ZModeleGeometry) { - GISZoneCollection zone=((ZModeleGeometry)calque.modeleDonnees()).getGeomData(); - CoordinateSequence seq=zone.getCoordinateSequence(idxGeom); - // Construction de la structure de tri - DataPoint[] points=new DataPoint[seq.size()]; - for(int j=0;j<points.length;j++) - points[j]=new DataPoint(seq.getCoordinate(j), _criterion); - Arrays.sort(points); - // R\xE9percution du tri - Coordinate[] coords=new Coordinate[points.length]; - for(int j=0;j<points.length;j++) - coords[j]=new Coordinate(points[j].c); - zone.setCoordinateSequence(idxGeom, new GISCoordinateSequenceFactory().create(coords), cmd); - } + int idxGeom=getScene().sceneId2LayerId(idxScenes[i]); + ZModeleDonnees mdld=getScene().getLayerForId(idxScenes[i]).modeleDonnees(); + + if (mdld instanceof MdlModel2dLine) + ((MdlModel2dLine)mdld).organizePoints(idxGeom, _icoord, cmp); } + if(getMng()!=null) - getMng().addCmd(cmd.getSimplify()); + getMng().addCmd(cmp.getSimplify()); } /** Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/SceneOrganizePointAction.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/SceneOrganizePointAction.java 2009-06-10 20:53:17 UTC (rev 4867) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/action/SceneOrganizePointAction.java 2009-06-10 20:59:11 UTC (rev 4868) @@ -56,6 +56,6 @@ } public void actionPerformed(final ActionEvent _e) { - sceneEditor_.organizePoint(criterion_); + sceneEditor_.organizePoint(criterion_==x ? 0:1); } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java 2009-06-10 20:53:17 UTC (rev 4867) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java 2009-06-10 20:59:11 UTC (rev 4868) @@ -9,15 +9,19 @@ import gnu.trove.TIntArrayList; +import java.util.Arrays; + import org.fudaa.ctulu.CtuluCommandComposite; import org.fudaa.ctulu.CtuluCommandContainer; import org.fudaa.ctulu.CtuluListSelection; import org.fudaa.ctulu.CtuluListSelectionInterface; import org.fudaa.ctulu.CtuluNamedCommand; import org.fudaa.ctulu.gis.GISAttributeModel; +import org.fudaa.ctulu.gis.GISCoordinateSequenceFactory; import org.fudaa.ctulu.gis.GISGeometryFactory; import org.fudaa.ctulu.gis.GISLib; import org.fudaa.ctulu.gis.GISPolyligne; +import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; import org.fudaa.ebli.calque.ZModelGeometryListener; import org.fudaa.ebli.calque.ZModelListener; @@ -216,4 +220,57 @@ }); } } + + /** + * Sort the points of selected polylignes. This sorting is done on the _icoord. + * @param _icoord 0: x, 1: y. + */ + public void organizePoints(int _idxGeom, int _icoord, CtuluCommandContainer _cmd) { + + /** This class contain needed data to sort points. */ + class SortableIndex implements Comparable<SortableIndex>{ + public double coord; + private int ind; + public SortableIndex(double _coord, int _ind) { + ind=_ind; + coord=_coord; + } + + public int compareTo(SortableIndex o) { + if (coord<o.coord) return -1; + else if (coord==o.coord) return 0; + else return 1; + } + } + + CtuluCommandComposite cmp=new CtuluCommandComposite(FudaaLib.getS("R\xE9organisation de la g\xE9om\xE9trie")); + + GISZoneCollection zone=getGeomData(); + CoordinateSequence oldseq=zone.getCoordinateSequence(_idxGeom); + // Construction de la structure de tri + SortableIndex[] points=new SortableIndex[oldseq.size()]; + for(int j=0;j<points.length;j++) + points[j]=new SortableIndex(oldseq.getOrdinate(j,_icoord), j); + Arrays.sort(points); + + // Remplacement de la g\xE9om\xE9trie r\xE9ordonn\xE9e. + Coordinate[] coords=new Coordinate[points.length]; + for(int j=0;j<points.length;j++) + coords[j]=oldseq.getCoordinateCopy(points[j].ind); + zone.setCoordinateSequence(_idxGeom, new GISCoordinateSequenceFactory().create(coords), cmp); + + // R\xE9ordonnancement des attributs atomiques. + for(int iatt=0;iatt<zone.getNbAttributes();iatt++) + if(zone.getAttribute(iatt).isAtomicValue()){ + GISAttributeModel oldvalues=(GISAttributeModel) zone.getDataModel(iatt).getObjectValueAt(_idxGeom); + GISAttributeModel newvalues=(GISAttributeModel)zone.getDataModel(iatt).getAttribute().createDataForGeom(oldvalues, oldvalues.getSize()); + for(int j=0;j<oldvalues.getSize();j++){ + newvalues.setObject(j,oldvalues.getObjectValueAt(points[j].ind), null); + } + zone.setAttributValue(iatt, _idxGeom,newvalues,cmp); + } + + if(_cmd!=null) + _cmd.addCmd(cmp.getSimplify()); + } } Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/org/fudaa/fudaa/modeleur/layer/TestJModel2dLine.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/org/fudaa/fudaa/modeleur/layer/TestJModel2dLine.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/org/fudaa/fudaa/modeleur/layer/TestJModel2dLine.java 2009-06-10 20:59:11 UTC (rev 4868) @@ -0,0 +1,244 @@ +/* + * @creation 10 juin 2009 + * @modification $Date:$ + * @license GNU General Public License 2 + * @copyright (c)1998-2009 CETMEF 2 bd Gambetta F-60231 Compiegne + * @mail fud...@li... + */ +package org.fudaa.fudaa.modeleur.layer; + +import junit.framework.TestCase; + +import org.fudaa.ctulu.CtuluCommandManager; +import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISAttributeInterface; +import org.fudaa.ctulu.gis.GISAttributeModel; +import org.fudaa.ctulu.gis.GISGeometryFactory; +import org.fudaa.ctulu.gis.GISPolyligne; + +import com.vividsolutions.jts.geom.Coordinate; + +/** + * @author Bertrand Marchand + * @version $Id:$ + */ + +/** + * Pour tester un modele de lignes 2D. + * @author Bertrand Marchand + * @version $Id$ + */ +public class TestJModel2dLine extends TestCase { + + static final double[][] coords_={ + {752.8254,1021.2861, 513.0 }, + {742.6896,1021.5333, 513.0 }, + {732.5538,1021.7806, 513.0 }, + {722.418 ,1022.0278, 513.0 }, + {712.2822,1022.275 , 513.0 }, + {702.1464,1022.5222, 513.0 }, + {692.0107,1022.7694, 513.0 }, + {681.8749,1023.0166, 512.0 }, + {671.7391,1023.2638, 512.6667 }, + {671.7391,1023.2638, 512.6667 }, + {665.8059,1023.5935, 512.6667 }, + {665.8059,1023.5935, 513.3333 }, + {665.8059,1023.5935, 513.3333 }, + {656.9062,1024.0879, 513.3333 }, + {646.3434,1024.1628, 514.0 }, + {635.7806,1024.2377, 514.0 }, + {625.2179,1024.3126, 514.0 }, + {614.6551,1024.3875, 514.0 }, + {604.0923,1024.4625, 514.0 }, + {593.5295,1024.5374, 514.0 }, + {582.9667,1024.6123, 514.0 }, + {572.4039,1024.6872, 514.0 }, + {561.8411,1024.7621, 514.0 }, + {551.2783,1024.837 , 514.0 }, + {540.7155,1024.9119, 514.0 }, + {540.7155,1024.9119, 514.0 }, + {534.5191,1023.9461, 514.0 }, + {534.5191,1023.9461, 514.0 }, + {528.3226,1022.9803, 514.0 }, + {528.3226,1022.9803, 514.0 }, + {522.1262,1022.0144, 514.0 }, + {514.7445,1021.9455, 514.0 }, + {507.3628,1021.8765, 514.0 }, + {499.9811,1021.8075, 514.0 }, + {492.5993,1021.7385, 514.0 }, + {485.2176,1021.6695, 514.0 }, + {477.8359,1021.6005, 514.0 }, + {470.4542,1021.5315, 513.8333 }, + {463.0725,1021.4625, 513.6667 }, + {455.6908,1021.3936, 513.5 }, + {448.3091,1021.3246, 513.3333 }, + {440.9274,1021.2556, 513.1667 }, + {433.5456,1021.1866, 513.0 }, + {433.5456,1021.1866, 512.8333 }, + {427.4747,1021.1866, 512.6667 }, + {427.4747,1021.1866, 512.5 }, + {421.4038,1021.1866, 512.3333 }, + {421.4038,1021.1866, 512.1667 }, + {415.3328,1021.1866, 512.0 }, + {409.5378,1021.2901, 512.0 }, + {403.7428,1021.3936, 512.0 }, + {397.9479,1021.497 , 512.0 }, + {392.1529,1021.6005, 512.0 }, + {386.3579,1021.704 , 512.0 }, + {380.5629,1021.8075, 512.0 }, + {374.7679,1021.911 , 512.5 }, + {368.9729,1022.0144, 513.0 }, + {368.9729,1022.0144, 513.5 }, + {368.9729,1022.0144, 514.0 }, + {361.5222,1021.1866, 514.5 }, + {361.5222,1021.1866, 515.0 }, + {361.5222,1021.1866,515.5 }, + {354.0715,1020.3587,516.0 }, + {354.0715,1020.3587, 516.5 }, + {354.0715,1020.3587, 517.0 }, + {347.1727,1020.6347, 517.5 }, + {347.1727,1020.6347, 517.5 }, + {347.1727,1020.6347, 517.5 }, + {340.2739,1020.9106, 517.5 }, + {340.2739,1020.9106, 517.5 }, + {340.2739,1020.9106, 517.5 }, + {333.3751,1021.1866, 517.55 } + }; + + /** Le mod\xE8le */ + static MdlModel2dLine mdl; + /** Des labels pos\xE9s sur des coordonn\xE9es particuli\xE8res */ + static int[] indLabels; + /** Le manager de commandes. */ + static CtuluCommandManager mng; + + /** Initialisation du test */ + static { + mdl=new MdlModel2dLine(null); + + // Cr\xE9ation d'une polyligne. + Coordinate[] coords=new Coordinate[coords_.length]; + for (int i=0; i<coords.length; i++) { + coords[i]=new Coordinate(coords_[i][0],coords_[i][1],coords_[i][2]); + } + GISPolyligne pl=GISGeometryFactory.INSTANCE.createLineString(coords); + mdl.getGeomData().addGeometry(pl, null, null); + + // Ajout des attributs Z et Label + mdl.getGeomData().setAttributes(new GISAttributeInterface[]{GISAttributeConstants.BATHY, GISAttributeConstants.LABEL},null); + + // Pour initialiser le Z Attribute depuis le Z coordinate. + mdl.getGeomData().postImport(0); + + // Definition de 3 labels. + int iattLb=mdl.getGeomData().getIndiceOf(GISAttributeConstants.LABEL); + indLabels=new int[]{3,8,9}; + for (int i=0; i<indLabels.length; i++) { + ((GISAttributeModel)mdl.getGeomData().getValue(iattLb, 0)).setObject(indLabels[i],"Pt"+indLabels[i],null); + } + + // Le manager de undo/redo + mng=new CtuluCommandManager(); + } + + /** + * Teste l'inversion d'orientation d'une ligne. + * Le parcours est invers\xE9, les attributs doivent correspondre. + */ + public void testInvertOrientation() { + assertEquals(mdl.getNombre(),1); + int iattLb=mdl.getGeomData().getIndiceOf(GISAttributeConstants.LABEL); + + GISPolyligne pl=(GISPolyligne)mdl.getGeomData().getGeometry(0); + int ilast=pl.getNumPoints()-1; + double x1=pl.getCoordinateSequence().getX(2); + double y1=pl.getCoordinateSequence().getY(2); + String lb11=(String)((GISAttributeModel)mdl.getGeomData().getValue(iattLb, 0)).getObjectValueAt(3); + String lb12=(String)((GISAttributeModel)mdl.getGeomData().getValue(iattLb, 0)).getObjectValueAt(8); + String lb13=(String)((GISAttributeModel)mdl.getGeomData().getValue(iattLb, 0)).getObjectValueAt(9); + + mdl.invertOrientation(0,mng); + + pl=(GISPolyligne)mdl.getGeomData().getGeometry(0); + double x2=pl.getCoordinateSequence().getX(ilast-2); + double y2=pl.getCoordinateSequence().getY(ilast-2); + String lb21=(String)((GISAttributeModel)mdl.getGeomData().getValue(iattLb, 0)).getObjectValueAt(ilast-3); + String lb22=(String)((GISAttributeModel)mdl.getGeomData().getValue(iattLb, 0)).getObjectValueAt(ilast-8); + String lb23=(String)((GISAttributeModel)mdl.getGeomData().getValue(iattLb, 0)).getObjectValueAt(ilast-9); + + assertEquals(y1, y2,0); + assertEquals(x1, x2,0); + assertEquals(lb11, lb21); + assertEquals(lb12, lb22); + assertEquals(lb13, lb23); + + // Reset. + mng.undo(); + } + + /** + * Teste la r\xE9organisation d'une ligne suivant X. + * Le parcours est ordonn\xE9 croissant suivant X, les attributs doivent correspondre. + */ + public void testOrganizeX() { + int iattLb=mdl.getGeomData().getIndiceOf(GISAttributeConstants.LABEL); + + GISPolyligne pl=(GISPolyligne)mdl.getGeomData().getGeometry(0); + // La coordonn\xE9e et le label correspondant. + Coordinate c1=pl.getCoordinateSequence().getCoordinate(indLabels[0]); + String lb1=(String)((GISAttributeModel)mdl.getGeomData().getValue(iattLb, 0)).getObjectValueAt(indLabels[0]); + // Le label doit \xEAtre le bon (sinon peut \xEAtre le test pr\xE9cedent est invalide). + assertEquals(lb1, "Pt"+indLabels[0]); + + mdl.organizePoints(0,0,mng); + + pl=(GISPolyligne)mdl.getGeomData().getGeometry(0); + boolean found=false; + for (int i=0; i<pl.getNumPoints()-1; i++) { + // Les coordonn\xE9es doivent \xEAtre croissantes en X + assertTrue(pl.getCoordinateSequence().getX(i+1)>=pl.getCoordinateSequence().getX(i)); + if (pl.getCoordinateSequence().getCoordinate(i).equals2D(c1)) { + // Le label doit toujours correspondre \xE0 la coordonn\xE9e. + assertEquals(lb1,(String)((GISAttributeModel)mdl.getGeomData().getValue(iattLb, 0)).getObjectValueAt(i)); + found=true; + } + } + assertTrue(found); + + // Reset. + mng.undo(); + } + + /** + * Teste la r\xE9organisation d'une ligne suivant Y. + * Le parcours est ordonn\xE9 croissant suivant Y, les attributs doivent correspondre. + */ + public void testOrganizeY() { + int iattLb=mdl.getGeomData().getIndiceOf(GISAttributeConstants.LABEL); + + GISPolyligne pl=(GISPolyligne)mdl.getGeomData().getGeometry(0); + // La coordonn\xE9e et le label correspondant. + Coordinate c1=pl.getCoordinateSequence().getCoordinate(indLabels[0]); + String lb1=(String)((GISAttributeModel)mdl.getGeomData().getValue(iattLb, 0)).getObjectValueAt(indLabels[0]); + // Le label doit \xEAtre le bon (sinon peut \xEAtre le test pr\xE9cedent est invalide). + assertEquals(lb1, "Pt"+indLabels[0]); + + mdl.organizePoints(0,1,mng); + + pl=(GISPolyligne)mdl.getGeomData().getGeometry(0); + boolean found=false; + for (int i=0; i<pl.getNumPoints()-1; i++) { + // Les coordonn\xE9es doivent \xEAtre croissantes en Y + assertTrue(pl.getCoordinateSequence().getY(i+1)>=pl.getCoordinateSequence().getY(i)); + if (pl.getCoordinateSequence().getCoordinate(i).equals2D(c1)) { + // Le label doit toujours correspondre \xE0 la coordonn\xE9e. + assertEquals(lb1,(String)((GISAttributeModel)mdl.getGeomData().getValue(iattLb, 0)).getObjectValueAt(i)); + found=true; + } + } + assertTrue(found); + + // Reset. + mng.undo(); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/org/fudaa/fudaa/modeleur/layer/TestJModel2dLine.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |