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 |
|
|
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; |
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]; |
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; |
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 |
|
|