Statistics
| Revision:

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

History | View | Annotate | Download (23.1 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 java.awt.Color;
44
import java.util.ArrayList;
45
import java.util.Comparator;
46
import java.util.TreeMap;
47

    
48
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
49
import com.hardcode.gdbms.engine.data.DataSource;
50
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException;
51
import com.hardcode.gdbms.engine.values.Value;
52
import com.iver.cit.gvsig.fmap.core.FShape;
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.SLDTags;
56
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol;
57
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
58
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
59
import com.iver.cit.gvsig.fmap.layers.XMLException;
60
import com.iver.utiles.StringUtilities;
61
import com.iver.utiles.XMLEntity;
62

    
63

    
64
/**
65
 * Leyenda Vectorial por intervalos.
66
 *
67
 * @author Vicente Caballero Navarro
68
 */
69
public class VectorialIntervalLegend implements IntervalLegend, VectorialLegend {
70
    public final static int EQUAL_INTERVALS = 0;
71
    public final static int NATURAL_INTERVALS = 1;
72
    public final static int QUANTILE_INTERVALS = 2;
73
    private TreeMap symbols = new TreeMap(new Comparator() {
74
                public int compare(Object o1, Object o2) {
75
                    if ((o1 != null) && (o2 != null)) {
76
                       if (o1 instanceof NullIntervalValue &&
77
                                o2 instanceof NullIntervalValue) {
78
                            return 0;
79
                        }
80

    
81
                        if (o2 instanceof NullIntervalValue) {
82
                            return 1;
83
                        }
84

    
85
                        if (o1 instanceof NullIntervalValue) {
86
                            return -1;
87
                        }
88

    
89
                        FInterval i2 = (FInterval) o2;
90
                        FInterval i1 = (FInterval) o1;
91

    
92
                        if (i1.getMin() > i2.getMin()) {
93
                            return 1;
94
                        }
95

    
96
                        if (i1.getMin() < i2.getMin()) {
97
                            return -1;
98
                        }
99
                        if (i1.getMax() < i2.getMax()) {
100
                                return -1;
101
                        }
102
                        if (i1.getMax() > i2.getMax()) {
103
                                return 1;
104
                        }
105
                    }
106

    
107
                    return 0;
108
                }
109
            }); // Para poder ordenar
110
    private ArrayList keys = new ArrayList(); // En lugar de un HashSet, para tener acceso por ?ndice
111
    private int index = 0;
112
    private String fieldName;
113
    private int fieldId;
114
    private String labelFieldName;
115
    private String labelFieldHeight;
116
    private String labelFieldRotation;
117
    private ISymbol defaultSymbol;
118
    private DataSource dataSource;
119
    private Color startColor = Color.red;
120
    private Color endColor = Color.blue;
121
    private int shapeType;
122
    private int intervalType = NATURAL_INTERVALS;
123
    private boolean useDefaultSymbol = false;
124
    // private boolean bWithHeightText;
125

    
126
    /**
127
     * Crea un nuevo VectorialIntervalLegend.
128
     */
129
    public VectorialIntervalLegend() {
130
        //defaultSymbol = LegendFactory.DEFAULT_POLYGON_SYMBOL;
131
    }
132

    
133
    /**
134
     * Crea un nuevo VectorialIntervalLegend.
135
     *
136
     * @param type tipo de shape.
137
     */
138
    public VectorialIntervalLegend(int type) {
139
        setShapeType(type);
140
    }
141

    
142
    /**
143
     * @see com.iver.cit.gvsig.fmap.rendering.UniqueValueLegend#addSymbol(java.lang.Object,
144
     *      ISymbol)
145
     */
146
    public void addSymbol(Object key, ISymbol symbol) {
147
        //TODO guardar los intervalos.
148
        Object resul;
149
        resul = symbols.put(key, symbol);
150

    
151
        /*if (resul != null) {
152
           System.err.println("Error: la clave " + key +
153
                   " ya exist?a. Resul = " + resul);
154
           System.err.println("symbol nuevo:" + symbol.m_Descrip +
155
                   " Sviejo= " + ((FSymbol) resul).m_Descrip);
156
           } else {
157
         */
158
        keys.add(key);
159

    
160
        //}
161
    }
162

    
163
    /*
164
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#getSymbol(java.lang.Object)
165
     *
166
                   public FStyle2D getSymbol(Object value) {
167
                       return (FStyle2D) symbols.get(value);
168
                   }
169
                   // TODO transformar la funci?n anterior en la siguiente
170
     *
171
     */
172

    
173
    /**
174
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getSymbol(int)
175
     */
176
    public ISymbol getSymbol(int recordIndex) throws ReadDriverException {
177
       Value val = dataSource.getFieldValue(recordIndex, fieldId);
178
       IInterval interval = getInterval(val);
179
       FSymbol theSymbol = getSymbolByInterval(interval);
180

    
181
       if (theSymbol != null) {
182
           return theSymbol;
183
       } else if (useDefaultSymbol) {
184
           return getDefaultSymbol();
185
       }
186

    
187
       return null;
188
    }
189

    
190
    /**
191
     * Devuelve un s?mbolo a partir de una IFeature.
192
     * OJO!! Cuando usamos un feature iterator de base de datos
193
     * el ?nico campo que vendr? rellenado es el de fieldID.
194
     * Los dem?s vendr?n a nulos para ahorra tiempo de creaci?n.
195
     *
196
     * @param feat IFeature.
197
     *
198
     * @return S?mbolo.
199
     */
200
    public ISymbol getSymbolByFeature(IFeature feat) {
201
        Value val = feat.getAttribute(fieldId);
202
        IInterval interval = getInterval(val);
203
        FSymbol theSymbol = getSymbolByInterval(interval);
204

    
205
        if (theSymbol != null) {
206
            return theSymbol;
207
        } else {
208
            return getDefaultSymbol();
209
        }
210
    }
211

    
212
    /**
213
     * Devuelve el s?mbolo a partir del intervalo.
214
     *
215
     * @param key intervalo.
216
     *
217
     * @return s?mbolo.
218
     */
219
    public FSymbol getSymbolByInterval(IInterval key) {
220
        if (key == null) {
221
            return null;
222
        }
223

    
224
        if (symbols.containsKey(key)) {
225
            return (FSymbol) symbols.get(key);
226
        }
227

    
228
        return null;
229
    }
230

    
231
    /**
232
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegendInfo#getDescriptions()
233
     */
234
    public String[] getDescriptions() {
235
        String[] descriptions = new String[symbols.size()];
236
        ISymbol[] auxSym = getSymbols();
237

    
238
        for (int i = 0; i < descriptions.length; i++)
239
            descriptions[i] = auxSym[i].getDescription();
240

    
241
        return descriptions;
242
    }
243

    
244
    /**
245
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegendInfo#getValues()
246
     */
247
    public Object[] getValues() {
248
        return (Object[]) symbols.keySet().toArray(new Object[0]);
249
    }
250

    
251
    /**
252
     * @see com.iver.cit.gvsig.fmap.rendering.IntervalLegend#setIntervalSymbol(com.iver.cit.gvsig.fmap.rendering.FInterval,
253
     *      org.geotools.renderer.style.Style2D)
254
     */
255
    public void setIntervalSymbol(IInterval interval, FSymbol symbol) {
256
        /*symbols.put(interval, symbol);
257
           values.put(new Integer(index), interval);
258
           index++;
259
         */
260
    }
261

    
262
    /**
263
     * @see com.iver.cit.gvsig.fmap.rendering.IntervalLegend#changeInterval(int,
264
     *      com.iver.cit.gvsig.fmap.rendering.FInterval)
265
     */
266
    public void changeInterval(int index, IInterval newInterval) {
267
        /*Object value = values.remove(new Integer(index));
268
           Object symbol = symbols.remove(value);
269
           values.put(new Integer(index), newInterval);
270
           symbols.put(newInterval, symbol);
271
         */
272
    }
273

    
274
    /**
275
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#clear()
276
     */
277
    public void clear() {
278
        index = 0;
279
        keys.clear();
280
        symbols.clear();
281
    }
282

    
283
    /**
284
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getSymbols()
285
     */
286
    public ISymbol[] getSymbols() {
287
        return (FSymbol[]) symbols.values().toArray(new FSymbol[0]);
288
    }
289

    
290
    /**
291
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#getFieldName()
292
     */
293
    public String getFieldName() {
294
        return fieldName;
295
    }
296

    
297
    /**
298
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDefaultSymbol(ISymbol)
299
     */
300
    public void setDefaultSymbol(ISymbol s) {
301
        defaultSymbol = s;
302
    }
303

    
304
    /**
305
     * @see com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend#setFieldName(String)
306
     */
307
    public void setFieldName(String str) {
308
        fieldName = str;
309
    }
310

    
311
    /**
312
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#setLabelField(int)
313
     */
314
    public void setLabelField(String fieldName) {
315
        labelFieldName = fieldName;
316
    }
317

    
318
    /**
319
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#getLabelField()
320
     */
321
    public String getLabelField() {
322
        return labelFieldName;
323
    }
324

    
325
    /**
326
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#getDefaultSymbol()
327
     */
328
    public ISymbol getDefaultSymbol() {
329
            NullIntervalValue niv=new NullIntervalValue();
330
            if (symbols.containsKey(niv))
331
                    return (ISymbol)symbols.get(niv);
332
        return defaultSymbol;
333
    }
334

    
335
        /**
336
         * creates the SLD String that defines this legend type.
337
         */
338
    public String getSLDString(String layerName) {
339

    
340
            try{
341

    
342
                        XmlBuilder xmlBuilder = new XmlBuilder();
343
                        xmlBuilder.writeHeader();
344
                        xmlBuilder.openTag(SLDTags.SLD_ROOT, SLDTags.VERSION_ATTR, SLDTags.VERSION_1_0_0);
345
                        xmlBuilder.openTag(SLDTags.NAMEDLAYER);
346
                        xmlBuilder.writeTag(SLDTags.NAME,layerName);
347
                        xmlBuilder.openTag(SLDTags.USERSTYLE);
348
                        xmlBuilder.openTag(SLDTags.FEATURETYPESTYLE);
349
                        xmlBuilder.writeTag(SLDTags.FEATURETYPENAME,fieldName);
350

    
351
                        ISymbol[] symbols = this.getSymbols();
352
                        Object[] values = this.getValues();
353

    
354
                        FInterval interval;
355
                        for(int i = 0; i < symbols.length; i++ )
356
                        {
357
                                interval = (FInterval)values[i];
358
                                //interval = (FInterval)getInterval(ValueFactory.createValue(valueDbl.doubleValue()));
359
                                xmlBuilder.openTag(SLDTags.RULE);
360
                                xmlBuilder.writeTag(SLDTags.NAME, ""+interval.getMin() +" - " +interval.getMax());
361
                                xmlBuilder.openTag(SLDTags.FILTER);
362
                                xmlBuilder.openTag(SLDTags.AND);
363
                                xmlBuilder.openTag(SLDTags.PROPERTYISGREATEROREQUALTHAN);
364
                                xmlBuilder.writeTag(SLDTags.PROPERTYNAME,fieldName);
365
                                xmlBuilder.writeTag(SLDTags.LITERAL, ""+interval.getMin());
366
                                xmlBuilder.closeTag();
367
                                xmlBuilder.openTag(SLDTags.PROPERTYISLESSOREQUALTHAN);
368
                                xmlBuilder.writeTag(SLDTags.PROPERTYNAME,fieldName);
369
                                xmlBuilder.writeTag(SLDTags.LITERAL, ""+interval.getMax());
370
                                xmlBuilder.closeTag();
371
                                xmlBuilder.closeTag();
372
                                if (symbols[i] instanceof ISLDCompatible)
373
                                {
374
                                        ISLDCompatible symSLD = (ISLDCompatible) symbols[i];
375
                                        xmlBuilder.writeRaw(symSLD.toSLD());
376
                                }
377
                                else
378
                                        throw new RuntimeException("Cannot convert Symbol " + i + " " + symbols[i].getDescription() + " to SLD");
379
                                xmlBuilder.closeTag();
380
                                xmlBuilder.closeTag();
381
                        }
382

    
383
                        xmlBuilder.closeTag();
384
                        xmlBuilder.closeTag();
385
                        xmlBuilder.closeTag();
386
                        xmlBuilder.closeTag();
387
                        return xmlBuilder.getXML();
388

    
389
            }catch(Exception e)
390
            {
391
                    e.printStackTrace();
392
                    return null;
393
            }
394
    }
395

    
396
    /**
397
     * DOCUMENT ME!
398
     *
399
     * @return DOCUMENT ME!
400
     *
401
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#getXMLEntity()
402
     */
403
    public XMLEntity getXMLEntity() {
404
        XMLEntity xml = new XMLEntity();
405
        xml.putProperty("className", this.getClass().getName());
406
        xml.putProperty("useDefaultSymbolB", useDefaultSymbol);
407
        if (getDefaultSymbol() == null) {
408
            xml.putProperty("useDefaultSymbol", 0);
409
        } else {
410
            xml.putProperty("useDefaultSymbol", 1);
411
            xml.addChild(getDefaultSymbol().getXMLEntity());
412
        }
413

    
414
        xml.putProperty("fieldName", fieldName);
415
        xml.putProperty("index", index);
416
        xml.putProperty("labelfield", labelFieldName);
417
        xml.putProperty("labelfield", labelFieldName);
418
        xml.putProperty("labelFieldHeight", labelFieldHeight);
419
        xml.putProperty("labelFieldRotation", labelFieldRotation);
420

    
421
        xml.putProperty("intervalType", intervalType);
422
        xml.putProperty("numKeys", keys.size());
423

    
424
        if (keys.size() > 0) {
425
            xml.putProperty("tipoValueKeys", keys.get(0).getClass().getName());
426

    
427
            String[] sk = new String[keys.size()];
428

    
429
            for (int i = 0; i < keys.size(); i++) {
430
                sk[i] = ((IInterval) keys.get(i)).toString();
431
            }
432

    
433
            xml.putProperty("keys", getValues());
434

    
435
            for (int i = 0; i < keys.size(); i++) {
436
                xml.addChild(getSymbols()[i].getXMLEntity());
437
            }
438
        }
439

    
440
        xml.putProperty("startColor", StringUtilities.color2String(startColor));
441
        xml.putProperty("endColor", StringUtilities.color2String(endColor));
442

    
443
        ///xml.putProperty("numSymbols", symbols.size());
444
        ///xml.putProperty("indexs", getIndexs());
445
        ///xml.putProperty("values", getValues());
446
        return xml;
447
    }
448

    
449
    /**
450
     * Inserta los atributos del XMLEntity.
451
     *
452
     * @param xml XMLEntity.
453
     */
454
    public void setXMLEntity03(XMLEntity xml) {
455
        fieldName = xml.getStringProperty("fieldName");
456
        index = xml.getIntProperty("index");
457
        labelFieldName = xml.getStringProperty("labelfield");
458

    
459
        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.
460
            intervalType = xml.getIntProperty("intervalType");
461
        }
462

    
463
        int useDefaultSymbol = xml.getIntProperty("useDefaultSymbol");
464

    
465
        if (useDefaultSymbol == 1) {
466
            setDefaultSymbol(FSymbol.createFromXML03(xml.getChild(0)));
467
        } else {
468
            setDefaultSymbol(null);
469
        }
470

    
471
        int numKeys = xml.getIntProperty("numKeys");
472

    
473
        if (numKeys > 0) {
474
            String className = xml.getStringProperty("tipoValueKeys");
475
            String[] sk = xml.getStringArrayProperty("keys");
476
            IInterval auxInterval;
477

    
478
            for (int i = 0; i < numKeys; i++) {
479
                auxInterval = FInterval.create(sk[i]);
480
                symbols.put(auxInterval,
481
                    FSymbol.createFromXML03(xml.getChild(i + useDefaultSymbol)));
482
                keys.add(auxInterval);
483
                System.out.println("auxInterval =" + auxInterval + "Symbol =" +
484
                    FSymbol.createFromXML03(xml.getChild(i + useDefaultSymbol))
485
                           .getDescription());
486
            }
487
        }
488

    
489
        startColor = StringUtilities.string2Color(xml.getStringProperty(
490
                    "startColor"));
491
        endColor = StringUtilities.string2Color(xml.getStringProperty(
492
                    "endColor"));
493
    }
494

    
495
    /**
496
     * Inserta los atributos del XMLEntity.
497
     *
498
     * @param xml XMLEntity.
499
     */
500
    public void setXMLEntity(XMLEntity xml) {
501
        fieldName = xml.getStringProperty("fieldName");
502
        index = xml.getIntProperty("index");
503
        labelFieldName = xml.getStringProperty("labelfield");
504
        if (xml.contains("labelFieldHeight")) {
505
            setLabelHeightField(xml.getStringProperty("labelFieldHeight"));
506
        }
507

    
508
        if (xml.contains("labelFieldRotation")) {
509
            setLabelRotationField(xml.getStringProperty("labelFieldRotation"));
510
        }
511

    
512
        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.
513
            intervalType = xml.getIntProperty("intervalType");
514
        }
515
        useDefaultSymbol = xml.getBooleanProperty("useDefaultSymbolB");
516
        int hasDefaultSymbol = xml.getIntProperty("useDefaultSymbol");
517

    
518
        if (hasDefaultSymbol == 1) {
519
            setDefaultSymbol(FSymbol.createFromXML(xml.getChild(0)));
520
        } else {
521
            setDefaultSymbol(null);
522
        }
523

    
524
        int numKeys = xml.getIntProperty("numKeys");
525

    
526
        if (numKeys > 0) {
527
            String className = xml.getStringProperty("tipoValueKeys");
528
            String[] sk = xml.getStringArrayProperty("keys");
529
            IInterval auxInterval;
530

    
531
            for (int i = 0; i < numKeys; i++) {
532
                auxInterval = FInterval.create(sk[i]);
533
                symbols.put(auxInterval,
534
                    FSymbol.createFromXML(xml.getChild(i + hasDefaultSymbol)));
535
                keys.add(auxInterval);
536
                System.out.println("auxInterval =" + auxInterval + "Symbol =" +
537
                    FSymbol.createFromXML(xml.getChild(i + hasDefaultSymbol))
538
                           .getDescription());
539
            }
540
        }
541

    
542
        startColor = StringUtilities.string2Color(xml.getStringProperty(
543
                    "startColor"));
544
        endColor = StringUtilities.string2Color(xml.getStringProperty(
545
                    "endColor"));
546
    }
