Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / VectorialIntervalLegend.java @ 6509

History | View | Annotate | Download (23.4 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.fmap.rendering;
42

    
43
import com.hardcode.gdbms.engine.data.DataSource;
44
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException;
45
import com.hardcode.gdbms.engine.values.Value;
46
import com.hardcode.gdbms.engine.values.ValueFactory;
47

    
48
import com.iver.cit.gvsig.fmap.DriverException;
49
import com.iver.cit.gvsig.fmap.core.FShape;
50
import com.iver.cit.gvsig.fmap.core.IFeature;
51
import com.iver.cit.gvsig.fmap.core.SLDTags;
52
import com.iver.cit.gvsig.fmap.core.SLDUtils;
53
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
54
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
55
import com.iver.cit.gvsig.fmap.layers.XMLException;
56

    
57
import com.iver.utiles.StringUtilities;
58
import com.iver.utiles.XMLEntity;
59

    
60
import java.awt.Color;
61

    
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
/**
80
 * Leyenda Vectorial por intervalos.
81
 *
82
 * @author Vicente Caballero Navarro
83
 */
84
public class VectorialIntervalLegend implements IntervalLegend, VectorialLegend {
85
    public final static int EQUAL_INTERVALS = 0;
86
    public final static int NATURAL_INTERVALS = 1;
87
    public final static int QUANTILE_INTERVALS = 2;
88
    private TreeMap symbols = new TreeMap(new Comparator() {
89
                public int compare(Object o1, Object o2) {
90
                    if ((o1 != null) && (o2 != null)) {
91
                       if (o1 instanceof NullIntervalValue &&
92
                                o2 instanceof NullIntervalValue) {
93
                            return 0;
94
                        }
95

    
96
                        if (o2 instanceof NullIntervalValue) {
97
                            return 1;
98
                        }
99

    
100
                        if (o1 instanceof NullIntervalValue) {
101
                            return -1;
102
                        }
103

    
104
                        FInterval i2 = (FInterval) o2;
105
                        FInterval i1 = (FInterval) o1;
106

    
107
                        if (i1.getMin() > i2.getMin()) {
108
                            return 1;
109
                        }
110

    
111
                        if (i1.getMin() < i2.getMin()) {
112
                            return -1;
113
                        }
114
                    }
115

    
116
                    return 0;
117
                }
118
            }); // Para poder ordenar
119
    private ArrayList keys = new ArrayList(); // En lugar de un HashSet, para tener acceso por ?ndice
120
    private int index = 0;
121
    private String fieldName;
122
    private int fieldId;
123
    private String labelFieldName;
124
    private String labelFieldHeight;
125
    private String labelFieldRotation;
126
    private FSymbol defaultSymbol;
127
    private DataSource dataSource;
128
    private Color startColor = Color.red;
129
    private Color endColor = Color.blue;
130
    private int shapeType;
131
    private int intervalType = NATURAL_INTERVALS;
132
    private boolean useDefaultSymbol = false;
133
    // private boolean bWithHeightText;
134

    
135
    /**
136
     * Crea un nuevo VectorialIntervalLegend.
137
     */
138
    public VectorialIntervalLegend() {
139
        //defaultSymbol = LegendFactory.DEFAULT_POLYGON_SYMBOL;
140
    }
141

    
142
    /**
143
     * Crea un nuevo VectorialIntervalLegend.
144
     *
145
     * @param type tipo de shape.
146
     */
147
    public VectorialIntervalLegend(int type) {
148
        setShapeType(type);
149
    }
150

    
151
    /**
152
     * @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#addSymbol(java.lang.Object,
153
     *      FSymbol)
154
     */
155
    public void addSymbol(Object key, FSymbol symbol) {
156
        //TODO guardar los intervalos.
157
        Object resul;
158
        resul = symbols.put(key, symbol);
159

    
160
        /*if (resul != null) {
161
           System.err.println("Error: la clave " + key +
162
                   " ya exist?a. Resul = " + resul);
163
           System.err.println("symbol nuevo:" + symbol.m_Descrip +
164
                   " Sviejo= " + ((FSymbol) resul).m_Descrip);
165
           } else {
166
         */
167
        keys.add(key);
168

    
169
        //}
170
    }
171

    
172
    /*
173
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#getSymbol(java.lang.Object)
174
     *
175
                   public FStyle2D getSymbol(Object value) {
176
                       return (FStyle2D) symbols.get(value);
177
                   }
178
                   // TODO transformar la funci?n anterior en la siguiente
179
     *
180
     */
181

    
182
    /**
183
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getSymbol(int)
184
     */
185
    public FSymbol getSymbol(int recordIndex) throws DriverException {
186
        try {
187
            Value val = dataSource.getFieldValue(recordIndex, fieldId);
188
            IInterval interval = getInterval(val);
189
            FSymbol theSymbol = getSymbolByInterval(interval);
190

    
191
            if (theSymbol != null) {
192
                return theSymbol;
193
            } else if (useDefaultSymbol) {
194
                return getDefaultSymbol();
195
            }
196

    
197
            return null;
198
        } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
199
            throw new DriverException(e);
200
        }
201
    }
202

    
203
    /**
204
     * Devuelve un s?mbolo a partir de una IFeature.
205
     * OJO!! Cuando usamos un feature iterator de base de datos
206
     * el ?nico campo que vendr? rellenado es el de fieldID.
207
     * Los dem?s vendr?n a nulos para ahorra tiempo de creaci?n.
208
     *
209
     * @param feat IFeature.
210
     *
211
     * @return S?mbolo.
212
     */
213
    public FSymbol getSymbolByFeature(IFeature feat) {
214
        Value val = feat.getAttribute(fieldId);
215
        IInterval interval = getInterval(val);
216
        FSymbol theSymbol = getSymbolByInterval(interval);
217

    
218
        if (theSymbol != null) {
219
            return theSymbol;
220
        } else {
221
            return getDefaultSymbol();
222
        }
223
    }
224

    
225
    /**
226
     * Devuelve el s?mbolo a partir del intervalo.
227
     *
228
     * @param key intervalo.
229
     *
230
     * @return s?mbolo.
231
     */
232
    public FSymbol getSymbolByInterval(IInterval key) {
233
        if (key == null) {
234
            return null;
235
        }
236

    
237
        if (symbols.containsKey(key)) {
238
            return (FSymbol) symbols.get(key);
239
        }
240

    
241
        return null;
242
    }
243

    
244
    /**
245
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegendInfo#getDescriptions()
246
     */
247
    public String[] getDescriptions() {
248
        String[] descriptions = new String[symbols.size()];
249
        FSymbol[] auxSym = getSymbols();
250

    
251
        for (int i = 0; i < descriptions.length; i++)
252
            descriptions[i] = auxSym[i].getDescription();
253

    
254
        return descriptions;
255
    }
256

    
257
    /**
258
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegendInfo#getValues()
259
     */
260
    public Object[] getValues() {
261
        return (Object[]) symbols.keySet().toArray(new Object[0]);
262
    }
263

    
264
    /**
265
     * @see com.iver.cit.gvsig.fmap.rendering.IntervalLegend#setIntervalSymbol(com.iver.cit.gvsig.fmap.rendering.FInterval,
266
     *      org.geotools.renderer.style.Style2D)
267
     */
268
    public void setIntervalSymbol(IInterval interval, FSymbol symbol) {
269
        /*symbols.put(interval, symbol);
270
           values.put(new Integer(index), interval);
271
           index++;
272
         */
273
    }
274

    
275
    /**
276
     * @see com.iver.cit.gvsig.fmap.rendering.IntervalLegend#changeInterval(int,
277
     *      com.iver.cit.gvsig.fmap.rendering.FInterval)
278
     */
279
    public void changeInterval(int index, IInterval newInterval) {
280
        /*Object value = values.remove(new Integer(index));
281
           Object symbol = symbols.remove(value);
282
           values.put(new Integer(index), newInterval);
283
           symbols.put(newInterval, symbol);
284
         */
285
    }
286

    
287
    /**
288
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#clear()
289
     */
290
    public void clear() {
291
        index = 0;
292
        keys.clear();
293
        symbols.clear();
294
    }
295

    
296
    /**
297
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getSymbols()
298
     */
299
    public FSymbol[] getSymbols() {
300
        return (FSymbol[]) symbols.values().toArray(new FSymbol[0]);
301
    }
302

    
303
    /**
304
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getFieldName()
305
     */
306
    public String getFieldName() {
307
        return fieldName;
308
    }
309

    
310
    /**
311
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDefaultSymbol(com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D)
312
     */
313
    public void setDefaultSymbol(FSymbol s) {
314
        defaultSymbol = s;
315
    }
316

    
317
    /**
318
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#setFieldName(String)
319
     */
320
    public void setFieldName(String str) {
321
        fieldName = str;
322
    }
323

    
324
    /**
325
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#setLabelField(int)
326
     */
327
    public void setLabelField(String fieldName) {
328
        labelFieldName = fieldName;
329
    }
330

    
331
    /**
332
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#getLabelField()
333
     */
334
    public String getLabelField() {
335
        return labelFieldName;
336
    }
337

    
338
    /**
339
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#getDefaultSymbol()
340
     */
341
    public FSymbol getDefaultSymbol() {
342
        return defaultSymbol;
343
    }
344
    
345
    /**
346
     * DOCUMENT ME!
347
     *
348
     * @return DOCUMENT ME!
349
     *
350
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#getSLDString()
351
     */
352
    public String getSLDString(String layerName) {
353
            
354
            try{
355
                    
356
                        XmlBuilder xmlBuilder = new XmlBuilder();
357
                        xmlBuilder.writeHeader();
358
                        xmlBuilder.openTag(SLDTags.SLD_ROOT, SLDTags.VERSION_ATTR, SLDTags.VERSION_1_0_0);
359
                        xmlBuilder.openTag(SLDTags.NAMEDLAYER);
360
                        xmlBuilder.writeTag(SLDTags.NAME,layerName);
361
                        xmlBuilder.openTag(SLDTags.USERSTYLE);
362
                        xmlBuilder.openTag(SLDTags.FEATURETYPESTYLE);
363
                        xmlBuilder.writeTag(SLDTags.FEATURETYPENAME,fieldName);
364
                        
365
                        FSymbol[] symbols = this.getSymbols(); 
366
                        Object[] values = this.getValues(); 
367
                        
368
                        FInterval interval;
369
                        for(int i = 0; i < symbols.length; i++ )
370
                        {
371
                                interval = (FInterval)values[i];                                                                
372
                                //interval = (FInterval)getInterval(ValueFactory.createValue(valueDbl.doubleValue()));
373
                                xmlBuilder.openTag(SLDTags.RULE);
374
                                xmlBuilder.openTag(SLDTags.FILTER);
375
                                xmlBuilder.openTag(SLDTags.AND);
376
                                xmlBuilder.openTag(SLDTags.PROPERTYISGREATEROREQUALTHAN);
377
                                xmlBuilder.writeTag(SLDTags.PROPERTYNAME,fieldName);
378
                                xmlBuilder.writeTag(SLDTags.LITERAL, ""+interval.getMin());
379
                                xmlBuilder.closeTag();
380
                                xmlBuilder.openTag(SLDTags.PROPERTYISLESSOREQUALTHAN);
381
                                xmlBuilder.writeTag(SLDTags.PROPERTYNAME,fieldName);
382
                                xmlBuilder.writeTag(SLDTags.LITERAL, ""+interval.getMax());
383
                                xmlBuilder.closeTag();                                
384
                                xmlBuilder.closeTag();                                                                                
385
                                xmlBuilder.writeRaw(symbols[i].toSLD());                                
386
                                xmlBuilder.closeTag();
387
                                xmlBuilder.closeTag();
388
                        }
389
                        
390
                        xmlBuilder.closeTag();
391
                        xmlBuilder.closeTag();
392
                        xmlBuilder.closeTag();
393
                        xmlBuilder.closeTag();                        
394
                        return xmlBuilder.getXML();                                                     
395
                               
396
            }catch(Exception e)
397
            {
398
                    e.printStackTrace(); 
399
                    return null;
400
            }
401
    }
402
        
403
    /**
404
     * DOCUMENT ME!
405
     *
406
     * @return DOCUMENT ME!
407
     *
408
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#getXMLEntity()
409
     */
410
    public XMLEntity getXMLEntity() {
411
        XMLEntity xml = new XMLEntity();
412
        xml.putProperty("className", this.getClass().getName());
413

    
414
        if (getDefaultSymbol() == null) {
415
            xml.putProperty("useDefaultSymbol", 0);
416
        } else {
417
            xml.putProperty("useDefaultSymbol", 1);
418
            xml.addChild(getDefaultSymbol().getXMLEntity());
419
        }
420

    
421
        xml.putProperty("fieldName", fieldName);
422
        xml.putProperty("index", index);
423
        xml.putProperty("labelfield", labelFieldName);
424
        xml.putProperty("labelfield", labelFieldName);
425
        xml.putProperty("labelFieldHeight", labelFieldHeight);
426
        xml.putProperty("labelFieldRotation", labelFieldRotation);
427
        
428
        xml.putProperty("intervalType", intervalType);
429
        xml.putProperty("numKeys", keys.size());
430

    
431
        if (keys.size() > 0) {
432
            xml.putProperty("tipoValueKeys", keys.get(0).getClass().getName());
433

    
434
            String[] sk = new String[keys.size()];
435

    
436
            for (int i = 0; i < keys.size(); i++) {
437
                sk[i] = ((IInterval) keys.get(i)).toString();
438
            }
439

    
440
            xml.putProperty("keys", getValues());
441

    
442
            for (int i = 0; i < keys.size(); i++) {
443
                xml.addChild(getSymbols()[i].getXMLEntity());
444
            }
445
        }
446

    
447
        xml.putProperty("startColor", StringUtilities.color2String(startColor));
448
        xml.putProperty("endColor", StringUtilities.color2String(endColor));
449

    
450
        ///xml.putProperty("numSymbols", symbols.size());
451
        ///xml.putProperty("indexs", getIndexs());
452
        ///xml.putProperty("values", getValues());
453
        return xml;
454
    }
455

    
456
    /**
457
     * Inserta los atributos del XMLEntity.
458
     *
459
     * @param xml XMLEntity.
460
     */
461
    public void setXMLEntity03(XMLEntity xml) {
462
        fieldName = xml.getStringProperty("fieldName");
463
        index = xml.getIntProperty("index");
464
        labelFieldName = xml.getStringProperty("labelfield");
465

    
466
        if (xml.contains("intervalType")) { //TODO Esta condici?n es para poder cargar la versi?n 0.3, se puede eliminar cuando ya no queramos soportar esta versi?n.
467
            intervalType = xml.getIntProperty("intervalType");
468
        }
469

    
470
        int useDefaultSymbol = xml.getIntProperty("useDefaultSymbol");
471

    
472
        if (useDefaultSymbol == 1) {
473
            setDefaultSymbol(FSymbol.createFromXML03(xml.getChild(0)));
474
        } else {
475
            setDefaultSymbol(null);
476
        }
477

    
478
        int numKeys = xml.getIntProperty("numKeys");
479

    
480
        if (numKeys > 0) {
481
            String className = xml.getStringProperty("tipoValueKeys");
482
            String[] sk = xml.getStringArrayProperty("keys");
483
            IInterval auxInterval;
484

    
485
            for (int i = 0; i < numKeys; i++) {
486
                auxInterval = FInterval.create(sk[i]);
487
                symbols.put(auxInterval,
488
                    FSymbol.createFromXML03(xml.getChild(i + useDefaultSymbol)));
489
                keys.add(auxInterval);
490
                System.out.println("auxInterval =" + auxInterval + "Symbol =" +
491
                    FSymbol.createFromXML03(xml.getChild(i + useDefaultSymbol))
492
                           .getDescription());
493
            }
494
        }
495

    
496
        startColor = StringUtilities.string2Color(xml.getStringProperty(
497
                    "startColor"));
498
        endColor = StringUtilities.string2Color(xml.getStringProperty(
499
                    "endColor"));
500
    }
501

    
502
    /**
503
     * Inserta los atributos del XMLEntity.
504
     *
505
     * @param xml XMLEntity.
506
     */
507
    public void setXMLEntity(XMLEntity xml) {
508
        fieldName = xml.getStringProperty("fieldName");
509
        index = xml.getIntProperty("index");
510
        labelFieldName = xml.getStringProperty("labelfield");
511
        if (xml.contains("labelFieldHeight")) {
512
            setLabelHeightField(xml.getStringProperty("labelFieldHeight"));
513
        }
514

    
515
        if (xml.contains("labelFieldRotation")) {
516
            setLabelRotationField(xml.getStringProperty("labelFieldRotation"));
517
        }
518

    
519
        if (xml.contains("intervalType")) { //TODO Esta condici?n es para poder cargar la versi?n 0.3, se puede eliminar cuando ya no queramos soportar esta versi?n.
520
            intervalType = xml.getIntProperty("intervalType");
521
        }
522

    
523
        int useDefaultSymbol = xml.getIntProperty("useDefaultSymbol");
524

    
525
        if (useDefaultSymbol == 1) {
526
            setDefaultSymbol(FSymbol.createFromXML(xml.getChild(0)));
527
            this.useDefaultSymbol=true;
528
        } else {
529
            setDefaultSymbol(null);
530
            this.useDefaultSymbol=false;
531
        }
532

    
533
        int numKeys = xml.getIntProperty("numKeys");
534

    
535
        if (numKeys > 0) {
536
            String className = xml.getStringProperty("tipoValueKeys");
537
            String[] sk = xml.getStringArrayProperty("keys");
538
            IInterval auxInterval;
539

    
540
            for (int i = 0; i < numKeys; i++) {
541
                auxInterval = FInterval.create(sk[i]);
542
                symbols.put(auxInterval,
543
                    FSymbol.createFromXML(xml.getChild(i + useDefaultSymbol)));
544
                keys.add(auxInterval);
545
                System.out.println("auxInterval =" + auxInterval + "Symbol =" +
546
                    FSymbol.createFromXML(xml.getChild(i + useDefaultSymbol))
547
                           .getDescription());
548
            }
549
        }
550

    
551
        startColor = StringUtilities.string2Color(xml.getStringProperty(
552
                    "startColor"));
553
        endColor = StringUtilities.string2Color(xml.getStringProperty(
554
                    "endColor"));
555
    }
556

    
557
    /**
558
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#cloneLegend()
559
     */
560
    public Legend cloneLegend() throws XMLException {
561
        return (Legend) LegendFactory.createFromXML(getXMLEntity());
562
    }
563

    
564
    /* (non-Javadoc)
565
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDataSource(com.hardcode.gdbms.engine.data.DataSource)
566
     */
567
    public void setDataSource(DataSource ds)
568
        throws FieldNotFoundException, DriverException {
569
        try {
570
            dataSource = ds;
571
            ds.start();
572
            fieldId = ds.getFieldIndexByName(fieldName);
573
            ds.stop();
574
        } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
575
            throw new DriverException(e);
576
        }
577
    }
