/[schmitzm]/branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java
ViewVC logotype

Diff of /branches/1.0-gt2-2.6/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java

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

revision 105 by alfonx, Fri May 8 15:02:28 2009 UTC revision 106 by alfonx, Fri May 8 15:13:49 2009 UTC
# Line 67  import skrueger.geotools.selection.Style Line 67  import skrueger.geotools.selection.Style
67   *         (University of Bonn/Germany)   *         (University of Bonn/Germany)
68   */   */
69  public class FeatureMapLayerSelectionSynchronizer extends  public class FeatureMapLayerSelectionSynchronizer extends
70                  StyledLayerSelectionModelSynchronizer<StyledFeatureLayerSelectionModel> implements                  StyledLayerSelectionModelSynchronizer<StyledFeatureLayerSelectionModel>
71                  JMapPaneListener {                  implements JMapPaneListener {
72          /**          /**
73           * Holds the {@link MapLayer} to keep synchronized with the layer selection           * Holds the {@link MapLayer} to keep synchronized with the layer selection
74           * model.           * model.
# Line 140  public class FeatureMapLayerSelectionSyn Line 140  public class FeatureMapLayerSelectionSyn
140    
141                                  selectionMapStyle = styledMapLayer.getStyle();                                  selectionMapStyle = styledMapLayer.getStyle();
142                                  LOGGER.debug("NO SELECTION .. reset original style");                                  LOGGER.debug("NO SELECTION .. reset original style");
143                                    
144                          } else {                          } else {
145                                  LOGGER.debug("SELECTION .. change style");                                  LOGGER.debug("SELECTION .. change style");
146                                    
147                                  Style originalStyle = styledMapLayer.getStyle();                                  Style originalStyle = styledMapLayer.getStyle();
148                                    
149                                  // TODO This clone is a deep clone and it is slow..                                  // TODO This clone is a deep clone and it is slow..
150                                  selectionMapStyle =  StylingUtil.clone(originalStyle);                                  selectionMapStyle = StylingUtil.clone(originalStyle);
151                                    
152                                                                    // TODO BAD CODE
153                                  Rule selectedRule = StylingUtil.STYLE_FACTORY.createRule();                                  Style defaultStyle = StylingUtil
154                                  selectedRule.setFilter(new Filter() {                                                  .createDefaultStyle(styledMapLayer.getGeoObject());
155    
156                                          @Override                                  // Rule selectedRule = StylingUtil.STYLE_FACTORY.createRule();
157                                          public Object accept(FilterVisitor visitor, Object extraData) {                                  defaultStyle.getFeatureTypeStyles()[0].getRules()[0]
158                                                  return null;                                                  .setFilter(new Filter() {
159                                          }  
160                                                            @Override
161                                          @Override                                                          public Object accept(FilterVisitor visitor,
162                                          public boolean evaluate(Object obj) {                                                                          Object extraData) {
163                                                  if (obj instanceof Feature) {                                                                  return null;
                                                         Feature f = (Feature)obj;  
                                                         LOGGER.info("treffer");  
                                                         // TODO BAD CODE  
                                                         for (Feature ff : newSelection){  
                                                                 if (ff.getID().equals(f.getID())) return true;  
164                                                          }                                                          }
165                                                          return false;  
166                                                                                                                    @Override
167                                                  }                                                          public boolean evaluate(Object obj) {
168                                                  LOGGER.info("kein treffer");                                                                  if (obj instanceof Feature) {
169                                                  return false;                                                                          Feature f = (Feature) obj;
170                                          }                                                                          // TODO BAD CODE
171                                                                                                                    for (Feature ff : newSelection) {
172                                  });                                                                                  if (ff.getID().equals(f.getID()))
173                                                                                                                            return true;
174                                  Style defaultStyle = StylingUtil.createDefaultStyle(styledMapLayer.getGeoObject());                                                                          }
175                                  selectedRule.setSymbolizers(new Symbolizer[] {defaultStyle.getFeatureTypeStyles()[0].getRules()[0].getSymbolizers()[0]} );                                                                          return false;
176                                    
177                                  Rule[] rules = selectionMapStyle.getFeatureTypeStyles()[0].getRules();                                                                  }
178                                  rules = LangUtil.extendArray(rules, selectedRule);                                                                  return false;
179                                                                                            }
180                                  selectionMapStyle.getFeatureTypeStyles()[0].setRules(rules);  
181                                                                                    });
182  //                              selectionMapStyle.setFeatureTypeStyles(originalStyle.getF)  
183                                                                    selectionMapStyle.setFeatureTypeStyles(LangUtil.extendArray(
184                                                    selectionMapStyle.getFeatureTypeStyles(), defaultStyle
185                                                                    .getFeatureTypeStyles()[0]));
186    
187                                    // selectionMapStyle.setFeatureTypeStyles(originalStyle.getF)
188    
189                                  // Flat copy the style                                  // Flat copy the style
190                                    
191  //                              selectionMapStyle = StylingUtil.createDefaultStyle(styledMapLayer.getGeoObject());                                  // selectionMapStyle =
192                                                                    // StylingUtil.createDefaultStyle(styledMapLayer.getGeoObject());
193                                    
194                          }                          }
195    
196                          mapLayer.setStyle(selectionMapStyle);                          mapLayer.setStyle(selectionMapStyle);
# Line 216  public class FeatureMapLayerSelectionSyn Line 216  public class FeatureMapLayerSelectionSyn
216    
217          @Override          @Override
218          public void performMapPaneEvent(JMapPaneEvent e) {          public void performMapPaneEvent(JMapPaneEvent e) {
219                    
220                  if (!(e instanceof FeatureSelectedEvent)) {                  if (!(e instanceof FeatureSelectedEvent)) {
221                          LOGGER.debug("Ignoring event "+e);  //                      LOGGER.debug("Ignoring event " + e);
222                          return;                          return;
223                  }                  }
224    
225                  FeatureSelectedEvent fse = (FeatureSelectedEvent) e;                  FeatureSelectedEvent fse = (FeatureSelectedEvent) e;
226                  LOGGER.debug("Do event "+fse);  //              LOGGER.debug("Do event " + fse);
227                  LOGGER.debug("Do event "+fse.getSelectionResult());  //              LOGGER.debug("Do event " + fse.getSelectionResult());
228    
229                  // ignore event if it is caused by the DpLayerVectorSelectionModel                  // ignore event if it is caused by the DpLayerVectorSelectionModel
230                  if (selectionChangeCausedByMe)                  if (selectionChangeCausedByMe)
# Line 252  public class FeatureMapLayerSelectionSyn Line 252  public class FeatureMapLayerSelectionSyn
252                  // Show selected feature in the map, which is not automatically done by                  // Show selected feature in the map, which is not automatically done by
253                  // the FeatureSelectedEvent                  // the FeatureSelectedEvent
254                  changeLayerStyle(layerSelModel.getSelection());                  changeLayerStyle(layerSelModel.getSelection());
255                    
256                  // Danger of event circles in propertyChange(..) banned                  // Danger of event circles in propertyChange(..) banned
257                  selectionChangeCausedByMe = false;                  selectionChangeCausedByMe = false;
258          }          }

Legend:
Removed from v.105  
changed lines
  Added in v.106

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26