Revision 41177 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/tools/PolygonSelectionListener.java
PolygonSelectionListener.java | ||
---|---|---|
110 | 110 |
.getDefaultFeatureType()); |
111 | 111 |
if (event.getEvent().isControlDown()) { |
112 | 112 |
FeatureSelection currentSelection = (FeatureSelection)lyrVect.getFeatureStore().getSelection(); |
113 |
if(isAnyGeomAlreadySelected(currentSelection, newSelection)) { |
|
114 |
currentSelection.deselect(newSelection); |
|
115 |
} else { |
|
116 |
currentSelection.select(newSelection); |
|
113 |
DisposableIterator it = newSelection.fastIterator(); |
|
114 |
while(it.hasNext()) { |
|
115 |
Object obj = it.next(); |
|
116 |
if(obj instanceof Feature) { |
|
117 |
Feature feat = ((Feature)obj); |
|
118 |
if(currentSelection.isSelected(feat)) |
|
119 |
currentSelection.deselect(feat); |
|
120 |
else |
|
121 |
currentSelection.select(feat); |
|
122 |
} |
|
117 | 123 |
} |
118 | 124 |
} else { |
119 | 125 |
lyrVect.getDataStore().setSelection(newSelection); |
... | ... | |
131 | 137 |
new CreateGeometryException(TYPES.SURFACE, SUBTYPES.GEOM2D, e)); |
132 | 138 |
} |
133 | 139 |
} |
134 |
|
|
135 |
private boolean isAnyGeomAlreadySelected(FeatureSelection currentSelection, FeatureSet newSelection) throws DataException { |
|
136 |
DisposableIterator it = newSelection.fastIterator(); |
|
137 |
while(it.hasNext()) { |
|
138 |
Object obj = it.next(); |
|
139 |
if(obj instanceof Feature) { |
|
140 |
Feature feat = ((Feature)obj); |
|
141 |
if(currentSelection.isSelected(feat)) |
|
142 |
return true; |
|
143 |
} |
|
144 |
} |
|
145 |
return false; |
|
146 |
} |
|
147 | 140 |
} |
Also available in: Unified diff