Revision 30788 branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/layers/VectorialLayerEdited.java
VectorialLayerEdited.java | ||
---|---|---|
127 | 127 |
SelectRowPanel selectionPanel=new SelectRowPanel(set, this); |
128 | 128 |
PluginServices.getMDIManager().addCentredWindow(selectionPanel); |
129 | 129 |
} |
130 |
selectAndDrawGeometries(featureStore, set, vp, multipleSelection);
|
|
130 |
selectGeometries(featureStore, set, vp, multipleSelection); |
|
131 | 131 |
} catch (ReadException e) { |
132 | 132 |
NotificationManager.addError(e.getMessage(), e); |
133 | 133 |
} catch (GeometryOperationNotSupportedException e) { |
... | ... | |
179 | 179 |
} |
180 | 180 |
fq.setFilter(evaluator); |
181 | 181 |
FeatureSet set = featureStore.getFeatureSet(fq); |
182 |
selectAndDrawGeometries(featureStore, set, vp, false);
|
|
182 |
selectGeometries(featureStore, set, vp, false); |
|
183 | 183 |
} catch (ReadException e) { |
184 | 184 |
NotificationManager.addError(e.getMessage(), e); |
185 | 185 |
} catch (GeometryOperationNotSupportedException e) { |
... | ... | |
202 | 202 |
Evaluator evaluator=new ContainsGeometryEvaluator(polygon, vp.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()); |
203 | 203 |
fq.setFilter(evaluator); |
204 | 204 |
FeatureSet set = featureStore.getFeatureSet(fq); |
205 |
selectAndDrawGeometries(featureStore, set, vp, false);
|
|
205 |
selectGeometries(featureStore, set, vp, false); |
|
206 | 206 |
} catch (ReadException e) { |
207 | 207 |
NotificationManager.addError(e.getMessage(), e); |
208 | 208 |
} catch (DataException e) { |
... | ... | |
213 | 213 |
NotificationManager.addError(e.getMessage(), e); |
214 | 214 |
} |
215 | 215 |
} |
216 |
private void selectAndDrawGeometries(FeatureStore featureStore, FeatureSet set, ViewPort vp, boolean multipleSelection) throws DataException, GeometryOperationNotSupportedException, GeometryOperationException{
|
|
216 |
private void selectGeometries(FeatureStore featureStore, FeatureSet set, ViewPort vp, boolean multipleSelection) throws DataException, GeometryOperationNotSupportedException, GeometryOperationException{ |
|
217 | 217 |
BufferedImage selectionImage = null; |
218 | 218 |
BufferedImage handlersImage = null; |
219 | 219 |
// if (!multipleSelection) { |
... | ... | |
237 | 237 |
featureSelection.select(set); |
238 | 238 |
featureStore.setSelection(featureSelection); |
239 | 239 |
} |
240 |
|
|
241 |
DisposableIterator iterator = null; |
|
242 |
|
|
243 |
try { |
|
244 |
iterator = set.iterator(); |
|
245 |
DrawOperationContext doc = new DrawOperationContext(); |
|
246 |
doc.setGraphics(gs); |
|
247 |
doc.setViewPort(vp); |
|
248 |
doc.setSymbol(mapControlManager.getSelectionSymbol()); |
|
249 |
while (iterator.hasNext()) { |
|
250 |
Feature feature = (Feature) iterator.next(); |
|
251 |
org.gvsig.fmap.geom.Geometry geom = feature |
|
252 |
.getDefaultGeometry(); |
|
253 |
if (geom == null) { |
|
254 |
continue; |
|
255 |
} |
|
256 |
geom.cloneGeometry().invokeOperation(Draw.CODE, doc); |
|
257 |
drawHandlers(geom.cloneGeometry(), gh, vp); |
|
258 |
} |
|
259 |
} finally { |
|
260 |
if (iterator != null) { |
|
261 |
iterator.dispose(); |
|
262 |
} |
|
263 |
} |
|
264 |
|
|
265 | 240 |
set.dispose(); |
266 |
setSelectionImage(selectionImage); |
|
267 |
setHandlersImage(handlersImage); |
|
268 | 241 |
} |
242 |
|
|
269 | 243 |
public void selectCrossPolygon(org.gvsig.fmap.geom.Geometry polygon) { |
270 | 244 |
try { |
271 | 245 |
FeatureStore featureStore = getFeatureStore(); |
... | ... | |
275 | 249 |
Evaluator evaluator=new CrossesGeometryEvaluator(polygon, vp.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()); |
276 | 250 |
fq.setFilter(evaluator); |
277 | 251 |
FeatureSet set = featureStore.getFeatureSet(fq); |
278 |
selectAndDrawGeometries(featureStore,set,vp,false);
|
|
252 |
selectGeometries(featureStore,set,vp,false); |
|
279 | 253 |
} catch (ReadException e) { |
280 | 254 |
NotificationManager.addError(e.getMessage(), e); |
281 | 255 |
} catch (DataException e) { |
... | ... | |
296 | 270 |
Evaluator evaluator=new OutGeometryEvaluator(polygon, vp.getProjection(), featureStore.getDefaultFeatureType(), featureStore.getDefaultFeatureType().getDefaultGeometryAttributeName()); |
297 | 271 |
fq.setFilter(evaluator); |
298 | 272 |
FeatureSet set = featureStore.getFeatureSet(fq); |
299 |
selectAndDrawGeometries(featureStore, set, vp, false);
|
|
273 |
selectGeometries(featureStore, set, vp, false); |
|
300 | 274 |
|
301 | 275 |
} catch (ReadException e) { |
302 | 276 |
NotificationManager.addError(e.getMessage(), e); |
... | ... | |
314 | 288 |
FeatureStore featureStore = getFeatureStore(); |
315 | 289 |
ViewPort vp = getLayer().getMapContext().getViewPort(); |
316 | 290 |
FeatureSet set = featureStore.getFeatureSet(); |
317 |
selectAndDrawGeometries(featureStore, set, vp, false);
|
|
291 |
selectGeometries(featureStore, set, vp, false); |
|
318 | 292 |
} catch (ReadException e) { |
319 | 293 |
NotificationManager.addError(e.getMessage(), e); |
320 | 294 |
} catch (DataException e) { |
... | ... | |
326 | 300 |
} |
327 | 301 |
} |
328 | 302 |
|
329 |
public void drawHandlers(org.gvsig.fmap.geom.Geometry geom, Graphics2D gs,
|
|
303 |
public void drawHandlers(org.gvsig.fmap.geom.Geometry geom, |
|
330 | 304 |
ViewPort vp) { |
331 | 305 |
Handler[] handlers = geom |
332 | 306 |
.getHandlers(org.gvsig.fmap.geom.Geometry.SELECTHANDLER); |
... | ... | |
351 | 325 |
} |
352 | 326 |
|
353 | 327 |
public void beforeLayerDraw(LayerDrawEvent e) throws CancelationException { |
328 |
|
|
329 |
} |
|
330 |
|
|
331 |
public void afterLayerDraw(LayerDrawEvent e) throws CancelationException { |
|
332 |
//Draw the selected geometries... |
|
354 | 333 |
FeatureStore featureStore = null; |
334 |
DisposableIterator iterator = null; |
|
355 | 335 |
try { |
356 | 336 |
featureStore = getFeatureStore(); |
357 |
} catch (ReadException e2) { |
|
358 |
e2.printStackTrace(); |
|
359 |
} |
|
360 |
if (featureStore.isEditing()) { |
|
361 |
ViewPort vp = getLayer().getMapContext().getViewPort(); |
|
362 |
BufferedImage selectionImage = new BufferedImage( |
|
363 |
vp.getImageWidth(), vp.getImageHeight(), |
|
364 |
BufferedImage.TYPE_INT_ARGB); |
|
365 |
BufferedImage handlersImage = new BufferedImage(vp.getImageWidth(), |
|
366 |
vp.getImageHeight(), BufferedImage.TYPE_INT_ARGB); |
|
367 |
Graphics2D gs = selectionImage.createGraphics(); |
|
368 |
Graphics2D gh = handlersImage.createGraphics(); |
|
369 |
DisposableIterator iterator = null; |
|
370 |
try { |
|
337 |
if (featureStore.isEditing()) { |
|
338 |
ViewPort vp = getLayer().getMapContext().getViewPort(); |
|
371 | 339 |
iterator = featureStore.getFeatureSelection() |
372 | 340 |
.iterator(); |
373 | 341 |
try { |
... | ... | |
375 | 343 |
Feature feature = (Feature) iterator.next(); |
376 | 344 |
org.gvsig.fmap.geom.Geometry geom = feature |
377 | 345 |
.getDefaultGeometry(); |
378 |
|
|
379 |
DrawOperationContext doc = new DrawOperationContext(); |
|
380 |
doc.setGraphics(gs); |
|
381 |
doc.setViewPort(vp); |
|
382 |
doc.setSymbol(mapControlManager.getSelectionSymbol()); |
|
383 |
try { |
|
384 |
geom.cloneGeometry() |
|
385 |
.invokeOperation(Draw.CODE, doc); |
|
386 |
} catch (GeometryOperationNotSupportedException e1) { |
|
387 |
e1.printStackTrace(); |
|
388 |
} catch (GeometryOperationException e1) { |
|
389 |
e1.printStackTrace(); |
|
390 |
} |
|
391 |
drawHandlers(geom.cloneGeometry(), gh, vp); |
|
346 |
mapControl.getMapControlDrawer().startDrawing(this); |
|
347 |
mapControl.getMapControlDrawer().setGraphics(e.getGraphics()); |
|
348 |
drawHandlers(geom.cloneGeometry(), vp); |
|
349 |
mapControl.getMapControlDrawer().stopDrawing(this); |
|
392 | 350 |
} |
393 | 351 |
} catch (ConcurrentModificationException e1) { |
394 | 352 |
// throw new CancelationException(e1); |
395 |
// A mitad de pintado se cambia la selecci�n y por tanto no
|
|
353 |
// A mitad de pintado se cambia la selecci?n y por tanto no
|
|
396 | 354 |
// se puede seguir recorriendo la anterior. |
397 | 355 |
return; |
398 | 356 |
} |
399 |
} catch (DataException e2) { |
|
400 |
e2.printStackTrace(); |
|
401 |
} finally { |
|
402 |
if (iterator != null) { |
|
403 |
iterator.dispose(); |
|
404 |
} |
|
405 | 357 |
} |
406 |
|
|
407 |
setSelectionImage(selectionImage); |
|
408 |
setHandlersImage(handlersImage); |
|
358 |
} catch (Exception e2) { |
|
359 |
e2.printStackTrace(); |
|
360 |
} finally { |
|
361 |
if (iterator != null) { |
|
362 |
iterator.dispose(); |
|
363 |
} |
|
409 | 364 |
} |
410 | 365 |
} |
411 | 366 |
|
412 |
public void afterLayerDraw(LayerDrawEvent e) throws CancelationException { |
|
413 |
} |
|
414 |
|
|
415 | 367 |
public void beforeGraphicLayerDraw(LayerDrawEvent e) |
416 | 368 |
throws CancelationException { |
417 | 369 |
} |
Also available in: Unified diff