Statistics
| Revision:

svn-gvsig-desktop / branches / v02_desarrollo / libraries / org.gvsig.sldsupport / org.gvsig.sldsupport.lib / org.gvsig.sldsupport.lib.api / src / main / java / org / gvsig / sldsupport / version / sld1_0_0 / symbolizers / SLDPointSymbolizer1_0_0.java @ 40749

History | View | Annotate | Download (5.15 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.sldsupport.version.sld1_0_0.symbolizers;
42

    
43
import java.io.IOException;
44

    
45
import org.gvsig.sldsupport.exception.SLDReadException;
46
import org.gvsig.sldsupport.symbolizer.SLDPointSymbolizer;
47
import org.gvsig.sldsupport.util.SLDTags;
48
import org.gvsig.sldsupport.util.XmlBuilder;
49
import org.gvsig.sldsupport.version.sld1_0_0.SLDGraphic1_0_0;
50
import org.xmlpull.v1.XmlPullParser;
51
import org.xmlpull.v1.XmlPullParserException;
52

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

    
66

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

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

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

    
104
                parser.require(XmlPullParser.END_TAG, null, SLDTags.POINTSYMBOLIZER);
105

    
106
        }
107

    
108

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

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

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

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

    
153
                parser.require(XmlPullParser.END_TAG, null, SLDTags.GEOMETRY);
154

    
155
        }
156

    
157

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

    
165
        }
166

    
167
        
168
        
169

    
170
}