root / branches / v10 / libraries / libArcIMS / src / org / gvsig / remoteClient / arcims / styling / symbols / ArcImsSymbolFactory.java @ 20977
History | View | Annotate | Download (12.8 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 Prodevelop 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 |
* Prodevelop Integraci?n de Tecnolog?as SL
|
34 |
* Conde Salvatierra de ?lava , 34-10
|
35 |
* 46004 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963 510 612
|
39 |
* +34 963 510 968
|
40 |
* gis@prodevelop.es
|
41 |
* http://www.prodevelop.es
|
42 |
*/
|
43 |
|
44 |
package org.gvsig.remoteClient.arcims.styling.symbols; |
45 |
|
46 |
import org.apache.log4j.Logger; |
47 |
|
48 |
import org.gvsig.remoteClient.arcims.utils.ServiceInfoTags; |
49 |
|
50 |
import org.kxml2.io.KXmlParser; |
51 |
|
52 |
|
53 |
public class ArcImsSymbolFactory { |
54 |
private static Logger logger = Logger.getLogger(ArcImsSymbolFactory.class.getName()); |
55 |
|
56 |
/**
|
57 |
* Tests if a TAG is one of the ArcIMS symbols
|
58 |
* @param name
|
59 |
* @return
|
60 |
*/
|
61 |
public static boolean isSymbol(String name) { |
62 |
for (int i = 0; i < ServiceInfoTags.SYMBOLS.length; i++) { |
63 |
if (name.equals(ServiceInfoTags.SYMBOLS[i])) {
|
64 |
return true; |
65 |
} |
66 |
} |
67 |
|
68 |
return false; |
69 |
} |
70 |
|
71 |
/**
|
72 |
* Tests if a TAG is one of the ArcIMS symbols
|
73 |
* @param name
|
74 |
* @return
|
75 |
*/
|
76 |
public static boolean isSupported(String name) { |
77 |
for (int i = 0; i < ServiceInfoTags.NOT_SUPP_SYMBOLS.length; i++) { |
78 |
if (name.equals(ServiceInfoTags.NOT_SUPP_SYMBOLS[i])) {
|
79 |
return true; |
80 |
} |
81 |
} |
82 |
|
83 |
return false; |
84 |
} |
85 |
|
86 |
/**
|
87 |
* This method will return valid IArcIMSSymbol from a ArcXML symbol definition
|
88 |
* @see com.iver.cit.gvsig.fmap.core.v02.FConstant
|
89 |
* @see org.gvsig.remoteClient.arcims.styling.symbols.IArcIMSSymbol
|
90 |
* @param parser
|
91 |
* @param featType Type of feature to get the symbol, useful when a default symbol has to be created
|
92 |
* @return
|
93 |
*/
|
94 |
public static IArcIMSSymbol parseSymbol(KXmlParser parser, int featType) { |
95 |
//TODO Parse symbols
|
96 |
// logger.debug("Start parsing Symbol with " + parser.getName());
|
97 |
|
98 |
IArcIMSSymbol symb = null;
|
99 |
|
100 |
// int depth = parser.getDepth();
|
101 |
// logger.debug("XML depth = "+depth);
|
102 |
|
103 |
// logger.debug("START =" + parser.getName());
|
104 |
|
105 |
//SIMPLELINESYMBOL;
|
106 |
if (parser.getName().equals(ServiceInfoTags.tSIMPLELINESYMBOL)) {
|
107 |
symb = new SimpleLineSymbol();
|
108 |
|
109 |
SimpleLineSymbol esymb = (SimpleLineSymbol) symb; |
110 |
|
111 |
String color = parser.getAttributeValue("", ServiceInfoTags.aCOLOR); |
112 |
|
113 |
if (color != null) { |
114 |
esymb.setColor(color); |
115 |
} |
116 |
|
117 |
String width = parser.getAttributeValue("", ServiceInfoTags.aWIDTH); |
118 |
|
119 |
if (width != null) { |
120 |
esymb.setWidth(width); |
121 |
} |
122 |
|
123 |
String type = parser.getAttributeValue("", ServiceInfoTags.aTYPE); |
124 |
|
125 |
if (type != null) { |
126 |
esymb.setType(type); |
127 |
} |
128 |
|
129 |
String captype = parser.getAttributeValue("", |
130 |
ServiceInfoTags.aCAPTYPE); |
131 |
|
132 |
if (captype != null) { |
133 |
esymb.setCaptype(captype); |
134 |
} |
135 |
|
136 |
String jointype = parser.getAttributeValue("", |
137 |
ServiceInfoTags.aJOINTYPE); |
138 |
|
139 |
if (jointype != null) { |
140 |
esymb.setJointype(jointype); |
141 |
} |
142 |
|
143 |
String transparency = parser.getAttributeValue("", |
144 |
ServiceInfoTags.aTRANSPARENCY); |
145 |
|
146 |
if (transparency != null) { |
147 |
esymb.setTransparency(transparency); |
148 |
} |
149 |
} |
150 |
//SIMPLEMARKERSYMBOL;
|
151 |
else if (parser.getName().equals(ServiceInfoTags.tSIMPLEMARKERSYMBOL)) { |
152 |
symb = new SimpleMarkerSymbol();
|
153 |
|
154 |
SimpleMarkerSymbol esymb = (SimpleMarkerSymbol) symb; |
155 |
|
156 |
String color = parser.getAttributeValue("", ServiceInfoTags.aCOLOR); |
157 |
|
158 |
if (color != null) { |
159 |
esymb.setColor(color); |
160 |
} |
161 |
|
162 |
String width = parser.getAttributeValue("", ServiceInfoTags.aWIDTH); |
163 |
|
164 |
if (width != null) { |
165 |
esymb.setWidth(width); |
166 |
} |
167 |
|
168 |
String type = parser.getAttributeValue("", ServiceInfoTags.aTYPE); |
169 |
|
170 |
if (type != null) { |
171 |
esymb.setType(type); |
172 |
} |
173 |
} |
174 |
//SIMPLEPOLYGONSYMBOL;
|
175 |
else if (parser.getName().equals(ServiceInfoTags.tSIMPLEPOLYGONSYMBOL)) { |
176 |
symb = new SimplePolygonSymbol();
|
177 |
|
178 |
SimplePolygonSymbol esymb = (SimplePolygonSymbol) symb; |
179 |
|
180 |
String hasBoundary = parser.getAttributeValue("", |
181 |
ServiceInfoTags.aBOUNDARY); |
182 |
|
183 |
if ((hasBoundary != null) && hasBoundary.equals("false")) { |
184 |
esymb.setHasBoundary(false);
|
185 |
} else {
|
186 |
SimpleLineSymbol lsymb = esymb.getBoundary(); |
187 |
String strBound = "boundary"; |
188 |
String color = parser.getAttributeValue("", |
189 |
strBound + ServiceInfoTags.aCOLOR); |
190 |
|
191 |
if (color != null) { |
192 |
lsymb.setColor(color); |
193 |
} |
194 |
|
195 |
String width = parser.getAttributeValue("", |
196 |
strBound + ServiceInfoTags.aWIDTH); |
197 |
|
198 |
if (width != null) { |
199 |
lsymb.setWidth(width); |
200 |
} |
201 |
|
202 |
String type = parser.getAttributeValue("", |
203 |
strBound + ServiceInfoTags.aTYPE); |
204 |
|
205 |
if (type != null) { |
206 |
lsymb.setType(type); |
207 |
} |
208 |
|
209 |
String captype = parser.getAttributeValue("", |
210 |
strBound + ServiceInfoTags.aCAPTYPE); |
211 |
|
212 |
if (captype != null) { |
213 |
lsymb.setCaptype(captype); |
214 |
} |
215 |
|
216 |
String jointype = parser.getAttributeValue("", |
217 |
strBound + ServiceInfoTags.aJOINTYPE); |
218 |
|
219 |
if (jointype != null) { |
220 |
lsymb.setJointype(jointype); |
221 |
} |
222 |
|
223 |
String transparency = parser.getAttributeValue("", |
224 |
strBound + ServiceInfoTags.aTRANSPARENCY); |
225 |
|
226 |
if (transparency != null) { |
227 |
lsymb.setTransparency(transparency); |
228 |
} |
229 |
} |
230 |
|
231 |
String strFill = "fill"; |
232 |
String color = parser.getAttributeValue("", |
233 |
strFill + ServiceInfoTags.aCOLOR); |
234 |
|
235 |
if (color != null) { |
236 |
esymb.setFillcolor(color); |
237 |
} |
238 |
|
239 |
String trans = parser.getAttributeValue("", |
240 |
strFill + ServiceInfoTags.aTRANSPARENCY); |
241 |
|
242 |
if (trans != null) { |
243 |
esymb.setFilltransparency(trans); |
244 |
} |
245 |
|
246 |
String type = parser.getAttributeValue("", |
247 |
strFill + ServiceInfoTags.aTYPE); |
248 |
|
249 |
if (type != null) { |
250 |
esymb.setFilltype(type); |
251 |
} |
252 |
} |
253 |
//TEXTSYMBOL;
|
254 |
else if (parser.getName().equals(ServiceInfoTags.tTEXTSYMBOL)) { |
255 |
symb = new TextSymbol();
|
256 |
|
257 |
TextSymbol esymb = (TextSymbol) symb; |
258 |
|
259 |
String font = parser.getAttributeValue("", ServiceInfoTags.aFONT); |
260 |
|
261 |
if (font != null) { |
262 |
esymb.setFont(font); |
263 |
} |
264 |
|
265 |
String fontcolor = parser.getAttributeValue("", |
266 |
ServiceInfoTags.aFONT + ServiceInfoTags.aCOLOR); |
267 |
|
268 |
if (fontcolor != null) { |
269 |
esymb.setFontColor(fontcolor); |
270 |
} |
271 |
|
272 |
String fontsize = parser.getAttributeValue("", |
273 |
ServiceInfoTags.aFONT + ServiceInfoTags.aSIZE); |
274 |
|
275 |
if (fontsize != null) { |
276 |
esymb.setFontSize(fontsize); |
277 |
} |
278 |
|
279 |
String fontstyle = parser.getAttributeValue("", |
280 |
ServiceInfoTags.aFONT + ServiceInfoTags.aSTYLE); |
281 |
|
282 |
if (fontstyle != null) { |
283 |
esymb.setFontStyle(fontstyle); |
284 |
} |
285 |
} |
286 |
//RASTERMARKERSYMBOL;
|
287 |
else if (parser.getName().equals(ServiceInfoTags.tRASTERMARKERSYMBOL)) { |
288 |
String url = parser.getAttributeValue("", ServiceInfoTags.aURL); |
289 |
|
290 |
if (url != null) { |
291 |
symb = new RasterMarkerSymbol(url);
|
292 |
|
293 |
RasterMarkerSymbol esymb = (RasterMarkerSymbol) symb; |
294 |
String size = parser.getAttributeValue("", ServiceInfoTags.aSIZE); |
295 |
|
296 |
if (size != null) { |
297 |
esymb.setSize(size); |
298 |
} |
299 |
|
300 |
String trans = parser.getAttributeValue("", |
301 |
ServiceInfoTags.aTRANSPARENCY); |
302 |
|
303 |
if (trans != null) { |
304 |
esymb.setTransparency(trans); |
305 |
} |
306 |
} |
307 |
} |
308 |
// RASTERFILLSYMBOL;
|
309 |
else if (parser.getName().equals(ServiceInfoTags.tRASTERFILLSYMBOL)) { |
310 |
String url = parser.getAttributeValue("", ServiceInfoTags.aURL); |
311 |
|
312 |
if (url != null) { |
313 |
symb = new RasterFillSymbol(url);
|
314 |
|
315 |
RasterFillSymbol esymb = (RasterFillSymbol) symb; |
316 |
String trans = parser.getAttributeValue("", |
317 |
ServiceInfoTags.aTRANSPARENCY); |
318 |
|
319 |
if (trans != null) { |
320 |
esymb.setTransparency(trans); |
321 |
} |
322 |
} |
323 |
} |
324 |
//Not supported
|
325 |
//GRADIENTFILLSYMBOL;
|
326 |
else if (parser.getName().equals(ServiceInfoTags.tGRADIENTFILLSYMBOL)) { |
327 |
symb = new GradientFillSymbol();
|
328 |
|
329 |
GradientFillSymbol esymb = (GradientFillSymbol) symb; |
330 |
|
331 |
String finishcolor = parser.getAttributeValue("", |
332 |
"finish" + ServiceInfoTags.aCOLOR);
|
333 |
|
334 |
if (finishcolor != null) { |
335 |
esymb.setFinishcolor(finishcolor); |
336 |
} |
337 |
|
338 |
String startcolor = parser.getAttributeValue("", |
339 |
"start" + ServiceInfoTags.aCOLOR);
|
340 |
|
341 |
if (startcolor != null) { |
342 |
esymb.setStartcolor(startcolor); |
343 |
} |
344 |
|
345 |
String transparency = parser.getAttributeValue("", |
346 |
ServiceInfoTags.aTRANSPARENCY); |
347 |
|
348 |
if (transparency != null) { |
349 |
esymb.setTransparency(transparency); |
350 |
} |
351 |
|
352 |
String type = parser.getAttributeValue("", ServiceInfoTags.aTYPE); |
353 |
|
354 |
if (type != null) { |
355 |
esymb.setType(type); |
356 |
} |
357 |
} |
358 |
//HASHLINESYMBOL;
|
359 |
else if (parser.getName().equals(ServiceInfoTags.tHASHLINESYMBOL)) { |
360 |
symb = new HashLineSymbol();
|
361 |
|
362 |
HashLineSymbol esymb = (HashLineSymbol) symb; |
363 |
|
364 |
String color = parser.getAttributeValue("", ServiceInfoTags.aCOLOR); |
365 |
|
366 |
if (color != null) { |
367 |
esymb.setColor(color); |
368 |
} |
369 |
|
370 |
String linethickness = parser.getAttributeValue("", |
371 |
ServiceInfoTags.aLINETHICKNESS); |
372 |
|
373 |
if (linethickness != null) { |
374 |
esymb.setLinethickness(linethickness); |
375 |
} |
376 |
} |
377 |
// TRUETYPEMARKERSYMBOL;
|
378 |
else if (parser.getName().equals(ServiceInfoTags.tTRUETYPEMARKERSYMBOL)) { |
379 |
symb = new TrueTypeMarkerSymbol();
|
380 |
} |
381 |
// CALLOUTMARKERSYMBOL
|
382 |
else if (parser.getName().equals(ServiceInfoTags.tCALLOUTMARKERSYMBOL)) { |
383 |
symb = new CallOutMarkerSymbol();
|
384 |
} |
385 |
// CHARTSYMBOL;
|
386 |
else if (parser.getName().equals(ServiceInfoTags.tCHARTSYMBOL)) { |
387 |
symb = new ChartSymbol();
|
388 |
} |
389 |
// RASTERSHIELDSYMBOL;
|
390 |
else if (parser.getName().equals(ServiceInfoTags.tRASTERSHIELDSYMBOL)) { |
391 |
String url = parser.getAttributeValue("", ServiceInfoTags.aURL); |
392 |
|
393 |
if (url != null) { |
394 |
symb = new RasterShieldSymbol(url);
|
395 |
} |
396 |
} |
397 |
// SHIELDSYMBOL;
|
398 |
else if (parser.getName().equals(ServiceInfoTags.tSHIELDSYMBOL)) { |
399 |
symb = new ShieldSymbol();
|
400 |
} |
401 |
// TEXTMARKERSYMBOL;
|
402 |
else if (parser.getName().equals(ServiceInfoTags.tTEXTMARKERSYMBOL)) { |
403 |
symb = new TextMarkerSymbol();
|
404 |
} |
405 |
|
406 |
// //Return allways a simplePolygon to test
|
407 |
// symb = new SimplePolygonSymbol();
|
408 |
return symb;
|
409 |
} |
410 |
} |