Revision 7659 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/VectorialUniqueValueLegend.java

View differences:

VectorialUniqueValueLegend.java
40 40
 */
41 41
package com.iver.cit.gvsig.fmap.rendering;
42 42

  
43
import java.sql.Types;
44
import java.text.ParseException;
45
import java.util.ArrayList;
46
import java.util.Comparator;
47
import java.util.TreeMap;
48

  
49
import org.geotools.filter.ExpressionBuilder;
50
import org.geotools.filter.Filter;
51
import org.geotools.styling.FeatureTypeStyle;
52
import org.geotools.styling.NamedLayer;
53
import org.geotools.styling.Rule;
54
import org.geotools.styling.SLDTransformer;
55
import org.geotools.styling.Style;
56
import org.geotools.styling.StyleBuilder;
57
import org.geotools.styling.StyleFactory;
58
import org.geotools.styling.StyledLayerDescriptor;
59
import org.geotools.styling.Symbolizer;
60

  
43 61
import com.hardcode.gdbms.engine.data.DataSource;
44 62
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException;
45 63
import com.hardcode.gdbms.engine.instruction.IncompatibleTypesException;
......
49 67
import com.hardcode.gdbms.engine.values.StringValue;
50 68
import com.hardcode.gdbms.engine.values.Value;
51 69
import com.hardcode.gdbms.engine.values.ValueFactory;
52

  
53 70
import com.iver.cit.gvsig.fmap.DriverException;
54 71
import com.iver.cit.gvsig.fmap.core.FShape;
55 72
import com.iver.cit.gvsig.fmap.core.IFeature;
73
import com.iver.cit.gvsig.fmap.core.ISLDCompatible;
74
import com.iver.cit.gvsig.fmap.core.ISymbol;
56 75
import com.iver.cit.gvsig.fmap.core.SLDTags;
57 76
import com.iver.cit.gvsig.fmap.core.SLDUtils;
58 77
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
59 78
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
60 79
import com.iver.cit.gvsig.fmap.layers.XMLException;
61

  
62 80
import com.iver.utiles.XMLEntity;
63 81

  
64
import java.sql.Types;
65

  
66
import java.text.ParseException;
67

  
68
import java.util.ArrayList;
69
import java.util.Comparator;
70
import java.util.TreeMap;
71

  
72
import org.geotools.filter.ExpressionBuilder;
73
import org.geotools.filter.Filter;
74
import org.geotools.styling.FeatureTypeStyle;
75
import org.geotools.styling.NamedLayer;
76
import org.geotools.styling.Rule;
77
import org.geotools.styling.SLDTransformer;
78
import org.geotools.styling.Style;
79
import org.geotools.styling.StyleBuilder;
80
import org.geotools.styling.StyleFactory;
81
import org.geotools.styling.StyledLayerDescriptor;
82
import org.geotools.styling.Symbolizer;
83

  
84 82
/**
85 83
 * Leyenda vectorial por valores ?nicos.
86 84
 *
......
152 150
    private String labelFieldName;
153 151
    private String labelFieldHeight;
154 152
    private String labelFieldRotation;
155
    private FSymbol defaultSymbol;
153
    private ISymbol defaultSymbol;
156 154
    private DataSource dataSource;
157 155
    private int shapeType;
158 156
    private String valueType = NullValue.class.getName();
......
208 206

  
209 207
    /**
210 208
     * @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#setValueSymbolByID(int,
211
     *      FSymbol)
209
     *      ISymbol)
212 210
     */
