/[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 111 by alfonx, Tue May 12 23:33:14 2009 UTC revision 125 by alfonx, Sat May 23 11:33:59 2009 UTC
# Line 15  package skrueger.geotools.selection; Line 15  package skrueger.geotools.selection;
15    
16  import java.beans.PropertyChangeEvent;  import java.beans.PropertyChangeEvent;
17  import java.beans.PropertyChangeListener;  import java.beans.PropertyChangeListener;
18    import java.util.Arrays;
19  import java.util.Collection;  import java.util.Collection;
20  import java.util.Vector;  import java.util.Vector;
21    
# Line 25  import javax.swing.event.ListSelectionLi Line 26  import javax.swing.event.ListSelectionLi
26  import org.geotools.feature.Feature;  import org.geotools.feature.Feature;
27  import org.geotools.feature.FeatureCollection;  import org.geotools.feature.FeatureCollection;
28  import org.geotools.map.MapLayer;  import org.geotools.map.MapLayer;
29    import org.geotools.styling.FeatureTypeStyle;
30  import org.geotools.styling.Style;  import org.geotools.styling.Style;
31  import org.opengis.filter.Filter;  import org.opengis.filter.Filter;
32  import org.opengis.filter.FilterVisitor;  import org.opengis.filter.FilterVisitor;
# Line 137  public class FeatureMapLayerSelectionSyn Line 139  public class FeatureMapLayerSelectionSyn
139                          } else {                          } else {
140                                  LOGGER.debug("SELECTION .. change style");                                  LOGGER.debug("SELECTION .. change style");
141    
142                                  Style originalStyle = styledMapLayer.getStyle();                                  // We take Style from the MapLayer that is displayed at the
143                                    // moment. We do not use the styledMapLayer.getStyle, because in
144                                    // the atlas, this always return the default style, but
145                                    // additionaly styles might be selected.
146                                    // Taking the style from the mapLayer indicated, that we have to
147                                    // remove any selection rules first.
148                                    Style originalStyle = mapLayer.getStyle();
149    
150                                  // TODO This clone is a deep clone and it is slow..                                  // TODO The default style is not good here. We need
151                                    // .createSelectionStyle(normalStyle, geoObj);
152                                  selectionMapStyle = StylingUtil                                  selectionMapStyle = StylingUtil
153                                                  .createDefaultStyle(styledMapLayer.getGeoObject());                                                  .createDefaultStyle(styledMapLayer.getGeoObject());
154                                  selectionMapStyle.getFeatureTypeStyles()[0].setName(SELECTION_STYLING);  
155                                    selectionMapStyle.getFeatureTypeStyles()[0]
156                                                    .setName(SELECTION_STYLING);
157    
158                                  // Symbolizer sss =                                  // Symbolizer sss =
159                                  // selectionMapStyle.getFeatureTypeStyles()[0].getRules()[0].getSymbolizers()[0];                                  // selectionMapStyle.getFeatureTypeStyles()[0].getRules()[0].getSymbolizers()[0];
# Line 165  public class FeatureMapLayerSelectionSyn Line 176  public class FeatureMapLayerSelectionSyn
176                                                          public boolean evaluate(Object obj) {                                                          public boolean evaluate(Object obj) {
177                                                                  if (obj instanceof Feature) {                                                                  if (obj instanceof Feature) {
178                                                                          Feature f = (Feature) obj;                                                                          Feature f = (Feature) obj;
179                                                                          // TODO BAD CODE?                                                                          // TODO BAD CODE! says Martin.. i am fine
180                                                                            // with it.. well.. not great...
181                                                                          for (String ffID : newSelection) {                                                                          for (String ffID : newSelection) {
182                                                                                  if (ffID.equals(f.getID()))                                                                                  if (ffID.equals(f.getID()))
183                                                                                          return true;                                                                                          return true;
# Line 178  public class FeatureMapLayerSelectionSyn Line 190  public class FeatureMapLayerSelectionSyn
190    
191                                                  });                                                  });
192    
193                                  selectionMapStyle.setFeatureTypeStyles(LangUtil.extendArray(                                  FeatureTypeStyle[] originalFeatureTypeStyles = originalStyle
194                                                  originalStyle.getFeatureTypeStyles(), selectionMapStyle                                                  .getFeatureTypeStyles();
195                                                                  .getFeatureTypeStyles()));                                  FeatureTypeStyle[] newFeatureTypes;
196                                    if (originalFeatureTypeStyles[originalFeatureTypeStyles.length - 1]
197                                                    .getName() != null
198                                                    && originalFeatureTypeStyles[originalFeatureTypeStyles.length - 1]
199                                                                    .getName().equals(SELECTION_STYLING)) {
200                                            newFeatureTypes = Arrays.copyOf(originalFeatureTypeStyles,
201                                                            originalFeatureTypeStyles.length - 1);
202                                    } else {
203                                            newFeatureTypes = originalFeatureTypeStyles;
204                                    }
205                                    //                              
206                                    // // REMOVE any Selection_Styling FTS (usually the last one)
207                                    //                              
208                                    // for (FeatureTypeStyle fts : originalFeatureTypeStyles){
209                                    // if (fts.getName().equals(SELECTION_STYLING)) continue;
210                                    // newFeatureTypes =
211                                    //                                      
212                                    // LangUtil.extendArray(
213                                    // originalFeatureTypeStyles, selectionMapStyle
214                                    // .getFeatureTypeStyles());
215                                    // }
216    
217                                    // The last FTS is the selection FTS
218                                    newFeatureTypes = LangUtil.extendArray(newFeatureTypes,
219                                                    selectionMapStyle.getFeatureTypeStyles());
220    
221                                    selectionMapStyle.setFeatureTypeStyles(newFeatureTypes);
222    
223                                  // selectionMapStyle.setFeatureTypeStyles(originalStyle.getF)                                  // selectionMapStyle.setFeatureTypeStyles(originalStyle.getF)
224    

Legend:
Removed from v.111  
changed lines
  Added in v.125

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26