578

    
579
    /**
580
     * Devuelve el intervalo a partir del valor.
581
     *
582
     * @param v valor.
583
     *
584
     * @return intervalo.
585
     */
586
    public IInterval getInterval(Value v) {
587
        /*if (v instanceof NullValue){
588
           System.out.println("Si");
589
           }*/
590
        for (int i = 0; i < keys.size(); i++) {
591
            if (((IInterval) keys.get(i)).isInInterval(v)) {
592
                return (IInterval) keys.get(i);
593
            }
594
        }
595

    
596
        return null;
597
    }
598

    
599
    /**
600
     * Devuelve el color final.
601
     *
602
     * @return color final.
603
     */
604
    public Color getEndColor() {
605
        return endColor;
606
    }
607

    
608
    /**
609
     * Inserta el color final.
610
     *
611
     * @param endColor Color final.
612
     */
613
    public void setEndColor(Color endColor) {
614
        this.endColor = endColor;
615
    }
616

    
617
    /**
618
     * Devuelve el color inicial.
619
     *
620
     * @return Color inicial.
621
     */
622
    public Color getStartColor() {
623
        return startColor;
624
    }
625

    
626
    /**
627
     * Inserta el color inicial.
628
     *
629
     * @param startColor Color inicial.
630
     */
631
    public void setStartColor(Color startColor) {
632
        this.startColor = startColor;
633
    }
