From: <emm...@us...> - 2008-10-14 15:02:17
|
Revision: 4057 http://fudaa.svn.sourceforge.net/fudaa/?rev=4057&view=rev Author: emmanuel_martin Date: 2008-10-14 15:02:06 +0000 (Tue, 14 Oct 2008) Log Message: ----------- R?\195?\169impl?\195?\169mentation (pas totalement termin?\195?\169e) de la partie conversion du wizard d'import du modeleur. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelAttributAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollection.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlEditionManager.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlWizardImport.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/FSigExportImportAttributesMapper.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigFileLoaderSinusX.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/wizard/FSigWizardFileModel.java Added Paths: ----------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelAttributSubstitution.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelMultiPointToPolyligne.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolygoneToMultiPoint.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolyligneToMultiPoint.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolyligneToPolygone.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelSelectionAdapter.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gui/CtuluTableCellEditorProxy.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/CalqueSelectorVisitor.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlWizardImportStepDestination.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelAttributAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelAttributAdapter.java 2008-10-13 17:18:22 UTC (rev 4056) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelAttributAdapter.java 2008-10-14 15:02:06 UTC (rev 4057) @@ -17,9 +17,9 @@ import com.vividsolutions.jts.geom.Geometry; /** - * Cet Adapter permet d'ajouter d'attributs globaux au DataModel. + * Cet Adapter permet l'ajout d'attributs au DataModel. * @author Emmanuel MARTIN - * @version $Id:$ + * @version $Id$ */ public class GISDataModelAttributAdapter implements GISDataModel{ @@ -209,11 +209,12 @@ * @see org.fudaa.ctulu.gis.GISDataModel#getValue(int, int) */ public Object getValue(int att, int geom) { - if(att<0||geom<0) return null; - if (dataModel_.getNbAttributes() > att && geom < dataModel_.getNumGeometries()) + if (att<0||geom<0) + return null; + if (dataModel_.getNbAttributes()>att&&geom<dataModel_.getNumGeometries()) return dataModel_.getValue(att, geom); - else if(newAttr_.size() > att - dataModel_.getNbAttributes() && geom < dataModel_.getNumGeometries()) - return newValues_.get(att - dataModel_.getNbAttributes())[geom]; + else if (newAttr_.size()>att-dataModel_.getNbAttributes()&&geom<dataModel_.getNumGeometries()) + return newValues_.get(att-dataModel_.getNbAttributes())[geom]; return null; } Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelAttributSubstitution.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelAttributSubstitution.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelAttributSubstitution.java 2008-10-14 15:02:06 UTC (rev 4057) @@ -0,0 +1,196 @@ +/* + * @creation 14 oct. 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.ctulu.gis; + +import java.util.HashMap; +import java.util.Map; + +import org.fudaa.ctulu.ProgressionInterface; + +import com.vividsolutions.jts.geom.Envelope; +import com.vividsolutions.jts.geom.Geometry; + +/** + * Cette adapter permet de substituer des attributs existant par d'autre. + * Par exemple, me model poss\xE8de deux attributs : V1 (type double) et Z + * (type double), l'adapter permet de substituer V& \xE0 Z. Ainsi toutes les + * requ\xEAtes sur Z seront redirig\xE9es sur V1. + * Les deux attributs doivent pr\xE9alablement exist\xE9s, avoir des types de valeur + * identique et \xEAtre de m\xEAme niveau (global ou atomique). + * A not\xE9 que se ne sont que les valeurs qui sont substituer. En cas d'appelle + * \xE0 la m\xE9thod getAttribut sur l'attribut substituer, sont GISAttributInterface + * sera toujours renvoy\xE9 comme avant. + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class GISDataModelAttributSubstitution implements GISDataModel { + + private final GISDataModel model_; + /** + * Table contenant les substitutions d'attributs \xE0 faire sur le model. + * Pour des raisons de performence, la substitution est m\xE9moris\xE9 par + * l'index des attributs. + */ + private final HashMap<Integer, Integer> substitutionTable_; + + /** + * Cette adapter permet de substituer des attributs existant par d'autre. Par + * exemple, me model poss\xE8de deux attributs : V1 (type double) et Z (type + * double), l'adapter permet de substituer V1 \xE0 Z. Ainsi toutes les requ\xEAtes + * sur Z seront redirig\xE9es sur V1. Les deux attributs doivent pr\xE9alablement + * exist\xE9s et avoir des types de valeur identique. Si les attributs sont de + * niveau (global ou atomique) diff\xE9rent, l'adapter converti les valeurs + * en utilisant la m\xE9thod createDataForGeom. + * A not\xE9 que se ne sont que les valeurs qui sont substituer. En + * cas d'appelle \xE0 la m\xE9thod getAttribut sur l'attribut substituer, sont + * GISAttributInterface sera toujours renvoy\xE9 comme avant. + * + * + * @param _model + * le model \xE0 adaoter + * @param _substitutionTable + * cette table contient les substitutions \xE0 faire. Une substitution + * est un tableau \xE0 deux \xE9l\xE9ments : le premier l'attribut a + * substituer et le second l'attribut par lequel le substituer. + * _substitutionTable est donc un tableau de tableau \xE0 deux \xE9l\xE9ments. + */ + public GISDataModelAttributSubstitution(GISDataModel _model, GISAttributeInterface[][] _substitutionTable){ + if(_substitutionTable==null||_model==null) + throw new IllegalArgumentException("_substitutionTable et _model ne doivent pas \xEAtre null."); + model_=_model; + substitutionTable_=new HashMap<Integer, Integer>(); + // Verification des substitutions + for(int i=0;i<_substitutionTable.length;i++){ + if(_substitutionTable[i].length!=2) + throw new IllegalArgumentException("Une substitution est un tableau \xE0 deux \xE9l\xE9ments, ni plus, ni moins."); + if(_substitutionTable[i][0].getDataClass()!=_substitutionTable[i][1].getDataClass()) + throw new IllegalArgumentException("Les deux substitutions doivent avoir des valeurs de m\xEAme type."); + if(model_.getIndiceOf(_substitutionTable[i][0])==-1) + throw new IllegalArgumentException(_substitutionTable[i][0].getID() + "n'est pas dans le model."); + if(model_.getIndiceOf(_substitutionTable[i][1])==-1) + throw new IllegalArgumentException(_substitutionTable[i][1].getID() + "n'est pas dans le model."); + // Ajout de la substitution + substitutionTable_.put(model_.getIndiceOf(_substitutionTable[i][0]), model_.getIndiceOf(_substitutionTable[i][1])); + } + } + + /** + * Cette adapter permet de substituer des attributs existant par d'autre. Par + * exemple, me model poss\xE8de deux attributs : V1 (type double) et Z (type + * double), l'adapter permet de substituer V& \xE0 Z. Ainsi toutes les requ\xEAtes + * sur Z seront redirig\xE9es sur V1. Les deux attributs doivent pr\xE9alablement + * exist\xE9s, avoir des types de valeur identique et \xEAtre de m\xEAme niveau (global + * ou atomique). + * A not\xE9 que se ne sont que les valeurs qui sont substituer. En + * cas d'appelle \xE0 la m\xE9thod getAttribut sur l'attribut substituer, sont + * GISAttributInterface sera toujours renvoy\xE9 comme avant. + * + * + * @param _model + * le model \xE0 adaoter + * @param _substitutionTable + * cette map contient les substitutions \xE0 faire. Le premier l'attribut + * a substituer et le second l'attribut par lequel le substituer. + */ + public GISDataModelAttributSubstitution(GISDataModel _model, Map<GISAttributeInterface, GISAttributeInterface> _substitutionTable){ + if(_substitutionTable==null||_model==null) + throw new IllegalArgumentException("_substitutionTable et _model ne doivent pas \xEAtre null."); + model_=_model; + substitutionTable_=new HashMap<Integer, Integer>(); + // Verification des substitutions + for(Map.Entry<GISAttributeInterface, GISAttributeInterface> entry:_substitutionTable.entrySet()){ + if(entry.getKey().getDataClass()!=entry.getValue().getDataClass()) + throw new IllegalArgumentException("Les deux substitutions doivent avoir des valeurs de m\xEAme type."); + if(model_.getIndiceOf(entry.getKey())==-1) + throw new IllegalArgumentException(entry.getKey().getID() + "n'est pas dans le model."); + if(model_.getIndiceOf(entry.getValue())==-1) + throw new IllegalArgumentException(entry.getValue().getID() + "n'est pas dans le model."); + // Ajout de la substitution + substitutionTable_.put(model_.getIndiceOf(entry.getKey()), model_.getIndiceOf(entry.getValue())); + } + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getAttribute(int) + */ + public GISAttributeInterface getAttribute(int _att) { + return model_.getAttribute(_att); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getDoubleValue(int, int) + */ + public double getDoubleValue(int _att, int _geom) { + if (substitutionTable_.containsKey(_att)) + return model_.getDoubleValue(substitutionTable_.get(_att), _geom); + else + return model_.getDoubleValue(_att, _geom); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getEnvelopeInternal() + */ + public Envelope getEnvelopeInternal() { + return model_.getEnvelopeInternal(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getGeometry(int) + */ + public Geometry getGeometry(int _geom) { + return model_.getGeometry(_geom); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getIndiceOf(org.fudaa.ctulu.gis.GISAttributeInterface) + */ + public int getIndiceOf(GISAttributeInterface _att) { + return model_.getIndiceOf(_att); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getNbAttributes() + */ + public int getNbAttributes() { + return model_.getNbAttributes(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getNumGeometries() + */ + public int getNumGeometries() { + return model_.getNumGeometries(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getValue(int, int) + */ + public Object getValue(int _att, int _geom) { + if (substitutionTable_.containsKey(_att)) + if (getAttribute(_att).isAtomicValue()!=getAttribute(substitutionTable_.get(_att)).isAtomicValue()) { + Object value; + if (getAttribute(substitutionTable_.get(_att)).isAtomicValue()) + value=((GISAttributeModel)model_.getValue(substitutionTable_.get(_att), _geom)).getAverage(); + else + value=model_.getValue(substitutionTable_.get(_att), _geom); + return model_.getAttribute(_att).createDataForGeom(value, model_.getGeometry(_geom).getNumPoints()); + } + else + return model_.getValue(substitutionTable_.get(_att), _geom); + else + return model_.getValue(_att, _geom); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#preload(org.fudaa.ctulu.gis.GISAttributeInterface[], org.fudaa.ctulu.ProgressionInterface) + */ + public void preload(GISAttributeInterface[] _att, ProgressionInterface _prog) { + model_.preload(_att, _prog); + } + +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelAttributSubstitution.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelMultiPointToPolyligne.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelMultiPointToPolyligne.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelMultiPointToPolyligne.java 2008-10-14 15:02:06 UTC (rev 4057) @@ -0,0 +1,125 @@ +/* + * @creation 14 oct. 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.ctulu.gis; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.fudaa.ctulu.ProgressionInterface; + +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.Envelope; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.LinearRing; +import com.vividsolutions.jts.geom.MultiPoint; + +/** + * Cette classe convertie les mulitpoints en polyligne. Les g\xE9om\xE9tries faisant + * partie du model ne pouvant \xEAtre converties (soit parce que se ne sont pas des + * multipoint soit parce qu'il n'y a pas assez de points pour faire la conversion) + * deviennent invisible. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class GISDataModelMultiPointToPolyligne implements GISDataModel { + + private final GISDataModel model_; + /** Table de translation d'indices des g\xE9om\xE9tries. */ + private final ArrayList<Integer> translationTable_; + /** Table cache des polylignes cr\xE9es.*/ + private final HashMap<Integer, LineString> cachePolyligne_; + + public GISDataModelMultiPointToPolyligne(GISDataModel _model){ + if(_model==null) + throw new IllegalArgumentException("_model ne doit pas \xEAtre null."); + translationTable_=new ArrayList<Integer>(); + cachePolyligne_=new HashMap<Integer, LineString>(); + model_=_model; + // Construction de la table de translation + for(int i=0;i<model_.getNumGeometries();i++) + if(model_.getGeometry(i) instanceof MultiPoint && model_.getGeometry(i).getNumPoints() >= 2) + translationTable_.add(i); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getAttribute(int) + */ + public GISAttributeInterface getAttribute(int _att) { + return model_.getAttribute(_att); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getDoubleValue(int, int) + */ + public double getDoubleValue(int _att, int _geom) { + if(_geom>0&&_geom<translationTable_.size()) + return getDoubleValue(_att, translationTable_.get(_geom)); + return 0; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getEnvelopeInternal() + */ + public Envelope getEnvelopeInternal() { + return model_.getEnvelopeInternal(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getGeometry(int) + */ + public Geometry getGeometry(int _geom) { + if (_geom>=0&&_geom<translationTable_.size()) { + if (!cachePolyligne_.containsKey(_geom)) { + Coordinate[] coordinates=model_.getGeometry(translationTable_.get(_geom)).getCoordinates(); + // Cr\xE9ation de la polyligne + cachePolyligne_.put(_geom, GISGeometryFactory.INSTANCE.createLineString(coordinates)); + } + return cachePolyligne_.get(_geom); + } + return null; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getIndiceOf(org.fudaa.ctulu.gis.GISAttributeInterface) + */ + public int getIndiceOf(GISAttributeInterface _att) { + return model_.getIndiceOf(_att); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getNbAttributes() + */ + public int getNbAttributes() { + return model_.getNbAttributes(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getNumGeometries() + */ + public int getNumGeometries() { + return translationTable_.size(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getValue(int, int) + */ + public Object getValue(int _att, int _geom) { + if(_geom>0&&_geom<translationTable_.size()) + return model_.getValue(_att, translationTable_.get(_geom)); + return null; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#preload(org.fudaa.ctulu.gis.GISAttributeInterface[], org.fudaa.ctulu.ProgressionInterface) + */ + public void preload(GISAttributeInterface[] _att, ProgressionInterface _prog) { + model_.preload(_att, _prog); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelMultiPointToPolyligne.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolygoneToMultiPoint.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolygoneToMultiPoint.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolygoneToMultiPoint.java 2008-10-14 15:02:06 UTC (rev 4057) @@ -0,0 +1,124 @@ +/* + * @creation 14 oct. 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.ctulu.gis; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.fudaa.ctulu.ProgressionInterface; + +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.Envelope; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.LinearRing; +import com.vividsolutions.jts.geom.MultiPoint; +import com.vividsolutions.jts.geom.Point; + +/** + * Cette classe convertie les polygones en Multipoint. Les g\xE9om\xE9tries faisant + * partie du model ne pouvant \xEAtre converties (parce que se ne sont pas des + * polygones) deviennent invisible. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class GISDataModelPolygoneToMultiPoint implements GISDataModel { + + private final GISDataModel model_; + /** Table de translation d'indices des g\xE9om\xE9tries. */ + private final ArrayList<Integer> translationTable_; + /** Table cache des multipoints cr\xE9es.*/ + private final HashMap<Integer, MultiPoint> cacheMultiPoint_; + + public GISDataModelPolygoneToMultiPoint(GISDataModel _model){ + if(_model==null) + throw new IllegalArgumentException("_model ne doit pas \xEAtre null."); + translationTable_=new ArrayList<Integer>(); + cacheMultiPoint_=new HashMap<Integer, MultiPoint>(); + model_=_model; + // Construction de la table de translation + for(int i=0;i<model_.getNumGeometries();i++) + if(model_.getGeometry(i) instanceof LinearRing) + translationTable_.add(i); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getAttribute(int) + */ + public GISAttributeInterface getAttribute(int _att) { + return model_.getAttribute(_att); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getDoubleValue(int, int) + */ + public double getDoubleValue(int _att, int _geom) { + if(_geom>0&&_geom<translationTable_.size()) + return getDoubleValue(_att, translationTable_.get(_geom)); + return 0; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getEnvelopeInternal() + */ + public Envelope getEnvelopeInternal() { + return model_.getEnvelopeInternal(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getGeometry(int) + */ + public Geometry getGeometry(int _geom) { + if (_geom>=0&&_geom<translationTable_.size()) { + if (!cacheMultiPoint_.containsKey(_geom)) { + Coordinate[] coordinates=model_.getGeometry(translationTable_.get(_geom)).getCoordinates(); + // Cr\xE9ation du MultiPoint + cacheMultiPoint_.put(_geom, GISGeometryFactory.INSTANCE.createMultiPoint(coordinates)); + } + return cacheMultiPoint_.get(_geom); + } + return null; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getIndiceOf(org.fudaa.ctulu.gis.GISAttributeInterface) + */ + public int getIndiceOf(GISAttributeInterface _att) { + return model_.getIndiceOf(_att); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getNbAttributes() + */ + public int getNbAttributes() { + return model_.getNbAttributes(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getNumGeometries() + */ + public int getNumGeometries() { + return translationTable_.size(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getValue(int, int) + */ + public Object getValue(int _att, int _geom) { + if(_geom>0&&_geom<translationTable_.size()) + return model_.getValue(_att, translationTable_.get(_geom)); + return null; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#preload(org.fudaa.ctulu.gis.GISAttributeInterface[], org.fudaa.ctulu.ProgressionInterface) + */ + public void preload(GISAttributeInterface[] _att, ProgressionInterface _prog) { + model_.preload(_att, _prog); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolygoneToMultiPoint.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolyligneToMultiPoint.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolyligneToMultiPoint.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolyligneToMultiPoint.java 2008-10-14 15:02:06 UTC (rev 4057) @@ -0,0 +1,123 @@ +/* + * @creation 14 oct. 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.ctulu.gis; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.fudaa.ctulu.ProgressionInterface; + +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.Envelope; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.MultiPoint; + +/** + * Cette classe convertie les polylignes en Multipoint. Les g\xE9om\xE9tries faisant + * partie du model ne pouvant \xEAtre converties (parce que se ne sont pas des + * polylignes) deviennent invisible. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class GISDataModelPolyligneToMultiPoint implements GISDataModel { + + private final GISDataModel model_; + /** Table de translation d'indices des g\xE9om\xE9tries. */ + private final ArrayList<Integer> translationTable_; + /** Table cache des multipoints cr\xE9es.*/ + private final HashMap<Integer, MultiPoint> cacheMultiPoint_; + + public GISDataModelPolyligneToMultiPoint(GISDataModel _model){ + if(_model==null) + throw new IllegalArgumentException("_model ne doit pas \xEAtre null."); + translationTable_=new ArrayList<Integer>(); + cacheMultiPoint_=new HashMap<Integer, MultiPoint>(); + model_=_model; + // Construction de la table de translation + for(int i=0;i<model_.getNumGeometries();i++) + if(model_.getGeometry(i) instanceof LineString) + translationTable_.add(i); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getAttribute(int) + */ + public GISAttributeInterface getAttribute(int _att) { + return model_.getAttribute(_att); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getDoubleValue(int, int) + */ + public double getDoubleValue(int _att, int _geom) { + if(_geom>0&&_geom<translationTable_.size()) + return getDoubleValue(_att, translationTable_.get(_geom)); + return 0; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getEnvelopeInternal() + */ + public Envelope getEnvelopeInternal() { + return model_.getEnvelopeInternal(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getGeometry(int) + */ + public Geometry getGeometry(int _geom) { + if (_geom>=0&&_geom<translationTable_.size()) { + if (!cacheMultiPoint_.containsKey(_geom)) { + Coordinate[] coordinates=model_.getGeometry(translationTable_.get(_geom)).getCoordinates(); + // Cr\xE9ation du MultiPoint + cacheMultiPoint_.put(_geom, GISGeometryFactory.INSTANCE.createMultiPoint(coordinates)); + } + return cacheMultiPoint_.get(_geom); + } + return null; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getIndiceOf(org.fudaa.ctulu.gis.GISAttributeInterface) + */ + public int getIndiceOf(GISAttributeInterface _att) { + return model_.getIndiceOf(_att); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getNbAttributes() + */ + public int getNbAttributes() { + return model_.getNbAttributes(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getNumGeometries() + */ + public int getNumGeometries() { + return translationTable_.size(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getValue(int, int) + */ + public Object getValue(int _att, int _geom) { + if(_geom>0&&_geom<translationTable_.size()) + return model_.getValue(_att, translationTable_.get(_geom)); + return null; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#preload(org.fudaa.ctulu.gis.GISAttributeInterface[], org.fudaa.ctulu.ProgressionInterface) + */ + public void preload(GISAttributeInterface[] _att, ProgressionInterface _prog) { + model_.preload(_att, _prog); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolyligneToMultiPoint.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolyligneToPolygone.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolyligneToPolygone.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolyligneToPolygone.java 2008-10-14 15:02:06 UTC (rev 4057) @@ -0,0 +1,132 @@ +/* + * @creation 14 oct. 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.ctulu.gis; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.fudaa.ctulu.ProgressionInterface; + +import com.vividsolutions.jts.geom.Coordinate; +import com.vividsolutions.jts.geom.Envelope; +import com.vividsolutions.jts.geom.Geometry; +import com.vividsolutions.jts.geom.LineString; +import com.vividsolutions.jts.geom.LinearRing; + +/** + * Cette classe convertie les polylignes en polygone. Les g\xE9om\xE9tries faisant + * partie du model ne pouvant \xEAtre converties (soit parce que se ne sont pas des + * polylignes soit parce qu'il n'y a pas assez de point dans la polyligne) + * deviennent invisible. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class GISDataModelPolyligneToPolygone implements GISDataModel { + + private final GISDataModel model_; + /** Table de translation d'indices des g\xE9om\xE9tries. */ + private final ArrayList<Integer> translationTable_; + /** Table cache des polygone cr\xE9es.*/ + private final HashMap<Integer, LinearRing> cachePolygone_; + + public GISDataModelPolyligneToPolygone(GISDataModel _model){ + if(_model==null) + throw new IllegalArgumentException("_model ne doit pas \xEAtre null."); + translationTable_=new ArrayList<Integer>(); + cachePolygone_=new HashMap<Integer, LinearRing>(); + model_=_model; + // Construction de la table de translation + for(int i=0;i<model_.getNumGeometries();i++) + if(model_.getGeometry(i) instanceof LineString && model_.getGeometry(i).getNumPoints() >= 3) + translationTable_.add(i); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getAttribute(int) + */ + public GISAttributeInterface getAttribute(int _att) { + return model_.getAttribute(_att); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getDoubleValue(int, int) + */ + public double getDoubleValue(int _att, int _geom) { + if(_geom>0&&_geom<translationTable_.size()) + return getDoubleValue(_att, translationTable_.get(_geom)); + return 0; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getEnvelopeInternal() + */ + public Envelope getEnvelopeInternal() { + return model_.getEnvelopeInternal(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getGeometry(int) + */ + public Geometry getGeometry(int _geom) { + if (_geom>=0&&_geom<translationTable_.size()) { + if (!cachePolygone_.containsKey(_geom)) { + Coordinate[] coordinates=model_.getGeometry(translationTable_.get(_geom)).getCoordinates(); + // Le premier point et le dernier point doivent \xEAtre les m\xEAmes pour le + // polygone + if (coordinates[0]!=coordinates[coordinates.length-1]) { + Coordinate[] newCoordinates=new Coordinate[coordinates.length+1]; + System.arraycopy(coordinates, 0, newCoordinates, 0, coordinates.length); + newCoordinates[newCoordinates.length-1]=newCoordinates[0]; + coordinates=newCoordinates; + } + // Cr\xE9ation du polygone + cachePolygone_.put(_geom, GISGeometryFactory.INSTANCE.createLinearRing(coordinates)); + } + return cachePolygone_.get(_geom); + } + return null; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getIndiceOf(org.fudaa.ctulu.gis.GISAttributeInterface) + */ + public int getIndiceOf(GISAttributeInterface _att) { + return model_.getIndiceOf(_att); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getNbAttributes() + */ + public int getNbAttributes() { + return model_.getNbAttributes(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getNumGeometries() + */ + public int getNumGeometries() { + return translationTable_.size(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getValue(int, int) + */ + public Object getValue(int _att, int _geom) { + if(_geom>0&&_geom<translationTable_.size()) + return model_.getValue(_att, translationTable_.get(_geom)); + return null; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#preload(org.fudaa.ctulu.gis.GISAttributeInterface[], org.fudaa.ctulu.ProgressionInterface) + */ + public void preload(GISAttributeInterface[] _att, ProgressionInterface _prog) { + model_.preload(_att, _prog); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelPolyligneToPolygone.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelSelectionAdapter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelSelectionAdapter.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelSelectionAdapter.java 2008-10-14 15:02:06 UTC (rev 4057) @@ -0,0 +1,160 @@ +/* + * @creation 14 oct. 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.ctulu.gis; + +import java.util.ArrayList; + +import org.fudaa.ctulu.ProgressionInterface; + +import com.vividsolutions.jts.geom.Envelope; +import com.vividsolutions.jts.geom.Geometry; + +/** + * Cette adapter permet de ne faire apparaitre dans le model que les g\xE9om\xE9tries + * r\xE9pondant \xE0 des conditions donn\xE9es sur les attributs. Par exemple on peut + * dire que seul les g\xE9om\xE9tries d'une certaine nature sont visbles. + * Plusieurs conditions peuvent \xEAtre donn\xE9es. Elles seront g\xE9r\xE9es avec un OU + * logique. Pour simuler un ET logique entre des conditions, il suffi d'empiler + * plusieurs fois cette adapter sur le model. + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class GISDataModelSelectionAdapter implements GISDataModel { + + public static final String ATTRIBUT_EXIST = "< GISDataModelSelectionAdapter:ATTRIBUT_EXIST >"; + public static final String ATTRIBUT_NOT_EXIST = "< GISDataModelSelectionAdapter:ATTRIBUT_NOT_EXIST >"; + + private final GISDataModel model_; + private final Object[][] conditions_; + /** Table de translation d'indices des g\xE9om\xE9tries. */ + private final ArrayList<Integer> translationTable_; + + /** + * Cette adapter permet de ne faire apparaitre dans le model que les + * g\xE9om\xE9tries r\xE9pondant \xE0 des conditions donn\xE9es sur les attributs.Par + * exemple on peut dire que seul les g\xE9om\xE9tries d'une certaine nature sont + * visbles. Plusieurs conditions peuvent \xEAtre donn\xE9es. Elles seront g\xE9r\xE9es + * avec un OU logique. Pour simuler un ET logique entre des conditions, il + * suffi d'empiler plusieurs fois cette adapter sur le model. + * + * @param _model + * le model sur lequel va se faire la selection + * @param _conditions + * un tableau de conditions. Une condition \xE9tant d\xE9finie par deux + * \xE9l\xE9ments : l'attribut concern\xE9 (GISAttributeInterface) et sa + * valeur (Object). Deux valeurs sp\xE9cials sont d\xE9finies dans cette + * classe : ATTRIBUT_EXIST pour indiquer que la condition est vrai a + * partir du moment o\xF9 l'attribut est d\xE9finie ; ATTRIBUT_NOT_EXIST + * indique que la condition est vrai a partir du moment o\xF9 l'attribut + * n'existe pas. + */ + public GISDataModelSelectionAdapter(GISDataModel _model, Object[][] _conditions){ + if(_model==null||_conditions==null) + throw new IllegalArgumentException("_model et _conditions ne doivent pas \xEAtre null."); + translationTable_=new ArrayList<Integer>(); + model_=_model; + // Verification de la validit\xE9 des conditions + for(int i=0;i<_conditions.length;i++){ + if(_conditions[i].length!=2) + throw new IllegalArgumentException("La taille de chaque condition doit \xEAtre \xE9gale \xE0 deux."); + if(!(_conditions[i][0] instanceof GISAttributeInterface)) + throw new IllegalArgumentException("Le premier \xE9l\xE9ment de la condition doit \xEAtre un GISAttributeInterface"); + } + conditions_=_conditions; + // R\xE9cup\xE9ration des indices des attribtus concernant les conditions + int[] indexAttributsConditions = new int[conditions_.length]; + for(int i=0;i<indexAttributsConditions.length;i++) + indexAttributsConditions[i]=model_.getIndiceOf((GISAttributeInterface)conditions_[i][0]); + // G\xE9n\xE9ration d'une table de translation d'index des g\xE9om\xE9tries + for(int i=0;i<model_.getNumGeometries();i++){ + // Verification des conditions + boolean valide=false; + int j=-1; + while(!valide&&++j<conditions_.length){ + if(indexAttributsConditions[j]==-1&&conditions_[j][1]==ATTRIBUT_NOT_EXIST) + valide=true; + else if(indexAttributsConditions[j]!=-1&&conditions_[j][1]==ATTRIBUT_EXIST) + valide=true; + else if(indexAttributsConditions[j]!=-1&&conditions_[j][1]==model_.getValue(indexAttributsConditions[j], i)) + valide=true; + } + if(valide) + translationTable_.add(i); + } + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getAttribute(int) + */ + public GISAttributeInterface getAttribute(int _att) { + return model_.getAttribute(_att); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getDoubleValue(int, int) + */ + public double getDoubleValue(int _att, int _geom) { + if(_geom>0&&_geom<translationTable_.size()) + return model_.getDoubleValue(_att, translationTable_.get(_geom)); + return 0; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getEnvelopeInternal() + */ + public Envelope getEnvelopeInternal() { + return model_.getEnvelopeInternal(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getGeometry(int) + */ + public Geometry getGeometry(int _geom) { + if(_geom<0||_geom>=translationTable_.size()) + return null; + return model_.getGeometry(translationTable_.get(_geom)); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getIndiceOf(org.fudaa.ctulu.gis.GISAttributeInterface) + */ + public int getIndiceOf(GISAttributeInterface _att) { + return model_.getIndiceOf(_att); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getNbAttributes() + */ + public int getNbAttributes() { + return model_.getNbAttributes(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getNumGeometries() + */ + public int getNumGeometries() { + return translationTable_.size(); + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#getValue(int, int) + */ + public Object getValue(int _att, int _geom) { + if(_geom>=0&&_geom<translationTable_.size()) + return model_.getValue(_att, translationTable_.get(_geom)); + return null; + } + + /* (non-Javadoc) + * @see org.fudaa.ctulu.gis.GISDataModel#preload(org.fudaa.ctulu.gis.GISAttributeInterface[], org.fudaa.ctulu.ProgressionInterface) + */ + public void preload(GISAttributeInterface[] _att, ProgressionInterface _prog) { + model_.preload(_att, _prog); + } + +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISDataModelSelectionAdapter.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollection.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollection.java 2008-10-13 17:18:22 UTC (rev 4056) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollection.java 2008-10-14 15:02:06 UTC (rev 4057) @@ -559,6 +559,19 @@ else fixedAttributes_.put(_att, _value); } + + /** + * Retourne la valeur associ\xE9e \xE0 un attribut immuable via la m\xE9thode + * setFixedAttributeValue. + * + * @param _att : l'attribut recherch\xE9 + * @return la valeur de l'attribut. Null si l'attribut n'est pas renseign\xE9. + */ + public Object getFixedAttributValue(GISAttributeInterface _att) { + if(_att!=null && fixedAttributes_.containsKey(_att)) + return fixedAttributes_.get(_att); + return null; + } /** * Associe les attributs aux objets de la collection. Pour chaque attribut inexistant dans la liste est cr\xE9\xE9 un nouveau mod\xE8le. Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gui/CtuluTableCellEditorProxy.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gui/CtuluTableCellEditorProxy.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gui/CtuluTableCellEditorProxy.java 2008-10-14 15:02:06 UTC (rev 4057) @@ -0,0 +1,187 @@ +/* + * @creation 10 oct. 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.ctulu.gui; + +import java.awt.Component; +import java.util.EventObject; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.table.TableCellEditor; + +/** + * Cette classe est un proxy qui permet de choisir un \xE9ditor diff\xE9rent par + * ligne. Il est possible de donner les editeurs soit via un table soit via une + * map. + * + * tableau : le tableau doit avoir le m\xEAme nombre de case que le nombre de ligne + * dans le tableau \xE0 \xE9diter. Si se n'est pas le cas, les cellules + * suppl\xE9mentaires seront consid\xE9r\xE9es comme non \xE9ditable. Il est possible que + * donner des valeurs null dans le tableau, il sera alors consid\xE9r\xE9 que la + * cellule n'est pas \xE9ditable. + * + * map : l'avantage de la map par rapport au tableau est de ne renseigner que + * les lignes voulus. Il est possible de donner un index par defaut. Cette index + * servira \xE0 retourner l'editeur par defaut si il n'y en a pas de d\xE9fini \xE0 + * l'index demand\xE9. Si aucune instance n'est renseign\xE9 pour l'index par defaut, + * les cases seront consid\xE9r\xE9es comme non \xE9ditable. Comme le tableau, la valeur + * null pour un \xE9diteur signifie que la cellule n'est pas \xE9ditable. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class CtuluTableCellEditorProxy extends AbstractCellEditor implements TableCellEditor, CellEditorListener { + + /** Le container d'editor, la clef est la ligne et la valeur le TableCellEditor.*/ + private final Map<Integer, TableCellEditor> mapEditors_; + /** Index par defaut en cas d'absence de la ligne dans la map. */ + private final int defaultIndex_; + /** L'index utilis\xE9 actuellement. */ + private int currentIndex_; + + /** + * Si le tableau n'est pas assez grand, null sera retourn\xE9 par la method + * getTableCellEditorComponent. + * + * Si _editors est null IllegalArgumentException sera lev\xE9e. + * + * @param _editors + * Tableau contenant l'editeur pour chaque ligne. Une valeur null + * pour un editeur undique que la cellule n'est pas \xE9ditable, null + * sera renvoy\xE9 par getTableCellEditorComponent. + */ + public CtuluTableCellEditorProxy(TableCellEditor[] _editors) { + if (_editors==null) + throw new IllegalArgumentException("_editors de doit pas \xEAtre null."); + mapEditors_=new HashMap<Integer, TableCellEditor>(); + defaultIndex_=-1; + currentIndex_=-1; + for (int i=0; i<_editors.length; i++) + mapEditors_.put(i, _editors[i]); + } + + /** + * Si _editors est null IllegalArgumentException sera lev\xE9e. + * + * @param _editors + * Une Map avec pour key le num\xE9ro de la ligne et pour Value un + * TableCellEditor. Une valeur null pour un editeur indique que la + * cellule n'est pas \xE9ditable : null sera renvoy\xE9 par + * getTableCellEditorComponent. + * @param _defaultChoice + * Si des lignes ne sont pas renseign\xE9s, la Key _defaultChoice sera + * utilis\xE9e \xE0 la place. Si la valeur par defaut n'est pas dans la map, + * null sera renvoy\xE9 par getTableCellEditor. + */ + public CtuluTableCellEditorProxy(Map<Integer, TableCellEditor> _editors, int _defaultChoice) { + if (_editors==null) + throw new IllegalArgumentException("_editors de doit pas \xEAtre null."); + defaultIndex_=_defaultChoice; + currentIndex_=-1; + mapEditors_=_editors; + } + + /* (non-Javadoc) + * @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(javax.swing.JTable, java.lang.Object, boolean, int, int) + */ + public Component getTableCellEditorComponent(JTable _table, Object _value, boolean _isSelected, int _row, int _column) { + // Suppression de l'\xE9coute d'\xE9venement sur l'ancien editeur + if(currentIndex_!=-1) + mapEditors_.get(currentIndex_).removeCellEditorListener(this); + // Actualisation de currentIndex_ + if(mapEditors_.containsKey(_row)) + if(mapEditors_.get(_row)!=null) + // Cas normal + currentIndex_=_row; + else{ + // Cas o\xF9 la cellule n'est pas \xE9ditable + currentIndex_=-1; + return null; + } + else if(mapEditors_.containsKey(defaultIndex_)) + // Cas o\xF9 l'editeur n'est pas renseign\xE9 : on utilise la valeur par defaut + if(mapEditors_.get(defaultIndex_)!=null) + // Cas normal de l'utilisation de l'editeur par defaut + currentIndex_=defaultIndex_; + else{ + // Cas o\xF9 l'index par defaut pointe sur null + currentIndex_=-1; + return null; + } + else{ + // Cas o\xF9 la valeur par defaut n'existe pas : la case est non \xE9ditable + currentIndex_=-1; + return null; + } + // Ajout de l'\xE9coute d'\xE9venement sur le nouvel \xE9diteur et transfert d'appelle + mapEditors_.get(currentIndex_).addCellEditorListener(this); + return mapEditors_.get(currentIndex_).getTableCellEditorComponent(_table, _value, _isSelected, _row, _column); + } + + /* (non-Javadoc) + * @see javax.swing.CellEditor#cancelCellEditing() + */ + public void cancelCellEditing() { + if(currentIndex_!=-1) + mapEditors_.get(currentIndex_).cancelCellEditing(); + } + + /* (non-Javadoc) + * @see javax.swing.CellEditor#getCellEditorValue() + */ + public Object getCellEditorValue() { + if(currentIndex_!=-1) + return mapEditors_.get(currentIndex_).getCellEditorValue(); + return null; + } + + /* (non-Javadoc) + * @see javax.swing.CellEditor#isCellEditable(java.util.EventObject) + */ + public boolean isCellEditable(EventObject _anEvent) { + if(currentIndex_!=-1) + return mapEditors_.get(currentIndex_).isCellEditable(_anEvent); + return true; + } + + /* (non-Javadoc) + * @see javax.swing.CellEditor#shouldSelectCell(java.util.EventObject) + */ + public boolean shouldSelectCell(EventObject _anEvent) { + if(currentIndex_!=-1) + return mapEditors_.get(currentIndex_).shouldSelectCell(_anEvent); + return true; + } + + /* (non-Javadoc) + * @see javax.swing.CellEditor#stopCellEditing() + */ + public boolean stopCellEditing() { + if(currentIndex_!=-1) + return mapEditors_.get(currentIndex_).stopCellEditing(); + return true; + } + + /* (non-Javadoc) + * @see javax.swing.event.CellEditorListener#editingCanceled(javax.swing.event.ChangeEvent) + */ + public void editingCanceled(ChangeEvent e) { + fireEditingCanceled(); + } + + /* (non-Javadoc) + * @see javax.swing.event.CellEditorListener#editingStopped(javax.swing.event.ChangeEvent) + */ + public void editingStopped(ChangeEvent e) { + fireEditingStopped(); + } +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gui/CtuluTableCellEditorProxy.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Added: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/CalqueSelectorVisitor.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/CalqueSelectorVisitor.java (rev 0) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/CalqueSelectorVisitor.java 2008-10-14 15:02:06 UTC (rev 4057) @@ -0,0 +1,55 @@ +/* + * @creation 13 oct. 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.ebli.calque; + +import java.util.ArrayList; + +import org.fudaa.ebli.calque.edition.ZCalqueEditable; + +/** + * Ce visiteur parcours la hi\xE9rarchie de calque et selectionne ceux poss\xE9dant un + * model de donn\xE9es du type choisie et impl\xE9mentant ZCalqueEditable. + * + * @author Emmanuel MARTIN + * @version $Id:$ + */ +public class CalqueSelectorVisitor implements BCalqueVisitor { + + /** Le type de model sur lequel se fait la selection des calques. */ + private Class<? extends ZModeleDonnees> typeModel_; + /** Liste contenant les calques selectionn\xE9s */ + private ArrayList<ZCalqueAffichageDonneesAbstract> selectedCalques_; + + public CalqueSelectorVisitor(Class<? extends ZModeleDonnees> _typeModel) { + typeModel_=_typeModel; + selectedCalques_=new ArrayList<ZCalqueAffichageDonneesAbstract>(); + } + + /* + * (non-Javadoc) + * + * @see + * org.fudaa.ebli.calque.BCalqueVisitor#visit(org.fudaa.ebli.calque.BCalque) + */ + public boolean visit(BCalque _cq) { + if (_cq instanceof ZCalqueAffichageDonneesAbstract && _cq instanceof ZCalqueEditable) { + ZModeleDonnees modelData=((ZCalqueAffichageDonneesAbstract)_cq).modeleDonnees(); + if (modelData!=null&&typeModel_.isInstance(modelData)) + selectedCalques_.add((ZCalqueAffichageDonneesAbstract)_cq); + } + return true; + } + + /** + * @return retourne la liste de calques selectionn\xE9s. + */ + public ZCalqueAffichageDonneesAbstract[] getSelectedCalques() { + return selectedCalques_.toArray(new ZCalqueAffichageDonneesAbstract[0]); + } + +} Property changes on: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/CalqueSelectorVisitor.java ___________________________________________________________________ Added: svn:keywords + Id Added: svn:eol-style + native Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlEditionManager.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlEditionManager.java 2008-10-13 17:18:22 UTC (rev 4056) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlEditionManager.java 2008-10-14 15:02:06 UTC (rev 4057) @@ -96,10 +96,9 @@ return; } - final MdlWizardImport importWizard = new MdlWizardImport(dest, this, getEnglobPolygone(), ed, - ((FSigVisuPanel) getPanel()).getImpl(),((FSigVisuPanel) getPanel()).getCmdMng()); - final BuWizardDialog dialog = new BuWizardDialog(CtuluLibSwing.getFrameAncestorHelper(super.getPanel()), - importWizard); + final MdlWizardImport importWizard=new MdlWizardImport(getPanel().getDonneesCalque(), getEnglobPolygone(), ed, + ((FSigVisuPanel)getPanel()).getImpl(), ((FSigVisuPanel)getPanel()).getCmdMng()); + final BuWizardDialog dialog=new BuWizardDialog(CtuluLibSwing.getFrameAncestorHelper(super.getPanel()), importWizard); importWizard.setDialog(dialog); dialog.pack(); dialog.setModal(true); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlWizardImport.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlWizardImport.java 2008-10-13 17:18:22 UTC (rev 4056) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlWizardImport.java 2008-10-14 15:02:06 UTC (rev 4057) @@ -7,10 +7,14 @@ */ package org.fudaa.fudaa.modeleur; +import java.awt.Component; import java.awt.Dimension; +import java.util.Arrays; import java.util.Map; +import javax.swing.DefaultListModel; import javax.swing.JComponent; +import javax.swing.JDialog; import javax.swing.event.ListDataEvent; import javax.swing.event.ListDataListener; import javax.swing.event.TableModelEvent; @@ -19,63 +23,75 @@ import org.fudaa.ctulu.CtuluAnalyze; import org.fudaa.ctulu.CtuluCommandComposite; import org.fudaa.ctulu.CtuluCommandManager; -import org.fudaa.ctulu.CtuluLib; +import org.fudaa.ctulu.CtuluLibString; import org.fudaa.ctulu.CtuluTaskDelegate; import org.fudaa.ctulu.CtuluUI; import org.fudaa.ctulu.ProgressionInterface; import org.fudaa.ctulu.gis.GISAttributeConstants; import org.fudaa.ctulu.gis.GISAttributeInterface; +import org.fudaa.ctulu.gis.GISAttributeNameComparator; import org.fudaa.ctulu.gis.GISDataModel; +import org.fudaa.ctulu.gis.GISDataModelAttributAdapter; +import org.fudaa.ctulu.gis.GISDataModelAttributSubstitution; import org.fudaa.ctulu.gis.GISDataModelFilterAdapter; +import org.fudaa.ctulu.gis.GISDataModelMultiPointToPolyligne; import org.fudaa.ctulu.gis.GISDataModelPointMultiPointAdapter; -import org.fudaa.ctulu.gis.GISDataModelPointPolyAdapter; +import org.fudaa.ctulu.gis.GISDataModelPolygoneToMultiPoint; +import org.fudaa.ctulu.gis.GISDataModelPolyligneToMultiPoint; +import org.fudaa.ctulu.gis.GISDataModelPolyligneToPolygone; +import org.fudaa.ctulu.gis.GISDataModelSelectionAdapter; import org.fudaa.ctulu.gis.GISPolygone; -import org.fudaa.ctulu.gis.GISZoneCollectionLigneBrisee; -import org.fudaa.ctulu.gis.GISZoneCollectionMultiPoint; -import org.fudaa.ctulu.gis.GISZoneCollectionPoint; +import org.fudaa.ctulu.gis.GISZoneCollection; import org.fudaa.ebli.calque.BGroupeCalque; -import org.fudaa.ebli.calque.ZCalqueAffichageDonnees; +import org.fudaa.ebli.calque.ZCalqueAffichageDonneesAbstract; +import org.fudaa.ebli.calque.ZModeleGeometry; import org.fudaa.ebli.calque.dessin.DeForme; import org.fudaa.ebli.calque.edition.ZCalqueEditable; -import org.fudaa.ebli.calque.edition.ZCalqueEditionGroup; import org.fudaa.fudaa.commun.FudaaLib; -import org.fudaa.fudaa.modeleur.layer.MdlLayer2dLine; -import org.fudaa.fudaa.modeleur.layer.MdlLayer2dMultiPoint; -import org.fudaa.fudaa.modeleur.layer.MdlLayerFactory; -import org.fudaa.fudaa.modeleur.layer.MdlLayerInterface; -import org.fudaa.fudaa.modeleur.layer.MdlModel2dLine; -import org.fudaa.fudaa.modeleur.layer.MdlModel2dMultiPoint; import org.fudaa.fudaa.sig.FSigExportImportAttributesMapper; +import org.fudaa.fudaa.sig.FSigGeomSrcData; import org.fudaa.fudaa.sig.FSigLib; -import org.fudaa.fudaa.sig.layer.FSigEditor; import org.fudaa.fudaa.sig.wizard.FSigFileLoaderPanel; -import org.fudaa.fudaa.sig.wizard.FSigWizardImport; -import org.fudaa.fudaa.sig.wizard.FSigWizardImportStepDestination; +import org.fudaa.fudaa.sig.wizard.FSigWizardImportHelper; +import com.memoire.bu.BuButtonPanel; +import com.memoire.bu.BuGlassPaneStop; +import com.memoire.bu.BuWizardTask; + /** - * Un wizard d'import de donn\xE9es dans le calque cible. Il est limit\xE9 \xE0 1 etape. + * Wizard d'import du modeleur. * @author Bertrand Marchand + * @author Emmanuel Martin * @version $Id:$ */ -public class MdlWizardImport extends FSigWizardImport { - CtuluCommandManager mng_; +public class MdlWizardImport extends BuWizardTask { + private CtuluCommandManager mng_; - private BGroupeCalque mdlDest_; - private FSigEditor mdlEditor_; + private BGroupeCalque calqueRacine_; + private MdlWizardImportStepDestination pnDest_; + protected final GISPolygone[] previewZone_; + protected final ZCalqueEditable selectedLayer_; + protected FSigGeomSrcData data_; + protected JDialog dialog_; + protected FSigFileLoaderPanel fileLoader_; + protected final CtuluUI impl_; + protected GISAttributeInterface[] src_; + protected final DefaultListModel srcAtt_ = new DefaultListModel(); - /** - * @param _previewZone - * @param _selectedLayer - * @param _impl + * @param _previewZone la zone a utiliser pour la pr\xE9visualisation + * @param _selectedLayer le calque en cours de selection: peut-etre null + * @param _impl l'impl parent */ - public MdlWizardImport(BGroupeCalque _dest, FSigEditor _editor, GISPolygone[] _previewZone, ZCalqueEditable _selectedLayer, CtuluUI _impl, CtuluCommandManager _mng) { - super(null, _previewZone, _selectedLayer, _impl); + public MdlWizardImport(BGroupeCalque _racine, GISPolygone[] _previewZone, ZCalqueEditable _selectedLayer, CtuluUI _impl, CtuluCommandManager _mng) { mng_=_mng; - mdlDest_=_dest; - mdlEditor_=_editor; + calqueRacine_=_racine; + impl_ = _impl; + previewZone_ = _previewZone; + selectedLayer_ = _selectedLayer; + // Exemple de cr\xE9ation d'un sous calque pour un BGroupeCalque /* int cqType_ = MdlLayerFactory.LAYER2D_CLOUD; @@ -86,200 +102,230 @@ } public JComponent getStepComponent() { - if (current_ == 0) { - if (fileLoader_ == null) { + if (current_==0) { + if (fileLoader_==null) { srcAtt_.addListDataListener(new ListDataListener() { - public void contentsChanged(final ListDataEvent _e) { rebuildAtt(); } - public void intervalAdded(final ListDataEvent _e) { rebuildAtt(); } - public void intervalRemoved(final ListDataEvent _e) { rebuildAtt(); } }); - fileLoader_ = new FSigFileLoaderPanel(srcAtt_, impl_, previewZone_); + fileLoader_=new FSigFileLoaderPanel(srcAtt_, impl_, previewZone_); fileLoader_.setPreferredSize(new Dimension(450, 400)); fileLoader_.setAttributeRequired(false); fileLoader_.getFileMng().getModel().addTableModelListener(new TableModelListener() { - public void tableChanged(final TableModelEvent _e) { - data_ = null; + data_=null; } }); } return fileLoader_; - } else if (current_ == 1) { - if (mapper_ == null) { - if (dest_!=null && dest_.getAttributes()!=null) - mapper_ = new FSigExportImportAttributesMapper(src_, dest_.getAttributes(), false); - } - if (pnDest_==null) pnDest_=new FSigWizardImportStepDestination(mdlDest_); - pnDest_.setMapper(mapper_); - pnDest_.setSrc(data_); - pnDest_.setSelectedLayer(selectedLayer_); - pnDest_.update(); + } + else if (current_==1) { + pnDest_=new MdlWizardImportStepDestination(calqueRacine_, data_, selectedLayer_); return pnDest_; } return null; } - public void doTask() { - CtuluAnalyze analyze=new CtuluAnalyze(); - if (data_==null) data_ = fileLoader_.loadAll(null, analyze); - // Affiche les erreurs dans une boite de dialogue. - impl_.manageAnalyzeAndIsFatal(analyze); - -... [truncated message content] |