/[schmitzm]/branches/2.1/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java
ViewVC logotype

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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26