42 |
**/ |
**/ |
43 |
package skrueger.geotools.selection; |
package skrueger.geotools.selection; |
44 |
|
|
45 |
|
import java.awt.RenderingHints; |
46 |
import java.beans.PropertyChangeEvent; |
import java.beans.PropertyChangeEvent; |
47 |
import java.beans.PropertyChangeListener; |
import java.beans.PropertyChangeListener; |
48 |
import java.io.File; |
import java.io.File; |
49 |
|
import java.util.HashMap; |
50 |
import java.util.HashSet; |
import java.util.HashSet; |
51 |
import java.util.Iterator; |
import java.util.Iterator; |
52 |
import java.util.Set; |
import java.util.Set; |
60 |
import org.geotools.feature.FeatureIterator; |
import org.geotools.feature.FeatureIterator; |
61 |
import org.geotools.filter.FidFilterImpl; |
import org.geotools.filter.FidFilterImpl; |
62 |
import org.geotools.map.MapLayer; |
import org.geotools.map.MapLayer; |
63 |
|
import org.geotools.renderer.GTRenderer; |
64 |
|
import org.geotools.renderer.label.LabelCacheImpl; |
65 |
|
import org.geotools.renderer.lite.StreamingRenderer; |
66 |
import org.geotools.styling.FeatureTypeStyle; |
import org.geotools.styling.FeatureTypeStyle; |
67 |
import org.geotools.styling.Style; |
import org.geotools.styling.Style; |
68 |
import org.geotools.styling.visitor.DuplicatingStyleVisitor; |
import org.geotools.styling.visitor.DuplicatingStyleVisitor; |
73 |
import org.opengis.filter.identity.FeatureId; |
import org.opengis.filter.identity.FeatureId; |
74 |
|
|
75 |
import schmitzm.geotools.FilterUtil; |
import schmitzm.geotools.FilterUtil; |
76 |
|
import schmitzm.geotools.GTUtil; |
77 |
import schmitzm.geotools.gui.SelectableXMapPane; |
import schmitzm.geotools.gui.SelectableXMapPane; |
78 |
import schmitzm.geotools.map.event.FeatureSelectedEvent; |
import schmitzm.geotools.map.event.FeatureSelectedEvent; |
|
import schmitzm.geotools.map.event.MapPaneEvent; |
|
79 |
import schmitzm.geotools.map.event.JMapPaneListener; |
import schmitzm.geotools.map.event.JMapPaneListener; |
80 |
|
import schmitzm.geotools.map.event.MapPaneEvent; |
81 |
import schmitzm.geotools.styling.StylingUtil; |
import schmitzm.geotools.styling.StylingUtil; |
82 |
import skrueger.geotools.MapPaneToolBar; |
import skrueger.geotools.MapPaneToolBar; |
83 |
import skrueger.geotools.StyledFeaturesInterface; |
import skrueger.geotools.StyledFeaturesInterface; |
205 |
&& fts.getName().equals(SELECTION_STYLING_FTS_NAME)) { |
&& fts.getName().equals(SELECTION_STYLING_FTS_NAME)) { |
206 |
originalStyle.featureTypeStyles().remove(fts); |
originalStyle.featureTypeStyles().remove(fts); |
207 |
|
|
208 |
replaceRenderer(); |
mapLayer.setStyle(originalStyle); |
209 |
// mapPane.refresh(); |
// replaceRenderer(); |
210 |
|
// // mapPane.refresh(); |
211 |
|
|
212 |
return; |
return; |
213 |
} |
} |
323 |
} |
} |
324 |
|
|
325 |
/** |
/** |
326 |
* Analyses whether the selection has changed in comparison to the selection |
* Analyzes whether the selection has changed in comparison to the selection |
327 |
* stored in the mapLayer.Style |
* stored in the mapLayer.Style |
328 |
* |
* |
329 |
* @param newSelection |
* @param newSelection a List<String> of all newly selected FIDs |
330 |
* @param originalStyle |
* @param originalStyle the original {@link Style} that has an earlier selection coded into the {@link Style} |
331 |
* @return |
* @return <code>true</code> if changed. |
332 |
*/ |
*/ |
333 |
private boolean selectionChanged(Vector<String> newSelection, |
private boolean selectionChanged(Vector<String> newSelection, |
334 |
Style originalStyle) { |
Style originalStyle) { |
337 |
|
|
338 |
/** |
/** |
339 |
* testing, whether the selection really changed. If not, we can save |
* testing, whether the selection really changed. If not, we can save |
340 |
* one paint! |
* one rendering! |
341 |
*/ |
*/ |
342 |
for (FeatureTypeStyle fts : originalStyle.featureTypeStyles()) { |
for (FeatureTypeStyle fts : originalStyle.featureTypeStyles()) { |
343 |
|
|
371 |
} |
} |
372 |
} |
} |
373 |
|
|
374 |
|
if (antiFids.size() + newSelection.size() != styledLayer |
375 |
|
.getFeatureCollectionFiltered().size()) |
376 |
|
return true; |
377 |
|
|
378 |
} else { |
} else { |
379 |
FidFilterImpl origFidsFilter = (FidFilterImpl) filter; |
FidFilterImpl origFidsFilter = (FidFilterImpl) filter; |
380 |
|
|
415 |
* Replaces the local renderer |
* Replaces the local renderer |
416 |
*/ |
*/ |
417 |
private void replaceRenderer() { |
private void replaceRenderer() { |
|
// // |
|
|
// // // Has to be done before we apply the new Renderer |
|
|
// // mapLayer.setStyle(style); |
|
|
// |
|
|
// GTRenderer oldRenderer = mapPane.getLocalRenderer(); |
|
|
// |
|
|
// /** |
|
|
// * Explicitly putting a new instance of LabelCacheDefault into the |
|
|
// * renderer instance, so JMapPane doesn't reuse the old one. This is |
|
|
// * very useful when changing the TextSymbolizer with AtlasStyler<br/> |
|
|
// * SK 9.7.09: It's not enought to user LabelCache.clear(). We can not |
|
|
// * reuse the old Renderer - better to create a new one! |
|
|
// */ |
|
|
// final GTRenderer newRenderer = GTUtil.createGTRenderer(); |
|
|
// |
|
|
// final HashMap<Object, Object> rendererHints = |
|
|
// defaultGTRenderingHints; |
|
|
// rendererHints.put(StreamingRenderer.LABEL_CACHE_KEY, |
|
|
// new LabelCacheImpl()); |
|
|
// |
|
|
// newRenderer.setRendererHints(rendererHints); |
|
|
// mapPane.setLocalRenderer(newRenderer); |
|
|
// |
|
|
// if (oldRenderer != null) { |
|
|
// |
|
|
// RenderingHints java2DHints = oldRenderer.getJava2DHints(); |
|
|
// if (java2DHints != null) { |
|
|
// newRenderer.setJava2DHints(java2DHints); |
|
|
// } |
|
|
// |
|
|
// oldRenderer.setContext(null); |
|
|
// oldRenderer = null; |
|
|
// } |
|
|
|
|
|
mapPane.refresh(); |
|
|
|
|
418 |
} |
} |
419 |
|
|
420 |
/** |
/** |