17 |
import java.beans.PropertyChangeListener; |
import java.beans.PropertyChangeListener; |
18 |
import java.util.Arrays; |
import java.util.Arrays; |
19 |
import java.util.Collection; |
import java.util.Collection; |
20 |
|
import java.util.HashSet; |
21 |
|
import java.util.Set; |
22 |
import java.util.Vector; |
import java.util.Vector; |
23 |
|
|
24 |
import javax.swing.JTable; |
import javax.swing.JTable; |
26 |
import javax.swing.event.ListSelectionListener; |
import javax.swing.event.ListSelectionListener; |
27 |
|
|
28 |
import org.geotools.feature.Feature; |
import org.geotools.feature.Feature; |
29 |
|
import org.geotools.filter.FidFilter; |
30 |
|
import org.geotools.filter.FidFilterImpl; |
31 |
import org.geotools.map.MapLayer; |
import org.geotools.map.MapLayer; |
32 |
import org.geotools.styling.FeatureTypeStyle; |
import org.geotools.styling.FeatureTypeStyle; |
33 |
import org.geotools.styling.Style; |
import org.geotools.styling.Style; |
34 |
import org.opengis.filter.Filter; |
import org.opengis.filter.Filter; |
35 |
import org.opengis.filter.FilterVisitor; |
import org.opengis.filter.FilterVisitor; |
36 |
|
import org.opengis.filter.identity.FeatureId; |
37 |
|
|
38 |
|
import schmitzm.geotools.FilterUtil; |
39 |
import schmitzm.geotools.gui.JMapPane; |
import schmitzm.geotools.gui.JMapPane; |
40 |
import schmitzm.geotools.map.event.FeatureSelectedEvent; |
import schmitzm.geotools.map.event.FeatureSelectedEvent; |
41 |
import schmitzm.geotools.map.event.JMapPaneEvent; |
import schmitzm.geotools.map.event.JMapPaneEvent; |
173 |
selectionMapStyle.getFeatureTypeStyles()[0] |
selectionMapStyle.getFeatureTypeStyles()[0] |
174 |
.setName(SELECTION_STYLING); |
.setName(SELECTION_STYLING); |
175 |
|
|
176 |
// Rule selectedRule = StylingUtil.STYLE_FACTORY.createRule(); |
/** |
177 |
selectionMapStyle.getFeatureTypeStyles()[0].getRules()[0] |
* |
178 |
.setFilter(new Filter() { |
* Add a Filter to the selectionMapStyle, so that it is only |
179 |
|
* used on objects that are selected. <br/> |
180 |
@Override |
* |
181 |
public Object accept(FilterVisitor visitor, |
* Note 1:<br/> |
182 |
Object extraData) { |
* It is NEVER allowed to GeoTools extend Filter () { .. } (and write |
183 |
return null; |
* tests into the evaluate block). Especially for the |
184 |
} |
* ShapeFileRenderer, we may only use a geotools Filter.<br/> |
185 |
|
* |
186 |
@Override |
* Note 2:<br/> |
187 |
public boolean evaluate(Object obj) { |
* The FilterUtil.FILTER_FAC2.id(fids) wants a set of FeatureId-Objects! |
188 |
if (obj instanceof Feature) { |
*/ |
189 |
Feature f = (Feature) obj; |
|
190 |
// TODO BAD CODE! says Martin.. i am fine |
Set<FeatureId> fids = new HashSet<FeatureId>(); |
191 |
// with it.. well.. not great... |
for (String fid : newSelection) { |
192 |
for (String ffID : newSelection) { |
fids.add(FilterUtil.FILTER_FAC2.featureId(fid)); |
193 |
if (ffID.equals(f.getID())) |
} |
|
return true; |
|
|
} |
|
|
return false; |
|
|
|
|
|
} |
|
|
return false; |
|
|
} |
|
194 |
|
|
195 |
}); |
selectionMapStyle.getFeatureTypeStyles()[0].getRules()[0] |
196 |
|
.setFilter(FilterUtil.FILTER_FAC2.id(fids)); |
197 |
|
|
198 |
FeatureTypeStyle[] originalFeatureTypeStyles = originalStyle |
FeatureTypeStyle[] originalFeatureTypeStyles = originalStyle |
199 |
.getFeatureTypeStyles(); |
.getFeatureTypeStyles(); |
258 |
FeatureSelectedEvent fse = (FeatureSelectedEvent) e; |
FeatureSelectedEvent fse = (FeatureSelectedEvent) e; |
259 |
|
|
260 |
/** |
/** |
261 |
* Checking, that the FeatureSelectedEvent actually contains features from this layer |
* Checking, that the FeatureSelectedEvent actually contains features |
262 |
|
* from this layer |
263 |
*/ |
*/ |
264 |
final String sourceID = fse.getSourceLayer().getTitle(); |
final String sourceID = fse.getSourceLayer().getTitle(); |
265 |
final String syncForID = mapLayer.getTitle(); |
final String syncForID = mapLayer.getTitle(); |
266 |
if (sourceID != null && syncForID != null |
if (sourceID != null && syncForID != null |
267 |
&& !sourceID.equals(syncForID)){ |
&& !sourceID.equals(syncForID)) { |
268 |
LOGGER.debug("Ignoring a FeatureSelectedEvent from "+sourceID); |
LOGGER.debug("Ignoring a FeatureSelectedEvent from " + sourceID); |
269 |
return; |
return; |
270 |
} |
} |
|
|
|
271 |
|
|
272 |
LOGGER.debug("do event " + fse); |
LOGGER.debug("do event " + fse); |
273 |
|
|