547

    
548
    /**
549
     * @see com.iver.cit.gvsig.fmap.rendering.Legend#cloneLegend()
550
     */
551
    public Legend cloneLegend() throws XMLException {
552
        return LegendFactory.createFromXML(getXMLEntity());
553
    }
554

    
555
    /* (non-Javadoc)
556
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDataSource(com.hardcode.gdbms.engine.data.DataSource)
557
     */
558
    public void setDataSource(DataSource ds)
559
        throws FieldNotFoundException, ReadDriverException {
560
        dataSource = ds;
561
        ds.start();
562
        fieldId = ds.getFieldIndexByName(fieldName);
563
        ds.stop();
564
    }
565

    
566
    /**
567
     * Devuelve el intervalo a partir del valor.
568
     *
569
     * @param v valor.
570
     *
571
     * @return intervalo.
572
     */
573
    public IInterval getInterval(Value v) {
574
        /*if (v instanceof NullValue){
575
           System.out.println("Si");
576
           }*/
577
        for (int i = 0; i < keys.size(); i++) {
578
            if (((IInterval) keys.get(i)).isInInterval(v)) {
579
                return (IInterval) keys.get(i);
580
            }
581
        }
582

    
583
        return null;
584
    }
585

    
586
    /**
587
     * Devuelve el color final.
588
     *
589
     * @return color final.
590
     */
