/[schmitzm]/branches/2.0-RC2/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java
ViewVC logotype

Diff of /branches/2.0-RC2/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 151 by alfonx, Fri Jun 19 16:22:29 2009 UTC revision 162 by alfonx, Mon Jun 22 21:05:20 2009 UTC
# Line 17  import java.beans.PropertyChangeEvent; Line 17  import java.beans.PropertyChangeEvent;
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;
# Line 27  import org.geotools.feature.Feature; Line 29  import org.geotools.feature.Feature;
29  import org.geotools.map.MapLayer;  import org.geotools.map.MapLayer;
30  import org.geotools.styling.FeatureTypeStyle;  import org.geotools.styling.FeatureTypeStyle;
31  import org.geotools.styling.Style;  import org.geotools.styling.Style;
32  import org.opengis.filter.Filter;  import org.opengis.filter.identity.FeatureId;
 import org.opengis.filter.FilterVisitor;  
33    
34    import schmitzm.geotools.FilterUtil;
35  import schmitzm.geotools.gui.JMapPane;  import schmitzm.geotools.gui.JMapPane;
36  import schmitzm.geotools.map.event.FeatureSelectedEvent;  import schmitzm.geotools.map.event.FeatureSelectedEvent;
37  import schmitzm.geotools.map.event.JMapPaneEvent;  import schmitzm.geotools.map.event.JMapPaneEvent;
# Line 167  public class FeatureMapLayerSelectionSyn Line 169  public class FeatureMapLayerSelectionSyn
169                                  selectionMapStyle.getFeatureTypeStyles()[0]                                  selectionMapStyle.getFeatureTypeStyles()[0]
170                                                  .setName(SELECTION_STYLING);                                                  .setName(SELECTION_STYLING);
171    
172                                  // Rule selectedRule = StylingUtil.STYLE_FACTORY.createRule();                                  /**
173                                  selectionMapStyle.getFeatureTypeStyles()[0].getRules()[0]                                   *
174                                                  .setFilter(new Filter() {                                   * Add a Filter to the selectionMapStyle, so that it is only
175                                     * used on objects that are selected. <br/>
176                                                          @Override                                   *
177                                                          public Object accept(FilterVisitor visitor,                                   * Note 1:<br/>
178                                                                          Object extraData) {                                   * It is NEVER allowed to GeoTools extend Filter () { .. } (and write
179                                                                  return null;                                   * tests into the evaluate block). Especially for the
180                                                          }                                   * ShapeFileRenderer, we may only use a geotools Filter.<br/>
181                                     *
182                                                          @Override                                   * Note 2:<br/>
183                                                          public boolean evaluate(Object obj) {                                   * The FilterUtil.FILTER_FAC2.id(fids) wants a set of FeatureId-Objects!
184                                                                  if (obj instanceof Feature) {                                   */
185                                                                          Feature f = (Feature) obj;  
186                                                                          // TODO BAD CODE! says Martin.. i am fine                                  Set<FeatureId> fids = new HashSet<FeatureId>();
187                                                                          // with it.. well.. not great...                                  for (String fid : newSelection) {
188                                                                          for (String ffID : newSelection) {                                          fids.add(FilterUtil.FILTER_FAC2.featureId(fid));
189                                                                                  if (ffID.equals(f.getID()))                                  }
                                                                                         return true;  
                                                                         }  
                                                                         return false;  
   
                                                                 }  
                                                                 return false;  
                                                         }  
190    
191                                                  });                                  selectionMapStyle.getFeatureTypeStyles()[0].getRules()[0]
192                                                    .setFilter(FilterUtil.FILTER_FAC2.id(fids));
193    
194                                  FeatureTypeStyle[] originalFeatureTypeStyles = originalStyle                                  FeatureTypeStyle[] originalFeatureTypeStyles = originalStyle
195                                                  .getFeatureTypeStyles();                                                  .getFeatureTypeStyles();
# Line 258  public class FeatureMapLayerSelectionSyn Line 254  public class FeatureMapLayerSelectionSyn
254                  FeatureSelectedEvent fse = (FeatureSelectedEvent) e;                  FeatureSelectedEvent fse = (FeatureSelectedEvent) e;
255    
256                  /**                  /**
257                   * Checking, that the FeatureSelectedEvent actually contains features from this layer                   * Checking, that the FeatureSelectedEvent actually contains features
258                     * from this layer
259                   */                   */
260                  final String sourceID = fse.getSourceLayer().getTitle();                  final String sourceID = fse.getSourceLayer().getTitle();
261                  final String syncForID = mapLayer.getTitle();                  final String syncForID = mapLayer.getTitle();
262                  if (sourceID != null && syncForID != null                  if (sourceID != null && syncForID != null
263                                  && !sourceID.equals(syncForID)){                                  && !sourceID.equals(syncForID)) {
264                          LOGGER.debug("Ignoring a FeatureSelectedEvent from "+sourceID);                          LOGGER.debug("Ignoring a FeatureSelectedEvent from " + sourceID);
265                          return;                          return;
266                  }                  }
                   
267    
268                  LOGGER.debug("do event " + fse);                  LOGGER.debug("do event " + fse);
269    

Legend:
Removed from v.151  
changed lines
  Added in v.162

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26