Revision 7659 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/VectorialIntervalLegend.java
VectorialIntervalLegend.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package com.iver.cit.gvsig.fmap.rendering; |
42 | 42 |
|
43 |
import java.awt.Color; |
|
44 |
import java.util.ArrayList; |
|
45 |
import java.util.Comparator; |
|
46 |
import java.util.TreeMap; |
|
47 |
|
|
43 | 48 |
import com.hardcode.gdbms.engine.data.DataSource; |
44 | 49 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
45 | 50 |
import com.hardcode.gdbms.engine.values.Value; |
46 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
47 |
|
|
48 | 51 |
import com.iver.cit.gvsig.fmap.DriverException; |
49 | 52 |
import com.iver.cit.gvsig.fmap.core.FShape; |
50 | 53 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
54 |
import com.iver.cit.gvsig.fmap.core.ISLDCompatible; |
|
55 |
import com.iver.cit.gvsig.fmap.core.ISymbol; |
|
51 | 56 |
import com.iver.cit.gvsig.fmap.core.SLDTags; |
52 |
import com.iver.cit.gvsig.fmap.core.SLDUtils; |
|
53 | 57 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
54 | 58 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
55 | 59 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
56 |
|
|
57 | 60 |
import com.iver.utiles.StringUtilities; |
58 | 61 |
import com.iver.utiles.XMLEntity; |
59 | 62 |
|
60 |
import java.awt.Color; |
|
61 | 63 |
|
62 |
import java.util.ArrayList; |
|
63 |
import java.util.Comparator; |
|
64 |
import java.util.TreeMap; |
|
65 |
|
|
66 |
import org.geotools.filter.ExpressionBuilder; |
|
67 |
import org.geotools.filter.Filter; |
|
68 |
import org.geotools.styling.FeatureTypeStyle; |
|
69 |
import org.geotools.styling.NamedLayer; |
|
70 |
import org.geotools.styling.Rule; |
|
71 |
import org.geotools.styling.SLDTransformer; |
|
72 |
import org.geotools.styling.Style; |
|
73 |
import org.geotools.styling.StyleBuilder; |
|
74 |
import org.geotools.styling.StyleFactory; |
|
75 |
import org.geotools.styling.StyledLayerDescriptor; |
|
76 |
import org.geotools.styling.Symbolizer; |
|
77 |
|
|
78 |
|
|
79 | 64 |
/** |
80 | 65 |
* Leyenda Vectorial por intervalos. |
81 | 66 |
* |
... | ... | |
123 | 108 |
private String labelFieldName; |
124 | 109 |
private String labelFieldHeight; |
125 | 110 |
private String labelFieldRotation; |
126 |
private FSymbol defaultSymbol;
|
|
111 |
private ISymbol defaultSymbol;
|
|
127 | 112 |
private DataSource dataSource; |
128 | 113 |
private Color startColor = Color.red; |
129 | 114 |
private Color endColor = Color.blue; |
... | ... | |
150 | 135 |
|
151 | 136 |
/** |
152 | 137 |
* @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#addSymbol(java.lang.Object, |
153 |
* FSymbol)
|
|
138 |
* ISymbol)
|
|
154 | 139 |
*/ |
155 |
public void addSymbol(Object key, FSymbol symbol) {
|
|
140 |
public void addSymbol(Object key, ISymbol symbol) {
|
|
156 | 141 |
//TODO guardar los intervalos. |
157 | 142 |
Object resul; |
158 | 143 |
resul = symbols.put(key, symbol); |
... | ... | |
182 | 167 |
/** |
183 | 168 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getSymbol(int) |
184 | 169 |
*/ |
185 |
public FSymbol getSymbol(int recordIndex) throws DriverException {
|
|
170 |
public ISymbol getSymbol(int recordIndex) throws DriverException {
|
|
186 | 171 |
try { |
187 | 172 |
Value val = dataSource.getFieldValue(recordIndex, fieldId); |
188 | 173 |
IInterval interval = getInterval(val); |
... | ... | |
210 | 195 |
* |
211 | 196 |
* @return S?mbolo. |
212 | 197 |
*/ |
213 |
public FSymbol getSymbolByFeature(IFeature feat) {
|
|
198 |
public ISymbol getSymbolByFeature(IFeature feat) {
|
|
214 | 199 |
Value val = feat.getAttribute(fieldId); |
215 | 200 |
IInterval interval = getInterval(val); |
216 | 201 |
FSymbol theSymbol = getSymbolByInterval(interval); |
... | ... | |
246 | 231 |
*/ |
247 | 232 |
public String[] getDescriptions() { |
248 | 233 |
String[] descriptions = new String[symbols.size()]; |
249 |
FSymbol[] auxSym = getSymbols();
|
|
234 |
ISymbol[] auxSym = getSymbols();
|
|
250 | 235 |
|
251 | 236 |
for (int i = 0; i < descriptions.length; i++) |
252 | 237 |
descriptions[i] = auxSym[i].getDescription(); |
... | ... | |
296 | 281 |
/** |
297 | 282 |
* @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getSymbols() |
298 | 283 |
*/ |
299 |
public FSymbol[] getSymbols() {
|
|
284 |
public ISymbol[] getSymbols() {
|
|
300 | 285 |
return (FSymbol[]) symbols.values().toArray(new FSymbol[0]); |
301 | 286 |
} |
302 | 287 |
|
... | ... | |
308 | 293 |
} |
309 | 294 |
|
310 | 295 |
/** |
311 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDefaultSymbol(com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D)
|
|
296 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDefaultSymbol(ISymbol)
|
|
312 | 297 |
*/ |
313 |
public void setDefaultSymbol(FSymbol s) {
|
|
298 |
public void setDefaultSymbol(ISymbol s) {
|
|
314 | 299 |
defaultSymbol = s; |
315 | 300 |
} |
316 | 301 |
|
... | ... | |
338 | 323 |
/** |
339 | 324 |
* @see com.iver.cit.gvsig.fmap.rendering.Legend#getDefaultSymbol() |
340 | 325 |
*/ |
341 |
public FSymbol getDefaultSymbol() {
|
|
326 |
public ISymbol getDefaultSymbol() {
|
|
342 | 327 |
return defaultSymbol; |
343 | 328 |
} |
344 | 329 |
|
... | ... | |
362 | 347 |
xmlBuilder.openTag(SLDTags.FEATURETYPESTYLE); |
363 | 348 |
xmlBuilder.writeTag(SLDTags.FEATURETYPENAME,fieldName); |
364 | 349 |
|
365 |
FSymbol[] symbols = this.getSymbols();
|
|
350 |
ISymbol[] symbols = this.getSymbols();
|
|
366 | 351 |
Object[] values = this.getValues(); |
367 | 352 |
|
368 | 353 |
FInterval interval; |
369 | 354 |
for(int i = 0; i < symbols.length; i++ ) |
370 | 355 |
{ |
371 |
interval = (FInterval)values[i];
|
|
356 |
interval = (FInterval)values[i]; |
|
372 | 357 |
//interval = (FInterval)getInterval(ValueFactory.createValue(valueDbl.doubleValue())); |
373 | 358 |
xmlBuilder.openTag(SLDTags.RULE); |
374 | 359 |
xmlBuilder.openTag(SLDTags.FILTER); |
... | ... | |
381 | 366 |
xmlBuilder.writeTag(SLDTags.PROPERTYNAME,fieldName); |
382 | 367 |
xmlBuilder.writeTag(SLDTags.LITERAL, ""+interval.getMax()); |
383 | 368 |
xmlBuilder.closeTag(); |
384 |
xmlBuilder.closeTag(); |
|
385 |
xmlBuilder.writeRaw(symbols[i].toSLD()); |
|
369 |
xmlBuilder.closeTag(); |
|
370 |
if (symbols[i] instanceof ISLDCompatible) |
|
371 |
{ |
|
372 |
ISLDCompatible symSLD = (ISLDCompatible) symbols[i]; |
|
373 |
xmlBuilder.writeRaw(symSLD.toSLD()); |
|
374 |
} |
|
375 |
else |
|
376 |
throw new RuntimeException("Cannot convert Symbol " + i + " " + symbols[i].getDescription() + " to SLD"); |
|
386 | 377 |
xmlBuilder.closeTag(); |
387 | 378 |
xmlBuilder.closeTag(); |
388 | 379 |
} |
Also available in: Unified diff