634

    
635
    /* (non-Javadoc)
636
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getShapeType()
637
     */
638
    public int getShapeType() {
639
        return shapeType;
640
    }
641

    
642
    /* (non-Javadoc)
643
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setShapeType(int)
644
     */
645
    public void setShapeType(int shapeType) {
646
        if (this.shapeType != shapeType) {
647
            switch (shapeType) {
648
                case FShape.POINT:
649
                    defaultSymbol = new FSymbol(FConstant.SYMBOL_TYPE_POINT);
650

    
651
                    break;
652

    
653
                case FShape.LINE:
654
                    defaultSymbol = new FSymbol(FConstant.SYMBOL_TYPE_LINE);
655

    
656
                    break;
657

    
658
                case FShape.POLYGON:
659
                    defaultSymbol = new FSymbol(FConstant.SYMBOL_TYPE_FILL);
660

    
661
                    break;
662

    
663
                default:
664
                    defaultSymbol = new FSymbol(shapeType);
665
            }
666

    
667
            this.shapeType = shapeType;
668
        }
669
    }
670

    
671
    /* (non-Javadoc)
672
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelHeightField()
673
     */
674
    public String getLabelHeightField() {
675
        return labelFieldHeight;
676
    }
677

    
678
    /**
679
     * Inserta el alto del campo.
680
     *
681
     * @param str alto.
682
     */