213
    public void setValueSymbolByID(int id, FSymbol symbol) {
211
    public void setValueSymbolByID(int id, ISymbol symbol) {
214 212
        symbols.put(keys.get(id), symbol);
215 213
    }
216 214

  
......
247 245

  
248 246
    /**
249 247
     * @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#addSymbol(java.lang.Object,
250
     *      FSymbol)
248
     *      ISymbol)
251 249
     */
252
    public void addSymbol(Object key, FSymbol symbol) {
250
    public void addSymbol(Object key, ISymbol symbol) {
253 251
        Object resul;
254 252
        resul = symbols.put(key, symbol);
255 253

  
......
280 278
     */
281 279
    public String[] getDescriptions() {
282 280
        String[] descriptions = new String[symbols.size()];
283
        FSymbol[] auxSym = getSymbols();
281
        ISymbol[] auxSym = getSymbols();
284 282

  
285 283
        for (int i = 0; i < descriptions.length; i++)
286 284
            descriptions[i] = auxSym[i].getDescription();
......
291 289
    /**
292 290
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getSymbols()
293 291
     */
294
    public FSymbol[] getSymbols() {
295
        return (FSymbol[]) symbols.values().toArray(new FSymbol[0]);
292
    public ISymbol[] getSymbols() {
293
        return (ISymbol[]) symbols.values().toArray(new ISymbol[0]);
296 294
    }
297 295

  
298 296
    /**
......
303 301
    }
304 302

  
305 303
    /**
306
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDefaultSymbol(com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D)
304
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDefaultSymbol(ISymbol)
307 305
     */
308
    public void setDefaultSymbol(FSymbol s) {
306
    public void setDefaultSymbol(ISymbol s) {
309 307
        defaultSymbol = s;
310 308
    }
311 309

  
......
333 331
    /**
334 332
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getSymbol(int)
335 333
     */
336
    public FSymbol getSymbol(int recordIndex) throws DriverException {
334
    public ISymbol getSymbol(int recordIndex) throws DriverException {
337 335
        try {
338 336
            Value val = dataSource.getFieldValue(recordIndex, fieldId);
339
            FSymbol theSymbol = getSymbolByValue(val);
337
            ISymbol theSymbol = getSymbolByValue(val);
340 338

  
341 339
            //if (theSymbol != null) {
342 340
            return theSymbol;
......
358 356
     *
359 357
     * @return S?mbolo.
360 358
     */
361
    public FSymbol getSymbolByFeature(IFeature feat) {
359
    public ISymbol getSymbolByFeature(IFeature feat) {
362 360
        Value val = feat.getAttribute(fieldId);
363 361
        // Value val = feat.getAttribute(0);
364
        FSymbol theSymbol = getSymbolByValue(val);
362
        ISymbol theSymbol = getSymbolByValue(val);
365 363

  
366 364
        //if (theSymbol != null) {
367 365
        return theSymbol;
......
374 372
    /**
375 373
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#getDefaultSymbol()
376 374
     */
377
    public FSymbol getDefaultSymbol() {
375
    public ISymbol getDefaultSymbol() {
378 376
        return defaultSymbol;
379 377
    }
380 378

  
......
397 395
			FeatureTypeStyle featStyle = styleFactory.createFeatureTypeStyle();
398 396
			featStyle.setFeatureTypeName(fieldName);
399 397

  
400
			FSymbol[] symbols = this.getSymbols();
398
			ISymbol[] symbols = this.getSymbols();
401 399
			Symbolizer[] theSymbolizers = new Symbolizer[symbols.length];
402 400
			Object[] values = this.getValues();
403 401
			String valueStr = null;
......
446 444
			xmlBuilder.openTag(SLDTags.FEATURETYPESTYLE);
447 445
			//xmlBuilder.writeTag(SLDTags.FEATURETYPENAME,"fieldName");
448 446

  
449
			FSymbol[] symbols = this.getSymbols();
447
			ISymbol[] symbols = this.getSymbols();
450 448
			Object[] values = this.getValues();
451 449
			String valueStr = null;
452 450

  
......
460 458
				xmlBuilder.writeTag(SLDTags.LITERAL, valueStr);
461 459
				xmlBuilder.closeTag();
462 460
				xmlBuilder.closeTag();
461
				if (symbols[i] instanceof ISLDCompatible)
462
				{
463
					ISLDCompatible symSLD = (ISLDCompatible) symbols[i];
464
					xmlBuilder.writeRaw(symSLD.toSLD());
465
				}
466
				else
467
					throw new RuntimeException("Cannot convert Symbol " + i + " " + symbols[i].getDescription() + " to SLD");
463 468

  
464
				xmlBuilder.writeRaw(symbols[i].toSLD());
465

  
466 469
				xmlBuilder.closeTag();
467 470
			}
468 471

  
......
501 504
            String[] sv = new String[keys.size()];
502 505
            int[] stk = new int[keys.size()];
503 506
            int[] stv = new int[keys.size()];
504
            FSymbol[] fsymbols = getSymbols();
507
            ISymbol[] fsymbols = getSymbols();
505 508
            Object[] values = getValues();
506 509

  
507 510
            for (int i = 0; i < keys.size(); i++) {
......
758 761
    /* (non-Javadoc)
759 762
     * @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#getSymbolByValue(com.hardcode.gdbms.engine.values.Value)
760 763
     */
761
    public FSymbol getSymbolByValue(Value key) {
764
    public ISymbol getSymbolByValue(Value key) {
762 765
        if (symbols.containsKey(key)) {
763 766
            return (FSymbol) symbols.get(key);
764 767
        } else if (useDefaultSymbol) {

Also available in: Unified diff