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 / FillElement.java @ 40793
History | View | Annotate | Download (2.28 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.graphic.SLDGraphicFill; |
9 |
import org.gvsig.sldsupport.sld.graphic.SLDMark; |
10 |
import org.gvsig.sldsupport.sld.symbol.misc.SLDFill; |
11 |
import org.gvsig.sldsupport.sld.symbol.misc.SLDSvgCssParameter; |
12 |
import org.kxml2.io.KXmlParser; |
13 |
import org.xmlpull.v1.XmlPullParser; |
14 |
import org.xmlpull.v1.XmlPullParserException; |
15 |
|
16 |
public class FillElement { |
17 |
|
18 |
public static SLDFill parse(XmlPullParser parser , String version) |
19 |
throws XmlPullParserException, IOException, SLDReadException { |
20 |
|
21 |
parser.require(KXmlParser.START_TAG, null, SLDTags.FILL);
|
22 |
int tag = 0; |
23 |
|
24 |
SLDFill resp = new SLDFill();
|
25 |
|
26 |
tag = parser.next(); |
27 |
String name = parser.getName();
|
28 |
String txt = null; |
29 |
String attName = null; |
30 |
while (!(SLDUtils.isStr(name, SLDTags.FILL) && tag == KXmlParser.END_TAG)) {
|
31 |
|
32 |
switch (tag) {
|
33 |
case KXmlParser.START_TAG:
|
34 |
if (SLDUtils.isStr(name, SLDTags.GRAPHICFILL)) {
|
35 |
SLDGraphicFill gf = GraphicFillElement.parse(parser, version); |
36 |
/*
|
37 |
* SLDFill has a 'fillGraphic' field which is a Graphic,
|
38 |
* it does not have a field of FillGraphic type which
|
39 |
* has a graphic (we are collapsing an element)
|
40 |
*/
|
41 |
resp.setFillGraphic(gf.getGraphic()); |
42 |
break;
|
43 |
} |
44 |
if (SLDUtils.isStr(name, SLDTags.CSSPARAMETER)
|
45 |
|| SLDUtils.isStr(name, SLDTags.SVGPARAMETER)) { |
46 |
|
47 |
SLDSvgCssParameter sp = SvgCssParameterElement.parse(parser, version); |
48 |
if (SLDUtils.isStr(sp.getName(), SLDTags.FILL_ATTR)) {
|
49 |
if (sp.getExpressionList().size() > 0) { |
50 |
// Using first item only
|
51 |
resp.setFill(sp.getExpressionList().get(0));
|
52 |
} |
53 |
} else {
|
54 |
if (SLDUtils.isStr(sp.getName(), SLDTags.FILLOPACITY_ATTR)) {
|
55 |
if (sp.getExpressionList().size() > 0) { |
56 |
// Using first item only
|
57 |
resp.setOpacity(sp.getExpressionList().get(0));
|
58 |
} |
59 |
} |
60 |
} |
61 |
break;
|
62 |
} |
63 |
break;
|
64 |
case KXmlParser.END_TAG:
|
65 |
break;
|
66 |
case KXmlParser.TEXT:
|
67 |
break;
|
68 |
} |
69 |
tag = parser.next(); |
70 |
} |
71 |
|
72 |
parser.next(); |
73 |
return resp;
|
74 |
} |
75 |
} |