svn-gvsig-desktop / branches / v02_desarrollo / libraries / sld / temp / org.gvsig.sldsupport.lib.impl / src / main / java / org / gvsig / sldsupport / impl / sld1_0_0 / parsing / GraphicElement.java @ 40794
History | View | Annotate | Download (2.67 KB)
1 |
package org.gvsig.sldsupport.impl.sld1_0_0.parsing; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import org.gvsig.sldsupport.exception.SLDReadException; |
6 |
import org.gvsig.sldsupport.impl.util.SLDUtils; |
7 |
import org.gvsig.sldsupport.sld.SLDTags; |
8 |
import org.gvsig.sldsupport.sld.extent.SLDExtent; |
9 |
import org.gvsig.sldsupport.sld.graphic.SLDAnchorPoint; |
10 |
import org.gvsig.sldsupport.sld.graphic.SLDDisplacement; |
11 |
import org.gvsig.sldsupport.sld.graphic.SLDExternalGraphic; |
12 |
import org.gvsig.sldsupport.sld.graphic.SLDGraphic; |
13 |
import org.gvsig.sldsupport.sld.graphic.SLDMark; |
14 |
import org.gvsig.sldsupport.sld.symbol.misc.SLDParameterValue; |
15 |
import org.kxml2.io.KXmlParser; |
16 |
import org.xmlpull.v1.XmlPullParser; |
17 |
import org.xmlpull.v1.XmlPullParserException; |
18 |
|
19 |
public class GraphicElement { |
20 |
|
21 |
public static SLDGraphic parse(XmlPullParser parser , String version) |
22 |
throws XmlPullParserException, IOException, SLDReadException { |
23 |
|
24 |
parser.require(KXmlParser.START_TAG, null, SLDTags.GRAPHIC);
|
25 |
int tag = 0; |
26 |
|
27 |
SLDGraphic resp = new SLDGraphic();
|
28 |
|
29 |
tag = parser.next(); |
30 |
String name = parser.getName();
|
31 |
String txt = null; |
32 |
while (!(SLDUtils.isStr(name, SLDTags.GRAPHIC) && tag == KXmlParser.END_TAG)) {
|
33 |
|
34 |
switch (tag) {
|
35 |
case KXmlParser.START_TAG:
|
36 |
if (SLDUtils.isStr(name, SLDTags.EXTERNALGRAPHIC)) {
|
37 |
SLDExternalGraphic ext = ExternalGraphicElement.parse(parser, version); |
38 |
resp.getElementStack().add(ext); |
39 |
break;
|
40 |
} |
41 |
if (SLDUtils.isStr(name, SLDTags.MARK)) {
|
42 |
SLDMark mk = MarkElement.parse(parser, version); |
43 |
resp.getElementStack().add(mk); |
44 |
break;
|
45 |
} |
46 |
if (SLDUtils.isStr(name, SLDTags.OPACITY)) {
|
47 |
SLDParameterValue pv = ParameterValueElement.parse(parser, version); |
48 |
resp.setOpacity(pv.getExpression()); |
49 |
break;
|
50 |
} |
51 |
if (SLDUtils.isStr(name, SLDTags.SIZE)) {
|
52 |
SLDParameterValue pv = ParameterValueElement.parse(parser, version); |
53 |
resp.setSize(pv.getExpression()); |
54 |
break;
|
55 |
} |
56 |
if (SLDUtils.isStr(name, SLDTags.ROTATION)) {
|
57 |
SLDParameterValue pv = ParameterValueElement.parse(parser, version); |
58 |
resp.setRotation(pv.getExpression()); |
59 |
break;
|
60 |
} |
61 |
if (SLDUtils.isStr(name, SLDTags.ANCHOR_POINT)) {
|
62 |
SLDAnchorPoint ap = AnchorPointElement.parse(parser, version); |
63 |
resp.setAnchor(ap); |
64 |
break;
|
65 |
} |
66 |
if (SLDUtils.isStr(name, SLDTags.DISPLACEMENT)) {
|
67 |
SLDDisplacement di = DisplacementElement.parse(parser, version); |
68 |
resp.setDisplacement(di); |
69 |
break;
|
70 |
} |
71 |
break;
|
72 |
case KXmlParser.END_TAG:
|
73 |
break;
|
74 |
case KXmlParser.TEXT:
|
75 |
break;
|
76 |
} |
77 |
tag = parser.next(); |
78 |
} |
79 |
|
80 |
parser.next(); |
81 |
name = parser.getName(); |
82 |
return resp;
|
83 |
} |
84 |
} |