683
    public void setLabelHeightField(String str) {
684
        labelFieldHeight = str;
685
    }
686

    
687
    /* (non-Javadoc)
688
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelRotationField()
689
     */
690
    public String getLabelRotationField() {
691
        return labelFieldRotation;
692
    }
693

    
694
    /**
695
     * Inserta la rotaci?n del campo.
696
     *
697
     * @param str Rotaci?n.
698
     */
699
    public void setLabelRotationField(String str) {
700
        labelFieldRotation = str;
701
    }
702

    
703
    /**
704
     * Inserta el tipo de clasificaci?n de los intervalos.
705
     *
706
     * @param tipoClasificacion Tipo de clasificaci?n.
707
     */
708
    public void setIntervalType(int tipoClasificacion) {
709
        intervalType = tipoClasificacion;
710
    }
711

    
712
    /**
713
     * Devuelve el tipo de clasificaci?n de los intervalos.
714
     *
715
     * @return Tipo de clasificaci?n.
716
     */
717
    public int getIntervalType() {
718
        return intervalType;
719
    }
720

    
721
    /**
722
     * Inserta si se representan el resto de valores o no.
723
     *
724
     * @param b True si se tienen que representar el resto de valores.
725
     */
726
    public void useDefaultSymbol(boolean b) {
727
        useDefaultSymbol = b;
728
    }
