svn-gvsig-desktop / branches / v02_desarrollo / libraries / org.gvsig.sldsupport / org.gvsig.sldsupport.lib / org.gvsig.sldsupport.lib.api / src / main / java / org / gvsig / sldsupport / version / sld1_0_0 / SLDMark1_0_0.java @ 40749
History | View | Annotate | Download (4.79 KB)
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. 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 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.sldsupport.version.sld1_0_0; |
42 |
|
43 |
import java.io.IOException; |
44 |
|
45 |
import org.gvsig.sldsupport.exception.SLDReadException; |
46 |
import org.gvsig.sldsupport.filterencoding.FExpression; |
47 |
import org.gvsig.sldsupport.graphic.SLDMark; |
48 |
import org.gvsig.sldsupport.util.SLDTags; |
49 |
import org.gvsig.sldsupport.util.XmlBuilder; |
50 |
import org.xmlpull.v1.XmlPullParser; |
51 |
import org.xmlpull.v1.XmlPullParserException; |
52 |
|
53 |
/**
|
54 |
* Implements the Mark element of an SLD implementation specification (version
|
55 |
* 1.0.0).<p>
|
56 |
* The Mark element of a Graphic defines a �shape� which has coloring applied to it.<p>
|
57 |
* The WellKnownName element gives the well-known name of the shape of the mark.
|
58 |
* Allowed values include at least �square�, �circle�, �triangle�, �star�, �cross�,
|
59 |
* and �x�, though map servers may draw a different symbol instead if they don't
|
60 |
* have a shape for all of these. The default WellKnownName is �square�. Renderings
|
61 |
* of these marks may be made solid or hollow depending on Fill and Stroke elements.
|
62 |
* <p>
|
63 |
* The Mark element serves two purposes. It allows the selection of simple shapes,
|
64 |
* and, in combination with the capability to select and mix multiple external-URL
|
65 |
* graphics and marks, it allows a style to be specified that can produce a usable
|
66 |
* result in a best-effort rendering environment, provided that a simple Mark is
|
67 |
* included at the bottom of the list of sources for every Graphic.<p>
|
68 |
*
|
69 |
* @see SLDFill1_0_0
|
70 |
* @see SLDStroke1_0_0
|
71 |
* @see http://portal.opengeospatial.org/files/?artifact_id=1188
|
72 |
*
|
73 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es
|
74 |
*/
|
75 |
public class SLDMark1_0_0 extends SLDMark { |
76 |
|
77 |
|
78 |
|
79 |
public void parse(XmlPullParser parser, int cuTag, String expressionType) |
80 |
throws IOException, XmlPullParserException, SLDReadException { |
81 |
|
82 |
int currentTag;
|
83 |
boolean end = false; |
84 |
|
85 |
parser.require(XmlPullParser.START_TAG, null, SLDTags.MARK);
|
86 |
currentTag = parser.next(); |
87 |
|
88 |
while (!end)
|
89 |
{ |
90 |
switch(currentTag)
|
91 |
{ |
92 |
case XmlPullParser.START_TAG:
|
93 |
if (parser.getName().compareTo(SLDTags.WELLKNOWNNAME)==0) { |
94 |
parser.next(); |
95 |
String s = parser.getText().trim();
|
96 |
FExpression wellKnownName = new FExpression();
|
97 |
|
98 |
if (s==null || "".equals(s)) { |
99 |
wellKnownName.parse(parser, parser.nextTag(),parser.getName()); |
100 |
} else {
|
101 |
wellKnownName.setLiteral(s); |
102 |
} |
103 |
setWellKnownName(wellKnownName); |
104 |
} |
105 |
|
106 |
else if (parser.getName().compareTo(SLDTags.FILL)==0) { |
107 |
SLDFill1_0_0 fill = new SLDFill1_0_0();
|
108 |
fill.parse(parser,currentTag,null);
|
109 |
setFill(fill); |
110 |
} |
111 |
else if (parser.getName().compareTo(SLDTags.STROKE)==0) { |
112 |
SLDStroke1_0_0 stroke = new SLDStroke1_0_0();
|
113 |
stroke.parse(parser,currentTag,null);
|
114 |
setStroke(stroke); |
115 |
} |
116 |
break;
|
117 |
case XmlPullParser.END_TAG:
|
118 |
if (parser.getName().compareTo(SLDTags.MARK) == 0) |
119 |
end = true;
|
120 |
break;
|
121 |
case XmlPullParser.TEXT:
|
122 |
break;
|
123 |
} |
124 |
if (!end)
|
125 |
currentTag = parser.next(); |
126 |
} |
127 |
|
128 |
parser.require(XmlPullParser.END_TAG, null, SLDTags.MARK);
|
129 |
|
130 |
} |
131 |
|
132 |
|
133 |
public String toXML() { |
134 |
XmlBuilder xmlBuilder = new XmlBuilder();
|
135 |
xmlBuilder.openTag(SLDTags.MARK); |
136 |
|
137 |
if (getWellKnownName().getLiteral() != null) |
138 |
xmlBuilder.writeTag(SLDTags.WELLKNOWNNAME, getWellKnownName().getLiteral().toString()); |
139 |
if (getFill() != null) |
140 |
xmlBuilder.writeRaw(getFill().toXML()); |
141 |
if (getStroke() != null) |
142 |
xmlBuilder.writeRaw(getStroke().toXML()); |
143 |
|
144 |
xmlBuilder.closeTag(); |
145 |
return xmlBuilder.getXML();
|
146 |
} |
147 |
} |