591
    public Color getEndColor() {
592
        return endColor;
593
    }
594

    
595
    /**
596
     * Inserta el color final.
597
     *
598
     * @param endColor Color final.
599
     */
600
    public void setEndColor(Color endColor) {
601
        this.endColor = endColor;
602
    }
603

    
604
    /**
605
     * Devuelve el color inicial.
606
     *
607
     * @return Color inicial.
608
     */
609
    public Color getStartColor() {
610
        return startColor;
611
    }
612

    
613
    /**
614
     * Inserta el color inicial.
615
     *
616
     * @param startColor Color inicial.
617
     */
618
    public void setStartColor(Color startColor) {
619
        this.startColor = startColor;
620
    }
621

    
622
    /* (non-Javadoc)
623
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getShapeType()
624
     */
625
    public int getShapeType() {
626
        return shapeType;
627
    }
628

    
629
    /* (non-Javadoc)
630
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setShapeType(int)
631
     */
632
    public void setShapeType(int shapeType) {
633
        if (this.shapeType != shapeType) {
634
            switch (shapeType) {
635
                case FShape.POINT:
636
                    defaultSymbol = new FSymbol(FConstant.SYMBOL_TYPE_POINT);
637

    
638
                    break;
639

    
640
                case FShape.LINE:
641
                    defaultSymbol = new FSymbol(FConstant.SYMBOL_TYPE_LINE);
642

    
643
                    break;
644

    
645
                case FShape.POLYGON:
646
                    defaultSymbol = new FSymbol(FConstant.SYMBOL_TYPE_FILL);
647

    
648
                    break;
649

    
650
                default:
651
                    defaultSymbol = new FSymbol(shapeType);
652
            }
653

    
654
            this.shapeType = shapeType;
655
        }
656
    }
