From: <de...@us...> - 2013-01-10 14:12:54
|
Revision: 8194 http://fudaa.svn.sourceforge.net/fudaa/?rev=8194&view=rev Author: deniger Date: 2013-01-10 14:12:46 +0000 (Thu, 10 Jan 2013) Log Message: ----------- Modified Paths: -------------- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/collection/CtuluCollectionObjectAbstract.java trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/GISAttribute.java trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/GISZoneCollection.java Modified: trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/collection/CtuluCollectionObjectAbstract.java =================================================================== --- trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/collection/CtuluCollectionObjectAbstract.java 2013-01-10 14:11:56 UTC (rev 8193) +++ trunk/framework/ctulu-common/src/main/java/org/fudaa/ctulu/collection/CtuluCollectionObjectAbstract.java 2013-01-10 14:12:46 UTC (rev 8194) @@ -104,7 +104,8 @@ /** * Initialise avec une liste de taille de 20 par defaut. */ - protected CtuluCollectionObjectAbstract() {} + protected CtuluCollectionObjectAbstract() { + } @Override protected void fireObjectChanged(int _indexGeom, Object _newValue) { Modified: trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/GISAttribute.java =================================================================== --- trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/GISAttribute.java 2013-01-10 14:11:56 UTC (rev 8193) +++ trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/GISAttribute.java 2013-01-10 14:12:46 UTC (rev 8194) @@ -132,6 +132,8 @@ @Override public GISAttributeModelObservable createAtomicModel(final Object[] _initValues, final int _nbValues) { if (_initValues != null) { + + //TODO voir ici if (_initValues.length != _nbValues) { throw new IllegalArgumentException("bad size value=" + _nbValues + " used=" + _initValues.length); } Modified: trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/GISZoneCollection.java =================================================================== --- trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/GISZoneCollection.java 2013-01-10 14:11:56 UTC (rev 8193) +++ trunk/framework/ctulu-gis/src/main/java/org/fudaa/ctulu/gis/GISZoneCollection.java 2013-01-10 14:12:46 UTC (rev 8194) @@ -37,7 +37,7 @@ * @version $Id$ */ public abstract class GISZoneCollection extends GISCollection implements GISAttributeListener, GISDataModel { - + private String title_; /** * La liste ordonn\xE9e des mod\xE8les d'attributs associ\xE9es \xE0 la collection. @@ -69,15 +69,15 @@ */ protected boolean attListHasChanged_ = true; protected boolean isGeomModifiable_ = true; - + public GISZoneCollection() { super(); } - + public GISZoneCollection(final boolean _isGeomModifiable) { isGeomModifiable_ = _isGeomModifiable; } - + public void setGeomModifiable(boolean isGeomModifiable) { this.isGeomModifiable_ = isGeomModifiable; } @@ -96,35 +96,35 @@ public GISZoneCollection(final int _nbObject) { super(_nbObject); } - + @Override public long getId() { return -1; } - + protected void fireAttributeAdded(int _newIdx, GISAttributeInterface _newAtt) { if (listener_ != null) { listener_.attributeAction(this, _newIdx, _newAtt, GISZoneListener.ATTRIBUTE_ACTION_ADD); } } - + protected void fireAttributeRemoved(int _oldIdx, GISAttributeInterface _oldAtt) { if (listener_ != null) { listener_.attributeAction(this, _oldIdx, _oldAtt, GISZoneListener.ATTRIBUTE_ACTION_REMOVE); } } - + protected void fireAttributeValueChanged(int _idxAtt, GISAttributeInterface _att, int _idxGeom, Object _newValue) { if (listener_ != null) { listener_.attributeValueChangeAction(this, _idxAtt, _att, _idxGeom, _newValue); } } - + @Override public void gisDataChanged(GISAttributeInterface _att, int _indexGeom, Object _newValue) { fireAttributeValueChanged(getIndiceOf(_att), _att, _indexGeom, _newValue); } - + protected void fireTitleChanged() { } @@ -136,11 +136,11 @@ protected CtuluCollection getData(final int _i) { return isDataCreated(_i) ? attr_[_i] : null; } - + protected Object getDefaultValuesObject(final int _idxValues) { return isDataCreated(_idxValues) ? attr_[_idxValues].getAttribute().getDefaultValue() : null; } - + @Override public Object clone() { GISZoneCollection cloned = (GISZoneCollection) super.superClone(); @@ -173,6 +173,7 @@ } } } + cloned.updateListeners(); return cloned; } @@ -183,7 +184,7 @@ protected GISAttributeModelObservable getModelListener(final int _i) { return (GISAttributeModelObservable) getData(_i); } - + protected void initAttributes(final GISAttributeInterface[] _att) { if (_att != null) { badIdxAttZ_ = true; @@ -199,7 +200,7 @@ } } } - + protected void initAttributes(final GISAttributeModelObservable[] _att) { badIdxAttZ_ = true; attListHasChanged_ = true; @@ -225,16 +226,16 @@ public void redo() { initAttributes(_att, null); } - + @Override public void undo() { initAttributes(old, null); } }); } - + } - + } /** @@ -244,7 +245,7 @@ protected boolean isDataCreated(final int _i) { return attr_ != null && attr_.length > _i && attr_[_i] != null; } - + @Override public abstract boolean accept(GISVisitor _v); @@ -279,15 +280,16 @@ os[igeom] = createOrAssignAttribut(iatt, _model.getValue(iatt, igeom), pt[igeom]); } data.add(nbGeom == 1 ? os[0] : os); - + } - + final int firstIdx = super.geometry_.getSize() - 1; super.geometry_.addAll(pt, data, _cmd); if (_doPostImport) { postImport(firstIdx); } - + updateListeners(); + return true; } @@ -308,6 +310,10 @@ val = _init; } ret = getDataModel(_iatt).getAttribute().createDataForGeom(val, nbPt); + //Fred pour mettre a jour le listener + if (ret instanceof GISAttributeModelObservable) { + ((GISAttributeModelObservable) ret).setListener(this); + } // FIXME B.M. : Pas sur que ce soit le bienvenu. Si on veut des valeurs par d\xE9faut et que la g\xE9om\xE9trie poss\xE8de // des Z, il ne faudrait pas que ce soit initialis\xE9 (cas d'import de fichier et ajout par addAll). if (getIdxAttZ() != -1 && getAttributeIsZ() != null && getAttributeIsZ().isAtomicValue() && _init == null @@ -319,7 +325,7 @@ } return ret; } - + public abstract void addCoordinateSequence(CoordinateSequence _seq, Object[] _datas, CtuluCommandContainer _cmd); /** @@ -331,7 +337,7 @@ * @return l'index de la g\xE9om\xE9trie cr\xE9\xE9e, -1 si rien n'est cr\xE9e */ public abstract int addGeometry(Geometry _geom, Object[] _datas, CtuluCommandContainer _cmd); - + public void removeGeometries(final int[] _idx, final CtuluCommandContainer _cmd) { if (!isGeomModifiable_) { return; @@ -349,7 +355,7 @@ geometry_.removeAll(_cmd); } } - + public GISAttributeModel[] getAtomicAttributeSubModel(final int _geomIdx) { final int nb = getNbAttributes(); final List<GISAttributeModel> r = new ArrayList<GISAttributeModel>(nb); @@ -364,7 +370,7 @@ r.toArray(rf); return rf; } - + @Override public GISAttributeInterface getAttribute(final int _i) { final GISAttributeModel model = getDataModel(_i); @@ -387,7 +393,7 @@ res[i] = getAttribute(i); } return res; - + } /** @@ -403,7 +409,7 @@ * @return la classe a utiliser pour les sauvegardes dans les data stores */ public abstract Class getDataStoreClass(); - + @Override public int getIndiceOf(final GISAttributeInterface _att) { if (attListHasChanged_) { @@ -421,7 +427,7 @@ } return -1; } - + public GISAttributeInterface getAttributeWithID(final String _attributId) { if (attr_ != null && _attributId != null) { for (int i = attr_.length - 1; i >= 0; i--) { @@ -444,22 +450,22 @@ } return null; } - + public GISAttributeModel getModel(final int _i) { return (GISAttributeModelObservable) getData(_i); } - + public GISAttributeModel[] getModels() { final GISAttributeModel[] res = new GISAttributeModel[attr_.length]; System.arraycopy(attr_, 0, res, 0, attr_.length); return res; } - + @Override public int getNbAttributes() { return attr_ == null ? 0 : attr_.length; } - + public int getNbGeometries() { return super.getNumGeometries(); } @@ -470,7 +476,7 @@ public final String getTitle() { return title_; } - + @Override public Object getValue(final int _idxAtt, final int _idxGeom) { if (_idxAtt < 0 || _idxAtt > getNbAttributes()) { @@ -521,13 +527,13 @@ if (getIdxAttZ() == -1) { return; } - + final int nb = getNumGeometries(); for (int i = (_firstIdx < 0 ? 0 : _firstIdx); i < nb; i++) { initZAttribute(i); } } - + @Override public void preload(final GISAttributeInterface[] _att, final ProgressionInterface _prog) { } @@ -542,13 +548,13 @@ if (getIdxAttZ() == -1) { return; } - + final int nb = getNumGeometries(); for (int i = 0; i < nb; i++) { initZCoordinate(i); } } - + protected int getIdxAttZ() { if (badIdxAttZ_) { idxAttZ_ = getIndiceOf(attributeIsZ_); @@ -569,7 +575,7 @@ // Il s'agit d'un polygone => Le dernier point doit prendre comme valeur celle du premier. boolean bgone = getGeometry(_idxGeom) instanceof GISPolygone; - + final GISAttributeModel model = getModel(getIdxAttZ()); if (!model.getAttribute().isAtomicValue()) { final CoordinateSequence seq = getCoordinateSequence(_idxGeom); @@ -612,9 +618,9 @@ // Il s'agit d'un polygone => Le dernier point doit prendre comme valeur celle du premier. boolean bgone = getGeometry(_idxGeom) instanceof GISPolygone; - + final GISAttributeModel model = getModel(getIdxAttZ()); - + if (model instanceof GISAttributeModelObjectInterface) { final CoordinateSequence seq = getCoordinateSequence(_idxGeom); final GISAttributeModelDoubleArray arr = (GISAttributeModelDoubleArray) model.getObjectValueAt(_idxGeom); @@ -694,7 +700,7 @@ // on recupere les valeurs d\xE9j\xE0 utilis\xE9es final Map<GISAttributeInterface, GISAttributeModel> exist = new HashMap<GISAttributeInterface, GISAttributeModel>( attr_ == null ? 0 : attr_.length); - + if (attr_ != null) { for (int i = attr_.length - 1; i >= 0; i--) { exist.put(attr_[i].getAttribute(), attr_[i]); @@ -722,7 +728,7 @@ fireAttributeAdded(-1, null); fireAttributeRemoved(-1, null); } - + @Override public void undo() { attr_ = old; @@ -731,9 +737,9 @@ } }); } - + } - + public abstract void setCoordinateSequence(int _idx, CoordinateSequence _newSeq, CtuluCommandContainer _cmd); /** @@ -755,7 +761,7 @@ public void redo() { setTitle(_title, null); } - + @Override public void undo() { setTitle(old, null); @@ -763,20 +769,20 @@ }); } return true; - + } /** * Mise a jour des listeners. */ public abstract void updateListeners(); - + @Override protected void internActionCleared(final CtuluCommandContainer _c) { for (int i = getNbAttributes() - 1; i >= 0; i--) { getData(i).removeAll(_c); } - + } /** @@ -819,14 +825,14 @@ } else { getData(i).addObject(o, _c); } - + } else { // la liste est cree automatiquement // elle fait deja la taille du nombre de point if (_nbValues > 1) { final int[] idx = new int[_nbValues]; final int max = getNumGeometries() - 1; - + for (int k = _nbValues - 1; k >= 0; k--) { idx[k] = max - k; } @@ -845,9 +851,9 @@ } } } - + } - + @Override protected void internActionPointInserted(final int _i, final List _l, final CtuluCommandContainer _c) { if (_l == null) { @@ -877,9 +883,9 @@ } } } - + } - + @Override protected void internActionPointRemoved(final int _i, final CtuluCommandContainer _c) { for (int i = getNbAttributes() - 1; i >= 0; i--) { @@ -888,7 +894,7 @@ } } } - + @Override protected void internActionPointRemoved(final int[] _i, final CtuluCommandContainer _c) { for (int i = getNbAttributes() - 1; i >= 0; i--) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |