svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wms / WMSStyle.java @ 40559
History | View | Annotate | Download (6.08 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
|
25 |
package org.gvsig.remoteclient.wms; |
26 |
|
27 |
import java.io.IOException; |
28 |
|
29 |
import org.kxml2.io.KXmlParser; |
30 |
import org.xmlpull.v1.XmlPullParserException; |
31 |
|
32 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
33 |
|
34 |
/**
|
35 |
* <p>Defines a OGC style. Theme that describes the appeareance of certain layer.</p>
|
36 |
*
|
37 |
*/
|
38 |
public abstract class WMSStyle { |
39 |
|
40 |
//style name, defined in the WMS capabilities
|
41 |
private String name; |
42 |
//style title, defined in the WMS capabilities
|
43 |
private String title; |
44 |
// style abstract, defined in the WMS capabilities
|
45 |
private String styleAbstract; |
46 |
|
47 |
private org.gvsig.remoteclient.wms.WMSStyle.LegendURL legendURL;
|
48 |
|
49 |
/**
|
50 |
* <p>Parses the STYLE tag in the WMS capabilities, filling the WMSStyle object
|
51 |
* loading the data in memory to be easily accesed</p>
|
52 |
*
|
53 |
*/
|
54 |
public abstract void parse(KXmlParser parser) throws IOException, XmlPullParserException; |
55 |
|
56 |
/**
|
57 |
* Parses the legendURL tag.
|
58 |
* @param parser
|
59 |
* @throws IOException
|
60 |
* @throws XmlPullParserException
|
61 |
*/
|
62 |
protected void parseLegendURL(KXmlParser parser) throws IOException, XmlPullParserException |
63 |
{ |
64 |
int currentTag;
|
65 |
boolean end = false; |
66 |
|
67 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.LEGENDURL);
|
68 |
|
69 |
String value = new String(); |
70 |
legendURL = new LegendURL();
|
71 |
|
72 |
//First of all set whether the layer is Queryable reading the attribute.
|
73 |
value = parser.getAttributeValue("", CapabilitiesTags.WIDTH);
|
74 |
if (value != null) |
75 |
{ |
76 |
legendURL.width = Integer.parseInt( value );
|
77 |
} |
78 |
value = parser.getAttributeValue("", CapabilitiesTags.HEIGHT);
|
79 |
if (value != null) |
80 |
{ |
81 |
legendURL.height = Integer.parseInt( value );
|
82 |
} |
83 |
currentTag = parser.nextTag(); |
84 |
|
85 |
while (!end)
|
86 |
{ |
87 |
switch(currentTag)
|
88 |
{ |
89 |
case KXmlParser.START_TAG:
|
90 |
if (parser.getName().compareTo(CapabilitiesTags.FORMAT)==0) |
91 |
{ |
92 |
legendURL.format = parser.nextText(); |
93 |
} |
94 |
else if (parser.getName().compareTo(CapabilitiesTags.ONLINERESOURCE)==0) |
95 |
{ |
96 |
value = parser.getAttributeValue("", CapabilitiesTags.XLINK_TYPE);
|
97 |
if (value != null) |
98 |
legendURL.onlineResource_type = value; |
99 |
value = parser.getAttributeValue("", CapabilitiesTags.XLINK_HREF);
|
100 |
if (value != null) |
101 |
legendURL.onlineResource_href = value; |
102 |
} |
103 |
break;
|
104 |
case KXmlParser.END_TAG:
|
105 |
if (parser.getName().compareTo(CapabilitiesTags.LEGENDURL) == 0) |
106 |
end = true;
|
107 |
break;
|
108 |
case KXmlParser.TEXT:
|
109 |
break;
|
110 |
} |
111 |
if (!end)
|
112 |
{ |
113 |
currentTag = parser.next(); |
114 |
} |
115 |
} |
116 |
parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.LEGENDURL);
|
117 |
} |
118 |
|
119 |
/**
|
120 |
* gets the LegendURL OnlineResource type
|
121 |
*/
|
122 |
public String getLegendURLOnlineResourceType() |
123 |
{ |
124 |
if (legendURL != null) |
125 |
{ |
126 |
return legendURL.onlineResource_type;
|
127 |
} |
128 |
else
|
129 |
{ |
130 |
return null; |
131 |
} |
132 |
} |
133 |
|
134 |
/**
|
135 |
* gets the LegendURL OnlineResource href
|
136 |
*/
|
137 |
public String getLegendURLOnlineResourceHRef() |
138 |
{ |
139 |
if (legendURL != null) |
140 |
{ |
141 |
return legendURL.onlineResource_href;
|
142 |
} |
143 |
else
|
144 |
{ |
145 |
return null; |
146 |
} |
147 |
} |
148 |
public String getLegendURLFormat() |
149 |
{ |
150 |
if (legendURL != null) |
151 |
{ |
152 |
return legendURL.format;
|
153 |
} |
154 |
else
|
155 |
{ |
156 |
return null; |
157 |
} |
158 |
} |
159 |
public int getLegendURLWidth() |
160 |
{ |
161 |
if (legendURL != null) |
162 |
{ |
163 |
return legendURL.width;
|
164 |
} |
165 |
return 0; |
166 |
} |
167 |
public int getLegendURLHeight() |
168 |
{ |
169 |
if (legendURL != null) |
170 |
{ |
171 |
return legendURL.height;
|
172 |
} |
173 |
return 0; |
174 |
} |
175 |
|
176 |
/**
|
177 |
* sets LegendURL
|
178 |
*/
|
179 |
protected void setLegendURL(LegendURL legendURL) |
180 |
{ |
181 |
this.legendURL = legendURL;
|
182 |
} |
183 |
|
184 |
/**
|
185 |
* <p>gets the style name</p>
|
186 |
*
|
187 |
* @return style name
|
188 |
*/
|
189 |
public String getName() { |
190 |
return name;
|
191 |
} |
192 |
|
193 |
/**
|
194 |
* <p>sets the style name.</p>
|
195 |
*
|
196 |
* @param _name
|
197 |
*/
|
198 |
public void setName(String _name) { |
199 |
name = _name; |
200 |
} |
201 |
|
202 |
/**
|
203 |
* <p>gets the style title</p>
|
204 |
*
|
205 |
*
|
206 |
* @return style title
|
207 |
*/
|
208 |
public String getTitle() { |
209 |
return title;
|
210 |
} |
211 |
|
212 |
/**
|
213 |
* <p>Sets style title</p>
|
214 |
*
|
215 |
*
|
216 |
* @param _title
|
217 |
*/
|
218 |
public void setTitle(String _title) { |
219 |
title = _title.trim(); |
220 |
} |
221 |
|
222 |
/**
|
223 |
* <p>gets style abstract</p>
|
224 |
*
|
225 |
*
|
226 |
* @return style abstract
|
227 |
*/
|
228 |
public String getAbstract() { |
229 |
return styleAbstract;
|
230 |
} |
231 |
|
232 |
/**
|
233 |
* <p>sets style abstract</p>
|
234 |
*
|
235 |
*
|
236 |
* @param _abstract, style abstract
|
237 |
*/
|
238 |
public void setAbstract(String _abstract) { |
239 |
styleAbstract = _abstract; |
240 |
} |
241 |
|
242 |
/**
|
243 |
* <p>Inner class describing the Legend URL defined for styles in the OGC specifications in WMS</p>
|
244 |
*
|
245 |
*/
|
246 |
protected class LegendURL |
247 |
{ |
248 |
public LegendURL()
|
249 |
{ |
250 |
width = 0;
|
251 |
height= 0;
|
252 |
format = new String(); |
253 |
onlineResource_type = new String(); |
254 |
onlineResource_href = new String(); |
255 |
} |
256 |
|
257 |
public int width; |
258 |
public int height; |
259 |
public String format; |
260 |
public String onlineResource_type; |
261 |
public String onlineResource_href; |
262 |
} |
263 |
} |