/[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 515 by alfonx, Thu Nov 5 08:51:33 2009 UTC revision 516 by alfonx, Wed Nov 11 21:17:33 2009 UTC
# Line 97  import skrueger.geotools.StyledFeaturesI Line 97  import skrueger.geotools.StyledFeaturesI
97  public class FeatureMapLayerSelectionSynchronizer extends  public class FeatureMapLayerSelectionSynchronizer extends
98                  StyledLayerSelectionModelSynchronizer<StyledFeatureLayerSelectionModel>                  StyledLayerSelectionModelSynchronizer<StyledFeatureLayerSelectionModel>
99                  implements JMapPaneListener {                  implements JMapPaneListener {
100          public static final String SELECTION_STYLING = "SELECTION";  
101            /**
102             * This constant is set as the {@link FeatureTypeStyle#getName()} attribute
103             * in the {@link FeatureTypeStyle}s that only exist to present the selected
104             * features
105             **/
106            public static final String SELECTION_STYLING_FTS_NAME = "SELECTION";
107    
108          /**          /**
109           * Holds the {@link MapLayer} to keep synchronized with the layer selection           * Holds the {@link MapLayer} to keep synchronized with the layer selection
110           * model.           * model.
# Line 189  public class FeatureMapLayerSelectionSyn Line 196  public class FeatureMapLayerSelectionSyn
196    
197                                  for (FeatureTypeStyle fts : clone) {                                  for (FeatureTypeStyle fts : clone) {
198                                          if (fts.getName() != null                                          if (fts.getName() != null
199                                                          && fts.getName().equals(SELECTION_STYLING)) {                                                          && fts.getName().equals(SELECTION_STYLING_FTS_NAME)) {
200                                                  originalStyle.featureTypeStyles().remove(fts);                                                  originalStyle.featureTypeStyles().remove(fts);
201    
202                                                  replaceRenderer();                                                  replaceRenderer();
# Line 218  public class FeatureMapLayerSelectionSyn Line 225  public class FeatureMapLayerSelectionSyn
225                                  FeatureTypeStyle selectionFTStyle = StylingUtil                                  FeatureTypeStyle selectionFTStyle = StylingUtil
226                                                  .createSelectionStyle(styledLayer.getGeoObject());                                                  .createSelectionStyle(styledLayer.getGeoObject());
227    
228                                  selectionFTStyle.setName(SELECTION_STYLING);                                  selectionFTStyle.setName(SELECTION_STYLING_FTS_NAME);
229    
230                                  /**                                  /**
231                                   *                                   *
# Line 266  public class FeatureMapLayerSelectionSyn Line 273  public class FeatureMapLayerSelectionSyn
273                                  boolean foundAndReplaced = false;                                  boolean foundAndReplaced = false;
274                                  for (FeatureTypeStyle fts : originalStyle.featureTypeStyles()) {                                  for (FeatureTypeStyle fts : originalStyle.featureTypeStyles()) {
275                                          if (fts.getName() != null                                          if (fts.getName() != null
276                                                          && fts.getName().equals(SELECTION_STYLING)) {                                                          && fts.getName().equals(SELECTION_STYLING_FTS_NAME)) {
277                                                  foundAndReplaced = true;                                                  foundAndReplaced = true;
278                                                  fts.rules().clear();                                                  fts.rules().clear();
279                                                  fts.rules().addAll(selectionFTStyle.rules());                                                  fts.rules().addAll(selectionFTStyle.rules());
# Line 328  public class FeatureMapLayerSelectionSyn Line 335  public class FeatureMapLayerSelectionSyn
335                  for (FeatureTypeStyle fts : originalStyle.featureTypeStyles()) {                  for (FeatureTypeStyle fts : originalStyle.featureTypeStyles()) {
336    
337                          if (fts.getName() != null                          if (fts.getName() != null
338                                          && fts.getName().equals(SELECTION_STYLING)) {                                          && fts.getName().equals(SELECTION_STYLING_FTS_NAME)) {
339    
340                                  SELECTION_STYLING_foundInMapStyle = true;                                  SELECTION_STYLING_foundInMapStyle = true;
341    
# Line 394  public class FeatureMapLayerSelectionSyn Line 401  public class FeatureMapLayerSelectionSyn
401          }          }
402    
403          /**          /**
404           * Replaces the local renderer           * Replaces the local renderer
405           */           */
406          private void replaceRenderer() {          private void replaceRenderer() {
407  //              //                  // //
408  //              // // Has to be done before we apply the new Renderer                  // // // Has to be done before we apply the new Renderer
409  //              // mapLayer.setStyle(style);                  // // mapLayer.setStyle(style);
410  //                  //
411  //              GTRenderer oldRenderer = mapPane.getLocalRenderer();                  // GTRenderer oldRenderer = mapPane.getLocalRenderer();
412  //                  //
413  //              /**                  // /**
414  //               * Explicitly putting a new instance of LabelCacheDefault into the                  // * Explicitly putting a new instance of LabelCacheDefault into the
415  //               * renderer instance, so JMapPane doesn't reuse the old one. This is                  // * renderer instance, so JMapPane doesn't reuse the old one. This is
416  //               * very useful when changing the TextSymbolizer with AtlasStyler<br/>                  // * very useful when changing the TextSymbolizer with AtlasStyler<br/>
417  //               * SK 9.7.09: It's not enought to user LabelCache.clear(). We can not                  // * SK 9.7.09: It's not enought to user LabelCache.clear(). We can not
418  //               * reuse the old Renderer - better to create a new one!                  // * reuse the old Renderer - better to create a new one!
419  //               */                  // */
420  //              final GTRenderer newRenderer = GTUtil.createGTRenderer();                  // final GTRenderer newRenderer = GTUtil.createGTRenderer();
421  //                  //
422  //              final HashMap<Object, Object> rendererHints = defaultGTRenderingHints;                  // final HashMap<Object, Object> rendererHints =
423  //              rendererHints.put(StreamingRenderer.LABEL_CACHE_KEY,                  // defaultGTRenderingHints;
424  //                              new LabelCacheImpl());                  // rendererHints.put(StreamingRenderer.LABEL_CACHE_KEY,
425  //                  // new LabelCacheImpl());
426  //              newRenderer.setRendererHints(rendererHints);                  //
427  //              mapPane.setLocalRenderer(newRenderer);                  // newRenderer.setRendererHints(rendererHints);
428  //                  // mapPane.setLocalRenderer(newRenderer);
429  //              if (oldRenderer != null) {                  //
430  //                  // if (oldRenderer != null) {
431  //                      RenderingHints java2DHints = oldRenderer.getJava2DHints();                  //
432  //                      if (java2DHints != null) {                  // RenderingHints java2DHints = oldRenderer.getJava2DHints();
433  //                              newRenderer.setJava2DHints(java2DHints);                  // if (java2DHints != null) {
434  //                      }                  // newRenderer.setJava2DHints(java2DHints);
435  //                  // }
436  //                      oldRenderer.setContext(null);                  //
437  //                      oldRenderer = null;                  // oldRenderer.setContext(null);
438  //              }                  // oldRenderer = null;
439                    // }
440    
441                  mapPane.refresh();                  mapPane.refresh();
442    

Legend:
Removed from v.515  
changed lines
  Added in v.516

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26