root / trunk / extensions / extSymbology / src / org / gvsig / remoteClient / sld / sld1_0_0 / SLDRule1_0_0.java @ 20768
History | View | Annotate | Download (6.77 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.remoteClient.sld.sld1_0_0; |
42 |
|
43 |
import java.io.IOException; |
44 |
|
45 |
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser; |
46 |
import org.gvsig.remoteClient.sld.SLDRule; |
47 |
import org.gvsig.remoteClient.sld.SLDTags; |
48 |
import org.gvsig.remoteClient.sld.filterEncoding.Filter; |
49 |
import org.gvsig.remoteClient.sld.filterEncoding.FilterTags; |
50 |
import org.gvsig.remoteClient.sld.filterEncoding.FilterUtils; |
51 |
import org.gvsig.remoteClient.sld.sld1_0_0.symbolizers.SLDLineSymbolizer1_0_0; |
52 |
import org.gvsig.remoteClient.sld.sld1_0_0.symbolizers.SLDPointSymbolizer1_0_0; |
53 |
import org.gvsig.remoteClient.sld.sld1_0_0.symbolizers.SLDPolygonSymbolizer1_0_0; |
54 |
import org.xmlpull.v1.XmlPullParserException; |
55 |
|
56 |
import com.iver.cit.gvsig.fmap.drivers.legend.LegendDriverException; |
57 |
|
58 |
/**
|
59 |
* Implements the Rule element of an SLD specification.<br>
|
60 |
*
|
61 |
* Rules are used to group rendering instructions by feature-property
|
62 |
* conditions and map scales.Rule definitions are placed inmediatelly inside
|
63 |
* of feature-style definitions.
|
64 |
*
|
65 |
*
|
66 |
* @see http://portal.opengeospatial.org/files/?artifact_id=1188
|
67 |
* @author pepe vidal salvador - jose.vidal.salvador@iver.es
|
68 |
*/
|
69 |
public class SLDRule1_0_0 extends SLDRule { |
70 |
|
71 |
|
72 |
public void parse(XMLSchemaParser parser,int cuTag, String expressionType)throws IOException, XmlPullParserException, LegendDriverException { |
73 |
int currentTag;
|
74 |
boolean end = false; |
75 |
|
76 |
parser.require(XMLSchemaParser.START_TAG, null, SLDTags.RULE);
|
77 |
currentTag = parser.next(); |
78 |
|
79 |
while (!end)
|
80 |
{ |
81 |
switch(currentTag)
|
82 |
{ |
83 |
case XMLSchemaParser.START_TAG:
|
84 |
if (parser.getName().compareTo(SLDTags.NAME)==0) { |
85 |
setName(parser.nextText()); |
86 |
} |
87 |
else if(parser.getName().compareTo(SLDTags.TITLE)==0) { |
88 |
setTitle(parser.nextText()); |
89 |
} |
90 |
else if(parser.getName().compareTo(SLDTags.ABSTRACT)==0) { |
91 |
setRuleAbstract(parser.nextText()); |
92 |
} |
93 |
else if(parser.getName().compareTo(SLDTags.LEGENDGRAPHIC)==0) { |
94 |
SLDLegendGraphic1_0_0 legend = new SLDLegendGraphic1_0_0();
|
95 |
legend.parse(parser,currentTag,null);
|
96 |
setLegendGraphic(legend); |
97 |
} |
98 |
else if(parser.getName().compareTo(SLDTags.MINSCALEDENOMINATOR)==0) { |
99 |
setMinScaleDenominator(Double.valueOf(parser.nextText()));
|
100 |
} |
101 |
else if(parser.getName().compareTo(SLDTags.MAXSCALEDENOMINATOR)==0) { |
102 |
setMaxScaleDenominator(Double.valueOf(parser.nextText()));
|
103 |
} |
104 |
else if(parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.FILTER))==0) { |
105 |
Filter filter = new Filter(); |
106 |
filter.parse(parser); |
107 |
setFilter(filter); |
108 |
} |
109 |
// else if(parser.getName().compareTo(SLDTags.ELSEFILTER)==0) {
|
110 |
// this.elseFilter = new Filter();
|
111 |
// elseFilter.parse(parser);
|
112 |
// }
|
113 |
// else if(parser.getName().compareTo(SLDTags.ELSEFILTER)==0) {
|
114 |
// throw new Error ("ElseFilter not yet implemented->Rule\n");
|
115 |
// }
|
116 |
else if(parser.getName().compareTo(SLDTags.LINESYMBOLIZER)==0) { |
117 |
SLDLineSymbolizer1_0_0 sldLine = new SLDLineSymbolizer1_0_0();
|
118 |
sldLine.parse(parser); |
119 |
addLineSymbolizer(sldLine); |
120 |
} |
121 |
else if(parser.getName().compareTo(SLDTags.POLYGONSYMBOLIZER)==0) { |
122 |
SLDPolygonSymbolizer1_0_0 sldPolygon = new SLDPolygonSymbolizer1_0_0();
|
123 |
sldPolygon.parse(parser); |
124 |
addPolygonSymbolizer(sldPolygon); |
125 |
} |
126 |
else if(parser.getName().compareTo(SLDTags.POINTSYMBOLIZER)==0) { |
127 |
SLDPointSymbolizer1_0_0 sldPoint = new SLDPointSymbolizer1_0_0();
|
128 |
sldPoint.parse(parser); |
129 |
addPointSymbolizer(sldPoint); |
130 |
} |
131 |
// else if(parser.getName().compareTo(SLDTags.TEXTSYMBOLIZER)==0) {
|
132 |
// throw new Error ("TextSymbolizer not yet implemented->Rule\n");
|
133 |
// }
|
134 |
// else if(parser.getName().compareTo(SLDTags.RASTERSYMBOLIZER)==0) {
|
135 |
// throw new Error ("RasterSymbolizer not yet implemented->Rule\n");
|
136 |
// }
|
137 |
|
138 |
break;
|
139 |
case XMLSchemaParser.END_TAG:
|
140 |
if (parser.getName().compareTo(SLDTags.RULE) == 0) |
141 |
end = true;
|
142 |
break;
|
143 |
case XMLSchemaParser.TEXT:
|
144 |
break;
|
145 |
} |
146 |
if (!end)
|
147 |
currentTag = parser.next(); |
148 |
} |
149 |
|
150 |
parser.require(XMLSchemaParser.END_TAG, null, SLDTags.RULE);
|
151 |
|
152 |
} |
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
public void applyScale2Symbolizers(double minScaleDenominator,double maxScaleDenominator) { |
159 |
|
160 |
for (int i = 0; i < getLineSymbolizers().size(); i++) { |
161 |
getLineSymbolizers().get(i).setMinScaleDenominator(minScaleDenominator); |
162 |
getLineSymbolizers().get(i).setMaxScaleDenominator(maxScaleDenominator); |
163 |
} |
164 |
for (int i = 0; i < getPolygonSymbolizers().size(); i++) { |
165 |
getPolygonSymbolizers().get(i).setMinScaleDenominator(minScaleDenominator); |
166 |
getPolygonSymbolizers().get(i).setMaxScaleDenominator(maxScaleDenominator); |
167 |
} |
168 |
for (int i = 0; i < getPointSymbolizers().size(); i++) { |
169 |
getPointSymbolizers().get(i).setMinScaleDenominator(minScaleDenominator); |
170 |
getPointSymbolizers().get(i).setMaxScaleDenominator(maxScaleDenominator); |
171 |
} |
172 |
} |
173 |
|
174 |
public boolean hasFilter() { |
175 |
if(this.filter != null) return true; |
176 |
else return false; |
177 |
} |
178 |
|
179 |
public void addSymbolizers2Filter() { |
180 |
if(getFilter() != null) { |
181 |
for (int i = 0; i < getLineSymbolizers().size(); i++) { |
182 |
getFilter().addSymbolizer2Filter(getLineSymbolizers().get(i)); |
183 |
} |
184 |
for (int i = 0; i < getPolygonSymbolizers().size(); i++) { |
185 |
getFilter().addSymbolizer2Filter(getPolygonSymbolizers().get(i)); |
186 |
} |
187 |
for (int i = 0; i < getPointSymbolizers().size(); i++) { |
188 |
getFilter().addSymbolizer2Filter(getPointSymbolizers().get(i)); |
189 |
} |
190 |
} |
191 |
} |
192 |
|
193 |
public String toXML() { |
194 |
// TODO Auto-generated method stub
|
195 |
throw new Error ("Not yet implemented"); |
196 |
} |
197 |
|
198 |
|
199 |
|
200 |
} |