Statistics
| Revision:

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

History | View | Annotate | Download (5.26 KB)

1

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

    
44
import java.io.IOException;
45

    
46
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser;
47
import org.gvsig.remoteClient.sld.SLDTags;
48
import org.gvsig.remoteClient.sld.sld1_0_0.SLDStroke1_0_0;
49
import org.gvsig.remoteClient.sld.symbolizers.SLDLineSymbolizer;
50
import org.xmlpull.v1.XmlPullParserException;
51

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

    
55
/**
56
 * Implements the LineSymbolizer element of an SLD implementation specification 
57
 * (version 1.0.0).<p>
58
 * A LineSymbolizer is used to style a �stroke� along a linear geometry type, such as
59
 * string of line segments.<p>
60
 * 
61
 * @see SLDStroke1_0_0
62
 * @see http://portal.opengeospatial.org/files/?artifact_id=1188
63
 * 
64
 * @author pepe vidal salvador - jose.vidal.salvador@iver.es
65
 */
66
public class SLDLineSymbolizer1_0_0  extends SLDLineSymbolizer{
67

    
68
        
69

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

    
79
                parser.require(XMLSchemaParser.START_TAG, null, SLDTags.LINESYMBOLIZER);
80
                currentTag = parser.next();
81

    
82
                while (!end)
83
                {
84
                        switch(currentTag)
85
                        {
86
                        case XMLSchemaParser.START_TAG:
87
                                if (parser.getName().compareTo(SLDTags.GEOMETRY)==0) {
88
                                        parseGeometry(parser);        
89
                                }
90
                                else if (parser.getName().compareTo(SLDTags.STROKE)==0) {
91
                                        SLDStroke1_0_0 stroke = new SLDStroke1_0_0();
92
                                        stroke.parse(parser, currentTag, null);
93
                                        setStroke(stroke);
94
                                }
95

    
96
                                break;
97
                        case XMLSchemaParser.END_TAG:
98
                                if (parser.getName().compareTo(SLDTags.LINESYMBOLIZER) == 0)
99
                                        end = true;
100
                                break;
101
                        case XMLSchemaParser.TEXT:
102
                                break;
103
                        }
104
                        if (!end)
105
                                currentTag = parser.next();
106
                }
107

    
108
                parser.require(XMLSchemaParser.END_TAG, null, SLDTags.LINESYMBOLIZER);
109

    
110
        }
111

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

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

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

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

    
156
                parser.require(XMLSchemaParser.END_TAG, null, SLDTags.GEOMETRY);
157

    
158
        }
159

    
160
        
161
        
162

    
163
        public String toXML() {
164
                XmlBuilder xmlBuilder = new XmlBuilder();
165
                xmlBuilder.openTag(SLDTags.LINESYMBOLIZER);
166
                xmlBuilder.writeRaw(getStroke().toXML());
167
                xmlBuilder.closeTag();
168
                return xmlBuilder.getXML();
169
        }
170

    
171

    
172

    
173

    
174
}