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 / SLDLineSymbolizer1_0_0.java @ 40749
History | View | Annotate | Download (5.18 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.sldsupport.version.sld1_0_0.symbolizers; |
43 |
|
44 |
import java.io.IOException; |
45 |
|
46 |
import org.gvsig.sldsupport.exception.SLDReadException; |
47 |
import org.gvsig.sldsupport.symbolizer.SLDLineSymbolizer; |
48 |
import org.gvsig.sldsupport.util.SLDTags; |
49 |
import org.gvsig.sldsupport.util.XmlBuilder; |
50 |
import org.gvsig.sldsupport.version.sld1_0_0.SLDStroke1_0_0; |
51 |
import org.xmlpull.v1.XmlPullParser; |
52 |
import org.xmlpull.v1.XmlPullParserException; |
53 |
/**
|
54 |
* Implements the LineSymbolizer element of an SLD implementation specification
|
55 |
* (version 1.0.0).<p>
|
56 |
* A LineSymbolizer is used to style a �stroke� along a linear geometry type, such as
|
57 |
* string of line segments.<p>
|
58 |
*
|
59 |
* @see SLDStroke1_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 SLDLineSymbolizer1_0_0 extends SLDLineSymbolizer { |
65 |
|
66 |
|
67 |
|
68 |
/**
|
69 |
* Parses the xml data retrieved from the SLD, it will parse the LineSymbolizer
|
70 |
* element</p>
|
71 |
* @throws SLDReadException
|
72 |
*/
|
73 |
public void parse(XmlPullParser parser)throws IOException, XmlPullParserException, SLDReadException { |
74 |
int currentTag;
|
75 |
boolean end = false; |
76 |
|
77 |
parser.require(XmlPullParser.START_TAG, null, SLDTags.LINESYMBOLIZER);
|
78 |
currentTag = parser.next(); |
79 |
|
80 |
while (!end)
|
81 |
{ |
82 |
switch(currentTag)
|
83 |
{ |
84 |
case XmlPullParser.START_TAG:
|
85 |
if (parser.getName().compareTo(SLDTags.GEOMETRY)==0) { |
86 |
parseGeometry(parser); |
87 |
} |
88 |
else if (parser.getName().compareTo(SLDTags.STROKE)==0) { |
89 |
SLDStroke1_0_0 stroke = new SLDStroke1_0_0();
|
90 |
stroke.parse(parser, currentTag, null);
|
91 |
setStroke(stroke); |
92 |
} |
93 |
|
94 |
break;
|
95 |
case XmlPullParser.END_TAG:
|
96 |
if (parser.getName().compareTo(SLDTags.LINESYMBOLIZER) == 0) |
97 |
end = true;
|
98 |
break;
|
99 |
case XmlPullParser.TEXT:
|
100 |
break;
|
101 |
} |
102 |
if (!end)
|
103 |
currentTag = parser.next(); |
104 |
} |
105 |
|
106 |
parser.require(XmlPullParser.END_TAG, null, SLDTags.LINESYMBOLIZER);
|
107 |
|
108 |
} |
109 |
|
110 |
/**
|
111 |
* Parses 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(XmlPullParser parser) throws IOException, XmlPullParserException{ |
127 |
int currentTag;
|
128 |
boolean end = false; |
129 |
|
130 |
parser.require(XmlPullParser.START_TAG, null, SLDTags.GEOMETRY);
|
131 |
currentTag = parser.next(); |
132 |
|
133 |
while (!end)
|
134 |
{ |
135 |
switch(currentTag)
|
136 |
{ |
137 |
case XmlPullParser.START_TAG:
|
138 |
if (parser.getName().compareTo(SLDTags.PROPERTY_NAME)==0) { |
139 |
setGeometry(parser.nextText()); |
140 |
} |
141 |
|
142 |
break;
|
143 |
case XmlPullParser.END_TAG:
|
144 |
if (parser.getName().compareTo(SLDTags.GEOMETRY) == 0) |
145 |
end = true;
|
146 |
break;
|
147 |
case XmlPullParser.TEXT:
|
148 |
break;
|
149 |
} |
150 |
if (!end)
|
151 |
currentTag = parser.next(); |
152 |
} |
153 |
|
154 |
parser.require(XmlPullParser.END_TAG, null, SLDTags.GEOMETRY);
|
155 |
|
156 |
} |
157 |
|
158 |
|
159 |
|
160 |
|
161 |
public String toXML() { |
162 |
XmlBuilder xmlBuilder = new XmlBuilder();
|
163 |
xmlBuilder.openTag(SLDTags.LINESYMBOLIZER); |
164 |
xmlBuilder.writeRaw(getStroke().toXML()); |
165 |
xmlBuilder.closeTag(); |
166 |
return xmlBuilder.getXML();
|
167 |
} |
168 |
|
169 |
|
170 |
|
171 |
|
172 |
} |