svn-gvsig-desktop / branches / v02_desarrollo / libraries / sld / temp / org.gvsig.sldsupport.lib.impl / src / main / java / org / gvsig / sldsupport / impl / sld / parsing / symbol / SymbolElement.java @ 40827
History | View | Annotate | Download (2.31 KB)
1 |
package org.gvsig.sldsupport.impl.sld.parsing.symbol; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
import java.util.Map; |
5 |
|
6 |
import org.gvsig.sldsupport.exception.InvalidSLDObjectException; |
7 |
import org.gvsig.sldsupport.exception.SLDReadException; |
8 |
import org.gvsig.sldsupport.exception.UnsupportedSLDObjectException; |
9 |
import org.gvsig.sldsupport.impl.util.SLDUtils; |
10 |
import org.gvsig.sldsupport.impl.util.XmlBuilder; |
11 |
import org.gvsig.sldsupport.sld.SLDTags; |
12 |
import org.gvsig.sldsupport.sld.symbol.SLDLineSymbol; |
13 |
import org.gvsig.sldsupport.sld.symbol.SLDPointSymbol; |
14 |
import org.gvsig.sldsupport.sld.symbol.SLDPolygonSymbol; |
15 |
import org.gvsig.sldsupport.sld.symbol.SLDSymbol; |
16 |
import org.xmlpull.v1.XmlPullParser; |
17 |
import org.xmlpull.v1.XmlPullParserException; |
18 |
|
19 |
public class SymbolElement { |
20 |
|
21 |
public static void append( |
22 |
SLDSymbol obj, XmlBuilder xb, Map<String, String> atts) |
23 |
throws InvalidSLDObjectException, UnsupportedSLDObjectException {
|
24 |
|
25 |
// ======================================
|
26 |
if (obj instanceof SLDPointSymbol) { |
27 |
PointSymbolElement.append((SLDPointSymbol) obj, xb, atts); |
28 |
return;
|
29 |
} |
30 |
if (obj instanceof SLDLineSymbol) { |
31 |
LineSymbolElement.append((SLDLineSymbol) obj, xb, atts); |
32 |
return;
|
33 |
} |
34 |
if (obj instanceof SLDPolygonSymbol) { |
35 |
PolygonSymbolElement.append((SLDPolygonSymbol) obj, xb, atts); |
36 |
return;
|
37 |
} |
38 |
/*
|
39 |
* Text, Raster, MappedColor
|
40 |
*/
|
41 |
throw new UnsupportedSLDObjectException( |
42 |
obj == null ? "Null" : obj.getClass().getName(), |
43 |
"Not supported yet");
|
44 |
|
45 |
} |
46 |
|
47 |
public static SLDSymbol parse(XmlPullParser parser , String version) |
48 |
throws XmlPullParserException, IOException, SLDReadException { |
49 |
|
50 |
String name = parser.getName();
|
51 |
if (SLDUtils.isStr(name, SLDTags.LINESYMBOL)
|
52 |
|| SLDUtils.isStr(name, SLDTags.LINESYMBOLIZER)) { |
53 |
return LineSymbolElement.parse(parser, version);
|
54 |
} |
55 |
|
56 |
if (SLDUtils.isStr(name, SLDTags.POINTSYMBOL)
|
57 |
|| SLDUtils.isStr(name, SLDTags.POINTSYMBOLIZER)) { |
58 |
return PointSymbolElement.parse(parser, version);
|
59 |
} |
60 |
|
61 |
if (SLDUtils.isStr(name, SLDTags.POLYGONSYMBOL)
|
62 |
|| SLDUtils.isStr(name, SLDTags.POLYGONSYMBOLIZER)) { |
63 |
return PolygonSymbolElement.parse(parser, version);
|
64 |
} |
65 |
|
66 |
/*
|
67 |
* RasterSymbol, TextSymbol, MappedColorSymbol
|
68 |
*/
|
69 |
throw new SLDReadException("Unsupported symbol entity: " + name); |
70 |
} |
71 |
} |