Statistics
| Revision:

root / trunk / extensions / extSymbology / src / org / gvsig / remoteClient / sld / sld1_0_0 / symbolizers / SLDPointSymbolizer1_0_0.java @ 20768

History | View | Annotate | Download (5.23 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 org.gvsig.remoteClient.sld.sld1_0_0.symbolizers;
42

    
43
import java.io.IOException;
44

    
45
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser;
46
import org.gvsig.remoteClient.sld.SLDTags;
47
import org.gvsig.remoteClient.sld.sld1_0_0.SLDGraphic1_0_0;
48
import org.gvsig.remoteClient.sld.symbolizers.SLDPointSymbolizer;
49
import org.xmlpull.v1.XmlPullParserException;
50

    
51
import com.iver.cit.gvsig.fmap.drivers.legend.LegendDriverException;
52
import com.iver.cit.gvsig.fmap.rendering.XmlBuilder;
53

    
54
/**
55
 *  * Implements the Point Symbolizer element of an SLD implementation specification (version 
56
 * 1.0.0).<p>
57
 * 
58
 * A point symbolizer is used to draw "graphic" at a point.
59
 * 
60
 * @see SLDGraphic1_0_0
61
 * @see http://portal.opengeospatial.org/files/?artifact_id=1188
62
 * 
63
 * @author pepe vidal salvador - jose.vidal.salvador@iver.es
64
 */
65
public class SLDPointSymbolizer1_0_0 extends SLDPointSymbolizer {
66

    
67

    
68
        /**
69
         * Parses the xml data retrieved from the SLD, it will parse the Point Symbolizer
70
         *  element</p>
71
         * @throws LegendDriverException 
72
         */
73
        public void parse(XMLSchemaParser parser)throws IOException, XmlPullParserException, LegendDriverException  {
74
                int currentTag;
75
                boolean end = false;
76

    
77
                parser.require(XMLSchemaParser.START_TAG, null, SLDTags.POINTSYMBOLIZER);
78
                currentTag = parser.next();
79

    
80
                while (!end)
81
                {
82
                        switch(currentTag)
83
                        {
84
                        case XMLSchemaParser.START_TAG:
85
                                if (parser.getName().compareTo(SLDTags.GEOMETRY)==0) {
86
                                        parseGeometry(parser);
87
                                }
88
                                else if (parser.getName().compareTo(SLDTags.GRAPHIC)==0) {
89
                                        SLDGraphic1_0_0 graphic = new SLDGraphic1_0_0();
90
                                        graphic.parseGraphic(parser,parser.getName());
91
                                        setGraphic(graphic);
92
                                }
93
                                break;
94
                        case XMLSchemaParser.END_TAG:
95
                                if (parser.getName().compareTo(SLDTags.POINTSYMBOLIZER) == 0)
96
                                        end = true;
97
                                break;
98
                        case XMLSchemaParser.TEXT:
99
                                break;
100
                        }
101
                        if (!end)
102
                                currentTag = parser.next();
103
                }
104

    
105
                parser.require(XMLSchemaParser.END_TAG, null, SLDTags.POINTSYMBOLIZER);
106

    
107
        }
108

    
109

    
110
        /**
111
         * Parse the xml data retrieved from the SLD, it will parse the Geometry element</p>
112
         * The Geometry element of a Symbolizer defines the geometry to be used
113
         * for styling. The Geometry element is optional and if it is absent then the
114
         * �default� geometry property of the feature type that is used in the containing 
115
         * FeatureStyleType is used. The precise meaning of �default� geometry property is
116
         * system-dependent. Most frequently, feature types will have only a single geometry
117
         * property.<p>
118
         * The only method available for defining a geometry is to reference a geometry 
119
         * property using the ogc:PropertyName element (defined in the WFS Specification). 
120
         * The content of the element gives the property name in XPath syntax. In principle, 
121
         * a fixed geometry could be defined using GML or operators could be defined for 
122
         * computing the geometry from references or literals. However, using a feature 
123
         * property directly is by far the most commonly useful method.
124
         *
125
         */
126
        private void parseGeometry(XMLSchemaParser parser) throws IOException, XmlPullParserException{
127
                int currentTag;
128
                boolean end = false;
129

    
130
                parser.require(XMLSchemaParser.START_TAG, null, SLDTags.GEOMETRY);
131
                currentTag = parser.next();
132

    
133
                while (!end)
134
                {
135
                        switch(currentTag)
136
                        {
137
                        case XMLSchemaParser.START_TAG:
138
                                if (parser.getName().compareTo(SLDTags.PROPERTY_NAME)==0) {
139
                                        setGeometry(parser.nextText());
140
                                }
141

    
142
                                break;
143
                        case XMLSchemaParser.END_TAG:
144
                                if (parser.getName().compareTo(SLDTags.GEOMETRY) == 0)
145
                                        end = true;
146
                                break;
147
                        case XMLSchemaParser.TEXT:
148
                                break;
149
                        }
150
                        if (!end)
151
                                currentTag = parser.next();
152
                }
153

    
154
                parser.require(XMLSchemaParser.END_TAG, null, SLDTags.GEOMETRY);
155

    
156
        }
157

    
158

    
159
        public String toXML() {
160
                XmlBuilder xmlBuilder = new XmlBuilder();
161
                xmlBuilder.openTag(SLDTags.POINTSYMBOLIZER);
162
                xmlBuilder.writeRaw(getGraphic().toXML());
163
                xmlBuilder.closeTag();
164
                return xmlBuilder.getXML();
165

    
166
        }
167

    
168
        
169
        
170

    
171
}