From: <emm...@us...> - 2008-12-22 14:50:16
|
Revision: 4312 http://fudaa.svn.sourceforge.net/fudaa/?rev=4312&view=rev Author: emmanuel_martin Date: 2008-12-22 14:50:07 +0000 (Mon, 22 Dec 2008) Log Message: ----------- Ajout de l'export mascaret 1d et 2d ; r?\195?\169organisation du d?\195?\169coupage en package des sources modeleur 1d ; Construction d'une premi?\195?\168re version des vues des modules biefs et profils (les controleurs ne sont pas faits). Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretFileFormat.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretReader.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlProjectExportPanel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/MdlFille1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/testModeleur1d/TestDataGeometryAdapter.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataError.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataIncomplete.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretProfilAbstractRepresentation.java branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/controller/Controller1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/DataGeometry.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/DataGeometryAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/DataGeometryException.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/DataGeometryListener.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/model/UtilsProfil1d.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueBief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueContainerModules.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueCourbe.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueExport.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionBief.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueModuleGestionProfil.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/view/VueTableau.java Removed 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/DataGeometryException.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryListener.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/VueBief.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 Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2008-12-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISAttributeConstants.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -11,11 +11,10 @@ import java.util.Arrays; import java.util.List; +import org.fudaa.ctulu.CtuluLib; import org.fudaa.ctulu.CtuluLibString; import org.fudaa.ctulu.gui.CtuluValueEditorChoice; -import org.fudaa.ctulu.CtuluLib; - import com.memoire.fu.FuLib; /** @@ -57,6 +56,10 @@ public final static String ATT_NATURE_CE="CE"; /** Nature axe hydraulique */ public final static String ATT_NATURE_AH="AH"; + /** Nature limite de stockage (gauche ou droite) */ + public final static String ATT_NATURE_LS="LS"; + /** Nature rive (gauche ou droite) */ + public final static String ATT_NATURE_RV="RV"; /** * Un attribut nom, global. @@ -263,4 +266,54 @@ } return false; } + + // Attributs 1D \\ + + /** + * Attribut contenant la coordonn\xE9e de l'intersection entre une rive gauche et + * un profil. La donn\xE9e sauvgard\xE9e est une coordonn\xE9e (Coordinate). + */ + public final static GISAttribute INTERSECTION_RIVE_GAUCHE=new GISAttribute(null, CtuluLib.getS("Intersection rive gauche"), false){ + @Override + public String getID() { + return "ATTRIBUTE_INTERSECTION_RIVE_GAUCHE"; + } + }; + + /** + * Attribut contenant la coordonn\xE9e de l'intersection entre une rive droite et + * un profil. La donn\xE9e sauvgard\xE9e est une coordonn\xE9e (Coordinate). + */ + public final static GISAttribute INTERSECTION_RIVE_DROITE=new GISAttribute(null, CtuluLib.getS("Intersection rive droite"), false){ + @Override + public String getID() { + return "ATTRIBUTE_INTERSECTION_RIVE_DROITE"; + } + }; + + /** + * Attribut contenant la coordonn\xE9e de l'intersection entre une limite de + * stockage gauche et un profil. La donn\xE9e sauvgard\xE9e est une coordonn\xE9e + * (Coordinate). + */ + public final static GISAttribute INTERSECTION_LIMITE_STOCKAGE_GAUCHE=new GISAttribute(null, CtuluLib + .getS("Intersection limite stockage gauche"), false){ + @Override + public String getID() { + return "ATTRIBUTE_INTERSECTION_LIMITE_STOCKAGE_GAUCHE"; + } + }; + + /** + * Attribut contenant la coordonn\xE9e de l'intersection entre une limite de + * stockage droite et un profil. La donn\xE9e sauvgard\xE9e est une coordonn\xE9e + * (Coordinate). + */ + public final static GISAttribute INTERSECTION_LIMITE_STOCKAGE_DROITE=new GISAttribute(null, CtuluLib + .getS("Intersection limite stockage droite"), false){ + @Override + public String getID() { + return "ATTRIBUTE_INTERSECTION_LIMITE_STOCKAGE_DROITE"; + } + }; } Copied: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataError.java (from rev 4305, branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java) =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataError.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataError.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -0,0 +1,22 @@ +/* + * @creation 19 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.dodico.mascaret.io; + +/** + * Exception utilis\xE9 par MascaretWriter indiquant que des donn\xE9es sont + * incoh\xE9rentes et rendent ainsi impossible l'export. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class MascaretDataError extends Exception { + + public MascaretDataError(String _msg){ + super(_msg); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataError.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:mergeinfo + /branches/Br_FudaaModeleur_TF/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java:3445-3850 /branches/FudaaModeleur_TC1/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java:3861-3891 Added: svn:eol-style + native Copied: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataIncomplete.java (from rev 4305, branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java) =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataIncomplete.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataIncomplete.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -0,0 +1,22 @@ +/* + * @creation 19 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.dodico.mascaret.io; + +/** + * Exception utilis\xE9 par MascaretWriter indiquant que des g\xE9om\xE9tries manque pour + * g\xE9n\xE9rer le fichier. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class MascaretDataIncomplete extends Exception { + + public MascaretDataIncomplete(String _msg){ + super(_msg); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretDataIncomplete.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:mergeinfo + /branches/Br_FudaaModeleur_TF/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java:3445-3850 /branches/FudaaModeleur_TC1/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java:3861-3891 Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretFileFormat.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretFileFormat.java 2008-12-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretFileFormat.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -1,6 +1,6 @@ /* * @creation 13 nov. 2008 - * @modification $Date:$ + * @modification $Date$ * @license GNU General Public License 2 * @copyright (c)1998-2008 CETMEF 2 bd Gambetta F-60231 Compiegne * @mail fud...@li... Copied: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretProfilAbstractRepresentation.java (from rev 4305, branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java) =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretProfilAbstractRepresentation.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretProfilAbstractRepresentation.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -0,0 +1,74 @@ +/* + * @creation 19 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.dodico.mascaret.io; + +import java.util.ArrayList; +import java.util.List; + +/** + * Container des informations relative \xE0 un profil. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class MascaretProfilAbstractRepresentation { + public String nomBief; + public String nomProfil; + public List<Double> coordZ=new ArrayList<Double>(); // Bathy ou Topo + public List<Character> bathyOuTopoOuStockage=new ArrayList<Character>(); // B ou T ou S + // Info sp\xE9cifique 1D + public double abscisseCurvilingeAxeHydraulique; + public List<Double> coordCurviligneProfil=new ArrayList<Double>(); + // Info sp\xE9cifique 2D + public List<double[]> coordXYTraceProfil=new ArrayList<double[]>(); + public double[] coordIntersectionAxeHydraulique; + public List<double[]> coordXYProfil=new ArrayList<double[]>(); + + /** @return vrai si seul des informations 1d sont pr\xE9sentes. */ + public boolean is1d(){ + return coordCurviligneProfil.size()>0&&coordXYTraceProfil.size()==0&&coordIntersectionAxeHydraulique==null + &&coordXYProfil.size()==0; + } + + /** @return vrai si les informations 2d sont pr\xE9sentes. (les infos 1d peuvent \xEAtre \xE9galement pr\xE9sentes) */ + public boolean is2d(){ + return (coordXYTraceProfil.size()!=0||coordIntersectionAxeHydraulique!=null&&coordIntersectionAxeHydraulique.length!=0||coordXYProfil + .size()!=0); + } + + /** Check les attributs communs \xE0 1d et 2d. */ + private boolean checkCommon(){ + boolean check=nomBief.length()>0&&nomProfil.length()>0&&coordZ.size()>0&&bathyOuTopoOuStockage.size()==coordZ.size(); + int i=-1; + // Verifi que bathyOuTopo ne comporte que B ou T + while(check&&++i<bathyOuTopoOuStockage.size()) + check=bathyOuTopoOuStockage.get(i).equals('T')||bathyOuTopoOuStockage.get(i).equals('B')||bathyOuTopoOuStockage.get(i).equals('S'); + return check; + } + + /** @return vrai si les informations utile 1D sont compl\xE8tes et coh\xE9rentes. */ + public boolean check1D(){ + boolean check=checkCommon()&&abscisseCurvilingeAxeHydraulique>=0&&coordCurviligneProfil.size()==coordZ.size(); + int i=0; + // Verifi que l'ordre des coordonn\xE9es est croissant. + while(check&&++i<coordCurviligneProfil.size()) + check=coordCurviligneProfil.get(i-1)<=coordCurviligneProfil.get(i); + return check; + } + + /** @return vrai si les informations utile 2D sont compl\xE8tes et coh\xE9rentes. */ + public boolean check2D(){ + boolean check=checkCommon()&&coordXYTraceProfil.size()>=2&&coordXYTraceProfil.size()<=4 + &&coordIntersectionAxeHydraulique.length==2&&coordXYProfil.size()==coordZ.size(); + // Verification de la taille des coordonn\xE9es XY du profile + int i=-1; + while(check&&++i<coordXYProfil.size()) + check=coordXYProfil.get(i).length==2; + return check; + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretProfilAbstractRepresentation.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:mergeinfo + /branches/Br_FudaaModeleur_TF/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java:3445-3850 /branches/FudaaModeleur_TC1/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryException.java:3861-3891 Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretReader.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretReader.java 2008-12-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretReader.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -32,66 +32,6 @@ */ public class MascaretReader extends FileReadOperationAbstract { - /** - * Container des informations relative \xE0 un profil. - */ - private class Profil{ - public String nomBief; - public String nomProfil; - public List<Double> coordZ=new ArrayList<Double>(); // Bathy ou Topo - public List<Character> bathyOuTopo=new ArrayList<Character>(); // B ou T - // Info sp\xE9cifique 1D - public double abscisseCurvilingeAxeHydraulique; - public List<Double> coordCurviligneProfil=new ArrayList<Double>(); - // Info sp\xE9cifique 2D - public List<double[]> coordXYTraceProfil=new ArrayList<double[]>(); - public double[] coordIntersectionAxeHydraulique; - public List<double[]> coordXYProfil=new ArrayList<double[]>(); - - /** @return vrai si seul des informations 1d sont pr\xE9sentes. */ - public boolean is1d(){ - return coordCurviligneProfil.size()>0&&coordXYTraceProfil.size()==0&&coordIntersectionAxeHydraulique==null - &&coordXYProfil.size()==0; - } - - /** @return vrai si les informations 2d sont pr\xE9sentes. (les infos 1d peuvent \xEAtre \xE9galement pr\xE9sentes) */ - public boolean is2d(){ - return (coordXYTraceProfil.size()!=0||coordIntersectionAxeHydraulique!=null&&coordIntersectionAxeHydraulique.length!=0||coordXYProfil - .size()!=0); - } - - /** Check les attributs communs \xE0 1d et 2d. */ - private boolean checkCommon(){ - boolean check=nomBief.length()>0&&nomProfil.length()>0&&coordZ.size()>0&&bathyOuTopo.size()==coordZ.size(); - int i=-1; - // Verifi que bathyOuTopo ne comporte que B ou T - while(check&&++i<bathyOuTopo.size()) - check=bathyOuTopo.get(i).equals('T')||bathyOuTopo.get(i).equals('B'); - return check; - } - - /** @return vrai si les informations utile 1D sont compl\xE8tes et coh\xE9rentes. */ - public boolean check1D(){ - boolean check=checkCommon()&&abscisseCurvilingeAxeHydraulique>=0&&coordCurviligneProfil.size()==coordZ.size(); - int i=0; - // Verifi que l'ordre des coordonn\xE9es est croissant. - while(check&&++i<coordCurviligneProfil.size()) - check=coordCurviligneProfil.get(i-1)<=coordCurviligneProfil.get(i); - return check; - } - - /** @return vrai si les informations utile 2D sont compl\xE8tes et coh\xE9rentes. */ - public boolean check2D(){ - boolean check=checkCommon()&&coordXYTraceProfil.size()>=2&&coordXYTraceProfil.size()<=4 - &&coordIntersectionAxeHydraulique.length==2&&coordXYProfil.size()==coordZ.size(); - // Verification de la taille des coordonn\xE9es XY du profile - int i=-1; - while(check&&++i<coordXYProfil.size()) - check=coordXYProfil.get(i).length==2; - return check; - } - } - /** Exception lev\xE9e quand une probl\xE8me est trouv\xE9 pendant le parsing. */ private class ParseError extends Exception{ public ParseError(String _message){ @@ -106,7 +46,7 @@ private char[] charSeparation_=new char[]{' ', '\t'}; private char charSeparationNewLigne_='\n'; /** Profiles extraits */ - List<Profil> profils_=new ArrayList<Profil>(); + List<MascaretProfilAbstractRepresentation> profils_=new ArrayList<MascaretProfilAbstractRepresentation>(); public MascaretReader() { rawData_=null; @@ -183,7 +123,7 @@ */ String token=nextWordToken(lineToken); while (lineToken!=null&&token.equalsIgnoreCase("profil")) { - Profil profil=new Profil(); + MascaretProfilAbstractRepresentation profil=new MascaretProfilAbstractRepresentation(); // Premi\xE8re ligne \\ // Extraction des informations commune \xE0 1d et 2d @@ -206,7 +146,7 @@ while (lineToken!=null&&!(token=nextWordToken(lineToken)).equalsIgnoreCase("profil")) { profil.coordCurviligneProfil.add(Double.parseDouble(token)); profil.coordZ.add(Double.parseDouble(nextWordToken(lineToken))); - profil.bathyOuTopo.add(nextWordToken(lineToken).charAt(0)); + profil.bathyOuTopoOuStockage.add(nextWordToken(lineToken).charAt(0)); // Coordonn\xE9es XY : non pr\xE9sent dans les fichiers 1d token=nextWordToken(lineToken); if (token!=null) @@ -245,7 +185,7 @@ // G\xE9n\xE9ration des profiles et des traces de profiles \\ for(int k=0;k<profils_.size();k++){ progress_.setProgression((int)((float)k/profils_.size()*100)); - Profil profil=profils_.get(k); + MascaretProfilAbstractRepresentation profil=profils_.get(k); CoordinateArraySequence coordSeq=new CoordinateArraySequence(profil.coordXYTraceProfil.size()); // Trace profil for(int i=0;i<profil.coordXYTraceProfil.size();i++){ Copied: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java (from rev 4303, branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryListener.java) =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -0,0 +1,372 @@ +/* + * @creation 19 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.dodico.mascaret.io; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.fudaa.ctulu.CtuluAnalyze; +import org.fudaa.ctulu.fileformat.FileWriteOperationAbstract; +import org.fudaa.ctulu.fileformat.FortranInterface; +import org.fudaa.ctulu.gis.GISAttributeConstants; +import org.fudaa.ctulu.gis.GISAttributeModelDoubleInterface; +import org.fudaa.ctulu.gis.GISGeometryFactory; +import org.fudaa.ctulu.gis.GISPoint; +import org.fudaa.ctulu.gis.GISPolyligne; +import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; + +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.CoordinateSequence; +import com.vividsolutions.jts.geom.Geometry; + +/** + * Ecrit au format mascaret 1d et 2d. + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class MascaretWriter extends FileWriteOperationAbstract { + + /** Le flux de sorti. */ + private Writer out_; + /** Les profils \xE0 \xE9crire. */ + private MascaretProfilAbstractRepresentation[] profils_; + /** Version du fichier mascaret de destination. */ + private String version_; + + /** + * Cette classe permet \xE0 l'exporteur de selectionner les + * profils \xE0 exporter. G\xE9n\xE9ralement les profiles invalides sont ignor\xE9s. + * @author Emmanuel MARTIN + * @version $Id:$ + */ + public interface FunctorSelectProfil { + public boolean exportProfil(GISZoneCollectionLigneBrisee _zone, int _idxProfil); + } + + public MascaretWriter() {} + + /** + * L'argument doit \xEAtre un tableau contenant : + * 0 : string : le nom du bief + * 1 : GISZoneCollectionLigneBrisee[] : les zones dans lesquelles trouver les g\xE9om\xE9tries + * 2 : FunctorSelectProfil : pour selectionner les profils \xE0 exporter + * 3 : string : la version du fichier mascaret g\xE9n\xE9r\xE9 + * + * On passe en param\xE8tre les diff\xE9rentes GISZoneCollectionLigneBrisee qui + * contiennent les g\xE9om\xE9tries n\xE9c\xE9ssaires \xE0 l'exportation. Ces zone peuvent + * contenir des g\xE9om\xE9tries incompatible avec l'export (comme des polygones), + * elles seront simplement ignor\xE9es. Dans le cas o\xF9 des g\xE9om\xE9tries manqueront, + * une exception du type MascaretDataIncomplete est lev\xE9e. Les profils invalides + * sont \xE9galements ignor\xE9s. Si certaines donn\xE9es sont incoh\xE9rentes une exception + * du type MascaretDataError est lev\xE9e. La version du fichier de destination ('1d' + * ou '2d'). Si un des trois param\xE8tres est null une exception de type + * {@link IllegalArgumentException} est lev\xE9e, si version n'est pas soit '1d' + * soit '2d' (case ignor\xE9e) la m\xEAme exception est lev\xE9e. + */ + @Override + protected void internalWrite(Object _o) { + try { + if(((Object[])_o).length!=4) + throw new IllegalArgumentException("Il doit y avoir 4 param\xE8tres dans _o."); + String nomBief=(String)((Object[])_o)[0]; + GISZoneCollectionLigneBrisee[] zones=(GISZoneCollectionLigneBrisee[])((Object[])_o)[1]; + FunctorSelectProfil selectorProfil=(FunctorSelectProfil)((Object[])_o)[2]; + version_=(String)((Object[])_o)[3]; + if (nomBief==null) + throw new IllegalArgumentException("nomBief ne doit pas \xEAtre null"); + if (zones==null) + throw new IllegalArgumentException("zones mustn't be null"); + if (version_==null||!version_.equalsIgnoreCase("1d")&&!version_.equalsIgnoreCase("2d")) + throw new IllegalArgumentException("version doit \xEAtre \xE9gale \xE0 1d ou 2d"); + generateMascaretProfilAbstractRepresentations(nomBief, zones, selectorProfil); + + for (int i=0; i<profils_.length; i++) { + MascaretProfilAbstractRepresentation profil=profils_[i]; + // Premi\xE8re ligne + out_.write("Profil "+profil.nomBief+" "+profil.nomProfil+" "+profil.abscisseCurvilingeAxeHydraulique); + if (version_.equals("1d")) + out_.write('\n'); + else { + out_.write(' '); + for (int j=0; j<profil.coordXYTraceProfil.size(); j++) { + out_.write(profil.coordXYTraceProfil.get(j)[0]+" "); + out_.write(profil.coordXYTraceProfil.get(j)[1]+" "); + } + out_.write("AXE "+profil.coordIntersectionAxeHydraulique[0]+" "+profil.coordIntersectionAxeHydraulique[1]); + out_.write('\n'); + } + // Les autres lignes + for (int j=0; j<profil.coordXYProfil.size(); j++) { + out_.write(profil.coordCurviligneProfil.get(j)+" "+profil.coordZ.get(j)+" "+profil.bathyOuTopoOuStockage.get(j)); + if (version_.equals("1d")) + out_.write('\n'); + else + out_.write(" "+profil.coordXYProfil.get(j)[0]+" "+profil.coordXYProfil.get(j)[1]+"\n"); + } + } + } + catch (Exception _exp) { + analyze_.manageException(_exp); + } + } + + @Override + protected FortranInterface getFortranInterface() { + return new FortranInterface() { + public void close() throws IOException { + if (out_ != null) { + out_.close(); + } + } + }; + } + + @Override + public void setFile(File _f) { + analyze_ = new CtuluAnalyze(); + analyze_.setResource(_f.getAbsolutePath()); + FileWriter out = null; + try { + out = new FileWriter(_f); + } catch (final IOException _e) { + analyze_.manageException(_e); + } + if (out != null) { + out_ = out; + } + } + + /** + * G\xE9n\xE8re les repr\xE9sentatino interm\xE9diaires des profils. + * @param zones_ + * @throws MascaretDataError + * @throws MascaretDataIncomplete + */ + private void generateMascaretProfilAbstractRepresentations(String _nomBief, GISZoneCollectionLigneBrisee[] _zones, FunctorSelectProfil _selectorProfil) throws MascaretDataError, MascaretDataIncomplete{ + // Recherche de l'axe hydraulique \\ + GISZoneCollectionLigneBrisee zoneAxeHydraulique=null; + int indexAxeHydraulique=-1; + for (int i=0; i<_zones.length; i++) { + int idxAttNature=_zones[i].getIndiceOf(GISAttributeConstants.NATURE); + if (idxAttNature!=-1) + for (int j=0; j<_zones[i].getNbGeometries(); j++) + if (_zones[i].getValue(idxAttNature, j)==GISAttributeConstants.ATT_NATURE_AH) + if (zoneAxeHydraulique==null) { + zoneAxeHydraulique=_zones[i]; + indexAxeHydraulique=j; + } + else + throw new MascaretDataError("Il existe plusieurs axes hydrauliques."); + } + if(zoneAxeHydraulique==null) + throw new MascaretDataIncomplete("Il n'y a pas d'axes hydrauliques."); + + // Recherche des profils \\ + List<GISZoneCollectionLigneBrisee> profils=new ArrayList<GISZoneCollectionLigneBrisee>(); + List<Integer> indexProfils=new ArrayList<Integer>(); + for (int i=0; i<_zones.length; i++) { + int idxAttNature=_zones[i].getIndiceOf(GISAttributeConstants.NATURE); + if (idxAttNature!=-1) + for (int j=0; j<_zones[i].getNbGeometries(); j++) + if (_zones[i].getValue(idxAttNature, j)==GISAttributeConstants.ATT_NATURE_PF&&_selectorProfil.exportProfil(_zones[i], i)) { + profils.add(_zones[i]); + indexProfils.add(j); + } + } + + // G\xE9n\xE9ration des MascaretProfilAbstractRepresentations \\ + profils_=new MascaretProfilAbstractRepresentation[profils.size()]; + int countNoName=1; + GISPolyligne axeHydraulique=(GISPolyligne)zoneAxeHydraulique.getGeometry(indexAxeHydraulique); + for (int i=0;i<profils.size();i++) { + GISZoneCollectionLigneBrisee zoneProfil=profils.get(i); + int idxProfil=indexProfils.get(i); + GISPolyligne profil=(GISPolyligne) zoneProfil.getGeometry(idxProfil); + MascaretProfilAbstractRepresentation profilAbs=new MascaretProfilAbstractRepresentation(); + + // Information globales sur le profil \\ + // Nom bief + if(_nomBief.contains(" ")) + throw new MascaretDataError("Le nom du bief ne doit pas contenir d'espace."); + profilAbs.nomBief=_nomBief; + // Nom profil + int idxTitle=zoneProfil.getIndiceOf(GISAttributeConstants.TITRE); + if(idxTitle!=-1){ + String nomProfil=(String) zoneProfil.getValue(idxTitle, idxProfil); + if(nomProfil.contains(" ")) + throw new MascaretDataError("Le nom du profil ne doit pas contenir d'espace."); + profilAbs.nomProfil=nomProfil; + } + else + profilAbs.nomProfil="No_Name_"+countNoName++; + // Intersection axe hydraulique + Geometry intersection=axeHydraulique.intersection(profil); + if(intersection.getNumPoints()!=1) + throw new MascaretDataError("Un profil \xE0 plusieurs ou aucun point(s) d'intersection(s) avec l'axe hydraulique."); + profilAbs.coordIntersectionAxeHydraulique=new double[]{intersection.getCoordinate().x, intersection.getCoordinate().y}; + // Abscisse curviligne axe hydraulique + CoordinateSequence coordSeq=axeHydraulique.getCoordinateSequence(); + profilAbs.abscisseCurvilingeAxeHydraulique=absCurv(coordSeq, intersection.getCoordinate()); + // Trace profil + coordSeq=profil.getCoordinateSequence(); + profilAbs.coordXYTraceProfil.add(new double[]{coordSeq.getX(0), coordSeq.getY(0)}); + profilAbs.coordXYTraceProfil.add(new double[]{coordSeq.getX(coordSeq.size()-1), coordSeq.getY(coordSeq.size()-1)}); + + // Information atomiques sur le profil \\ + coordSeq=profil.getCoordinateSequence(); + int idxZ=zoneProfil.getIndiceOf(zoneProfil.getAttributeIsZ()); + for(int j=0;j<profil.getNumPoints();j++){ + // Valeur curviligne + profilAbs.coordCurviligneProfil.add(absCurv(coordSeq, j)); + // Coordonn\xE9es X Y + profilAbs.coordXYProfil.add(new double[]{coordSeq.getCoordinate(j).x, coordSeq.getCoordinate(j).y}); + // Coordinate Z + if(idxZ!=-1) + profilAbs.coordZ.add(((GISAttributeModelDoubleInterface)zoneProfil.getValue(idxZ, idxProfil)).getValue(j)); + } + // Extraction des valeurs d'intersection + ArrayList<Integer> seps=new ArrayList<Integer>(); + //INTERSECTION_RIVE_GAUCHE + int idxInterRiveG=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_GAUCHE); + Coordinate intersectionRiveGauche; + Integer idxRG=-1; + if(idxInterRiveG!=-1) { + intersectionRiveGauche=(Coordinate) zoneProfil.getValue(idxInterRiveG, idxProfil); + idxRG=idxIntersection(coordSeq, intersectionRiveGauche); + seps.add(idxRG); + } + //INTERSECTION_RIVE_DROITE + int idxInterRiveD=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_RIVE_DROITE); + Coordinate intersectionRiveDroite; + Integer idxRD=-1; + if(idxInterRiveD!=-1) { + intersectionRiveDroite=(Coordinate) zoneProfil.getValue(idxInterRiveD, idxProfil); + idxRD=idxIntersection(coordSeq, intersectionRiveDroite); + seps.add(idxRD); + } + //INTERSECTION_LIMITE_STOCKAGE_GAUCHE + int idxInterStockageG=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_GAUCHE); + Coordinate intersectionStockageGauche; + Integer idxSG=-1; + if(idxInterStockageG!=-1) { + intersectionStockageGauche=(Coordinate) zoneProfil.getValue(idxInterStockageG, idxProfil); + idxSG=idxIntersection(coordSeq, intersectionStockageGauche); + seps.add(idxSG); + } + //INTERSECTION_LIMITE_STOCKAGE_DROITE + int idxInterStockageD=zoneProfil.getIndiceOf(GISAttributeConstants.INTERSECTION_LIMITE_STOCKAGE_DROITE); + Coordinate intersectionStockageDroit; + Integer idxSD=-1; + if(idxInterStockageD!=-1) { + intersectionStockageDroit=(Coordinate) zoneProfil.getValue(idxInterStockageD, idxProfil); + idxSD=idxIntersection(coordSeq, intersectionStockageDroit); + seps.add(idxSD); + } + if(idxRG==-1&&idxRD!=-1||idxRG!=-1&&idxRD==-1) + throw new MascaretDataIncomplete("Il y a une seule rive (il doit y en avoir soit 0 soit 2)"); + if(idxSG==-1&&idxSD!=-1||idxSG!=-1&&idxSD==-1) + throw new MascaretDataIncomplete("Il y a une seule limite de stockage (il doit y en avoir soit 0 soit 2)"); + Integer[] sepsT=seps.toArray(new Integer[0]); + Arrays.sort(sepsT); + // Bathy Topo ou Stockage + if(sepsT.length==4){ + int j; + for(j=0;j<sepsT[0];j++) + profilAbs.bathyOuTopoOuStockage.add('S'); + for(;j<sepsT[1];j++) + profilAbs.bathyOuTopoOuStockage.add('T'); + for(;j<sepsT[2];j++) + profilAbs.bathyOuTopoOuStockage.add('B'); + for(;j<sepsT[3];j++) + profilAbs.bathyOuTopoOuStockage.add('T'); + for(;j<coordSeq.size();j++) + profilAbs.bathyOuTopoOuStockage.add('S'); + } + if(sepsT.length==2) { + if(sepsT[0]==idxRG||sepsT[0]==idxRD){ + int j; + for(j=0;j<sepsT[0];j++) + profilAbs.bathyOuTopoOuStockage.add('T'); + for(;j<sepsT[1];j++) + profilAbs.bathyOuTopoOuStockage.add('B'); + for(;j<coordSeq.size();j++) + profilAbs.bathyOuTopoOuStockage.add('T'); + } + else{ + int j; + for(j=0;j<sepsT[0];j++) + profilAbs.bathyOuTopoOuStockage.add('S'); + for(;j<sepsT[1];j++) + profilAbs.bathyOuTopoOuStockage.add('B'); + for(;j<coordSeq.size();j++) + profilAbs.bathyOuTopoOuStockage.add('S'); + } + } + else + for(int j=0;j<coordSeq.size();j++) + profilAbs.bathyOuTopoOuStockage.add('B'); + + // Verification de la coh\xE9rence des r\xE9sultats + if(version_.equals("1d")) + if(!profilAbs.check1D()) + throw new MascaretDataError("Erreur de programmation : les donn\xE9es g\xE9n\xE9r\xE9es ne sont pas coh\xE9rente pour le 1d."); + else + if(!profilAbs.check2D()) + throw new MascaretDataError("Erreur de programmation : les donn\xE9es g\xE9n\xE9r\xE9es ne sont pas coh\xE9rente pour le 2d."); + + // Stockage avec les autres \\ + profils_[i]=profilAbs; + } + } + + /** + * Calcul l'abscisse curviligne du point indiqu\xE9 en param\xE8tre + */ + private double absCurv(CoordinateSequence _coordSeq, Coordinate _point){ + int k=idxIntersection(_coordSeq, _point); + // Calcule de l'abscisse curviligne + double valueCurviligne=0; + for (int j=1; j<=k; j++) + valueCurviligne+=_coordSeq.getCoordinate(j).distance(_coordSeq.getCoordinate(j-1)); + // Mise \xE0 jour de l'abscisse curviligne + valueCurviligne+=_coordSeq.getCoordinate(k).distance(_point); + return valueCurviligne; + } + + /** + * Calcul l'abscisse curviligne du point indiqu\xE9 en param\xE8tre + */ + private double absCurv(CoordinateSequence _coordSeq, int _idxPoint){ + if(_idxPoint==0) + return 0; + double valueCurviligne=0; + for (int j=1; j<=_idxPoint; j++) + valueCurviligne+=_coordSeq.getCoordinate(j).distance(_coordSeq.getCoordinate(j-1)); + return valueCurviligne; + } + + /** + * Retourne l'indice pr\xE9c\xE9dent d'un point d'intersectin avec une geometrie. + */ + private int idxIntersection(CoordinateSequence _coordSeq, Coordinate _point){ + /* Recherche de l'index du dernier point de la polyligne \xE0 prendre en + * compte. */ + boolean fini=false; + int k=-1; + GISPoint point= new GISPoint(_point); + while (!fini&&++k<_coordSeq.size()-1) + fini=(GISGeometryFactory.INSTANCE + .createLineString(new Coordinate[]{_coordSeq.getCoordinate(k), _coordSeq.getCoordinate(k+1)})).intersects(point); + return k; + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/dodico/src/org/fudaa/dodico/mascaret/io/MascaretWriter.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:mergeinfo + /branches/Br_FudaaModeleur_TF/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryListener.java:3445-3850 /branches/FudaaModeleur_TC1/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryListener.java:3861-3891 Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlProjectExportPanel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlProjectExportPanel.java 2008-12-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlProjectExportPanel.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -284,7 +284,7 @@ nbFiles++; } String name=CtuluLibFile.getSansExtension(f.getName()); - // Teste sur l'existance des fichier. Dans le cas d'un enregistrement en + // Test sur l'existence des fichier. Dans le cas d'un enregistrement en // rubar, il faut aussi tester avec les extensions .sem et .cn et aussi <nom>_autres.st if (CtuluLibFile.getExtension(f.getName()).equalsIgnoreCase("st")) { if ((new File(f.getParent()+File.separatorChar+name+".sem")).exists()) { Deleted: 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-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/Controller1d.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -1,262 +0,0 @@ -/* - * @creation 9 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; - -import java.awt.Color; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; - -import javax.swing.Action; -import javax.swing.JComponent; -import javax.swing.JDesktopPane; -import javax.swing.event.InternalFrameAdapter; -import javax.swing.event.InternalFrameEvent; -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; -import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; -import org.fudaa.ebli.calque.BArbreCalqueModel; -import org.fudaa.ebli.calque.ZCalqueAffichageDonneesInterface; -import org.fudaa.ebli.calque.ZScene; -import org.fudaa.ebli.calque.ZSelectionEvent; -import org.fudaa.ebli.calque.ZSelectionListener; -import org.fudaa.ebli.calque.edition.ZModeleLigneBriseeEditable; -import org.fudaa.ebli.commun.EbliActionInterface; -import org.fudaa.ebli.commun.EbliFormatter; -import org.fudaa.ebli.commun.EbliFormatterInterface; -import org.fudaa.ebli.commun.EbliLib; -import org.fudaa.fudaa.commun.FudaaLib; -import org.fudaa.fudaa.modeleur.MdlImplementation; - -import com.memoire.bu.BuDesktop; -import com.memoire.bu.BuLabel; - -/** - * Cette classe a la charge et la responsabilit\xE9 de g\xE9rer toutes les actions, - * interactions et r\xE9actions de la fen\xEAtre 1d dans son ensemble. - * - * @author Emmanuel MARTIN - * @version $Id$ - */ -public class Controller1d extends InternalFrameAdapter implements ZSelectionListener, ListSelectionListener, CtuluListSelectionListener { - - /** La vue du bief. */ - private VueBief vueBief_; - /** La vue d'un profil par tableau. */ - private VueTableau vueTableau_; - /** La vue d'un profil via une courbe. */ - private VueCourbe vueCourbe_; - /** Un label pour afficher les erreurs. */ - private BuLabel vueError_; - /** Le lien avec le reste de l'application. */ - private MdlImplementation appli_; - /** La frame contenant tous les widgets 1d. */ - private MdlFille1d frame1d_; - /** Indique si on doit \xE9couter les \xE9venements de selection. */ - private boolean listenEventSelection_=true; - /** L'adapter des donn\xE9es de la geometry en cours de manipulation. */ - 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) - throw new IllegalArgumentException("Les param\xE8tres ne doivent pas \xEAtre null."); - appli_=_appli; - frame1d_=_frame1d; - frame1d_.addInternalFrameListener(this); - mng_=new CtuluCommandManager(); - vueBief_=new VueBief(appli_, this); - vueBief_.getScene().addSelectionListener(this); - treeModel_=vueBief_.getArbreCalqueModel(); - 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); - clearError(); - } - - public VueBief getVueBief(){ - return vueBief_; - } - public VueTableau getVueTableau(){ - return vueTableau_; - } - public VueCourbe getVueCourbe(){ - return vueCourbe_; - } - public JComponent getVueError(){ - return vueError_; - } - - public EbliFormatterInterface getFormater(){ - return formater_; - } - - public CtuluCommandManager getCommandManager(){ - return mng_; - } - - // 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(" "); - } - - // Gestion de l'arbre \\ - - /** Le model de l'arbre a afficher sur la droite de l'\xE9cran. */ - private BArbreCalqueModel treeModel_; - - /** Retourne le model de l'abre a afficher sur la droite de l'\xE9can. */ - public BArbreCalqueModel getTreeModel(){ - return treeModel_; - } - - /** - * Mise \xE0 jour de l'arbre des calques a chaque activation de la fen\xEAtre 1d. La - * mise \xE0 jour s'effectue en fonction des calques 2d. - */ - public void internalFrameActivated(InternalFrameEvent e) { - vueBief_.updateTree(); - } - - // Gestion des actions \\ - - /** Les action \xE0 la fen\xEAtre 1d. */ - JComponent[] specificTools_; - - /** - * Renvoie les actions sp\xE9cifiques \xE0 la fen\xEAtre 1d. Ils seront affiches dans la - * tool bar de l'application. - * - * @return specificTools_ - */ - public JComponent[] getToolsActions() { - if (specificTools_==null) { - final JDesktopPane j=frame1d_.getDesktopPane(); - BuDesktop buJ=null; - if (j instanceof BuDesktop) - buJ=(BuDesktop)j; - List<EbliActionInterface> actionAbs=vueBief_.getController().getActions(); - // Selection des actions - String[] tmpAction=new String[]{"RECTANGLE_SELECTION", "POLYGON_SELECTION", "RESTORE", "ZOOM", "ZOOM_ON_SELECTED", - "LAST_VIEW", "MOVE_VIEW", "CHANGE_REFERENCE", "NAVIGATE"}; - // info : Actions not kept : "CHOOSE_COLOR_PALET", "EDIT_LEGEND", "CONFIGURE", "INFOS", "TABLE" - HashSet<String> actionsKept=new HashSet<String>(); - for (int i=0; i<tmpAction.length; i++) - actionsKept.add(tmpAction[i]); - List<EbliActionInterface> actions=new ArrayList<EbliActionInterface>(); - for (int i=0; i<actionAbs.size(); i++) - if (actionAbs.get(i)==null) - actions.add(actionAbs.get(i)); - else if (actionsKept.contains(actionAbs.get(i).getValue(Action.ACTION_COMMAND_KEY))) - actions.add(actionAbs.get(i)); - // Construction des boutons - final List<?> l=EbliLib.updateToolButtons(actions, buJ); - specificTools_=new JComponent[l.size()]; - l.toArray(specificTools_); - } - if (specificTools_==null) - return null; - final JComponent[] r=new JComponent[specificTools_.length]; - System.arraycopy(specificTools_, 0, r, 0, r.length); - return r; - } - - // Gestion de la selection entre les trois widgets (tableau, bief et courbe) \\ - - /** - * Changement de la selection dans le widget de bief. - */ - public void selectionChanged(ZSelectionEvent _evt) { - clearError(); - ZScene scene=vueBief_.getScene(); - int sceneIdSelected=scene.getSelectionHelper().getUniqueSelectedIdx(); - boolean ok=true; // Indique si tout s'est bien pass\xE9. - if (sceneIdSelected==-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 - // courbe \\ - ZCalqueAffichageDonneesInterface calque=scene.getLayerForId(sceneIdSelected); - if (calque.modeleDonnees() instanceof ZModeleLigneBriseeEditable) { - GISZoneCollectionLigneBrisee zone=((ZModeleLigneBriseeEditable)calque.modeleDonnees()).getGeomData(); - if (zone.getIndiceOf(GISAttributeConstants.NATURE)!=-1) { - if (zone.getValue(zone.getIndiceOf(GISAttributeConstants.NATURE), idSelected)==GISAttributeConstants.ATT_NATURE_PF) { - try { - dataGeomAdapter_.setData(zone, idSelected); - } - catch (DataGeometryException _exc) { - showError(_exc.getMessage()); - } - } - else - // On a pas selectionn\xE9 un profil, on annule la selection - ok=false; - } - else - // Il n'y a pas d'attribut Nature, on annule la selection - ok=false; - } - else - // Le type de model ne correspond pas, on annule la selection - ok=false; - } - if(!ok) { - //dataGeomAdapter_.setData(null, -1); - scene.clearSelection(); - showError(FudaaLib.getS("Seuls les profils sont selectionnables.")); - } - } - - /** - * Changement de la selection dans le widget du tableau. - */ - public void valueChanged(ListSelectionEvent e) { - if (listenEventSelection_) { - listenEventSelection_=false; - vueCourbe_.setSelection(vueTableau_.getSelection()); - listenEventSelection_=true; - } - } - - /** - * Changement de la selection dans le widget de la courbe. - */ - public void listeSelectionChanged(CtuluListSelectionEvent _e) { - if (listenEventSelection_) { - listenEventSelection_=false; - vueTableau_.setSelection(vueCourbe_.getSelection()); - listenEventSelection_=true; - } - } -} Deleted: 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-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometry.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -1,68 +0,0 @@ -/* - * @creation 10 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; - -import org.fudaa.ctulu.CtuluCommandContainer; - -/** - * Une interface permettant d'acc\xE9der aux informations manipul\xE9es par les - * widgets tableau et courbe. - * - * @author Emmanuel MARTIN - * @version $Id$ - */ -public interface DataGeometry { - - /** Ajout d'un nouveau listener. */ - public void addDataGeometryListener(DataGeometryListener _listener); - - /** Supprime le listener. */ - public void removeDataGeometryListener(DataGeometryListener _listener); - - /** Retourne le nombre de points total de la geometry. */ - public int getNbPoint(); - - /** Retourne l'abcisse curviligne du point indiqu\xE9 en param\xE8tre. */ - public double getCurv(int _idxPoint); - - /** Retourne la valeur maximal de l'abcisse curviligne. */ - public double getCurvMax(); - - /** Retourne la valeur minimal de l'abcisse curvilgne. */ - public double getCurvMin(); - - /** Retourne la valeur de z du point indiqu\xE9 en param\xE8tre. */ - public double getZ(int _idxPoint); - - /** Retourne la valeur maximal de z. */ - public double getZMax(); - - /** Retourne la valeur minimal de z. */ - public double getZMin(); - - /** - * 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, CtuluCommandContainer _cmd) throws DataGeometryException; - - /** Enregistre la valeur de z du point indiqu\xE9 en param\xE8tre. */ - 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, CtuluCommandContainer _cmd) throws DataGeometryException; - - /** Supprime le point indiqu\xE9 en param\xE8tre. */ - public void remove(int _idxPoint, CtuluCommandContainer _cmd) throws DataGeometryException; -} Deleted: 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-22 14:20:55 UTC (rev 4311) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/modeleur1d/DataGeometryAdapter.java 2008-12-22 14:50:07 UTC (rev 4312) @@ -1,737 +0,0 @@ -/* - * @creation 10 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; - -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; -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 - * simplement. Cette simplification se fait en cachant toutes les informations - * inutils et en ajoutant une information d'abcisse curviligne. - * - * @author Emmanuel MARTIN - * @version $Id$ - */ -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_; - private List<Double> curv_; - // Caches \\ - int idxZMax_; - int idxZMin_; - // Le profil est potentiellement coup\xE9 en trois, les deux indices qui suivent - // indique l'index de chacune de ces ruptures. - int idxRupture1_; - int idxRupture2_; - - public DataGeometryAdapter(GISZoneCollectionLigneBrisee _zone, int _idxGeom) throws IllegalArgumentException, DataGeometryException { - setData(_zone, _idxGeom); - } - - /** - * 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 - * curviligne). La veracit\xE9 de cette hypoth\xE8se n'est PAS v\xE9rifi\xE9 dans setData. - * - * @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, DataGeometryException { - if (_zone==null&&_idxGeom==-1) { - zone_=null; - idxGeom_=-1; - z_=null; - curv_=null; - } - else if (_zone!=null&&_idxGeom>=0&&_idxGeom<_zone.getNbGeometries()&&_zone.getAttributeIsZ()!=null) { - try { - zone_=_zone; - idxGeom_=_idxGeom; - z_=(CtuluCollection)zone_.getValue(zone_.getIndiceOf(zone_.getAttributeIsZ()), idxGeom_); - curv_=new ArrayList<Double>(); - CoordinateSequence seq=((GISCoordinateSequenceContainerInterface)zone_.getGeometry(idxGeom_)).getCoordinateSequence(); - // Verifie qu'on a bien au minimum deux points. \\ - if (seq.size()<2) - 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 DataGeometryException(FudaaLib.getS("Au moins deux points dans le profil sont confondus.")); - // Calcul des acbscisses curvilignes => hypoth\xE8se d'ordonnancement correcte des points \\ - updateCacheCurv(); - // Remplissage du cache Z \\ - 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++){ - 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.intersectio... [truncated message content] |