729

    
730
    /**
731
     * Devuelve si se utiliza o no el resto de valores para representarse.
732
     *
733
     * @return True si se utiliza el resto de valores.
734
     */
735
    public boolean isUseDefaultSymbol() {
736
        return useDefaultSymbol;
737
    }
738

    
739
    /**
740
     * Devuelve si ha sido modificado el etiquetado de la capa.
741
     *
742
     * @return True si el etiquetado de la capa ha sido modificado.
743
     */
744
    /* public boolean isBWithHeightText() {
745
        return bWithHeightText;
746
    } */
747

    
748
    /**
749
     * Introduce si el etiquetado de la capa ha sido modificado.
750
     *
751
     * @param withHeightText Boolean que indica si el etiquetado de la capa ha
752
     *        sido modificado.
753
     */
754
    /* public void setBWithHeightText(boolean withHeightText) {
755
        bWithHeightText = withHeightText;
756
    } */
757

    
758
    /**
759
     * Elimina un s?mbolo a partir de su clave.
760
     *
761
     * @param obj clave.
762
     */
763
    public void delSymbol(Object obj) {
764
        keys.remove(obj);
765
        symbols.remove(obj);
766
    }
767

    
768
    /* (non-Javadoc)
769
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getUsedFields()
770
     */
771
    public String[] getUsedFields() {
772
        ArrayList usedFields = new ArrayList();
773
        if (getFieldName() != null)
774
            usedFields.add(getFieldName());        
775
        if (getLabelField() != null)
776
            usedFields.add(getLabelField());
777
        if (getLabelHeightField() != null)
778
            usedFields.add(getLabelHeightField());
779
        if (getLabelRotationField() != null)
780
            usedFields.add(getLabelRotationField());
781
                
782
        return (String[]) usedFields.toArray(new String[0]);
783

    
784
    }
785
}