Revision 23086 branches/v2_0_0_prep/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/MoveCADTool.java
MoveCADTool.java | ||
---|---|---|
41 | 41 |
package com.iver.cit.gvsig.gui.cad.tools; |
42 | 42 |
|
43 | 43 |
import java.awt.Graphics; |
44 |
import java.awt.Graphics2D; |
|
44 | 45 |
import java.awt.Image; |
45 | 46 |
import java.awt.event.InputEvent; |
46 | 47 |
import java.awt.geom.Point2D; |
47 | 48 |
import java.util.ArrayList; |
49 |
import java.util.Iterator; |
|
48 | 50 |
|
49 | 51 |
import org.cresques.cts.ICoordTrans; |
52 |
import org.gvsig.fmap.data.DataException; |
|
50 | 53 |
import org.gvsig.fmap.data.ReadException; |
54 |
import org.gvsig.fmap.data.feature.Feature; |
|
51 | 55 |
import org.gvsig.fmap.data.feature.FeatureCollection; |
56 |
import org.gvsig.fmap.data.feature.FeatureStore; |
|
57 |
import org.gvsig.fmap.data.feature.IsNotFeatureSettingException; |
|
52 | 58 |
import org.gvsig.fmap.geom.Geometry; |
59 |
import org.gvsig.fmap.geom.operation.Draw; |
|
60 |
import org.gvsig.fmap.geom.operation.DrawOperationContext; |
|
61 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
62 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
53 | 63 |
import org.gvsig.fmap.geom.util.UtilFunctions; |
54 | 64 |
import org.gvsig.fmap.mapcontext.ViewPort; |
55 | 65 |
|
... | ... | |
139 | 149 |
MoveCADToolState actualState = (MoveCADToolState) _fsm.getPreviousState(); |
140 | 150 |
String status = actualState.getName(); |
141 | 151 |
VectorialLayerEdited vle=getVLE(); |
142 |
VectorialEditableAdapter vea = vle.getVEA(); |
|
143 |
ArrayList selectedRow=getSelectedRows(); |
|
144 |
ArrayList selectedRowAux=new ArrayList(); |
|
152 |
FeatureStore featureStore=null; |
|
153 |
try { |
|
154 |
featureStore = vle.getFeatureStore(); |
|
155 |
} catch (ReadException e1) { |
|
156 |
// TODO Auto-generated catch block |
|
157 |
e1.printStackTrace(); |
|
158 |
} |
|
159 |
FeatureCollection selection=(FeatureCollection)featureStore.getSelection();//getSelectedRows(); |
|
160 |
// ArrayList selectedRowAux=new ArrayList(); |
|
145 | 161 |
ICoordTrans ct=getVLE().getLayer().getCoordTrans(); |
146 | 162 |
if (status.equals("Move.FirstPointToMove")) { |
147 | 163 |
firstPoint = new Point2D.Double(x, y); |
148 | 164 |
} else if (status.equals("Move.SecondPointToMove")) { |
149 | 165 |
PluginServices.getMDIManager().setWaitCursor(); |
150 | 166 |
lastPoint = new Point2D.Double(x, y); |
151 |
vea.startComplexRow();
|
|
167 |
featureStore.getCommandsRecord().startComplex();
|
|
152 | 168 |
|
153 | 169 |
try { |
154 |
for (int i = 0; i < selectedRow.size(); i++) { |
|
155 |
IRowEdited edRow = (IRowEdited) selectedRow.get(i); |
|
156 |
IFeature feat = (IFeature) edRow.getLinkedRow().cloneRow(); |
|
157 |
Geometry ig = feat.getGeometry(); |
|
170 |
Iterator iterator=selection.iterator(); |
|
171 |
while (iterator.hasNext()) { |
|
172 |
Feature feature = (Feature) iterator.next(); |
|
173 |
|
|
174 |
// } |
|
175 |
// for (int i = 0; i < selection.size(); i++) { |
|
176 |
// IRowEdited edRow = (IRowEdited) selectedRow.get(i); |
|
177 |
// IFeature feat = (IFeature) edRow.getLinkedRow().cloneRow(); |
|
178 |
Geometry ig = ((Geometry)feature.getDefaultGeometry()).cloneGeometry(); |
|
179 |
feature.editing(); |
|
158 | 180 |
if (ig == null) |
159 | 181 |
continue; |
160 | 182 |
if (ct!=null) { |
... | ... | |
170 | 192 |
|
171 | 193 |
// if (ct!=null) |
172 | 194 |
// ig.reProject(ct.getInverted()); |
173 |
|
|
174 |
vea.modifyRow(edRow.getIndex(),feat,getName(),EditionEvent.GRAPHIC); |
|
175 |
selectedRowAux.add(new DefaultRowEdited(feat,IRowEdited.STATUS_MODIFIED,edRow.getIndex())); |
|
195 |
feature.setGeometry(featureStore.getDefaultFeatureType().getDefaultGeometry(),ig); |
|
196 |
featureStore.update(feature); |
|
197 |
// vea.modifyRow(edRow.getIndex(),feat,getName(),EditionEvent.GRAPHIC); |
|
198 |
// selectedRowAux.add(new DefaultRowEdited(feat,IRowEdited.STATUS_MODIFIED,edRow.getIndex())); |
|
176 | 199 |
} |
177 |
vea.endComplexRow(getName());
|
|
178 |
vle.setSelectionCache(VectorialLayerEdited.NOTSAVEPREVIOUS, selectedRowAux); |
|
200 |
featureStore.getCommandsRecord().endComplex(getName());
|
|
201 |
// vle.setSelectionCache(VectorialLayerEdited.NOTSAVEPREVIOUS, selectedRowAux);
|
|
179 | 202 |
//clearSelection(); |
180 | 203 |
//selectedRow.addAll(selectedRowAux); |
181 | 204 |
|
182 |
} catch (ValidateRowException e) { |
|
183 |
NotificationManager.addError(e.getMessage(),e); |
|
184 |
} catch (ExpansionFileWriteException e) { |
|
205 |
} catch (ReadException e) { |
|
185 | 206 |
NotificationManager.addError(e.getMessage(),e); |
186 |
} catch (ReadException e) { |
|
187 |
NotificationManager.addError(e.getMessage(),e); |
|
207 |
} catch (IsNotFeatureSettingException e) { |
|
208 |
// TODO Auto-generated catch block |
|
209 |
e.printStackTrace(); |
|
210 |
} catch (DataException e) { |
|
211 |
// TODO Auto-generated catch block |
|
212 |
e.printStackTrace(); |
|
188 | 213 |
} |
189 | 214 |
PluginServices.getMDIManager().restoreCursor(); |
190 | 215 |
} |
... | ... | |
213 | 238 |
int dy = -vp.fromMapDistance(y - firstPoint.getY()); |
214 | 239 |
Image img = vle.getSelectionImage(); |
215 | 240 |
g.drawImage(img, dx, dy, null); |
216 |
/*for (int i = 0; i < selectedRow.size(); i++) { |
|
241 |
// try { |
|
242 |
// Iterator iterator=vle.getFeatureStore().getSelection().iterator(); |
|
243 |
// while (iterator.hasNext()) { |
|
244 |
// Feature feature = (Feature) iterator.next(); |
|
245 |
// Geometry ig = ((Geometry)feature.getDefaultGeometry()).cloneGeometry(); |
|
246 |
// if (ig == null) |
|
247 |
// continue; |
|
248 |
// // Movemos la geometr?a |
|
249 |
// UtilFunctions.moveGeom(ig, x - firstPoint.getX(), y - firstPoint.getY()); |
|
250 |
// |
|
251 |
// DrawOperationContext doc=new DrawOperationContext(); |
|
252 |
// doc.setGraphics((Graphics2D)g); |
|
253 |
// doc.setViewPort(vp); |
|
254 |
// doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
|
255 |
// try { |
|
256 |
// ig.invokeOperation(Draw.CODE,doc); |
|
257 |
// } catch (GeometryOperationNotSupportedException e) { |
|
258 |
// e.printStackTrace(); |
|
259 |
// } catch (GeometryOperationException e) { |
|
260 |
// e.printStackTrace(); |
|
261 |
// } |
|
262 |
// } |
|
263 |
// } catch (ReadException e) { |
|
264 |
// // TODO Auto-generated catch block |
|
265 |
// e.printStackTrace(); |
|
266 |
// } |
|
267 |
/*for (int i = 0; i < selectedRow.size(); i++) { |
|
217 | 268 |
IRowEdited edRow = (IRowEdited) selectedRow.get(i); |
218 | 269 |
IFeature feat = (IFeature) edRow.getLinkedRow(); |
219 | 270 |
IGeometry ig = feat.getGeometry().cloneGeometry(); |
Also available in: Unified diff