42 |
**/ |
**/ |
43 |
package skrueger.geotools.selection; |
package skrueger.geotools.selection; |
44 |
|
|
|
import java.awt.RenderingHints; |
|
45 |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeEvent; |
46 |
import java.beans.PropertyChangeListener; |
import java.beans.PropertyChangeListener; |
47 |
import java.util.HashMap; |
import java.io.File; |
48 |
import java.util.HashSet; |
import java.util.HashSet; |
49 |
import java.util.Iterator; |
import java.util.Iterator; |
50 |
import java.util.Set; |
import java.util.Set; |
54 |
import javax.swing.ListSelectionModel; |
import javax.swing.ListSelectionModel; |
55 |
import javax.swing.event.ListSelectionListener; |
import javax.swing.event.ListSelectionListener; |
56 |
|
|
57 |
|
import org.geotools.feature.FeatureCollection; |
58 |
|
import org.geotools.feature.FeatureIterator; |
59 |
|
import org.geotools.filter.FidFilterImpl; |
60 |
import org.geotools.map.MapLayer; |
import org.geotools.map.MapLayer; |
|
import org.geotools.renderer.GTRenderer; |
|
|
import org.geotools.renderer.label.LabelCacheImpl; |
|
|
import org.geotools.renderer.lite.StreamingRenderer; |
|
|
import org.geotools.renderer.shape.ShapefileRenderer; |
|
61 |
import org.geotools.styling.FeatureTypeStyle; |
import org.geotools.styling.FeatureTypeStyle; |
62 |
import org.geotools.styling.Style; |
import org.geotools.styling.Style; |
63 |
import org.geotools.styling.visitor.DuplicatingStyleVisitor; |
import org.geotools.styling.visitor.DuplicatingStyleVisitor; |
64 |
import org.opengis.feature.simple.SimpleFeature; |
import org.opengis.feature.simple.SimpleFeature; |
65 |
|
import org.opengis.feature.simple.SimpleFeatureType; |
66 |
|
import org.opengis.filter.Filter; |
67 |
|
import org.opengis.filter.Not; |
68 |
import org.opengis.filter.identity.FeatureId; |
import org.opengis.filter.identity.FeatureId; |
69 |
|
|
70 |
import schmitzm.geotools.FilterUtil; |
import schmitzm.geotools.FilterUtil; |
71 |
import schmitzm.geotools.GTUtil; |
import schmitzm.geotools.gui.SelectableXMapPane; |
|
import schmitzm.geotools.gui.JMapPane; |
|
72 |
import schmitzm.geotools.map.event.FeatureSelectedEvent; |
import schmitzm.geotools.map.event.FeatureSelectedEvent; |
|
import schmitzm.geotools.map.event.JMapPaneEvent; |
|
73 |
import schmitzm.geotools.map.event.JMapPaneListener; |
import schmitzm.geotools.map.event.JMapPaneListener; |
74 |
|
import schmitzm.geotools.map.event.MapPaneEvent; |
75 |
import schmitzm.geotools.styling.StylingUtil; |
import schmitzm.geotools.styling.StylingUtil; |
76 |
import skrueger.geotools.MapPaneToolBar; |
import skrueger.geotools.MapPaneToolBar; |
77 |
import skrueger.geotools.StyledLayerInterface; |
import skrueger.geotools.StyledFeaturesInterface; |
78 |
|
|
79 |
/** |
/** |
80 |
* This class keeps the selection of a (feature) {@link JTable} synchronized |
* This class keeps the selection of a (feature) {@link JTable} synchronized |
97 |
public class FeatureMapLayerSelectionSynchronizer extends |
public class FeatureMapLayerSelectionSynchronizer extends |
98 |
StyledLayerSelectionModelSynchronizer<StyledFeatureLayerSelectionModel> |
StyledLayerSelectionModelSynchronizer<StyledFeatureLayerSelectionModel> |
99 |
implements JMapPaneListener { |
implements JMapPaneListener { |
100 |
public static final String SELECTION_STYLING = "SELECTION"; |
|
101 |
|
/** |
102 |
|
* This constant is set as the {@link FeatureTypeStyle#getName()} attribute |
103 |
|
* in the {@link FeatureTypeStyle}s that only exist to present the selected |
104 |
|
* features |
105 |
|
**/ |
106 |
|
public static final String SELECTION_STYLING_FTS_NAME = "SELECTION"; |
107 |
|
|
108 |
/** |
/** |
109 |
* Holds the {@link MapLayer} to keep synchronized with the layer selection |
* Holds the {@link MapLayer} to keep synchronized with the layer selection |
110 |
* model. |
* model. |
111 |
*/ |
*/ |
112 |
protected final MapLayer mapLayer; |
protected final MapLayer mapLayer; |
113 |
protected final StyledLayerInterface<?> styledLayer; |
protected final StyledFeaturesInterface<?> styledLayer; |
114 |
protected final JMapPane mapPane; |
protected final SelectableXMapPane mapPane; |
115 |
private final MapPaneToolBar toolBar; |
private final MapPaneToolBar toolBar; |
|
private final HashMap<Object, Object> defaultGTRenderingHints; |
|
116 |
|
|
117 |
/** |
/** |
118 |
* Creates a new synchronizer |
* Creates a new synchronizer |
126 |
*/ |
*/ |
127 |
public FeatureMapLayerSelectionSynchronizer( |
public FeatureMapLayerSelectionSynchronizer( |
128 |
StyledFeatureLayerSelectionModel layerSelModel, |
StyledFeatureLayerSelectionModel layerSelModel, |
129 |
StyledLayerInterface<?> styledLayer, MapLayer mapLayer, |
StyledFeaturesInterface<?> styledLayer, MapLayer mapLayer, |
130 |
JMapPane mapPane, MapPaneToolBar toolBar, HashMap<Object, Object> defaultGTRenderingHints) { |
SelectableXMapPane mapPane, MapPaneToolBar toolBar) { |
131 |
|
|
132 |
super(layerSelModel); |
super(layerSelModel); |
133 |
this.styledLayer = styledLayer; |
this.styledLayer = styledLayer; |
135 |
this.mapLayer = mapLayer; |
this.mapLayer = mapLayer; |
136 |
this.mapPane = mapPane; |
this.mapPane = mapPane; |
137 |
this.toolBar = toolBar; |
this.toolBar = toolBar; |
|
if (defaultGTRenderingHints != null) |
|
|
this.defaultGTRenderingHints = defaultGTRenderingHints; |
|
|
else |
|
|
this.defaultGTRenderingHints = new HashMap<Object, Object>(); |
|
138 |
} |
} |
139 |
|
|
140 |
/** |
/** |
184 |
*/ |
*/ |
185 |
private void changeLayerStyle(final Vector<String> newSelection) { |
private void changeLayerStyle(final Vector<String> newSelection) { |
186 |
try { |
try { |
187 |
|
|
188 |
Style originalStyle = mapLayer.getStyle(); |
Style originalStyle = mapLayer.getStyle(); |
189 |
|
|
190 |
if (newSelection.isEmpty()) { |
if (newSelection.isEmpty()) { |
191 |
|
|
192 |
// Check if the Style contains a SELECTION FTS |
// Check if the Style contains a SELECTION FTS |
193 |
|
|
194 |
FeatureTypeStyle[] clone = originalStyle.featureTypeStyles().toArray( new FeatureTypeStyle[] {} ).clone(); |
FeatureTypeStyle[] clone = originalStyle.featureTypeStyles() |
195 |
|
.toArray(new FeatureTypeStyle[] {}).clone(); |
196 |
|
|
197 |
for (FeatureTypeStyle fts : clone) { |
for (FeatureTypeStyle fts : clone) { |
198 |
if (fts.getName() != null |
if (fts.getName() != null |
199 |
&& fts.getName().equals(SELECTION_STYLING)) { |
&& fts.getName().equals(SELECTION_STYLING_FTS_NAME)) { |
200 |
originalStyle.featureTypeStyles().remove(fts); |
originalStyle.featureTypeStyles().remove(fts); |
201 |
|
|
202 |
replaceRenderer(); |
mapLayer.setStyle(originalStyle); |
203 |
// mapPane.refresh(); |
// replaceRenderer(); |
204 |
|
// // mapPane.refresh(); |
205 |
|
|
206 |
return; |
return; |
207 |
} |
} |
208 |
} |
} |
209 |
|
|
210 |
} else { |
} else { |
211 |
|
|
212 |
LOGGER.debug("SELECTION .. change style"); |
LOGGER.debug("SELECTION .. change style"); |
213 |
|
|
214 |
|
// Saving a repaint if the selection didn't change |
215 |
|
if (!selectionChanged(newSelection, originalStyle)) { |
216 |
|
return; |
217 |
|
} |
218 |
|
|
219 |
// We take Style from the MapLayer that is displayed at the |
// We take Style from the MapLayer that is displayed at the |
220 |
// moment. We do not use the styledLayer.getStyle, because in |
// moment. We do not use the styledLayer.getStyle, because in |
221 |
// the atlas, this always return the default style, but |
// the atlas, this always return the default style, but |
226 |
FeatureTypeStyle selectionFTStyle = StylingUtil |
FeatureTypeStyle selectionFTStyle = StylingUtil |
227 |
.createSelectionStyle(styledLayer.getGeoObject()); |
.createSelectionStyle(styledLayer.getGeoObject()); |
228 |
|
|
229 |
selectionFTStyle.setName(SELECTION_STYLING); |
selectionFTStyle.setName(SELECTION_STYLING_FTS_NAME); |
230 |
|
|
231 |
/** |
/** |
232 |
* |
* |
233 |
* Add a Filter to the selectionMapStyle, so that it is only |
* Add a Filter to the selectionMapStyle, so that it is only |
234 |
* used on objects that are selected. <br/> |
* used on objects that are selected. <br/> |
235 |
|
* To optimize rendering speed, the filter checks whether more |
236 |
|
* than half of the features are selected. If so, the filter is |
237 |
|
* inverted to be shorter. |
238 |
* |
* |
|
* Note 1:<br/> |
|
|
* It is NEVER allowed to GeoTools extend Filter () { .. } (and |
|
|
* write tests into the evaluate block). Especially for the |
|
|
* ShapeFileRenderer, we may only use a geotools Filter.<br/> |
|
|
* |
|
|
* Note 2:<br/> |
|
|
* The FilterUtil.FILTER_FAC2.id(fids) wants a set of |
|
|
* FeatureId-Objects! |
|
239 |
*/ |
*/ |
240 |
|
final FeatureCollection<SimpleFeatureType, SimpleFeature> featureCollectionFiltered = styledLayer |
241 |
|
.getFeatureCollectionFiltered(); |
242 |
|
if (newSelection.size() > featureCollectionFiltered.size() / 2) { |
243 |
|
FeatureIterator<SimpleFeature> iterator = featureCollectionFiltered |
244 |
|
.features(); |
245 |
|
Set<FeatureId> antiFids = new HashSet<FeatureId>(); |
246 |
|
try { |
247 |
|
while (iterator.hasNext()) { |
248 |
|
SimpleFeature next = iterator.next(); |
249 |
|
if (!newSelection.contains(next.getID())) |
250 |
|
antiFids.add(FilterUtil.FILTER_FAC2 |
251 |
|
.featureId(next.getID())); |
252 |
|
} |
253 |
|
|
254 |
|
selectionFTStyle.rules().get(0).setFilter( |
255 |
|
FilterUtil.FILTER_FAC2 |
256 |
|
.not(FilterUtil.FILTER_FAC2 |
257 |
|
.id(antiFids))); |
258 |
|
|
259 |
Set<FeatureId> fids = new HashSet<FeatureId>(); |
} finally { |
260 |
for (String fid : newSelection) { |
featureCollectionFiltered.close(iterator); |
261 |
fids.add(FilterUtil.FILTER_FAC2.featureId(fid)); |
} |
262 |
} |
} else { |
263 |
|
Set<FeatureId> fids = new HashSet<FeatureId>(); |
264 |
|
for (String fid : newSelection) { |
265 |
|
if (fid != null) |
266 |
|
fids.add(FilterUtil.FILTER_FAC2.featureId(fid)); |
267 |
|
} |
268 |
|
|
269 |
selectionFTStyle.rules().get(0).setFilter( |
selectionFTStyle.rules().get(0).setFilter( |
270 |
FilterUtil.FILTER_FAC2.id(fids)); |
FilterUtil.FILTER_FAC2.id(fids)); |
271 |
|
} |
272 |
|
|
273 |
// Maybe there has already been another selection |
// Maybe there has already been another selection |
274 |
// FeatureTypeStyle... Let's replace it... |
// FeatureTypeStyle... Let's replace it... |
275 |
boolean foundAndReplaced = false; |
boolean foundAndReplaced = false; |
276 |
for (FeatureTypeStyle fts : originalStyle.featureTypeStyles()) { |
for (FeatureTypeStyle fts : originalStyle.featureTypeStyles()) { |
277 |
if (fts.getName() != null |
if (fts.getName() != null |
278 |
&& fts.getName().equals(SELECTION_STYLING)) { |
&& fts.getName().equals(SELECTION_STYLING_FTS_NAME)) { |
279 |
foundAndReplaced = true; |
foundAndReplaced = true; |
280 |
fts.rules().clear(); |
fts.rules().clear(); |
281 |
fts.rules().addAll(selectionFTStyle.rules()); |
fts.rules().addAll(selectionFTStyle.rules()); |
285 |
if (!foundAndReplaced) { |
if (!foundAndReplaced) { |
286 |
originalStyle.featureTypeStyles().add(selectionFTStyle); |
originalStyle.featureTypeStyles().add(selectionFTStyle); |
287 |
} |
} |
|
|
|
|
|
|
288 |
|
|
289 |
// Refresh the map |
// Refresh the map |
290 |
// mapPane.refresh(); |
// mapPane.refresh(); |
291 |
|
|
292 |
DuplicatingStyleVisitor dsv = new DuplicatingStyleVisitor(); |
DuplicatingStyleVisitor dsv = new DuplicatingStyleVisitor(); |
293 |
dsv.visit(originalStyle); |
dsv.visit(originalStyle); |
294 |
Style newStyle = (Style)dsv.getCopy(); |
Style newStyle = (Style) dsv.getCopy(); |
295 |
|
|
296 |
// Style newStyle = StylingUtil.STYLE_BUILDER.createStyle(); |
// SK-Debug |
297 |
// newStyle.featureTypeStyles().addAll(originalStyle.featureTypeStyles()); |
try { |
298 |
|
// |
299 |
|
StylingUtil.saveStyleToSLD(newStyle, new File( |
300 |
|
"/home/stefan/Desktop/selection.sld")); |
301 |
|
} catch (Exception e) { |
302 |
|
} |
303 |
|
|
304 |
|
// DuplicatingStyleVisitor dsv = new DuplicatingStyleVisitor(); |
305 |
|
// dsv.visit(originalStyle); |
306 |
|
// Style newStyle = originalStyle; |
307 |
|
|
308 |
|
// Style newStyle = StylingUtil.STYLE_BUILDER.createStyle(); |
309 |
|
// newStyle.featureTypeStyles().addAll(originalStyle.featureTypeStyles()); |
310 |
mapLayer.setStyle(newStyle); |
mapLayer.setStyle(newStyle); |
311 |
|
|
312 |
replaceRenderer(); |
replaceRenderer(); |
313 |
} |
} |
314 |
|
|
317 |
} |
} |
318 |
} |
} |
319 |
|
|
320 |
private void replaceRenderer() { |
/** |
321 |
// |
* Analyzes whether the selection has changed in comparison to the selection |
322 |
// // Has to be done before we apply the new Renderer |
* stored in the mapLayer.Style |
323 |
// mapLayer.setStyle(style); |
* |
324 |
|
* @param newSelection a List<String> of all newly selected FIDs |
325 |
|
* @param originalStyle the original {@link Style} that has an earlier selection coded into the {@link Style} |
326 |
|
* @return <code>true</code> if changed. |
327 |
|
*/ |
328 |
|
private boolean selectionChanged(Vector<String> newSelection, |
329 |
|
Style originalStyle) { |
330 |
|
|
331 |
GTRenderer oldRenderer = mapPane.getRenderer(); |
boolean SELECTION_STYLING_foundInMapStyle = false; |
332 |
|
|
333 |
/** |
/** |
334 |
* Explicitly putting a new instance of LabelCacheDefault into the |
* testing, whether the selection really changed. If not, we can save |
335 |
* renderer instance, so JMapPane doesn't reuse the old one. This is |
* one rendering! |
|
* very useful when changing the TextSymbolizer with AtlasStyler<br/> |
|
|
* SK 9.7.09: It's not enought to user LabelCache.clear(). We can not |
|
|
* reuse the old Renderer - better to create a new one! |
|
336 |
*/ |
*/ |
337 |
final GTRenderer newRenderer = GTUtil.createGTRenderer(oldRenderer.getContext()); |
for (FeatureTypeStyle fts : originalStyle.featureTypeStyles()) { |
338 |
|
|
339 |
|
if (fts.getName() != null |
340 |
|
&& fts.getName().equals(SELECTION_STYLING_FTS_NAME)) { |
341 |
|
|
342 |
|
SELECTION_STYLING_foundInMapStyle = true; |
343 |
|
|
344 |
|
Filter filter = fts.rules().get(0).getFilter(); |
345 |
|
if (filter instanceof Not) { |
346 |
|
FidFilterImpl antiOrigFidsFilter = (FidFilterImpl) ((Not) filter) |
347 |
|
.getFilter(); |
348 |
|
|
349 |
final HashMap<Object, Object> rendererHints = defaultGTRenderingHints; |
// Check one way |
350 |
rendererHints.put(StreamingRenderer.LABEL_CACHE_KEY, |
final Set<String> antiFids = antiOrigFidsFilter |
351 |
new LabelCacheImpl()); |
.getFidsSet(); |
352 |
|
|
353 |
newRenderer.setRendererHints(rendererHints); |
if (antiFids.isEmpty() && !newSelection.isEmpty()) |
354 |
mapPane.setRenderer(newRenderer); |
return true; |
355 |
|
|
356 |
if (oldRenderer != null) { |
for (String fid : antiFids) { |
357 |
|
if (newSelection.contains(fid)) { |
358 |
RenderingHints java2DHints = oldRenderer.getJava2DHints(); |
return true; |
359 |
if (java2DHints != null) { |
} |
360 |
newRenderer.setJava2DHints(java2DHints); |
} |
361 |
|
|
362 |
|
// Check the other way |
363 |
|
for (String fid : newSelection) { |
364 |
|
if (antiFids.contains(fid)) { |
365 |
|
return true; |
366 |
|
} |
367 |
|
} |
368 |
|
|
369 |
|
if (antiFids.size() + newSelection.size() != styledLayer |
370 |
|
.getFeatureCollectionFiltered().size()) |
371 |
|
return true; |
372 |
|
|
373 |
|
} else { |
374 |
|
FidFilterImpl origFidsFilter = (FidFilterImpl) filter; |
375 |
|
|
376 |
|
// Check one way |
377 |
|
final Set<String> fids = origFidsFilter.getFidsSet(); |
378 |
|
|
379 |
|
if (fids.isEmpty() && newSelection.isEmpty()) |
380 |
|
return false; |
381 |
|
if (fids.size() != newSelection.size()) |
382 |
|
return true; |
383 |
|
|
384 |
|
for (String fid : fids) { |
385 |
|
if (!newSelection.contains(fid)) { |
386 |
|
return true; |
387 |
|
} |
388 |
|
} |
389 |
|
|
390 |
|
// Check the other way |
391 |
|
for (String fid : newSelection) { |
392 |
|
if (!fids.contains(fid)) { |
393 |
|
return true; |
394 |
|
} |
395 |
|
} |
396 |
|
|
397 |
|
} |
398 |
|
|
399 |
|
break; |
400 |
} |
} |
|
|
|
|
oldRenderer.setContext(null); |
|
|
oldRenderer = null; |
|
401 |
} |
} |
|
|
|
|
mapPane.refresh(); |
|
402 |
|
|
403 |
|
if (!SELECTION_STYLING_foundInMapStyle && !newSelection.isEmpty()) |
404 |
|
return true; |
405 |
|
|
406 |
|
return false; |
407 |
|
} |
408 |
|
|
409 |
|
/** |
410 |
|
* Replaces the local renderer |
411 |
|
*/ |
412 |
|
private void replaceRenderer() { |
413 |
} |
} |
414 |
|
|
415 |
/** |
/** |
417 |
* {@link StyledFeatureLayerSelectionModel} |
* {@link StyledFeatureLayerSelectionModel} |
418 |
*/ |
*/ |
419 |
@Override |
@Override |
420 |
public void performMapPaneEvent(JMapPaneEvent e) { |
public void performMapPaneEvent(MapPaneEvent e) { |
421 |
|
|
422 |
// Ignore event if it is caused by us or the synchronizer is disabled. |
// Ignore event if it is caused by us or the synchronizer is disabled. |
423 |
if (!isEnabled() || selectionChangeCausedByMe) |
if (!isEnabled() || selectionChangeCausedByMe) |
444 |
if (e.getSourceObject() != this.mapPane) |
if (e.getSourceObject() != this.mapPane) |
445 |
return; |
return; |
446 |
|
|
|
FeatureSelectedEvent fse = (FeatureSelectedEvent) e; |
|
|
|
|
447 |
/** |
/** |
448 |
* Checking, that the FeatureSelectedEvent actually contains features |
* Checking, that the FeatureSelectedEvent actually contains features |
449 |
* from this layer |
* from this layer |
450 |
*/ |
*/ |
451 |
|
FeatureSelectedEvent fse = (FeatureSelectedEvent) e; |
452 |
final String sourceID = fse.getSourceLayer().getTitle(); |
final String sourceID = fse.getSourceLayer().getTitle(); |
453 |
final String syncForID = mapLayer.getTitle(); |
final String syncForID = mapLayer.getTitle(); |
454 |
if (sourceID != null && syncForID != null |
if (sourceID != null && syncForID != null |
457 |
return; |
return; |
458 |
} |
} |
459 |
|
|
460 |
LOGGER.debug("do event " + fse); |
// LOGGER.debug("do event " + fse); |
461 |
|
|
462 |
// Avoid event circles in propertyChange(..) |
// Avoid event circles in propertyChange(..) |
463 |
selectionChangeCausedByMe = true; |
selectionChangeCausedByMe = true; |
464 |
|
|
465 |
Iterator<SimpleFeature> fi = fse.getSelectionResult().iterator(); |
final FeatureCollection<SimpleFeatureType, SimpleFeature> selectionResult = fse |
466 |
|
.getSelectionResult(); |
467 |
|
Iterator<SimpleFeature> fi = selectionResult.iterator(); |
468 |
|
try { |
469 |
|
|
470 |
// reset the selection of the DpLayerSelectionModel |
// reset the selection of the DpLayerSelectionModel |
471 |
// layerSelModel.setValueIsAdjusting(true); |
// layerSelModel.setValueIsAdjusting(true); |
472 |
|
|
473 |
if (selectedTool == MapPaneToolBar.TOOL_SELECTION_ADD) { |
if (selectedTool == MapPaneToolBar.TOOL_SELECTION_ADD) { |
474 |
layerSelModel.setValueIsAdjusting(true); |
layerSelModel.setValueIsAdjusting(true); |
475 |
|
|
476 |
for (int fIdx = 0; fi.hasNext(); fIdx++) { |
for (int fIdx = 0; fi.hasNext(); fIdx++) { |
477 |
SimpleFeature f = fi.next(); |
SimpleFeature f = fi.next(); |
478 |
layerSelModel.addSelection(f.getID()); |
layerSelModel.addSelection(f.getID()); |
479 |
} |
} |
480 |
layerSelModel.setValueIsAdjusting(false); |
layerSelModel.setValueIsAdjusting(false); |
481 |
} else if (selectedTool == MapPaneToolBar.TOOL_SELECTION_SET) { |
} else if (selectedTool == MapPaneToolBar.TOOL_SELECTION_SET) { |
482 |
layerSelModel.setValueIsAdjusting(true); |
layerSelModel.setValueIsAdjusting(true); |
483 |
layerSelModel.clearSelection(); |
layerSelModel.clearSelection(); |
484 |
|
|
485 |
for (int fIdx = 0; fi.hasNext(); fIdx++) { |
for (int fIdx = 0; fi.hasNext(); fIdx++) { |
486 |
SimpleFeature f = fi.next(); |
SimpleFeature f = fi.next(); |
487 |
layerSelModel.addSelection(f.getID()); |
layerSelModel.addSelection(f.getID()); |
488 |
} |
} |
489 |
|
|
490 |
// LOGGER.debug("Setting selection to " + fi.()); |
// LOGGER.debug("Setting selection to " + fi.()); |
491 |
|
|
492 |
layerSelModel.setValueIsAdjusting(false); |
layerSelModel.setValueIsAdjusting(false); |
493 |
} else if (selectedTool == MapPaneToolBar.TOOL_SELECTION_REMOVE) { |
} else if (selectedTool == MapPaneToolBar.TOOL_SELECTION_REMOVE) { |
494 |
layerSelModel.setValueIsAdjusting(true); |
layerSelModel.setValueIsAdjusting(true); |
495 |
for (int fIdx = 0; fi.hasNext(); fIdx++) { |
for (int fIdx = 0; fi.hasNext(); fIdx++) { |
496 |
SimpleFeature f = fi.next(); |
SimpleFeature f = fi.next(); |
497 |
layerSelModel.removeSelection(f.getID()); |
layerSelModel.removeSelection(f.getID()); |
498 |
|
} |
499 |
|
layerSelModel.setValueIsAdjusting(false); |
500 |
} |
} |
501 |
layerSelModel.setValueIsAdjusting(false); |
|
502 |
|
} finally { |
503 |
|
selectionResult.close(fi); |
504 |
} |
} |
505 |
|
|
506 |
// Show selected features in the map, which is not automatically done by |
// Show selected features in the map, which is not automatically done by |