657

    
658
    /* (non-Javadoc)
659
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelHeightField()
660
     */
661
    public String getLabelHeightField() {
662
        return labelFieldHeight;
663
    }
664

    
665
    /**
666
     * Inserta el alto del campo.
667
     *
668
     * @param str alto.
669
     */
670
    public void setLabelHeightField(String str) {
671
        labelFieldHeight = str;
672
    }
673

    
674
    /* (non-Javadoc)
675
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getLabelRotationField()
676
     */
677
    public String getLabelRotationField() {
678
        return labelFieldRotation;
679
    }
680

    
681
    /**
682
     * Inserta la rotaci?n del campo.
683
     *
684
     * @param str Rotaci?n.
685
     */
686
    public void setLabelRotationField(String str) {
687
        labelFieldRotation = str;
688
    }
689

    
690
    /**
691
     * Inserta el tipo de clasificaci?n de los intervalos.
692
     *
693
     * @param tipoClasificacion Tipo de clasificaci?n.
694
     */
695
    public void setIntervalType(int tipoClasificacion) {
696
        intervalType = tipoClasificacion;
697
    }
698

    
699
    /**
700
     * Devuelve el tipo de clasificaci?n de los intervalos.
701
     *
702
     * @return Tipo de clasificaci?n.
703
     */
