/[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 128 by alfonx, Sat May 30 16:27:26 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());                                                  .createSelectionStyle(styledMapLayer.getGeoObject());
153                                  selectionMapStyle.getFeatureTypeStyles()[0].setName(SELECTION_STYLING);  //                              selectionMapStyle = StylingUtil
154    //                              .createDefaultStyle(styledMapLayer.getGeoObject());
155    
156                                  // Symbolizer sss =                                  selectionMapStyle.getFeatureTypeStyles()[0]
157                                  // selectionMapStyle.getFeatureTypeStyles()[0].getRules()[0].getSymbolizers()[0];                                                  .setName(SELECTION_STYLING);
                                 // if (sss instanceof PolygonSymbolizer) {  
                                 // PolygonSymbolizer ps = (PolygonSymbolizer) sss;  
                                 // ps.getFill().setOpacity( FilterUtil.FILTER_FAC.literal(0.5));  
                                 // }  
158    
159                                  // Rule selectedRule = StylingUtil.STYLE_FACTORY.createRule();                                  // Rule selectedRule = StylingUtil.STYLE_FACTORY.createRule();
160                                  selectionMapStyle.getFeatureTypeStyles()[0].getRules()[0]                                  selectionMapStyle.getFeatureTypeStyles()[0].getRules()[0]
# Line 165  public class FeatureMapLayerSelectionSyn Line 170  public class FeatureMapLayerSelectionSyn
170                                                          public boolean evaluate(Object obj) {                                                          public boolean evaluate(Object obj) {
171                                                                  if (obj instanceof Feature) {                                                                  if (obj instanceof Feature) {
172                                                                          Feature f = (Feature) obj;                                                                          Feature f = (Feature) obj;
173                                                                          // TODO BAD CODE?                                                                          // TODO BAD CODE! says Martin.. i am fine
174                                                                            // with it.. well.. not great...
175                                                                          for (String ffID : newSelection) {                                                                          for (String ffID : newSelection) {
176                                                                                  if (ffID.equals(f.getID()))                                                                                  if (ffID.equals(f.getID()))
177                                                                                          return true;                                                                                          return true;
# Line 178  public class FeatureMapLayerSelectionSyn Line 184  public class FeatureMapLayerSelectionSyn
184    
185                                                  });                                                  });
186    
187                                  selectionMapStyle.setFeatureTypeStyles(LangUtil.extendArray(                                  FeatureTypeStyle[] originalFeatureTypeStyles = originalStyle
188                                                  originalStyle.getFeatureTypeStyles(), selectionMapStyle                                                  .getFeatureTypeStyles();
189                                                                  .getFeatureTypeStyles()));                                  FeatureTypeStyle[] newFeatureTypes;
190                                    if (originalFeatureTypeStyles[originalFeatureTypeStyles.length - 1]
191                                                    .getName() != null
192                                                    && originalFeatureTypeStyles[originalFeatureTypeStyles.length - 1]
193                                                                    .getName().equals(SELECTION_STYLING)) {
194                                            newFeatureTypes = Arrays.copyOf(originalFeatureTypeStyles,
195                                                            originalFeatureTypeStyles.length - 1);
196                                    } else {
197                                            newFeatureTypes = originalFeatureTypeStyles;
198                                    }
199                                    
200                                    // The last FTS is the selection FTS
201                                    newFeatureTypes = LangUtil.extendArray(newFeatureTypes,
202                                                    selectionMapStyle.getFeatureTypeStyles());
203    
204                                  // selectionMapStyle.setFeatureTypeStyles(originalStyle.getF)                                  selectionMapStyle.setFeatureTypeStyles(newFeatureTypes);
   
                                 // Flat copy the style  
   
                                 // selectionMapStyle =  
                                 // StylingUtil.createDefaultStyle(styledMapLayer.getGeoObject());  
205    
206                          }                          }
207    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26