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