Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / SingleSymbolLegend.java @ 490

History | View | Annotate | Download (2.24 KB)

1
package com.iver.cit.gvsig.fmap.rendering;
2

    
3

    
4
import com.hardcode.gdbms.engine.data.DataSource;
5
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
6
import com.iver.cit.gvsig.fmap.layers.XMLException;
7
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D;
8
import com.iver.utiles.XMLEntity;
9

    
10

    
11

    
12
public class SingleSymbolLegend implements VectorialLegend, Legend {
13

    
14
        private FSymbol symbol;
15
        private String labelFieldName;
16
        
17
        public SingleSymbolLegend(FSymbol style){
18
                symbol = style;
19
        }
20
        public SingleSymbolLegend(){
21
                symbol = LegendFactory.DEFAULT_POLYGON_SYMBOL;
22
        }
23
        /**
24
         * @see com.iver.cit.gvsig.fmap.rendering.Legend#setDefaultSymbol(FStyle2D)
25
         */
26
        public void setDefaultSymbol(FSymbol s) {
27
                symbol = s;
28
        }
29

    
30
        /**
31
         * @see com.iver.cit.gvsig.fmap.rendering.Legend#getLabelField()
32
         */
33
        public String getLabelField() {
34
                return labelFieldName;
35
        }
36

    
37
        /**
38
         * @see com.iver.cit.gvsig.fmap.rendering.Legend#setLabelField(int)
39
         */
40
        public void setLabelField(String fieldName) {
41
                labelFieldName = fieldName;
42
        }
43

    
44
        /**
45
         * @see com.iver.cit.gvsig.fmap.rendering.Legend#getSymbol(int)
46
         */
47
        public FSymbol getSymbol(int recordIndex) {
48
                return symbol;
49
        }
50

    
51
        /**
52
         * @see com.iver.cit.gvsig.fmap.rendering.Legend#getDefaultSymbol()
53
         */
54
        public FSymbol getDefaultSymbol() {
55
                return symbol;
56
        }
57
        /**
58
         * @see com.iver.cit.gvsig.fmap.rendering.Legend#getXMLEntity()
59
         */
60
        public XMLEntity getXMLEntity() {
61
                XMLEntity xml=new XMLEntity();
62
                xml.putProperty("nameClass",this.getClass().getName());
63
                // xml.putProperty("labelField",labelFieldName);
64
                // xml.putProperty("defaultSymbol","defaultSymbol");
65
                xml.addChild(symbol.getXMLEntity());
66
                return xml;
67
        }
68
        
69
public void setXMLEntity(XMLEntity xml){
70
        
71
        // setLabelField(xml.getStringProperty("labelField"));
72
        // xml.getStringProperty("defaultSymbol");
73
        FSymbol auxSym = FSymbol.createFromXML(xml.getChild(0));
74
        setDefaultSymbol(auxSym);
75
        
76
}
77

    
78
/**
79
 * @see com.iver.cit.gvsig.fmap.rendering.Legend#cloneLegend()
80
 */
81
public Legend cloneLegend() throws XMLException {
82
        return (Legend)LegendFactory.createFromXML(getXMLEntity());
83
}
84
/* (non-Javadoc)
85
 * @see com.iver.cit.gvsig.fmap.rendering.VectorialLegend#setDataSource(com.hardcode.gdbms.engine.data.DataSource)
86
 */
87
public void setDataSource(DataSource ds) {
88
        // No hacemos nada, no lo vamos a usar
89
}
90

    
91
}