704
    public int getIntervalType() {
705
        return intervalType;
706
    }
707

    
708
    /**
709
     * Inserta si se representan el resto de valores o no.
710
     *
711
     * @param b True si se tienen que representar el resto de valores.
712
     */
713
    public void useDefaultSymbol(boolean b) {
714
        useDefaultSymbol = b;
715
    }
716

    
717
    /**
718
     * Devuelve si se utiliza o no el resto de valores para representarse.
719
     *
720
     * @return True si se utiliza el resto de valores.
721
     */
722
    public boolean isUseDefaultSymbol() {
723
        return useDefaultSymbol;
724
    }
725

    
726
    /**
727
     * Devuelve si ha sido modificado el etiquetado de la capa.
728
     *
729
     * @return True si el etiquetado de la capa ha sido modificado.
730
     */
731
    /* public boolean isBWithHeightText() {
732
        return bWithHeightText;
733
    } */
734

    
735
    /**
736
     * Introduce si el etiquetado de la capa ha sido modificado.
737
     *
738
     * @param withHeightText Boolean que indica si el etiquetado de la capa ha
739
     *        sido modificado.
740
     */
741
    /* public void setBWithHeightText(boolean withHeightText) {
742
        bWithHeightText = withHeightText;
743
    } */
744

    
745
    /**
746
     * Elimina un s?mbolo a partir de su clave.
747
     *
748
     * @param obj clave.
749
     */
750
    public void delSymbol(Object obj) {
751
        keys.remove(obj);
752
        symbols.remove(obj);
753
    }
754

    
755
    /* (non-Javadoc)
756
     * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#getUsedFields()
757
     */
758
    public String[] getUsedFields() {
759
        ArrayList usedFields = new ArrayList();
760
        if (getFieldName() != null)
761
            usedFields.add(getFieldName());
762
        if (getLabelField() != null)
763
            usedFields.add(getLabelField());
764
        if (getLabelHeightField() != null)
765
            usedFields.add(getLabelHeightField());
766
        if (getLabelRotationField() != null)
767
            usedFields.add(getLabelRotationField());
768

    
769
        return (String[]) usedFields.toArray(new String[0]);
770

    
771
    }
772
}