From: <bma...@us...> - 2008-10-06 12:50:54
|
Revision: 4035 http://fudaa.svn.sourceforge.net/fudaa/?rev=4035&view=rev Author: bmarchan Date: 2008-10-06 12:46:31 +0000 (Mon, 06 Oct 2008) Log Message: ----------- Factorisation des GISZoneCollection Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionGeometry.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionLigneBrisee.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionMultiPoint.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleLigneBriseeEditable.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/FSigLineSingleModel.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/data/TrSiProfilLayer.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/data/TrSiProfileSplitter.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionGeometry.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionGeometry.java 2008-10-05 22:05:30 UTC (rev 4034) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionGeometry.java 2008-10-06 12:46:31 UTC (rev 4035) @@ -83,7 +83,11 @@ } /** - * Ne peut \xEAtre utilis\xE9 que si la liste contient des objets GIS homogenes. + * Ajoute une g\xE9om\xE9trie, d\xE9finie a partir d'une sequence de coordonn\xE9es.<p> + * Attention : Ne peut \xEAtre utilis\xE9 que si la liste contient des objets GIS homogenes. + * @param _seq La sequence de coordonnees + * @param _data Les valeurs d'attribut associ\xE9es \xE0 la g\xE9om\xE9trie, dans l'ordre des attributs. + * @param _cmd Le manager de commandes. */ public void addCoordinateSequence(final CoordinateSequence _seq, final Object[] _data, final CtuluCommandContainer _cmd) { @@ -110,15 +114,21 @@ } return true; } + /** - * @todo Les poly de niveau sont mal trait\xE9es + * Ajoute un sommet a une g\xE9om\xE9trie. + * @param _idxGeom L'index de la g\xE9om\xE9trie + * @param _idxBefore L'indice du point juste avant. + * @param _x La coordonn\xE9e X du sommet ajout\xE9. + * @param _y LA coordonn\xE9e Y du sommet ajout\xE9. + * @param _cmd Le manager de commandes. */ - public void addAtomic(final int _ligneIdx, final int _idxBefore, final double _x, final double _y, + public void addAtomic(final int _idxGeom, final int _idxBefore, final double _x, final double _y, final CtuluCommandContainer _cmd) { if (!isGeomModifiable_) { return; } - Geometry geom = (Geometry)super.geometry_.getValueAt(_ligneIdx); + Geometry geom = (Geometry)super.geometry_.getValueAt(_idxGeom); final Coordinate[] oldcs = geom.getCoordinates(); final int initSize = oldcs.length; final Coordinate[] cs = new Coordinate[initSize + 1]; @@ -131,7 +141,7 @@ } geom = GISGeometryFactory.INSTANCE.createGeometry(geom.getClass(),cs); - setGeometry(_ligneIdx,geom, _cmd); + setGeometry(_idxGeom,geom, _cmd); } /** @@ -238,11 +248,15 @@ return true; } + // dans le cas polygone le dernier point n'est pas a considerer=premier point + if (old instanceof GISPolygone) { + nbPt--; + } // les nouvelles coordonnees. - final Coordinate[] newCs = new Coordinate[nbPt]; + final Coordinate[] newCs = new Coordinate[nbPt-nbSel]; // cette liste contient les indice a enlever : creee que si necessaire // si des attribute atomics existent - final TIntArrayList idxToRemove = containsAtomicAttribute() ? new TIntArrayList(nbPt) : null; + final TIntArrayList idxToRemove = containsAtomicAttribute() ? new TIntArrayList(nbPt-nbSel) : null; // compteur tempo int count = 0; @@ -252,7 +266,8 @@ idxToRemove.add(idxPt); } } else { - newCs[count++] = (Coordinate)old.getCoordinates()[idxPt].clone(); + newCs[count++] = ((GISCoordinateSequenceContainerInterface)old).getCoordinateSequence().getCoordinate(idxPt); +// newCs[count++] = (Coordinate)old.getCoordinates()[idxPt].clone(); } } Geometry newGeom = null; @@ -283,14 +298,15 @@ } } else { - final Coordinate[] coord=new Coordinate[count]; - System.arraycopy(newCs, 0, coord, 0, coord.length); - newGeom=GISGeometryFactory.INSTANCE.createGeometry(old.getClass(), coord); +// final Coordinate[] coord=new Coordinate[count]; +// System.arraycopy(newCs, 0, coord, 0, coord.length); + newGeom=GISGeometryFactory.INSTANCE.createGeometry(old.getClass(), newCs); newGeom.setUserData(old.getUserData()); } if (r) { - super.geometry_.setObject(_idxGeom, newGeom, _cmd); + final CtuluCommandComposite cmp = new CtuluCommandComposite(); + super.geometry_.setObject(_idxGeom, newGeom, cmp); // si des attributs atomics sont concerne if (idxToRemove != null && idxToRemove.size() > 0) { final int[] idx = idxToRemove.toNativeArray(); @@ -303,10 +319,12 @@ // on recupere le sous-model concerne par la modif de geometrie final GISAttributeModel atomicModel = (GISAttributeModel) m.getObjectValueAt(_idxGeom); // on le change - m.setObject(_idxGeom, atomicModel.createSubModel(idx), _cmd); + m.setObject(_idxGeom, atomicModel.createSubModel(idx), cmp); } } } + if (_cmd!=null) + _cmd.addCmd(cmp.getSimplify()); } return r; } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionLigneBrisee.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionLigneBrisee.java 2008-10-05 22:05:30 UTC (rev 4034) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionLigneBrisee.java 2008-10-06 12:46:31 UTC (rev 4035) @@ -23,17 +23,15 @@ import org.fudaa.ctulu.CtuluCommandComposite; import org.fudaa.ctulu.CtuluCommandContainer; import org.fudaa.ctulu.CtuluLib; -import org.fudaa.ctulu.CtuluLibArray; import org.fudaa.ctulu.CtuluLibString; import org.fudaa.ctulu.CtuluListSelectionInterface; import org.fudaa.ctulu.CtuluUI; -import org.fudaa.ctulu.collection.CtuluCollectionDouble; /** * @author Fred Deniger * @version $Id: GISZoneCollectionLigneBrisee.java,v 1.20.6.4 2008-04-01 07:22:47 bmarchan Exp $ */ -public class GISZoneCollectionLigneBrisee extends GISZoneCollection { +public class GISZoneCollectionLigneBrisee extends GISZoneCollectionGeometry { public GISZoneCollectionLigneBrisee() { this(null); @@ -49,18 +47,12 @@ /** * @param _listener le listener */ - public GISZoneCollectionLigneBrisee(final GISZoneListener _listener, final GISZoneCollectionLigneBrisee _br) { - this(10, _listener); - if (_br != null) { - for (int i = 0; i < _br.getNumGeometries(); i++) { - super.geometry_.add(_br.getGeometry(i), null, null); - } - } + public GISZoneCollectionLigneBrisee(final GISZoneListener _listener, final GISZoneCollectionLigneBrisee _col) { + super(_listener,_col); } public GISZoneCollectionLigneBrisee(final int _nbObject, final GISZoneListener _listener) { - super(_nbObject); - listener_ = _listener; + super(_nbObject,_listener); } private List createListForSeveralAdd(final Object[][] _att, final int _nbGeom) { @@ -76,69 +68,6 @@ return attListe; } - /** - * @param _idx l'indice de la ligne a changer - * @param _newLine la nouvelle ligne - * @param _cmd le receveur de commande - */ - private void setValueIntern(final int _idx, final LineString _newLine, final CtuluCommandContainer _cmd) { - if (!isGeomModifiable_) { - return; - } - final LineString old = (LineString) super.geometry_.getValueAt(_idx); - if (old.getNumPoints() == _newLine.getNumPoints() || !containsAtomicAttribute()) { - super.geometry_.setObject(_idx, _newLine, _cmd); - } else { - final CtuluCommandComposite cmp = new CtuluCommandComposite(); - for (int i = getNbAttributes() - 1; i >= 0; i--) { - final GISAttributeInterface att = getAttribute(i); - if (att.isAtomicValue()) { - final GISAttributeModel m = (GISAttributeModel) (getModelListener(i).getObjectValueAt(_idx)); - final GISReprojectInterpolateurI interpolateur = GISZoneAttributeFactory.create1DInterpolateur(att, - (GISCoordinateSequenceContainerInterface)old, - (GISCoordinateSequenceContainerInterface)_newLine, m); - getModelListener(i).setObject(_idx, m.deriveNewModel(_newLine.getNumPoints(), interpolateur), cmp); - } - } - super.geometry_.setObject(_idx, _newLine, cmp); - if (_cmd != null) { - _cmd.addCmd(cmp.getSimplify()); - } - } - } - - /** - * Cr\xE9e un tableau de valeurs d'attributs.<p> - * - * Les valeurs peuvent \xEAtre globales ou atomiques. - * - * @param _init Les valeurs d'initialisation, dans l'ordre et au nombre des mod\xE8les d'attributs. - * Si null, les valeurs par d\xE9faut sont affect\xE9es (voir {@link GISAttributeInterface#getDefaultValue()}) - * @param _dest La g\xE9ometrie polyligne ou polygone. - * @param _isClosed Param\xE8tre inutilis\xE9. - * @return - */ - protected Object[] createAttributeList(final Object[] _init, final Geometry _dest, final boolean _isClosed) { - final Object[] rf = new Object[getNbAttributes()]; - if (_init != null && _init.length != getNbAttributes()) { - throw new IllegalArgumentException("bad size"); - } - for (int i = getNbAttributes() - 1; i >= 0; i--) { - rf[i]=createOrAssignAttribut(i,_init==null?null:_init[i],_dest); - } - return rf; - } - - public boolean accept(final GISVisitor _v) { - final int nb = getNumGeometries(); - for (int i = 0; i < nb; i++) { - if (!((GISLigneBrisee) getGeometry(i)).accept(_v)) { - return false; - } - } - return true; - } - public void addAllLineStringClosedOrNode(final LineString[] _gs, final CtuluCommandContainer _cmd) { if (isGeomModifiable_) { @@ -186,44 +115,11 @@ public int addGeometry(final Geometry _geom, final Object[] _data, final CtuluCommandContainer _cmd) { if (!(_geom instanceof LineString)) throw new IllegalArgumentException("Bad type geometry"); - - if (isGeomModifiable_) { - geometry_.add(_geom, Arrays.asList(createAttributeList(_data, _geom, true)), _cmd); - return geometry_.getSize() - 1; - } - return -1; + + return super.addGeometry(_geom, _data, _cmd); } - /** - * @todo Les poly de niveau sont mal trait\xE9es - */ - public void addPoint(final int _ligneIdx, final int _idxBefore, final double _x, final double _y, - final CtuluCommandContainer _cmd) { - if (!isGeomModifiable_) { - return; - } - LineString str = (LineString) super.geometry_.getValueAt(_ligneIdx); - final CoordinateSequence newSeq = str.getCoordinateSequence(); - final int initSize = newSeq.size(); - final Coordinate[] cs = new Coordinate[initSize + 1]; - int idx = 0; - for (int i = 0; i < initSize; i++) { - cs[idx++] = newSeq.getCoordinateCopy(i); - if (i == _idxBefore) { - cs[idx++] = new Coordinate(_x, _y, newSeq.getOrdinate(i, 2)); - } - } - if (str/*.isClosed()*/ instanceof GISPolygone) { - str = GISGeometryFactory.INSTANCE.createLinearRing(cs); - setValue(_ligneIdx, (GISPolygone) str, _cmd); - } - else if (str instanceof GISPolyligne) { - str = GISGeometryFactory.INSTANCE.createLineString(cs); - setValue(_ligneIdx, (GISPolyligne) str, _cmd); - } - } - public void addPolygone(final CoordinateSequence _g, final CtuluCommandContainer _cmd) { addPolygone((GISPolygone) GISGeometryFactory.INSTANCE.createLinearRing(_g), _cmd); } @@ -280,15 +176,6 @@ addPolyligne((GISPolyligne) GISGeometryFactory.INSTANCE.createLineStringNiveau(_g), _cmd); } - public boolean containsAtomicAttribute() { - for (int i = getNbAttributes() - 1; i >= 0; i--) { - if (getAttribute(i).isAtomicValue()) { - return true; - } - } - return false; - } - /** * @return true si contient au moins un polygone (ligne brisee fermee). */ @@ -317,28 +204,12 @@ return false; } - public CoordinateSequence getCoordinateSequence(final int _i) { - return ((LineString) getGeometry(_i)).getCoordinateSequence(); - } - public Class getDataStoreClass() { return LineString.class; } - public double getDoubleValue(final int _idxAtt, final int _idxGeom) { - if (getAttribute(_idxAtt).isAtomicValue()) { - return CtuluLibArray.getMoyenne(((CtuluCollectionDouble) getModel(_idxAtt).getObjectValueAt(_idxGeom)).getValues()); - } - return ((CtuluCollectionDouble) getModel(_idxAtt)).getValue(_idxGeom); - } - - /** - * Supprime des sommets sur une g\xE9om\xE9trie. - * @param _idxGeom L'indice de la g\xE9om\xE9trie. - * @param _sel La liste des sommets s\xE9lectionn\xE9s. - * @param _ui L'interface utilisateur. - * @param _cmd Le manager de commandes. - * @return true si tout s'est bien pass\xE9. + /* + * Surcharge, en attendant d'etre sur que la methode m\xE8re fonctionne dans tous les cas. */ public boolean removeAtomics(final int _idxGeom, final CtuluListSelectionInterface _sel, final CtuluUI _ui, final CtuluCommandContainer _cmd) { @@ -441,58 +312,4 @@ } return r; } - - public void removeLignes(final int[] _idx, final CtuluCommandContainer _cmd) { - super.geometry_.remove(_idx, _cmd); - } - - public void setCoordinateSequence(final int _idx, final CoordinateSequence _newSeq, final CtuluCommandContainer _cmd) { - final LineString old = (LineString) super.geometry_.getValueAt(_idx); - if (_newSeq != null && _newSeq.size() == old.getNumPoints()) { - final CoordinateSequence seq = GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create(_newSeq); - if (old/*.isClosed()*/ instanceof GISPolygone) { - geometry_.setObject(_idx, GISGeometryFactory.INSTANCE.createLinearRing(seq), _cmd); - } else { - GISPolyligne nl = (GISPolyligne)GISGeometryFactory.INSTANCE.createLineString(seq); - geometry_.setObject(_idx, nl, _cmd); - } - } - } - - - /** - * Remplace une ancienne g\xE9om\xE9trie par un nouveau polygone, en interpolant si n\xE9cessaire les attributs. - * @param _idx L'index de la g\xE9ometrie. - * @param _newLine La nouvelle g\xE9om\xE9trie. - * @param _cmd Le container de commandes. - */ - public void setValue(final int _idx, final GISPolygone _newLine, final CtuluCommandContainer _cmd) { - setValueIntern(_idx, _newLine, _cmd); - } - - /** - * Remplace une ancienne g\xE9om\xE9trie par une nouvelle polyligne, en interpolant si n\xE9cessaire les attributs. - * @param _idx L'index de la g\xE9ometrie. - * @param _newLine La nouvelle g\xE9om\xE9trie. - * @param _cmd Le container de commandes. - */ - public void setValue(final int _idx, final GISPolyligne _newLine, final CtuluCommandContainer _cmd) { - setValueIntern(_idx, _newLine, _cmd); - } - - public void updateListeners() { - for (int i = getNbAttributes() - 1; i >= 0; i--) { - final GISAttributeModelListener m = getModelListener(i); - if (m != null) { - if (m.getAttribute().isAtomicValue()) { - for (int j = m.getSize() - 1; j >= 0; j--) { - ((GISAttributeModelListener) m.getObjectValueAt(j)).setListener(this); - } - - } else { - m.setListener(this); - } - } - } - } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionMultiPoint.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionMultiPoint.java 2008-10-05 22:05:30 UTC (rev 4034) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ctulu/src/org/fudaa/ctulu/gis/GISZoneCollectionMultiPoint.java 2008-10-06 12:46:31 UTC (rev 4035) @@ -7,33 +7,22 @@ */ package org.fudaa.ctulu.gis; -import gnu.trove.TIntArrayList; import gnu.trove.TIntIntHashMap; -import java.util.Arrays; +import org.fudaa.ctulu.CtuluCommandComposite; +import org.fudaa.ctulu.CtuluCommandContainer; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.CoordinateSequence; import com.vividsolutions.jts.geom.Geometry; -import com.memoire.fu.FuLog; - -import org.fudaa.ctulu.CtuluCommandComposite; -import org.fudaa.ctulu.CtuluCommandContainer; -import org.fudaa.ctulu.CtuluLib; -import org.fudaa.ctulu.CtuluLibArray; -import org.fudaa.ctulu.CtuluLibString; -import org.fudaa.ctulu.CtuluListSelectionInterface; -import org.fudaa.ctulu.CtuluUI; -import org.fudaa.ctulu.collection.CtuluCollectionDouble; - /** * Une collection pour les multipoints. * * @author Bertrand Marchand * @version $Id: GISZoneCollectionMultiPoint.java,v 1.1.2.2 2008-04-01 07:22:48 bmarchan Exp $ */ -public class GISZoneCollectionMultiPoint extends GISZoneCollection { +public class GISZoneCollectionMultiPoint extends GISZoneCollectionGeometry { public GISZoneCollectionMultiPoint() { this(null); @@ -50,119 +39,13 @@ * @param _listener le listener */ public GISZoneCollectionMultiPoint(final GISZoneListener _listener, final GISZoneCollectionMultiPoint _col) { - this(10, _listener); - if (_col != null) { - for (int i = 0; i < _col.getNumGeometries(); i++) { - super.geometry_.add(_col.getGeometry(i), null, null); - } - } + super(_listener,_col); } public GISZoneCollectionMultiPoint(final int _nbObject, final GISZoneListener _listener) { - super(_nbObject); - listener_ = _listener; + super(_nbObject,_listener); } -// private List createListForSeveralAdd(final Object[][] _att, final int _nbGeom) { -// final int nbAttributes = getNbAttributes(); -// final List attListe = new ArrayList(nbAttributes); -// for (int i = 0; i < nbAttributes; i++) { -// final Object[] oi = new Object[_nbGeom]; -// for (int j = 0; j < _nbGeom; j++) { -// oi[j] = _att[j][i]; -// } -// attListe.add(oi); -// } -// return attListe; -// } -// -// /** -// * @param _idx l'indice de la ligne a changer -// * @param _newLine la nouvelle ligne -// * @param _cmd le receveur de commande -// */ -// private void setValueIntern(final int _idx, final LineString _newLine, final CtuluCommandContainer _cmd) { -// if (!isGeomModifiable_) { -// return; -// } -// final LineString old = (LineString) super.geometry_.getValueAt(_idx); -// if (old.getNumPoints() == _newLine.getNumPoints() || !containsAtomicAttribute()) { -// super.geometry_.setObject(_idx, _newLine, _cmd); -// } else { -// final CtuluCommandComposite cmp = new CtuluCommandComposite(); -// for (int i = getNbAttributes() - 1; i >= 0; i--) { -// final GISAttributeInterface att = getAttribute(i); -// if (att.isAtomicValue()) { -// final GISAttributeModel m = (GISAttributeModel) (getModelListener(i).getObjectValueAt(_idx)); -// final GISReprojectInterpolateurI interpolateur = GISZoneAttributeFactory.create1DInterpolateur(att, old, -// _newLine, m); -// getModelListener(i).setObject(_idx, m.deriveNewModel(_newLine.getNumPoints(), interpolateur), cmp); -// } -// } -// super.geometry_.setObject(_idx, _newLine, cmp); -// if (_cmd != null) { -// _cmd.addCmd(cmp.getSimplify()); -// } -// } -// } - - /** - * Cr\xE9e un tableau de valeurs d'attributs.<p> - * - * Les valeurs peuvent \xEAtre globales ou atomiques. - * - * @param _init Les valeurs d'initialisation, dans l'ordre et au nombre des mod\xE8les d'attributs. - * Si null, les valeurs par d\xE9faut sont affect\xE9es (voir {@link GISAttributeInterface#getDefaultValue()}) - * @param _dest La g\xE9ometrie. - * @param _isClosed Param\xE8tre inutilis\xE9. - * @return - */ - protected Object[] createAttributeList(final Object[] _init, final Geometry _dest, final boolean _isClosed) { - final Object[] rf = new Object[getNbAttributes()]; - if (_init != null && _init.length != getNbAttributes()) { - throw new IllegalArgumentException("bad size"); - } - for (int i = getNbAttributes() - 1; i >= 0; i--) { - rf[i]=createOrAssignAttribut(i,_init==null?null:_init[i],_dest); - } - return rf; - } - -// public void addAllLineStringClosedOrNode(final LineString[] _gs, final CtuluCommandContainer _cmd) { -// if (isGeomModifiable_) { -// -// final Object[][] att = new Object[_gs.length][]; -// for (int i = 0; i < _gs.length; i++) { -// att[i] = createAttributeList(null, _gs[i], _gs[i].isClosed()); -// } -// -// geometry_.addAll(_gs, createListForSeveralAdd(att, _gs.length), _cmd); -// } -// } - -// public void addAllPolygones(final GISPolygone[] _gs, final CtuluCommandContainer _cmd) { -// if (isGeomModifiable_) { -// final Object[][] att = new Object[_gs.length][]; -// for (int i = 0; i < _gs.length; i++) { -// att[i] = createAttributeList(null, _gs[i], true); -// } -// geometry_.addAll(_gs, createListForSeveralAdd(att, _gs.length), _cmd); -// } -// } -// -// public void addAllPolylignes(final GISPolyligne[] _gs, final CtuluCommandContainer _cmd) { -// if (isGeomModifiable_) { -// final Object[][] att = new Object[_gs.length][]; -// for (int i = 0; i < _gs.length; i++) { -// att[i] = createAttributeList(null, _gs[i], false); -// } -// geometry_.addAll(_gs, createListForSeveralAdd(att, _gs.length), _cmd); -// } -// } - - /** - * Ne peut \xEAtre utilis\xE9 que si la liste contient des objets GIS homogenes. - */ public void addCoordinateSequence(final CoordinateSequence _seq, final Object[] _data, final CtuluCommandContainer _cmd) { if (_seq == null || _seq.size() < 1) { @@ -176,25 +59,13 @@ public int addGeometry(final Geometry _geom, final Object[] _data, final CtuluCommandContainer _cmd) { if (!(_geom instanceof GISMultiPoint)) throw new IllegalArgumentException("Bad type geometry"); - - if (isGeomModifiable_) { - Object[] atts = createAttributeList(_data, _geom, true); - geometry_.add(_geom, Arrays.asList(atts), _cmd); - return geometry_.getSize() - 1; - } - return -1; + + return super.addGeometry(_geom, _data, _cmd); } - public boolean accept(final GISVisitor _v) { - final int nb = getNumGeometries(); - for (int i = 0; i < nb; i++) { - if (!((GISMultiPoint) getGeometry(i)).accept(_v)) { - return false; - } - } - return true; - } - + /* + * Le sommet est ajout\xE9 sans interpolation des valeurs atomiques. + */ public void addAtomic(final int _idxGeom, final int _idxBefore, final double _x, final double _y, final CtuluCommandContainer _cmd) { if (!isGeomModifiable_) { @@ -237,265 +108,10 @@ } } - /** - * @param _idxGeom l'indice de la g\xE9om\xE9trie a remplacer - * @param _geom la nouvelle g\xE9ometrie - * @param _cmd le receveur de commande - */ - public void setGeometry(final int _idxGeom, final Geometry _geom, final CtuluCommandContainer _cmd) { - if (!isGeomModifiable_) { - return; - } - final Geometry old = (Geometry) super.geometry_.getValueAt(_idxGeom); - if (old.getNumPoints() == _geom.getNumPoints() || !containsAtomicAttribute()) { - super.geometry_.setObject(_idxGeom, _geom, _cmd); - } else { - final CtuluCommandComposite cmp = new CtuluCommandComposite(); - for (int i = getNbAttributes() - 1; i >= 0; i--) { - final GISAttributeInterface att = getAttribute(i); - if (att.isAtomicValue()) { - final GISAttributeModel m = (GISAttributeModel) (getModelListener(i).getObjectValueAt(_idxGeom)); - final GISReprojectInterpolateurI interpolateur = GISZoneAttributeFactory.create1DInterpolateur(att, - (GISCoordinateSequenceContainerInterface)old, - (GISCoordinateSequenceContainerInterface)_geom, m); - getModelListener(i).setObject(_idxGeom, m.deriveNewModel(_geom.getNumPoints(), interpolateur), cmp); - } - } - super.geometry_.setObject(_idxGeom, _geom, cmp); - if (_cmd != null) { - _cmd.addCmd(cmp.getSimplify()); - } - } - } - - public CoordinateSequence getCoordinateSequence(final int _i) { - if (!(getGeometry(_i) instanceof GISMultiPoint)) return null; - return ((GISMultiPoint) getGeometry(_i)).getCoordinateSequence(); - } - public Class getDataStoreClass() { return GISMultiPoint.class; } - public double getDoubleValue(final int _idxAtt, final int _idxGeom) { - if (getAttribute(_idxAtt).isAtomicValue()) { - return CtuluLibArray.getMoyenne(((CtuluCollectionDouble) getModel(_idxAtt).getObjectValueAt(_idxGeom)).getValues()); - } - return ((CtuluCollectionDouble) getModel(_idxAtt)).getValue(_idxGeom); - } - - public void setCoordinateSequence(final int _idx, final CoordinateSequence _newSeq, final CtuluCommandContainer _cmd) { - final Geometry old = (Geometry) super.geometry_.getValueAt(_idx); - if (_newSeq != null && _newSeq.size() == old.getNumPoints()) { - final CoordinateSequence seq = GISGeometryFactory.INSTANCE.getCoordinateSequenceFactory().create(_newSeq); - geometry_.setObject(_idx, GISGeometryFactory.INSTANCE.createMultiPoint(seq), _cmd); - } - } - - public void updateListeners() { - for (int i = getNbAttributes() - 1; i >= 0; i--) { - final GISAttributeModelListener m = getModelListener(i); - if (m != null) { - if (m.getAttribute().isAtomicValue()) { - for (int j = m.getSize() - 1; j >= 0; j--) { - ((GISAttributeModelListener) m.getObjectValueAt(j)).setListener(this); - } - - } else { - m.setListener(this); - } - } - } - } - -// /** -// * @todo Les poly de niveau sont mal trait\xE9es -// */ -// public void addPoint(final int _ligneIdx, final int _idxBefore, final double _x, final double _y, -// final CtuluCommandContainer _cmd) { -// if (!isGeomModifiable_) { -// return; -// } -// LineString str = (LineString) super.geometry_.getValueAt(_ligneIdx); -// final CoordinateSequence newSeq = str.getCoordinateSequence(); -// final int initSize = newSeq.size(); -// final Coordinate[] cs = new Coordinate[initSize + 1]; -// int idx = 0; -// for (int i = 0; i < initSize; i++) { -// cs[idx++] = newSeq.getCoordinateCopy(i); -// if (i == _idxBefore) { -// cs[idx++] = new Coordinate(_x, _y, newSeq.getOrdinate(i, 2)); -// } -// } -// -// if (str/*.isClosed()*/ instanceof GISPolygone) { -// str = GISGeometryFactory.INSTANCE.createLinearRing(cs); -// setValue(_ligneIdx, (GISPolygone) str, _cmd); -// } -// else if (str instanceof GISPolyligne) { -// boolean breliee=((GISPolyligne)str).isReliee(); -// str = GISGeometryFactory.INSTANCE.createLineString(cs); -// ((GISPolyligne)str).setReliee(breliee); -// setValue(_ligneIdx, (GISPolyligne) str, _cmd); -// } -// } - -/* public void addPolygone(final CoordinateSequence _g, final CtuluCommandContainer _cmd) { - addPolygone((GISPolygone) GISGeometryFactory.INSTANCE.createLinearRing(_g), _cmd); - } - - public void addPolygone(final CoordinateSequence _g, final Object[] _data, final CtuluCommandContainer _cmd) { - addPolygone((GISPolygone) GISGeometryFactory.INSTANCE.createLinearRing(_g), _data, _cmd); - } - - public void addPolygone(final GISPolygone _g, final CtuluCommandContainer _cmd) { - addPolygone(_g, null, _cmd); - } - - public void addPolygone(final GISPolygone _g, final Object[] _data, final CtuluCommandContainer _cmd) { - if (isGeomModifiable_) { - super.geometry_.add(_g, Arrays.asList(createAttributeList(_data, _g, true)), _cmd); - } - } - - public void addPolygoneNiveau(final CoordinateSequence _g, final CtuluCommandContainer _cmd) { - addPolygone((GISPolygone) GISGeometryFactory.INSTANCE.createLinearRingNiveau(_g), _cmd); - }*/ - - /** - * Ajoute une polyligne sous forme d'une liste de coordonn\xE9es, avec attributs et gestionnaire de commandes. - * @param _g La liste de coordonn\xE9es, renseign\xE9e en Z. - * @param _data Les attributs, dans l'ordre dans lequel ils sont d\xE9finis dans la collection. - * @param _cmd Le gestionnaire de commandes. Peut \xEAtre null. - */ -/* public void addPolyligne(final CoordinateSequence _g, final Object[] _data, final CtuluCommandContainer _cmd) { - addPolyligne((GISPolyligne) GISGeometryFactory.INSTANCE.createLineString(_g), _data, _cmd); - } - - public void addPolyligne(final GISCoordinateSequence _g, final CtuluCommandContainer _cmd) { - addPolyligne((GISPolyligne) GISGeometryFactory.INSTANCE.createLineString(_g), _cmd); - } - - public void addPolyligne(final GISPolyligne _g, final CtuluCommandContainer _cmd) { - addPolyligne(_g, null, _cmd); - }*/ - - /** - * Ajoute une polyligne, avec attributs et gestionnaire de commandes. - * @param _g La polyligne, renseign\xE9e en Z. - * @param _data Les attributs, dans l'ordre dans lequel ils sont d\xE9finis dans la collection. - * @param _cmd Le gestionnaire de commandes. Peut \xEAtre null. - */ -/* public void addPolyligne(final GISPolyligne _g, final Object[] _data, final CtuluCommandContainer _cmd) { - if (isGeomModifiable_) { - super.geometry_.add(_g, Arrays.asList(createAttributeList(_data, _g, false)), _cmd); - } - } - - public void addMultiPoint(final GISMultiPoint _g, final Object[] _data, final CtuluCommandContainer _cmd) { - if (isGeomModifiable_) { - super.geometry_.add(_g, Arrays.asList(createAttributeList(_data, _g, false)), _cmd); - } - }*/ - -// public void addPolyligneNiveau(final GISCoordinateSequence _g, final CtuluCommandContainer _cmd) { -// addPolyligne((GISPolyligne) GISGeometryFactory.INSTANCE.createLineStringNiveau(_g), _cmd); -// } - - public boolean containsAtomicAttribute() { - for (int i = getNbAttributes() - 1; i >= 0; i--) { - if (getAttribute(i).isAtomicValue()) { - return true; - } - } - return false; - } - - /** - * Supprime des sommets sur une g\xE9om\xE9trie. - * @param _idxGeom L'indice de la g\xE9om\xE9trie. - * @param _sel La liste des sommets s\xE9lectionn\xE9s. - * @param _ui L'interface utilisateur. - * @param _cmd Le manager de commandes. - * @return true si tout s'est bien pass\xE9. - */ - public boolean removeAtomics(final int _idxGeom, final CtuluListSelectionInterface _sel, final CtuluUI _ui, - final CtuluCommandContainer _cmd) { - if (_sel == null || _sel.isEmpty()) { - return false; - } - boolean r = true; - final Geometry old = (Geometry) getGeometry(_idxGeom); - int nbPt = old.getNumPoints(); - - // Raccourci si tous les sommets sont s\xE9lectionn\xE9s. - int nbSel=_sel.getNbSelectedIndex(); - if (nbSel==nbPt) { - removeGeometries(new int[]{_idxGeom}, _cmd); - return true; - } - - // les nouvelles coordonnees. - final Coordinate[] newCs = new Coordinate[nbPt-nbSel]; - // cette liste contient les indice a enlever : creee que si necessaire - // si des attribute atomics existent - final TIntArrayList idxToRemove = containsAtomicAttribute() ? new TIntArrayList(nbPt-nbSel) : null; - - // compteur tempo - int count = 0; - for (int idxPt = 0; idxPt < nbPt; idxPt++) { - if (_sel.isSelected(idxPt)) { - if (idxToRemove != null) { - idxToRemove.add(idxPt); - } - } else { - newCs[count++] = ((GISCoordinateSequenceContainerInterface)old).getCoordinateSequence().getCoordinate(idxPt); - } - } - GISMultiPoint newGeom=null; - if (count<1) { - r=false; - if (_ui!=null) { - _ui.error(null, CtuluLib.getS("La ligne non reliee doit contenir {0} points au moins", CtuluLibString.UN), false); - } - if (FuLog.isTrace()) { - FuLog.trace("EBLI: polylignes: not enough points"); - // message - } - } - else { -// final Coordinate[] coord=new Coordinate[count]; -// System.arraycopy(newCs, 0, coord, 0, coord.length); - newGeom=(GISMultiPoint)GISGeometryFactory.INSTANCE.createMultiPoint(newCs); - newGeom.setUserData(old.getUserData()); - } - - if (r) { - CtuluCommandComposite cmp=new CtuluCommandComposite(); - super.geometry_.setObject(_idxGeom, newGeom, cmp); - // si des attributs atomics sont concerne - if (idxToRemove != null && idxToRemove.size() > 0) { - final int[] idx = idxToRemove.toNativeArray(); - Arrays.sort(idx); - for (int i = getNbAttributes() - 1; i >= 0; i--) { - // attribut atomic - if (getAttribute(i).isAtomicValue()) { - // dans ce cas on recupere le model contenant cet attribut - final GISAttributeModel m = getModelListener(i); - // on recupere le sous-model concerne par la modif de geometrie - final GISAttributeModel atomicModel = (GISAttributeModel) m.getObjectValueAt(_idxGeom); - // on le change - m.setObject(_idxGeom, atomicModel.createSubModel(idx), cmp); - } - } - } - if (_cmd!=null) { - _cmd.addCmd(cmp.getSimplify()); - } - } - return r; - } - public boolean addAll(final GISDataModel _model, final CtuluCommandContainer _cmd, final boolean _doPostImport) { if (!isGeomModifiable_ || _model == null) { return false; @@ -507,16 +123,4 @@ } return super.addAll(_model, _cmd, _doPostImport); } - -// public void removeLignes(final int[] _idx, final CtuluCommandContainer _cmd) { -// super.geometry_.remove(_idx, _cmd); -// } -// -// public void setValue(final int _idx, final GISPolygone _newLine, final CtuluCommandContainer _cmd) { -// setValueIntern(_idx, _newLine, _cmd); -// } -// -// public void setValue(final int _idx, final GISPolyligne _newLine, final CtuluCommandContainer _cmd) { -// setValueIntern(_idx, _newLine, _cmd); -// } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleLigneBriseeEditable.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleLigneBriseeEditable.java 2008-10-05 22:05:30 UTC (rev 4034) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZModeleLigneBriseeEditable.java 2008-10-06 12:46:31 UTC (rev 4035) @@ -269,7 +269,7 @@ GrPoint point = (new GrSegment(new GrPoint(g.getX(_idxBefore), g.getY(_idxBefore), 0), new GrPoint(g.getX(_idxBefore + 1), g.getY(_idxBefore + 1), 0))) .pointPlusProche(new GrPoint(_x, _y, 0)); - geometries_.addPoint(_ligneIdx, _idxBefore, point.x_, point.y_, _cmd); + geometries_.addAtomic(_ligneIdx, _idxBefore, point.x_, point.y_, _cmd); } /** @@ -333,7 +333,7 @@ } // Remplacement dans la collection. - geometries_.removeLignes(new int[]{_ligneIdx}, cmp); + geometries_.removeGeometries(new int[]{_ligneIdx}, cmp); geometries_.addPolyligne((GISPolyligne)GISGeometryFactory.INSTANCE.createLineString(cline1), dataline1, cmp); geometries_.addPolyligne((GISPolyligne)GISGeometryFactory.INSTANCE.createLineString(cline2), dataline2, cmp); @@ -432,7 +432,7 @@ // Remplacement dans la collection. geometries_.addPolyligne((GISPolyligne)GISGeometryFactory.INSTANCE.createLineString(cline), dataline, cmp); - geometries_.removeLignes(_ligneIdx, cmp); + geometries_.removeGeometries(_ligneIdx, cmp); if (_cmd != null) { _cmd.addCmd(cmp.getSimplify()); @@ -526,11 +526,11 @@ if (isGeometryFermee(i)) { final GISPolygone poly = (GISPolygone) GISGeometryFactory.INSTANCE.createLinearRing(newSeq); - geometries_.setValue(i, poly, cmp); + geometries_.setGeometry(i, poly, cmp); } else { final GISPolyligne poly = (GISPolyligne) GISGeometryFactory.INSTANCE.createLineString(newSeq); - geometries_.setValue(i, poly, cmp); + geometries_.setGeometry(i, poly, cmp); } } } @@ -605,7 +605,7 @@ } return false; } - geometries_.setValue(idx, poly, cmp); + geometries_.setGeometry(idx, poly, cmp); } else { final GISPolyligne poly = (GISPolyligne) GISGeometryFactory.INSTANCE.createLineString(newSeq); @@ -615,7 +615,7 @@ } return false; } - geometries_.setValue(idx, poly, cmp); + geometries_.setGeometry(idx, poly, cmp); } if (newvals!=null) @@ -661,11 +661,11 @@ } if (isGeometryFermee(i)) { final GISPolygone poly = (GISPolygone) GISGeometryFactory.INSTANCE.createLinearRing(newSeq); - geometries_.setValue(i, poly, cmp); + geometries_.setGeometry(i, poly, cmp); } else { final GISPolyligne poly = (GISPolyligne) GISGeometryFactory.INSTANCE.createLineString(newSeq); - geometries_.setValue(i, poly, cmp); + geometries_.setGeometry(i, poly, cmp); } } } @@ -727,7 +727,7 @@ } return false; } - geometries_.setValue(idx, poly, cmp); + geometries_.setGeometry(idx, poly, cmp); } else { final GISPolyligne poly = (GISPolyligne) GISGeometryFactory.INSTANCE.createLineString(newSeq); @@ -737,7 +737,7 @@ } return false; } - geometries_.setValue(idx, poly, cmp); + geometries_.setGeometry(idx, poly, cmp); } } } @@ -758,7 +758,7 @@ if (geometries_ == null) { return false; } - geometries_.removeLignes(_idx, _cmd); + geometries_.removeGeometries(_idx, _cmd); for(int i=0 ; i<_idx.length;i++) setGeomModif(_idx[i], _cmd); // Modification de l'\xE9tat de la g\xE9om\xE9trie return true; Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java 2008-10-05 22:05:30 UTC (rev 4034) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/layer/MdlModel2dLine.java 2008-10-06 12:46:31 UTC (rev 4035) @@ -225,7 +225,7 @@ } GISPolyligne newgeom=(GISPolyligne)GISGeometryFactory.INSTANCE.createLineString((Coordinate[])coords.toArray(new Coordinate[0])); - geometries_.setValue(_idxGeom, newgeom, _cmd); + geometries_.setGeometry(_idxGeom, newgeom, _cmd); setGeomModif(_idxGeom, _cmd); // Modification de l'etat de la g\xE9om\xE9trie return true; } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/FSigLineSingleModel.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/FSigLineSingleModel.java 2008-10-05 22:05:30 UTC (rev 4034) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/FSigLineSingleModel.java 2008-10-06 12:46:31 UTC (rev 4035) @@ -53,7 +53,7 @@ public final void setLine(final LineString _r) { if (geom_.getNumGeometries() > 0) { - geom_.removeLignes(new int[] { 0 }, null); + geom_.removeGeometries(new int[] { 0 }, null); } r_ = _r; geom_.addCoordinateSequence(r_.getCoordinateSequence(), null, null); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/data/TrSiProfilLayer.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/data/TrSiProfilLayer.java 2008-10-05 22:05:30 UTC (rev 4034) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/data/TrSiProfilLayer.java 2008-10-06 12:46:31 UTC (rev 4035) @@ -364,7 +364,7 @@ } if (!l.containsLegend(this)) { l.ajoute(this, buildPanel(null), getTitle()); - if (getModelePoly().getNombre() == 0) { + if (modeleDonnees().getNombre() == 0) { l.setVisible(this, false); } } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/data/TrSiProfileSplitter.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/data/TrSiProfileSplitter.java 2008-10-05 22:05:30 UTC (rev 4034) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/tr/data/TrSiProfileSplitter.java 2008-10-06 12:46:31 UTC (rev 4035) @@ -346,7 +346,7 @@ zonei = GISGeometryFactory.INSTANCE.createPolygon(ringi, null); } else { final int idx = _zone.indexOf(ringi.lit_); - _zone.removeLignes(new int[] { idx }, null); + _zone.removeGeometries(new int[] { idx }, null); zonei = GISGeometryFactory.INSTANCE.createPolygon(ringi.lit_, null); envi = ringi.lit_.getEnvelopeInternal(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |