/[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 122 by alfonx, Tue May 12 23:33:14 2009 UTC revision 123 by alfonx, Wed May 20 15:54:51 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 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.getFeatureTypeStyles();
193                                                  originalStyle.getFeatureTypeStyles(), selectionMapStyle                                  FeatureTypeStyle[] newFeatureTypes ;
194                                                                  .getFeatureTypeStyles()));                                  if (originalFeatureTypeStyles[originalFeatureTypeStyles.length-1].getName() != null && originalFeatureTypeStyles[originalFeatureTypeStyles.length-1].getName().equals(SELECTION_STYLING)){
195                                            newFeatureTypes = Arrays.copyOf(originalFeatureTypeStyles, originalFeatureTypeStyles.length-1);
196                                    } else {
197                                            newFeatureTypes = originalFeatureTypeStyles;
198                                    }
199    //                              
200    //                              // REMOVE any Selection_Styling FTS (usually the last one)
201    //                              
202    //                              for (FeatureTypeStyle fts : originalFeatureTypeStyles){
203    //                                      if (fts.getName().equals(SELECTION_STYLING)) continue;
204    //                                      newFeatureTypes =
205    //                                      
206    //                                      LangUtil.extendArray(
207    //                                              originalFeatureTypeStyles, selectionMapStyle
208    //                                                              .getFeatureTypeStyles());
209    //                              }
210                                    
211                                    // The last FTS is the selection FTS
212                                    newFeatureTypes =  LangUtil.extendArray(newFeatureTypes, selectionMapStyle
213                                                    .getFeatureTypeStyles());
214                                    
215                                    
216                                    selectionMapStyle.setFeatureTypeStyles(newFeatureTypes);
217    
218                                  // selectionMapStyle.setFeatureTypeStyles(originalStyle.getF)                                  // selectionMapStyle.setFeatureTypeStyles(originalStyle.getF)
219    

Legend:
Removed from v.122  
changed lines
  Added in v.123

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26