Revision 21293 trunk/extensions/extTopology/src/com/iver/cit/gvsig/cad/SplitGeometryCADTool.java
SplitGeometryCADTool.java | ||
---|---|---|
50 | 50 |
|
51 | 51 |
import java.awt.Graphics; |
52 | 52 |
import java.awt.Graphics2D; |
53 |
import java.awt.Image; |
|
54 | 53 |
import java.awt.event.InputEvent; |
55 | 54 |
import java.awt.event.MouseEvent; |
56 | 55 |
import java.awt.geom.Point2D; |
... | ... | |
66 | 65 |
import com.iver.cit.gvsig.cad.sm.SplitGeometryCADToolContext; |
67 | 66 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException; |
68 | 67 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileWriteException; |
69 |
import com.iver.cit.gvsig.exceptions.validate.ValidateRowException; |
|
70 | 68 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
71 | 69 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
72 | 70 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
... | ... | |
77 | 75 |
import com.iver.cit.gvsig.fmap.edition.EditionEvent; |
78 | 76 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
79 | 77 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
80 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
|
81 | 78 |
import com.iver.cit.gvsig.gui.cad.DefaultCADTool; |
82 | 79 |
import com.iver.cit.gvsig.gui.cad.exception.CommandException; |
83 | 80 |
import com.iver.cit.gvsig.layers.VectorialLayerEdited; |
... | ... | |
154 | 151 |
} |
155 | 152 |
|
156 | 153 |
public ArrayList getSelectedRows(){ |
157 |
ArrayList selection = super.getSelectedRows(); |
|
158 |
if(selection != null ){ |
|
159 |
if( selection.size() == 0){ |
|
160 |
VectorialEditableAdapter vea = getVLE().getVEA(); |
|
161 |
try { |
|
162 |
FBitSet bitset = vea.getSelection(); |
|
163 |
for (int j = bitset.nextSetBit(0);j >= 0;j = bitset.nextSetBit(j + 1)){ |
|
164 |
IRowEdited rowEd =vea.getRow(j); |
|
165 |
selection.add(rowEd); |
|
166 |
} |
|
167 |
} catch (ExpansionFileReadException e) { |
|
168 |
e.printStackTrace(); |
|
169 |
} catch (ReadDriverException e) { |
|
170 |
e.printStackTrace(); |
|
171 |
} |
|
172 |
}//selection size |
|
173 |
} |
|
174 |
return selection; |
|
154 |
return (ArrayList) CADUtil.getSelectedFeatures(getVLE()); |
|
175 | 155 |
} |
176 | 156 |
|
177 | 157 |
public void splitSelectedGeometryWithDigitizedLine(){ |
... | ... | |
187 | 167 |
IRowEdited editedRow = null; |
188 | 168 |
VectorialLayerEdited vle = getVLE(); |
189 | 169 |
VectorialEditableAdapter vea = vle.getVEA(); |
190 |
// vea.startComplexRow();
|
|
170 |
vea.startComplexRow(); |
|
191 | 171 |
for (int i = 0; i < selectedRows.size(); i++) { |
192 | 172 |
editedRow = (IRowEdited) selectedRows.get(i); |
193 | 173 |
IFeature feat = (IFeature) editedRow.getLinkedRow().cloneRow(); |
... | ... | |
205 | 185 |
GeometryCollection gc = (GeometryCollection)splittedGeo; |
206 | 186 |
for(int j = 0; j < gc.getNumGeometries(); j++){ |
207 | 187 |
Geometry g = gc.getGeometryN(j); |
208 |
System.out.println("g"+j+":"+g.toText()); |
|
209 | 188 |
IGeometry fmapGeo = FConverter.jts_to_igeometry(g); |
210 |
DefaultFeature newFeature = new DefaultFeature(fmapGeo, feat.getAttributes(), vea.getNewFID()); |
|
211 |
int calculatedIndex = vea.addRow(newFeature, getName(), EditionEvent.GRAPHIC); |
|
189 |
String newFID = vea.getNewFID(); |
|
190 |
DefaultFeature df = new DefaultFeature(fmapGeo, feat.getAttributes(), newFID); |
|
191 |
int newIdx = CADUtil.addFeature(vle, df, getName()); |
|
212 | 192 |
|
213 |
DefaultRowEdited newRowEdited = new DefaultRowEdited(newFeature,
|
|
214 |
IRowEdited.STATUS_ADDED,
|
|
215 |
calculatedIndex);
|
|
193 |
DefaultRowEdited newRowEdited = new DefaultRowEdited(df,
|
|
194 |
IRowEdited.STATUS_ADDED, |
|
195 |
newIdx);
|
|
216 | 196 |
splittedSelectionGeoms.add(newRowEdited); |
217 | 197 |
}//for j |
218 | 198 |
} catch (ExpansionFileReadException e) { |
... | ... | |
221 | 201 |
e.printStackTrace(); |
222 | 202 |
} catch (ReadDriverException e) { |
223 | 203 |
e.printStackTrace(); |
224 |
} catch (ValidateRowException e) { |
|
225 |
e.printStackTrace(); |
|
226 | 204 |
} |
227 | 205 |
}//if splittedGeo |
228 | 206 |
} |
229 |
// vea.endComplexRow(description);
|
|
230 |
// vle.setSelectionCache(VectorialLayerEdited.SAVEPREVIOUS,
|
|
231 |
// splittedSelectionGeoms);
|
|
207 |
vea.endComplexRow(getName());
|
|
208 |
vle.setSelectionCache(VectorialLayerEdited.SAVEPREVIOUS, |
|
209 |
splittedSelectionGeoms);
|
|
232 | 210 |
} |
233 | 211 |
|
234 | 212 |
public void end(){ |
Also available in: Unified diff