Revision 3156
branches/gvSIG_WMSv2/extensions/extWMS/text.properties | ||
---|---|---|
1 |
nombre_capa=lalalalalala |
|
0 | 2 |
branches/gvSIG_WMSv2/extensions/extWMS/.classpath | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 | 2 |
<classpath> |
3 |
<classpathentry kind="src" path="src"> |
|
4 |
<attributes> |
|
5 |
</attributes> |
|
6 |
</classpathentry> |
|
7 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> |
|
8 |
<attributes> |
|
9 |
</attributes> |
|
10 |
</classpathentry> |
|
11 |
<classpathentry combineaccessrules="false" kind="src" path="/Andami"> |
|
12 |
<attributes> |
|
13 |
</attributes> |
|
14 |
</classpathentry> |
|
15 |
<classpathentry kind="lib" path="/Andami/lib/castor-0.9.5.3-xml.jar"> |
|
16 |
<attributes> |
|
17 |
</attributes> |
|
18 |
</classpathentry> |
|
19 |
<classpathentry kind="lib" path="/Andami/lib/log4j-1.2.8.jar"> |
|
20 |
<attributes> |
|
21 |
</attributes> |
|
22 |
</classpathentry> |
|
23 |
<classpathentry sourcepath="/Utiles/src" kind="lib" path="/Andami/lib/iver-utiles.jar"> |
|
24 |
<attributes> |
|
25 |
</attributes> |
|
26 |
</classpathentry> |
|
27 |
<classpathentry sourcepath="/WMSClient/src/com/iver/wmsclient" kind="lib" path="/FMap 03/lib/wmsclient.jar"> |
|
28 |
<attributes> |
|
29 |
</attributes> |
|
30 |
</classpathentry> |
|
31 |
<classpathentry combineaccessrules="false" kind="src" path="/FMap 03"> |
|
32 |
<attributes> |
|
33 |
</attributes> |
|
34 |
</classpathentry> |
|
35 |
<classpathentry combineaccessrules="false" kind="src" path="/gvSIG 03"> |
|
36 |
<attributes> |
|
37 |
</attributes> |
|
38 |
</classpathentry> |
|
3 |
<classpathentry kind="src" path="src"/> |
|
4 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
|
5 |
<classpathentry kind="src" path="/Andami"/> |
|
6 |
<classpathentry kind="lib" path="/Andami/lib/castor-0.9.5.3-xml.jar"/> |
|
7 |
<classpathentry kind="lib" path="/Andami/lib/log4j-1.2.8.jar"/> |
|
8 |
<classpathentry sourcepath="/Utiles/src" kind="lib" path="/Andami/lib/iver-utiles.jar"/> |
|
9 |
<classpathentry sourcepath="/WMSClient/src/com/iver/wmsclient" kind="lib" path="/FMap 03/lib/wmsclient.jar"/> |
|
10 |
<classpathentry kind="src" path="/FMap 03"/> |
|
11 |
<classpathentry kind="src" path="/gvSIG 03"/> |
|
12 |
<classpathentry sourcepath="/jCMS" kind="lib" path="/FMap 03/lib/cms.jar"/> |
|
13 |
<classpathentry sourcepath="/DriverManager/src" kind="lib" path="/FMap 03/lib/driver-manager-1.0.jar"/> |
|
14 |
<classpathentry kind="lib" path="/Andami/lib/tempFileManager.jar"/> |
|
39 | 15 |
<classpathentry kind="output" path="bin"/> |
40 | 16 |
</classpath> |
branches/gvSIG_WMSv2/extensions/extWMS/config/config.xml | ||
---|---|---|
4 | 4 |
<libraries library-dir="."/> |
5 | 5 |
<resourceBundle name="text"/> |
6 | 6 |
<extensions> |
7 |
<extension class-name="com.iver.cit.gvsig.wms.ExtWMS"
|
|
7 |
<extension class-name="com.iver.cit.gvsig.wms.WMSClientModule"
|
|
8 | 8 |
description="Support to access WMS" |
9 | 9 |
active="true" |
10 | 10 |
priority="1"> |
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/fmap/layers/FLyrWMS.java | ||
---|---|---|
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 com.iver.cit.gvsig.fmap.layers; |
|
42 |
|
|
43 |
import java.awt.Graphics2D; |
|
44 |
import java.awt.Point; |
|
45 |
import java.awt.geom.AffineTransform; |
|
46 |
import java.awt.geom.NoninvertibleTransformException; |
|
47 |
import java.awt.geom.Point2D; |
|
48 |
import java.awt.geom.Rectangle2D; |
|
49 |
import java.awt.image.BufferedImage; |
|
50 |
import java.awt.image.DataBuffer; |
|
51 |
import java.io.BufferedOutputStream; |
|
52 |
import java.io.ByteArrayInputStream; |
|
53 |
import java.io.DataOutputStream; |
|
54 |
import java.io.File; |
|
55 |
import java.io.FileOutputStream; |
|
56 |
import java.io.IOException; |
|
57 |
import java.lang.reflect.Constructor; |
|
58 |
import java.lang.reflect.InvocationTargetException; |
|
59 |
import java.net.MalformedURLException; |
|
60 |
import java.net.URL; |
|
61 |
import java.util.ArrayList; |
|
62 |
import java.util.Hashtable; |
|
63 |
|
|
64 |
import javax.imageio.ImageIO; |
|
65 |
|
|
66 |
import org.cresques.geo.ViewPortData; |
|
67 |
import org.cresques.io.GdalFile; |
|
68 |
import org.cresques.io.GeoRasterFile; |
|
69 |
import org.cresques.io.raster.RasterFilterStack; |
|
70 |
import org.cresques.io.raster.RasterFilterStackManager; |
|
71 |
import org.cresques.px.Extent; |
|
72 |
import org.cresques.px.PxRaster; |
|
73 |
import org.exolab.castor.xml.ValidationException; |
|
74 |
|
|
75 |
import com.devx.io.TempFileManager; |
|
76 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
77 |
import com.iver.cit.gvsig.fmap.ViewPort; |
|
78 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
79 |
import com.iver.cit.gvsig.fmap.drivers.WMSException; |
|
80 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint; |
|
81 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
|
82 |
import com.iver.utiles.StringUtilities; |
|
83 |
import com.iver.utiles.XMLEntity; |
|
84 |
import com.iver.wmsclient.FeatureInfoQuery; |
|
85 |
import com.iver.wmsclient.MapQuery; |
|
86 |
import com.iver.wmsclient.UnsupportedVersionException; |
|
87 |
import com.iver.wmsclient.WMSClient; |
|
88 |
import com.iver.wmsclient.WMSClientFactory; |
|
89 |
|
|
90 |
|
|
91 |
/** |
|
92 |
* Capa WMS. |
|
93 |
* |
|
94 |
* @author Fernando Gonz?lez Cort?s |
|
95 |
*/ |
|
96 |
public class FLyrWMS extends FLyrDefault implements InfoByPoint, RasterOperations { |
|
97 |
|
|
98 |
boolean isPrinting = false; |
|
99 |
boolean mustTileDraw = false; |
|
100 |
boolean mustTilePrint = true; |
|
101 |
int maxTileDrawWidth = -1; |
|
102 |
int maxTileDrawHeight = -1; |
|
103 |
int maxTilePrintWidth = 1500; |
|
104 |
int maxTilePrintHeight = 1500; |
|
105 |
|
|
106 |
private String m_SRS; |
|
107 |
private String m_Format; |
|
108 |
private String layerQuery; |
|
109 |
private String infoLayerQuery; |
|
110 |
private URL host; |
|
111 |
private WMSClient wmsClient; |
|
112 |
private MapQuery lastMapQuery; |
|
113 |
private Rectangle2D fullExtent; |
|
114 |
|
|
115 |
private StatusRasterInterface status = null; |
|
116 |
private int posX = 0, posY = 0; |
|
117 |
private double posXWC = 0, posYWC = 0; |
|
118 |
private int r = 0, g = 0, b = 0; |
|
119 |
private GeoRasterFile rasterFile = null; |
|
120 |
private PxRaster raster = null; |
|
121 |
private RasterFilterStack filterStack = null; |
|
122 |
public boolean firstLoad = false; |
|
123 |
private int transparency = -1; |
|
124 |
private int rband = 0, gband = 1, bband = 2; |
|
125 |
private RasterFilterStackManager stackManager = null; |
|
126 |
|
|
127 |
/** |
|
128 |
* Slecciona el formato del WMS. |
|
129 |
* |
|
130 |
* @return formato seleccionado. |
|
131 |
* |
|
132 |
* @throws WMSException |
|
133 |
* @throws IllegalStateException |
|
134 |
* @throws ValidationException |
|
135 |
* @throws UnsupportedVersionException |
|
136 |
* @throws IOException |
|
137 |
*/ |
|
138 |
private String selectFormat() |
|
139 |
throws WMSException, IllegalStateException, ValidationException, |
|
140 |
UnsupportedVersionException, IOException { |
|
141 |
String[] formats; |
|
142 |
formats = getWmsClient().getInfoFormats(); |
|
143 |
|
|
144 |
for (int i = 0; i < formats.length; i++) { |
|
145 |
if (formats[i].equals("GML.1")) { |
|
146 |
return formats[i]; |
|
147 |
} |
|
148 |
|
|
149 |
if (formats[i].equals("GML.2")) { |
|
150 |
return formats[i]; |
|
151 |
} |
|
152 |
|
|
153 |
if (formats[i].equals("GML.3")) { |
|
154 |
return formats[i]; |
|
155 |
} |
|
156 |
|
|
157 |
if (formats[i].equals("application/vnd.ogc.gml")) { |
|
158 |
return formats[i]; |
|
159 |
} |
|
160 |
|
|
161 |
if (formats[i].indexOf("XML") != -1) { |
|
162 |
return formats[i]; |
|
163 |
} |
|
164 |
} |
|
165 |
|
|
166 |
throw new WMSException("No format supported"); |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* Devuelve el XMLEntity con la informaci?n necesaria para reproducir la |
|
171 |
* capa. |
|
172 |
* |
|
173 |
* @return XMLEntity. |
|
174 |
* @throws XMLException |
|
175 |
*/ |
|
176 |
public XMLEntity getXMLEntity() throws XMLException { |
|
177 |
XMLEntity xml = super.getXMLEntity(); |
|
178 |
|
|
179 |
xml.putProperty("fullExtent", StringUtilities.rect2String(fullExtent)); |
|
180 |
xml.putProperty("host", host.toExternalForm()); |
|
181 |
xml.putProperty("infoLayerQuery", infoLayerQuery); |
|
182 |
xml.putProperty("layerQuery", layerQuery); |
|
183 |
xml.putProperty("format", m_Format); |
|
184 |
xml.putProperty("srs", m_SRS); |
|
185 |
if (status!=null) |
|
186 |
status.getXMLEntity(xml, true, this); |
|
187 |
else{ |
|
188 |
status = new StatusLayerRaster(); |
|
189 |
status.getXMLEntity(xml, true, this); |
|
190 |
} |
|
191 |
return xml; |
|
192 |
} |
|
193 |
|
|
194 |
/** |
|
195 |
* A partir del XMLEntity reproduce la capa. |
|
196 |
* |
|
197 |
* @param xml XMLEntity |
|
198 |
* |
|
199 |
* @throws XMLException |
|
200 |
* @throws DriverException |
|
201 |
* @throws DriverIOException |
|
202 |
*/ |
|
203 |
public void setXMLEntity03(XMLEntity xml) |
|
204 |
throws XMLException { |
|
205 |
super.setXMLEntity(xml); |
|
206 |
fullExtent = StringUtilities.string2Rect(xml.getStringProperty( |
|
207 |
"fullExtent")); |
|
208 |
|
|
209 |
try { |
|
210 |
host = new URL(xml.getStringProperty("host")); |
|
211 |
} catch (MalformedURLException e) { |
|
212 |
throw new XMLException(e); |
|
213 |
} |
|
214 |
|
|
215 |
infoLayerQuery = xml.getStringProperty("infoLayerQuery"); |
|
216 |
layerQuery = xml.getStringProperty("layerQuery"); |
|
217 |
m_Format = xml.getStringProperty("format"); |
|
218 |
m_SRS = xml.getStringProperty("srs"); |
|
219 |
} |
|
220 |
|
|
221 |
/** |
|
222 |
* A partir del XMLEntity reproduce la capa. |
|
223 |
* |
|
224 |
* @param xml XMLEntity |
|
225 |
* |
|
226 |
* @throws XMLException |
|
227 |
* @throws DriverException |
|
228 |
* @throws DriverIOException |
|
229 |
*/ |
|
230 |
public void setXMLEntity(XMLEntity xml) |
|
231 |
throws XMLException { |
|
232 |
super.setXMLEntity(xml); |
|
233 |
fullExtent = StringUtilities.string2Rect(xml.getStringProperty( |
|
234 |
"fullExtent")); |
|
235 |
|
|
236 |
try { |
|
237 |
host = new URL(xml.getStringProperty("host")); |
|
238 |
} catch (MalformedURLException e) { |
|
239 |
throw new XMLException(e); |
|
240 |
} |
|
241 |
|
|
242 |
infoLayerQuery = xml.getStringProperty("infoLayerQuery"); |
|
243 |
layerQuery = xml.getStringProperty("layerQuery"); |
|
244 |
m_Format = xml.getStringProperty("format"); |
|
245 |
m_SRS = xml.getStringProperty("srs"); |
|
246 |
|
|
247 |
String claseStr = null; |
|
248 |
if (xml.contains("raster.class")) { |
|
249 |
claseStr = xml.getStringProperty("raster.class"); |
|
250 |
} |
|
251 |
if(status!=null) |
|
252 |
status.setXMLEntity(xml, this); |
|
253 |
else{ |
|
254 |
|
|
255 |
//Cuando cargamos un proyecto |
|
256 |
|
|
257 |
if(claseStr!=null && !claseStr.equals("")){ |
|
258 |
try{ |
|
259 |
Class clase = Class.forName(claseStr); |
|
260 |
Constructor constr = clase.getConstructor(null); |
|
261 |
status = (StatusRasterInterface)constr.newInstance(null); |
|
262 |
if(status!=null) |
|
263 |
status.setXMLEntity(xml, this); |
|
264 |
}catch(ClassNotFoundException exc){ |
|
265 |
exc.printStackTrace(); |
|
266 |
}catch(InstantiationException exc){ |
|
267 |
exc.printStackTrace(); |
|
268 |
}catch(IllegalAccessException exc){ |
|
269 |
exc.printStackTrace(); |
|
270 |
}catch(NoSuchMethodException exc){ |
|
271 |
exc.printStackTrace(); |
|
272 |
}catch(InvocationTargetException exc){ |
|
273 |
exc.printStackTrace(); |
|
274 |
} |
|
275 |
} |
|
276 |
} |
|
277 |
firstLoad = true; |
|
278 |
} |
|
279 |
|
|
280 |
/** |
|
281 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#queryByPoint(com.iver.cit.gvsig.fmap.operations.QueriedPoint) |
|
282 |
*/ |
|
283 |
public String queryByPoint(Point p) throws DriverException { |
|
284 |
FeatureInfoQuery query = new FeatureInfoQuery(lastMapQuery); |
|
285 |
query.setFeatureCount(Integer.MAX_VALUE); |
|
286 |
query.setX((int) p.getX()); |
|
287 |
query.setY((int) p.getY()); |
|
288 |
query.setInfoQuery(infoLayerQuery); |
|
289 |
|
|
290 |
try { |
|
291 |
query.setInfoFormat(selectFormat()); |
|
292 |
|
|
293 |
return new String(getWmsClient().doFeatureInfo(query)); |
|
294 |
} catch (WMSException e) { |
|
295 |
return "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><exception>" + |
|
296 |
e.getMessage() + "</exception>"; |
|
297 |
} catch (ValidationException e) { |
|
298 |
/* |
|
299 |
* TODO Las traducciones en este m?todo han de ser |
|
300 |
* las mismas que en el m?todo de dibujado |
|
301 |
*/ |
|
302 |
throw new DriverException("No se reconoce el formato de la respuesta", |
|
303 |
e); |
|
304 |
} catch (UnsupportedVersionException e) { |
|
305 |
throw new DriverException("Conflicto de versiones", e); |
|
306 |
} catch (IOException e) { |
|
307 |
throw new DriverException("Error en la conexi?n", e); |
|
308 |
} catch (com.iver.wmsclient.WMSException e) { |
|
309 |
throw new DriverException(e.getMessage(), e); |
|
310 |
} catch (NoSuchFieldException e) { |
|
311 |
throw new RuntimeException( |
|
312 |
"No se rellenaron todos los campos de la petici?n"); |
|
313 |
} |
|
314 |
} |
|
315 |
|
|
316 |
/** |
|
317 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#getFullExtent() |
|
318 |
*/ |
|
319 |
public Rectangle2D getFullExtent() throws DriverException { |
|
320 |
return fullExtent; |
|
321 |
} |
|
322 |
|
|
323 |
/** |
|
324 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#draw(java.awt.image.BufferedImage, |
|
325 |
* java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, |
|
326 |
* com.iver.cit.gvsig.fmap.operations.Cancellable) |
|
327 |
*/ |
|
328 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
|
329 |
Cancellable cancel,double scale) throws DriverException { |
|
330 |
if (isWithinScale(scale)){ |
|
331 |
try { |
|
332 |
MapQuery mapQuery = getWmsClient().createQuery(); |
|
333 |
mapQuery.setBBOX(viewPort.getAdjustedExtent()); |
|
334 |
mapQuery.setFormat(m_Format); |
|
335 |
mapQuery.setHeight(viewPort.getImageHeight()); |
|
336 |
|
|
337 |
// System.err.println("m_Mapa.getHeight() = " + m_Mapa.getHeight()); |
|
338 |
mapQuery.setLayers(layerQuery); |
|
339 |
mapQuery.setSRS(m_SRS); |
|
340 |
mapQuery.setStyles(""); |
|
341 |
mapQuery.setWidth(viewPort.getImageWidth()); |
|
342 |
mapQuery.setExceptions("application/vnd.ogc.se_xml"); |
|
343 |
|
|
344 |
byte[] bytes; |
|
345 |
lastMapQuery = mapQuery; |
|
346 |
bytes = getWmsClient().doMapQuery(lastMapQuery); |
|
347 |
|
|
348 |
ByteArrayInputStream inbytes = new ByteArrayInputStream(bytes); |
|
349 |
//BufferedImage tempImg = ImageIO.read(inbytes); |
|
350 |
// LWS Cambio de estrategia en el posicionado para la impresi?n. |
|
351 |
Point2D p2=new Point2D.Double(viewPort.getAdjustedExtent().getX(), viewPort.getAdjustedExtent().getMaxY()); //viewPort.getOffset(); |
|
352 |
viewPort.getAffineTransform().transform(p2, p2); |
|
353 |
|
|
354 |
rasterProcess(g, viewPort, createTemp(inbytes, "wms_Query", viewPort)); |
|
355 |
if(status!=null && firstLoad){ |
|
356 |
status.applyStatus(this); |
|
357 |
firstLoad = false; |
|
358 |
} |
|
359 |
|
|
360 |
//g.drawImage(tempImg,(int)p2.getX(),(int)p2.getY(), null); |
|
361 |
} catch (ValidationException e) { |
|
362 |
throw new DriverException("No se reconoce el formato de la respuesta", |
|
363 |
e); |
|
364 |
} catch (UnsupportedVersionException e) { |
|
365 |
throw new DriverException("Conflicto de versiones", e); |
|
366 |
} catch (IOException e) { |
|
367 |
throw new DriverException("Error en la conexi?n", e); |
|
368 |
} catch (com.iver.wmsclient.WMSException e) { |
|
369 |
throw new DriverException(e.getMessage(), e); |
|
370 |
} catch (NoSuchFieldException e) { |
|
371 |
throw new RuntimeException( |
|
372 |
"No se rellenaron todos los campos de la petici?n"); |
|
373 |
} |
|
374 |
} |
|
375 |
} |
|
376 |
|
|
377 |
/** |
|
378 |
* Crea un fichero temporal con los datos obtenidos |
|
379 |
* @param img |
|
380 |
* @param name |
|
381 |
* @return |
|
382 |
* @throws IOException |
|
383 |
*/ |
|
384 |
public File createTemp(ByteArrayInputStream is, String name, ViewPort vp) throws IOException{ |
|
385 |
File f = null; |
|
386 |
File tfw = null; |
|
387 |
try{ |
|
388 |
f = TempFileManager.createTempFile(name, "tmp"); |
|
389 |
tfw = new File(f.getAbsolutePath().substring(0, f.getAbsolutePath().lastIndexOf("/"))+File.separator+f.getName()+ ".tfw"); |
|
390 |
f.deleteOnExit(); |
|
391 |
tfw.deleteOnExit(); |
|
392 |
} catch (IOException io) { |
|
393 |
io.printStackTrace(); |
|
394 |
} |
|
395 |
|
|
396 |
//Generamos un world file para gdal |
|
397 |
DataOutputStream dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(tfw)) ); |
|
398 |
dos.writeBytes((vp.getAdjustedExtent().getMaxX() - vp.getAdjustedExtent().getMinX())/vp.getImageWidth()+"\n"); |
|
399 |
dos.writeBytes("0.0\n"); |
|
400 |
dos.writeBytes("0.0\n"); |
|
401 |
dos.writeBytes((vp.getAdjustedExtent().getMaxY() - vp.getAdjustedExtent().getMinY())/vp.getImageHeight()+"\n"); |
|
402 |
dos.writeBytes(""+vp.getAdjustedExtent().getMinX()+"\n"); |
|
403 |
dos.writeBytes(""+vp.getAdjustedExtent().getMinY()+"\n"); |
|
404 |
dos.close(); |
|
405 |
|
|
406 |
//Salvamos la imagen a disco |
|
407 |
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(f)); |
|
408 |
int data = is.read(); |
|
409 |
while(data != -1){ |
|
410 |
bos.write(data); |
|
411 |
data = is.read(); |
|
412 |
} |
|
413 |
bos.close(); |
|
414 |
return f; |
|
415 |
} |
|
416 |
|
|
417 |
/** |
|
418 |
* Draws using PxRaster |
|
419 |
* |
|
420 |
* Pinta usando PxRaster |
|
421 |
*/ |
|
422 |
private void rasterProcess(Graphics2D g, ViewPort viewPort, File file) { |
|
423 |
|
|
424 |
//Creamos el PxRaster |
|
425 |
rasterFile = new GdalFile(viewPort.getProjection(), file.getAbsolutePath()); |
|
426 |
Extent e = new Extent(viewPort.getAdjustedExtent()); |
|
427 |
raster = new PxRaster(rasterFile, null, rasterFile.getExtent()); |
|
428 |
|
|
429 |
//Recuperamos la pila de filtros si ya hubiese sido cargado antes |
|
430 |
|
|
431 |
if(this.filterStack!=null) |
|
432 |
raster.filterStack = this.filterStack; |
|
433 |
|
|
434 |
raster.setTransparency(false); |
|
435 |
|
|
436 |
//Creamos el viewportdata |
|
437 |
|
|
438 |
ViewPortData vpData = new ViewPortData(viewPort.getProjection(), e, viewPort.getImageSize() ); |
|
439 |
vpData.setMat(viewPort.getAffineTransform()); |
|
440 |
|
|
441 |
//Asignamos transparencia y orden de bandas |
|
442 |
if(this.transparency==-1 && !firstLoad); |
|
443 |
else |
|
444 |
raster.setTransparency(this.transparency); |
|
445 |
|
|
446 |
raster.setBand(GeoRasterFile.RED_BAND,rband); |
|
447 |
raster.setBand(GeoRasterFile.GREEN_BAND, gband); |
|
448 |
raster.setBand(GeoRasterFile.BLUE_BAND, bband); |
|
449 |
|
|
450 |
//Despues del primer pxRaster asignamos el stackManager guardado para los siguientes. |
|
451 |
//Con esto conseguimos asignar los cambios que se hayan producido desde el cuadro de |
|
452 |
//propiedades cuando creamos un nuevo pxRaster |
|
453 |
|
|
454 |
if(this.stackManager != null) |
|
455 |
raster.setStackManager(this.stackManager); |
|
456 |
|
|
457 |
raster.draw(g, vpData); |
|
458 |
|
|
459 |
//En el primer pxRaster de una imagen obtenemos el Stack Manager para poder modificarlo |
|
460 |
//si queremos desde las propiedades |
|
461 |
|
|
462 |
if(this.stackManager == null) |
|
463 |
this.stackManager = raster.getStackManager(); |
|
464 |
|
|
465 |
if(this.filterStack == null) |
|
466 |
this.filterStack = raster.filterStack; |
|
467 |
} |
|
468 |
|
|
469 |
/** |
|
470 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D, |
|
471 |
* com.iver.cit.gvsig.fmap.ViewPort, |
|
472 |
* com.iver.cit.gvsig.fmap.operations.Cancellable) |
|
473 |
*/ |
|
474 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale) |
|
475 |
throws DriverException { |
|
476 |
if (isVisible() && isWithinScale(scale)){ |
|
477 |
isPrinting = true; |
|
478 |
if (!mustTilePrint) { |
|
479 |
draw(null, g, viewPort, cancel,scale); |
|
480 |
} else { |
|
481 |
// Para no pedir imagenes demasiado grandes, vamos |
|
482 |
// a hacer lo mismo que hace EcwFile: chunkear. |
|
483 |
// Llamamos a drawView con cuadraditos m?s peque?os |
|
484 |
// del BufferedImage ni caso, cuando se imprime viene con null |
|
485 |
Tiling tiles = new Tiling(maxTilePrintWidth, maxTilePrintHeight, g.getClipRect()); |
|
486 |
tiles.setAffineTransform((AffineTransform) viewPort.getAffineTransform().clone()); |
|
487 |
for (int tileNr=0; tileNr < tiles.getNumTiles(); tileNr++) { |
|
488 |
// Parte que dibuja |
|
489 |
try { |
|
490 |
ViewPort vp = tiles.getTileViewPort(viewPort, tileNr); |
|
491 |
draw(null, g, vp, cancel,scale); |
|
492 |
} catch (NoninvertibleTransformException e) { |
|
493 |
// TODO Auto-generated catch block |
|
494 |
e.printStackTrace(); |
|
495 |
} |
|
496 |
} |
|
497 |
} |
|
498 |
isPrinting = false; |
|
499 |
} |
|
500 |
} |
|
501 |
|
|
502 |
public void _print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale) |
|
503 |
throws DriverException { |
|
504 |
draw(null, g, viewPort, cancel,scale); |
|
505 |
} |
|
506 |
|
|
507 |
/** |
|
508 |
* Devuelve el WMSClient. |
|
509 |
* |
|
510 |
* @return WMSClient |
|
511 |
* |
|
512 |
* @throws IllegalStateException |
|
513 |
* @throws ValidationException |
|
514 |
* @throws UnsupportedVersionException |
|
515 |
* @throws IOException |
|
516 |
*/ |
|
517 |
private WMSClient getWmsClient() |
|
518 |
throws IllegalStateException, ValidationException, |
|
519 |
UnsupportedVersionException, IOException { |
|
520 |
if (wmsClient == null) { |
|
521 |
wmsClient = WMSClientFactory.getClient(host); |
|
522 |
} |
|
523 |
|
|
524 |
return wmsClient; |
|
525 |
} |
|
526 |
|
|
527 |
/** |
|
528 |
* Devuelve el URL. |
|
529 |
* |
|
530 |
* @return URL. |
|
531 |
*/ |
|
532 |
public URL getHost() { |
|
533 |
return host; |
|
534 |
} |
|
535 |
|
|
536 |
/** |
|
537 |
* Inserta el URL. |
|
538 |
* |
|
539 |
* @param host URL. |
|
540 |
*/ |
|
541 |
public void setHost(URL host) { |
|
542 |
this.host = host; |
|
543 |
} |
|
544 |
|
|
545 |
/** |
|
546 |
* Devuelve la informaci?n de la consulta. |
|
547 |
* |
|
548 |
* @return String. |
|
549 |
*/ |
|
550 |
public String getInfoLayerQuery() { |
|
551 |
return infoLayerQuery; |
|
552 |
} |
|
553 |
|
|
554 |
/** |
|
555 |
* Inserta la informaci?n de la consulta. |
|
556 |
* |
|
557 |
* @param infoLayerQuery String. |
|
558 |
*/ |
|
559 |
public void setInfoLayerQuery(String infoLayerQuery) { |
|
560 |
this.infoLayerQuery = infoLayerQuery; |
|
561 |
} |
|
562 |
|
|
563 |
/** |
|
564 |
* Devuelve la consulta. |
|
565 |
* |
|
566 |
* @return String. |
|
567 |
*/ |
|
568 |
public String getLayerQuery() { |
|
569 |
return layerQuery; |
|
570 |
} |
|
571 |
|
|
572 |
/** |
|
573 |
* Inserta la consulta. |
|
574 |
* |
|
575 |
* @param layerQuery consulta. |
|
576 |
*/ |
|
577 |
public void setLayerQuery(String layerQuery) { |
|
578 |
this.layerQuery = layerQuery; |
|
579 |
} |
|
580 |
|
|
581 |
/** |
|
582 |
* Devuelve el formato. |
|
583 |
* |
|
584 |
* @return Formato. |
|
585 |
*/ |
|
586 |
public String getFormat() { |
|
587 |
return m_Format; |
|
588 |
} |
|
589 |
|
|
590 |
/** |
|
591 |
* Inserta el formato. |
|
592 |
* |
|
593 |
* @param format Formato. |
|
594 |
*/ |
|
595 |
public void setFormat(String format) { |
|
596 |
m_Format = format; |
|
597 |
} |
|
598 |
|
|
599 |
/** |
|
600 |
* Devuelve el SRS. |
|
601 |
* |
|
602 |
* @return SRS. |
|
603 |
*/ |
|
604 |
public String getSRS() { |
|
605 |
return m_SRS; |
|
606 |
} |
|
607 |
|
|
608 |
/** |
|
609 |
* Inserta el SRS. |
|
610 |
* |
|
611 |
* @param m_srs SRS. |
|
612 |
*/ |
|
613 |
public void setSRS(String m_srs) { |
|
614 |
m_SRS = m_srs; |
|
615 |
} |
|
616 |
|
|
617 |
/** |
|
618 |
* Inserta la extensi?n total de la capa. |
|
619 |
* |
|
620 |
* @param fullExtent Rect?ngulo. |
|
621 |
*/ |
|
622 |
public void setFullExtent(Rectangle2D fullExtent) { |
|
623 |
this.fullExtent = fullExtent; |
|
624 |
} |
|
625 |
|
|
626 |
public Hashtable getProperties() { |
|
627 |
Hashtable info = new Hashtable(); |
|
628 |
info.put("layerName", getLayerQuery()); |
|
629 |
info.put("host", getHost()); |
|
630 |
info.put("srs", getSRS()); |
|
631 |
info.put("format", getFormat()); |
|
632 |
|
|
633 |
return info; |
|
634 |
} |
|
635 |
|
|
636 |
/** |
|
637 |
* Asignar el estado del raster |
|
638 |
* @param status |
|
639 |
*/ |
|
640 |
public void setStatus(StatusRasterInterface status){ |
|
641 |
this.status = status; |
|
642 |
} |
|
643 |
|
|
644 |
/** |
|
645 |
* Obtiene el estado del raster |
|
646 |
* @return |
|
647 |
*/ |
|
648 |
public StatusRasterInterface getStatus(){ |
|
649 |
return this.status; |
|
650 |
} |
|
651 |
|
|
652 |
/* (non-Javadoc) |
|
653 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getAttributes() |
|
654 |
*/ |
|
655 |
public ArrayList getAttributes() { |
|
656 |
if(rasterFile != null){ |
|
657 |
ArrayList attr = new ArrayList(); |
|
658 |
String dataType = "Byte"; |
|
659 |
if (rasterFile.getDataType() == DataBuffer.TYPE_BYTE) dataType = "Byte"; |
|
660 |
else if (rasterFile.getDataType() == DataBuffer.TYPE_SHORT) |
|
661 |
dataType = "Short"; |
|
662 |
else if (rasterFile.getDataType() == DataBuffer.TYPE_USHORT) |
|
663 |
dataType = "Unsigned Short"; |
|
664 |
else if (rasterFile.getDataType() == DataBuffer.TYPE_INT) |
|
665 |
dataType = "Integer"; |
|
666 |
else if (rasterFile.getDataType() == DataBuffer.TYPE_FLOAT) |
|
667 |
dataType = "Float"; |
|
668 |
else if (rasterFile.getDataType() == DataBuffer.TYPE_DOUBLE) |
|
669 |
dataType = "Double"; |
|
670 |
else |
|
671 |
dataType = "Unknown"; |
|
672 |
Object [][] a = { |
|
673 |
{"Filename",rasterFile.getName().substring(rasterFile.getName().lastIndexOf("/")+1, rasterFile.getName().length())}, |
|
674 |
{"Filesize",new Long(rasterFile.getFileSize())}, |
|
675 |
{"Width",new Integer(rasterFile.getWidth())}, |
|
676 |
{"Height", new Integer(rasterFile.getHeight())}, |
|
677 |
{"Bands", new Integer(rasterFile.getBandCount())} |
|
678 |
//{"BandDataType", dataType} |
|
679 |
}; |
|
680 |
for (int i=0; i<a.length; i++){ |
|
681 |
System.out.println("===> "+a[i][0]+" "+a[i][1]); |
|
682 |
attr.add(a[i]); |
|
683 |
} |
|
684 |
return attr; |
|
685 |
} |
|
686 |
return null; |
|
687 |
} |
|
688 |
/* (non-Javadoc) |
|
689 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getFilterStack() |
|
690 |
*/ |
|
691 |
public RasterFilterStack getFilterStack() { |
|
692 |
if(raster!=null) |
|
693 |
return raster.filterStack; |
|
694 |
return null; |
|
695 |
} |
|
696 |
/* (non-Javadoc) |
|
697 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getHeight() |
|
698 |
*/ |
|
699 |
public double getHeight() { |
|
700 |
if(getGeoRasterFile() != null) |
|
701 |
return getGeoRasterFile().getHeight(); |
|
702 |
else |
|
703 |
return 0; |
|
704 |
} |
|
705 |
/* (non-Javadoc) |
|
706 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getMaxX() |
|
707 |
*/ |
|
708 |
public double getMaxX() { |
|
709 |
if(getPxRaster() != null) |
|
710 |
return getPxRaster().getExtent().getMax().getX(); |
|
711 |
else |
|
712 |
return 0; |
|
713 |
} |
|
714 |
/* (non-Javadoc) |
|
715 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getMaxY() |
|
716 |
*/ |
|
717 |
public double getMaxY() { |
|
718 |
if(getPxRaster() != null) |
|
719 |
return getPxRaster().getExtent().getMax().getY(); |
|
720 |
else |
|
721 |
return 0; |
|
722 |
} |
|
723 |
/* (non-Javadoc) |
|
724 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getMinX() |
|
725 |
*/ |
|
726 |
public double getMinX() { |
|
727 |
if(getPxRaster() != null) |
|
728 |
return getPxRaster().getExtent().getMin().getX(); |
|
729 |
else |
|
730 |
return 0; |
|
731 |
} |
|
732 |
/* (non-Javadoc) |
|
733 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getMinY() |
|
734 |
*/ |
|
735 |
public double getMinY() { |
|
736 |
if(getPxRaster() != null) |
|
737 |
return getPxRaster().getExtent().getMin().getY(); |
|
738 |
else |
|
739 |
return 0; |
|
740 |
} |
|
741 |
/* (non-Javadoc) |
|
742 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getPixel(double, double) |
|
743 |
*/ |
|
744 |
public int[] getPixel(double wcx, double wcy) { |
|
745 |
if(getPxRaster() != null) |
|
746 |
return getPxRaster().getPixel(wcx, wcy); |
|
747 |
else |
|
748 |
return null; |
|
749 |
} |
|
750 |
/* (non-Javadoc) |
|
751 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getSource() |
|
752 |
*/ |
|
753 |
public RasterAdapter getSource() { |
|
754 |
// TODO Auto-generated method stub |
|
755 |
return null; |
|
756 |
} |
|
757 |
/* (non-Javadoc) |
|
758 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#getWidth() |
|
759 |
*/ |
|
760 |
public double getWidth() { |
|
761 |
if(getGeoRasterFile() != null) |
|
762 |
return getGeoRasterFile().getWidth(); |
|
763 |
else |
|
764 |
return 0; |
|
765 |
} |
|
766 |
/* (non-Javadoc) |
|
767 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#setBand(int, int) |
|
768 |
*/ |
|
769 |
public void setBand(int flag, int nBand) { |
|
770 |
switch(flag){ |
|
771 |
case GeoRasterFile.RED_BAND:setBandR(nBand);break; |
|
772 |
case GeoRasterFile.GREEN_BAND:setBandG(nBand);break; |
|
773 |
case GeoRasterFile.BLUE_BAND:setBandB(nBand);break; |
|
774 |
} |
|
775 |
} |
|
776 |
/* (non-Javadoc) |
|
777 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#setFilterStack(org.cresques.io.raster.RasterFilterStack) |
|
778 |
*/ |
|
779 |
public void setFilterStack(RasterFilterStack stack) { |
|
780 |
this.filterStack = stack; |
|
781 |
} |
|
782 |
/* (non-Javadoc) |
|
783 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#setPos(int, int) |
|
784 |
*/ |
|
785 |
public void setPos(int x, int y) { |
|
786 |
this.posX = x; |
|
787 |
this.posY = y; |
|
788 |
} |
|
789 |
|
|
790 |
/* (non-Javadoc) |
|
791 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#setPosWC(double, double) |
|
792 |
*/ |
|
793 |
public void setPosWC(double x, double y) { |
|
794 |
this.posXWC = x; |
|
795 |
this.posYWC = y; |
|
796 |
} |
|
797 |
|
|
798 |
/* (non-Javadoc) |
|
799 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#setRGB(int, int, int) |
|
800 |
*/ |
|
801 |
public void setRGB(int r, int g, int b) { |
|
802 |
this.r = r; |
|
803 |
this.g = g; |
|
804 |
this.b = b; |
|
805 |
} |
|
806 |
/* (non-Javadoc) |
|
807 |
* @see com.iver.cit.gvsig.fmap.layers.RasterOperations#setSource(com.iver.cit.gvsig.fmap.layers.RasterAdapter) |
|
808 |
*/ |
|
809 |
public void setSource(RasterAdapter ra) { |
|
810 |
// TODO Auto-generated method stub |
|
811 |
|
|
812 |
} |
|
813 |
/** |
|
814 |
* @return Returns the raster. |
|
815 |
*/ |
|
816 |
public PxRaster getPxRaster() { |
|
817 |
return raster; |
|
818 |
} |
|
819 |
/** |
|
820 |
* @return Returns the rasterFile. |
|
821 |
*/ |
|
822 |
public GeoRasterFile getGeoRasterFile() { |
|
823 |
return rasterFile; |
|
824 |
} |
|
825 |
|
|
826 |
public void setTransparency(int trans) { |
|
827 |
this.transparency = trans; |
|
828 |
} |
|
829 |
|
|
830 |
/** |
|
831 |
* Sets the R-band. |
|
832 |
* |
|
833 |
* Asigna la banda R. |
|
834 |
* @param r |
|
835 |
*/ |
|
836 |
public void setBandR(int r){ |
|
837 |
this.rband = r; |
|
838 |
} |
|
839 |
|
|
840 |
/** |
|
841 |
* Sets the G-band. |
|
842 |
* |
|
843 |
* Asigna la banda G |
|
844 |
* @param g |
|
845 |
*/ |
|
846 |
public void setBandG(int g){ |
|
847 |
this.gband = g; |
|
848 |
} |
|
849 |
|
|
850 |
/** |
|
851 |
* Sets the B-band. |
|
852 |
* |
|
853 |
* Asigna la banda B |
|
854 |
* @param b |
|
855 |
*/ |
|
856 |
public void setBandB(int b){ |
|
857 |
this.bband = b; |
|
858 |
} |
|
859 |
|
|
860 |
} |
|
0 | 861 |
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/gui/toc/WMSPropsRaster.java | ||
---|---|---|
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 com.iver.cit.gvsig.gui.toc; |
|
42 |
|
|
43 |
import java.awt.event.ActionEvent; |
|
44 |
|
|
45 |
import javax.swing.JMenuItem; |
|
46 |
|
|
47 |
import org.cresques.io.GeoRasterFile; |
|
48 |
import org.cresques.io.raster.RasterFilterStackManager; |
|
49 |
import org.cresques.px.PxRaster; |
|
50 |
import org.cresques.ui.raster.BandSetupPanel; |
|
51 |
import org.cresques.ui.raster.EnhancedPanel; |
|
52 |
import org.cresques.ui.raster.FilterRasterDialogPanel; |
|
53 |
import org.cresques.ui.raster.RasterTransparencyPanel; |
|
54 |
|
|
55 |
import com.iver.andami.PluginServices; |
|
56 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
57 |
import com.iver.cit.gvsig.fmap.layers.FLyrWMS; |
|
58 |
import com.iver.cit.gvsig.gui.dialogs.PropertiesWMSDialog; |
|
59 |
|
|
60 |
/** |
|
61 |
* |
|
62 |
* @author Nacho Brodin (brodin_ign@gva.es) |
|
63 |
*/ |
|
64 |
public class WMSPropsRaster extends TocMenuEntry { |
|
65 |
private JMenuItem propsMenuItem; |
|
66 |
FLayer lyr = null; |
|
67 |
private PropertiesWMSDialog propsDialog = null; |
|
68 |
private BandSetupPanel bandSetup = null; |
|
69 |
|
|
70 |
public void initialize(FPopupMenu m) { |
|
71 |
super.initialize(m); |
|
72 |
|
|
73 |
if (isTocItemBranch()) { |
|
74 |
lyr = getNodeLayer(); |
|
75 |
// Opcciones para capas WCS |
|
76 |
if ((lyr instanceof FLyrWMS)) { |
|
77 |
propsMenuItem = new JMenuItem(PluginServices.getText(this, "propiedades_raster")); |
|
78 |
getMenu().add( propsMenuItem ); |
|
79 |
propsMenuItem.setFont(FPopupMenu.theFont); |
|
80 |
getMenu().setEnabled(true); |
|
81 |
//getMenu().addSeparator(); |
|
82 |
//Cambio color |
|
83 |
propsMenuItem.addActionListener(this); |
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
87 |
/* (non-Javadoc) |
|
88 |
* @see com.iver.cit.gvsig.gui.toc.TocMenuEntry#execute(com.iver.cit.gvsig.gui.toc.ITocItem) |
|
89 |
*/ |
|
90 |
public void actionPerformed(ActionEvent e) { |
|
91 |
lyr = getNodeLayer(); |
|
92 |
|
|
93 |
if(lyr instanceof FLyrWMS && ((FLyrWMS)lyr).getPxRaster()!=null){ |
|
94 |
RasterFilterStackManager stackManager = null; |
|
95 |
|
|
96 |
FLyrWMS layer = (FLyrWMS)lyr; |
|
97 |
|
|
98 |
stackManager = new RasterFilterStackManager(layer.getFilterStack()); |
|
99 |
|
|
100 |
int[][] rangeR = stackManager.getTransparecyR(); |
|
101 |
int[][] rangeG = stackManager.getTransparecyG(); |
|
102 |
int[][] rangeB = stackManager.getTransparecyB(); |
|
103 |
|
|
104 |
propsDialog = new PropertiesWMSDialog(layer, rangeR, rangeG, rangeB); |
|
105 |
|
|
106 |
int alpha = layer.getPxRaster().getAlpha(); |
|
107 |
|
|
108 |
bandSetup = ((FilterRasterDialogPanel)propsDialog.getContentPane()).getBandSetup(); |
|
109 |
GeoRasterFile[] files = layer.getPxRaster().getFiles(); |
|
110 |
bandSetup.addFiles(files); |
|
111 |
for(int i=0; i< files.length;i++) |
|
112 |
propsDialog.addNumBands(files[i].getBandCount()); |
|
113 |
|
|
114 |
PxRaster px = layer.getPxRaster(); |
|
115 |
int posR = 0, posG = 0, posB = 0; |
|
116 |
|
|
117 |
for(int i=0;i<px.getPosFile(GeoRasterFile.RED_BAND);i++) |
|
118 |
posR += files[i].getBandCount(); |
|
119 |
posR += px.getBand(GeoRasterFile.RED_BAND); |
|
120 |
|
|
121 |
for(int i=0;i<px.getPosFile(GeoRasterFile.GREEN_BAND);i++) |
|
122 |
posG += files[i].getBandCount(); |
|
123 |
posG += px.getBand(GeoRasterFile.GREEN_BAND); |
|
124 |
|
|
125 |
for(int i=0;i<px.getPosFile(GeoRasterFile.BLUE_BAND);i++) |
|
126 |
posB += files[i].getBandCount(); |
|
127 |
posB += px.getBand(GeoRasterFile.BLUE_BAND); |
|
128 |
|
|
129 |
|
|
130 |
bandSetup.assignBand(posR, GeoRasterFile.RED_BAND); |
|
131 |
bandSetup.assignBand(posG, GeoRasterFile.GREEN_BAND); |
|
132 |
bandSetup.assignBand(posB, GeoRasterFile.BLUE_BAND); |
|
133 |
|
|
134 |
//Asignaci?n del alpha actual de la imagen al dialogo |
|
135 |
RasterTransparencyPanel rasterTrans = ((FilterRasterDialogPanel)propsDialog.getContentPane()).getTransparencyPanel(); |
|
136 |
rasterTrans.setOpacity(alpha); |
|
137 |
|
|
138 |
//Asignaci?n del porcentaje de recorte actual de la imagen al dialogo |
|
139 |
EnhancedPanel pEnhan = ((FilterRasterDialogPanel)propsDialog.getContentPane()).getEnhancedPanel(); |
|
140 |
|
|
141 |
propsDialog.setRasterFilterStackManager(stackManager); |
|
142 |
int tail = 0; |
|
143 |
if( pEnhan != null && |
|
144 |
stackManager.getStackStats() != null){ |
|
145 |
tail = (int)(stackManager.getStackStats().tailPercent*200); |
|
146 |
pEnhan.setPercentTail(tail); |
|
147 |
} |
|
148 |
if(stackManager.isActive(stackManager.getTypeFilter("enhanced"))) |
|
149 |
pEnhan.setSelectedFilter(1); |
|
150 |
else |
|
151 |
pEnhan.setSelectedFilter(0); |
|
152 |
|
|
153 |
propsDialog.readStat(); |
|
154 |
|
|
155 |
PluginServices.getMDIManager().addView(propsDialog); |
|
156 |
} |
|
157 |
} |
|
158 |
} |
|
0 | 159 |
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/gui/wizard/WizardWMS.java | ||
---|---|---|
49 | 49 |
import java.awt.geom.Rectangle2D; |
50 | 50 |
import java.net.MalformedURLException; |
51 | 51 |
import java.net.URL; |
52 |
import java.util.ArrayList; |
|
53 |
import java.util.HashSet; |
|
54 |
import java.util.Iterator; |
|
55 |
import java.util.TreeSet; |
|
56 | 52 |
|
57 | 53 |
import javax.swing.DefaultComboBoxModel; |
58 |
import javax.swing.DefaultListModel; |
|
59 | 54 |
import javax.swing.JPanel; |
60 |
import javax.swing.JTextField; |
|
61 | 55 |
import javax.swing.tree.TreePath; |
62 | 56 |
|
63 | 57 |
import org.apache.log4j.Logger; |
64 | 58 |
|
65 | 59 |
import com.iver.andami.PluginServices; |
66 | 60 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
67 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
|
|
61 |
import com.iver.cit.gvsig.fmap.layers.FLyrWMS;
|
|
68 | 62 |
import com.iver.cit.gvsig.gui.WMSDataSourceAdapter; |
69 | 63 |
import com.iver.cit.gvsig.gui.WizardPanel; |
70 | 64 |
import com.iver.cit.gvsig.gui.panels.WMSParamsPanel; |
71 |
import com.iver.cit.gvsig.gui.wizards.FormatListModel; |
|
72 |
import com.iver.cit.gvsig.gui.wizards.LayerInfo; |
|
73 |
import com.iver.cit.gvsig.gui.wizards.LayerListModel; |
|
74 |
import com.iver.cit.gvsig.gui.wizards.LayerTreeModel; |
|
75 | 65 |
import com.iver.cit.gvsig.gui.wizards.WizardData; |
76 | 66 |
import com.iver.cit.gvsig.gui.wizards.WizardDataSource; |
77 | 67 |
import com.iver.cit.gvsig.gui.wizards.WizardListener; |
... | ... | |
572 | 562 |
*/ |
573 | 563 |
public FLayer getLayer() { |
574 | 564 |
WizardWMS wms = this; |
575 |
return LayerFactory.createLayer(wms.getLayerName(), |
|
576 |
wms.getLayersRectangle(), wms.getHost(), |
|
577 |
wms.getFormat(), wms.getLayersQuery(), |
|
578 |
wms.getQueryableLayerQuery(), wms.getSRS()); |
|
565 |
FLyrWMS layer = new FLyrWMS(); |
|
566 |
layer.setHost(wms.getHost()); |
|
567 |
layer.setFullExtent(wms.getLayersRectangle()); |
|
568 |
layer.setFormat(wms.getFormat()); |
|
569 |
layer.setLayerQuery(wms.getLayersQuery()); |
|
570 |
layer.setInfoLayerQuery(wms.getQueryableLayerQuery()); |
|
571 |
layer.setSRS(wms.getSRS()); |
|
572 |
layer.setName(wms.getLayerName()); |
|
573 |
return layer; |
|
579 | 574 |
} |
580 | 575 |
|
581 | 576 |
/** |
branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/gui/dialogs/PropertiesWMSDialog.java | ||
---|---|---|
1 |
/* |
|
2 |
* Creado el 7-marzo-2005 |
|
3 |
*/ |
|
4 |
package com.iver.cit.gvsig.gui.dialogs; |
|
5 |
|
|
6 |
import java.awt.Container; |
|
7 |
import java.awt.event.ActionEvent; |
|
8 |
import java.awt.geom.Rectangle2D; |
|
9 |
import java.io.File; |
|
10 |
import java.util.ArrayList; |
|
11 |
import java.util.Vector; |
|
12 |
|
|
13 |
import javax.swing.JFileChooser; |
|
14 |
import javax.swing.JOptionPane; |
|
15 |
import javax.swing.JPanel; |
|
16 |
import javax.swing.filechooser.FileFilter; |
|
17 |
|
|
18 |
import org.cresques.cts.IProjection; |
|
19 |
import org.cresques.io.GeoRasterFile; |
|
20 |
import org.cresques.io.raster.RasterFilterStackManager; |
|
21 |
import org.cresques.px.Extent; |
|
22 |
import org.cresques.px.PxRaster; |
|
23 |
import org.cresques.ui.raster.BandSetupPanel; |
|
24 |
import org.cresques.ui.raster.EnhancedPanel; |
|
25 |
import org.cresques.ui.raster.FilterRasterDialogPanel; |
|
26 |
import org.cresques.ui.raster.RasterTransparencyPanel; |
|
27 |
|
|
28 |
import com.hardcode.driverManager.Driver; |
|
29 |
import com.hardcode.driverManager.DriverLoadException; |
|
30 |
import com.iver.andami.PluginServices; |
|
31 |
import com.iver.andami.messages.NotificationManager; |
|
32 |
import com.iver.andami.ui.mdiManager.View; |
|
33 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
|
34 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
35 |
import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
|
36 |
import com.iver.cit.gvsig.fmap.layers.FLyrWMS; |
|
37 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
|
38 |
import com.iver.cit.gvsig.fmap.layers.StatusLayerRaster; |
|
39 |
|
|
40 |
/** |
|
41 |
* <P> |
|
42 |
* Dialog for the properties of a WCS layer. It manages the avants and aplies |
|
43 |
* filters to the raster through the filter stack manager according to the user's |
|
44 |
* selection. This dialog contains some panels. |
|
45 |
* </P> |
|
46 |
* <UL> |
|
47 |
* <LI>Propierties</LI> |
|
48 |
* <LI>Band selection</LI> |
|
49 |
* <LI>Transparency</LI> |
|
50 |
* <LI>Enhancement</LI> |
|
51 |
* </UL> |
|
52 |
* @author Nacho Brodin (brodin_ign@gva.es) |
|
53 |
*/ |
|
54 |
public class PropertiesWMSDialog extends FilterRasterDialogPanel implements View { |
|
55 |
|
|
56 |
private FilterRasterDialogPanel contentPane = null; |
|
57 |
private JPanel propPanel = null; |
|
58 |
private IProjection currentProjection = null; |
|
59 |
private FLyrWMS fLayer = null; |
|
60 |
private static final int nprops = 11; |
|
61 |
private Object[][] props = null; |
|
62 |
private RasterFilterStackManager stackManager = null; |
|
63 |
private Status status = null; |
|
64 |
private StatusLayerRaster rasterStatus = null; |
|
65 |
private JFileChooser fileChooser = null; |
|
66 |
private String lastPath = new String("./"); |
|
67 |
private PxRaster px = null; |
|
68 |
private GeoRasterFile grf = null; |
|
69 |
|
|
70 |
/** |
|
71 |
* Class that holds the dialog state and restores the initial state if it |
|
72 |
* is cancelled. |
|
73 |
* @author Nacho Brodin <brodin_ign@gva.es> |
|
74 |
*/ |
|
75 |
class Status{ |
|
76 |
public String inicAlpha; |
|
77 |
public int bandR; |
|
78 |
public int bandG; |
|
79 |
public int bandB; |
|
80 |
private ArrayList filters = new ArrayList(); |
|
81 |
|
|
82 |
public Status(String alpha, int bandR, int bandG, int bandB){ |
|
83 |
this.inicAlpha = alpha; |
|
84 |
this.bandR = bandR; |
|
85 |
this.bandG = bandG; |
|
86 |
this.bandB = bandB; |
|
87 |
filters = stackManager.getStringsFromStack(); |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* Restaura el Estado salvado |
|
92 |
* @param status Estado |
|
93 |
*/ |
|
94 |
public void restoreStatus(PropertiesWMSDialog props){ |
|
95 |
//Devolvemos la pila de filtros al estado inicial |
|
96 |
/*if(stackManager != null) |
|
97 |
stackManager.deleteTempFilters();*/ |
|
98 |
|
|
99 |
//Devolvemos el alpha al estado inicial |
|
100 |
int opac = Integer.parseInt(status.inicAlpha); |
|
101 |
opac = (int)((opac*255)/100); |
|
102 |
fLayer.setTransparency(255-opac); |
|
103 |
|
|
104 |
if (fLayer != null) { |
|
105 |
fLayer.setBandR(bandR); |
|
106 |
fLayer.setBandG(bandG); |
|
107 |
fLayer.setBandB(bandB); |
|
108 |
} |
|
109 |
|
|
110 |
//Restauramos los filtros |
|
111 |
if(filters!=null) |
|
112 |
stackManager.createStackFromStrings(filters); |
|
113 |
|
|
114 |
fLayer.getFMap().invalidate(); |
|
115 |
|
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
public class DriverFileFilter extends FileFilter{ |
|
120 |
|
|
121 |
private Driver driver; |
|
122 |
|
|
123 |
public DriverFileFilter(String driverName) throws DriverLoadException{ |
|
124 |
driver = LayerFactory.getDM().getDriver(driverName); |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* @see javax.swing.filechooser.FileFilter#accept(java.io.File) |
|
129 |
*/ |
|
130 |
public boolean accept(File f) { |
|
131 |
if (f.isDirectory()) return true; |
|
132 |
if (driver instanceof RasterDriver){ |
|
133 |
return ((RasterDriver) driver).fileAccepted(f); |
|
134 |
}else{ |
|
135 |
throw new RuntimeException("Tipo no reconocido"); |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
/** |
|
140 |
* @see javax.swing.filechooser.FileFilter#getDescription() |
|
141 |
*/ |
|
142 |
public String getDescription() { |
|
143 |
return ((Driver) driver).getName(); |
|
144 |
} |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* Dialog window constructor. |
|
149 |
* |
|
150 |
* @param app |
|
151 |
*/ |
|
152 |
public PropertiesWMSDialog(FLyrWMS layer, int[][] rangeR, int[][] rangeG, int[][] rangeB){ |
|
153 |
super(); |
|
154 |
fLayer = layer; |
|
155 |
this.px = layer.getPxRaster(); |
|
156 |
this.grf = layer.getGeoRasterFile(); |
|
157 |
if(fLayer.getStatus()==null){ |
|
158 |
rasterStatus = new StatusLayerRaster(); |
|
159 |
fLayer.setStatus(rasterStatus); |
|
160 |
}else |
|
161 |
rasterStatus = (StatusLayerRaster)fLayer.getStatus(); |
|
162 |
initialize(); |
|
163 |
this.setRanges(rangeR, rangeG, rangeB); |
|
164 |
FilterRasterDialogPanel fr = ((FilterRasterDialogPanel)this.getContentPane()); |
|
165 |
fr.getBandSetup().getFileList().getJButtonAdd().setEnabled(false); |
|
166 |
fr.getBandSetup().getFileList().getJButtonRemove().setEnabled(false); |
|
167 |
this.setTranslation(); |
|
168 |
|
|
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* Asigna los textos a los paneles |
|
173 |
*/ |
|
174 |
private void setTranslation(){ |
|
175 |
this.getBandSetup().getFileList().getJButtonAdd().setText(PluginServices.getText(this,"Anadir")); |
|
176 |
this.getBandSetup().getFileList().getJButtonRemove().setText(PluginServices.getText(this,"Eliminar")); |
|
177 |
this.getBandSetup().getFileList().lbandasVisibles.setText(PluginServices.getText(this,"bandas")); |
|
178 |
|
|
179 |
RasterTransparencyPanel tpan = this.getTransparencyPanel(); |
|
180 |
|
|
181 |
tpan.lGreenValue.setText(PluginServices.getText(this,"Valor_verde")); |
|
182 |
tpan.lRedValue.setText(PluginServices.getText(this,"Valor_rojo")); |
|
183 |
tpan.lBlueValue.setText(PluginServices.getText(this,"Valor_azul")); |
|
184 |
tpan.getTransparencyCheck().setText(PluginServices.getText(this,"transparencia")); |
|
185 |
tpan.getOpacityCheck().setText(PluginServices.getText(this,"opacidad")); |
|
186 |
tpan.lRange.setText(PluginServices.getText(this,"usar_rango")); |
|
187 |
tpan.lPixelValue.setText(PluginServices.getText(this,"valor_pixel")+": 0 a 255"); |
|
188 |
|
|
189 |
EnhancedPanel ep = this.getEnhancedPanel(); |
|
190 |
ep.lLineal.setText(PluginServices.getText(this,"lineal_directo")); |
|
191 |
ep.lQueue.setText(PluginServices.getText(this,"recorte_colas")); |
|
192 |
ep.lWithoutEnhanced.setText(PluginServices.getText(this,"sin_realce")); |
|
193 |
ep.lCut.setText(PluginServices.getText(this,"recorte")); |
|
194 |
ep.lRemove.setText(PluginServices.getText(this,"eliminar_extremos")); |
|
195 |
|
|
196 |
//Recorremos los Tab y traducimos el nombre |
|
197 |
for(int i=0;i<this.getTab().getTabCount();i++){ |
|
198 |
if(this.getTab().getTitleAt(i).equals("Info")) |
|
199 |
this.getTab().setTitleAt(i,PluginServices.getText(this,"info")); |
|
200 |
if(this.getTab().getTitleAt(i).equals("Transparencia")) |
|
201 |
this.getTab().setTitleAt(i,PluginServices.getText(this,"Transparencia")); |
|
202 |
if(this.getTab().getTitleAt(i).equals("Bandas")) |
|
203 |
this.getTab().setTitleAt(i,PluginServices.getText(this,"bandas")); |
|
204 |
if(this.getTab().getTitleAt(i).equals("Realce")) |
|
205 |
this.getTab().setTitleAt(i,PluginServices.getText(this,"realce")); |
|
206 |
} |
|
207 |
|
|
208 |
this.getAcceptButton().setText(PluginServices.getText(this,"Aceptar")); |
|
209 |
this.getApplyButton().setText(PluginServices.getText(this,"Aplicar")); |
|
210 |
this.getCancelButton().setText(PluginServices.getText(this,"Cancelar")); |
|
211 |
} |
|
212 |
|
|
213 |
/** |
|
214 |
* Assigns a FLayerRaster |
|
215 |
* @param layer capa a asignar |
|
216 |
*/ |
|
217 |
public void setFLyrWMS(FLyrWMS layer){ |
|
218 |
fLayer = layer; |
|
219 |
} |
|
220 |
|
|
221 |
/** |
|
222 |
* Dialog window constructor. |
|
223 |
*/ |
|
224 |
public PropertiesWMSDialog() { |
|
225 |
initialize(); |
|
226 |
} |
|
227 |
|
|
228 |
/** |
|
229 |
* Loads the info panel data. |
|
230 |
*/ |
|
231 |
private void loadInfoData(){ |
|
232 |
Rectangle2D r = null; |
|
233 |
try{ |
|
234 |
r = fLayer.getFullExtent(); |
|
235 |
}catch(DriverException exc){ |
|
236 |
return; |
|
237 |
} |
|
238 |
if(fLayer!=null){ |
|
239 |
props = new Object[nprops][2]; |
|
240 |
props[0][0] = new String(PluginServices.getText(this,"Fichero_")); |
|
241 |
props[0][1] = grf.getName(); |
|
242 |
props[1][0] = new String(PluginServices.getText(this,"num_bandas")); |
|
243 |
props[1][1] = new String(String.valueOf( grf.getBandCount())); |
|
244 |
props[2][0] = new String(PluginServices.getText(this,"ancho_alto")); |
|
245 |
props[2][1] = (int)(r.getWidth())+" X "+(int)(r.getHeight()); |
|
246 |
props[3][0] = new String(PluginServices.getText(this,"formato")); |
|
247 |
props[3][1] = grf.getName().substring( |
|
248 |
grf.getName().lastIndexOf('.')+1, |
|
249 |
grf.getName().length()); |
|
250 |
props[4][0] = new String(PluginServices.getText(this,"tipo_dato")); |
|
251 |
String type = null; |
|
252 |
switch(grf.getDataType()){ |
|
253 |
case 0: type = new String("BYTE");break; |
|
254 |
case 1: type = new String("USHORT");break; |
|
255 |
case 2: type = new String("SHORT");break; |
|
256 |
case 3: type = new String("INT");break; |
|
257 |
case 4: type = new String("FLOAT");break; |
|
258 |
case 5: type = new String("DOUBLE");break; |
|
259 |
default: type = new String("UNDEFINED");break; |
|
260 |
} |
|
261 |
props[4][1] = type; |
|
262 |
props[5][0] = new String(PluginServices.getText(this,"coor_geograficas")); |
|
263 |
props[6][0] = new String(PluginServices.getText(this,"xmin")); |
|
264 |
props[6][1] = String.valueOf(px.getExtent().minX()); |
|
265 |
props[7][0] = new String(PluginServices.getText(this,"ymin")); |
|
266 |
props[7][1] = String.valueOf(px.getExtent().minY()); |
|
267 |
props[8][0] = new String(PluginServices.getText(this,"xmax")); |
|
268 |
props[8][1] = String.valueOf(px.getExtent().maxX()); |
|
269 |
props[9][0] = new String(PluginServices.getText(this,"ymax")); |
|
270 |
props[9][1] = String.valueOf(px.getExtent().maxY()); |
|
271 |
|
|
272 |
}else{ |
|
273 |
props = new Object[1][2]; |
|
274 |
props[0][0] = new String("No props"); |
|
275 |
props[0][1] = new String("-"); |
|
276 |
} |
|
277 |
|
|
278 |
} |
|
279 |
|
|
280 |
/** |
|
281 |
* A?ade bandas al contador de bandas del FilterRasterDialogPanel |
|
282 |
* @param numBands N?mero de bandas a a?adir |
|
283 |
*/ |
|
284 |
public void addNumBands(int numBands){ |
|
285 |
nbands += numBands; |
|
286 |
if(this.getTransparencyPanel() != null && this.getTransparencyPanel().getTRojo().isEnabled()) |
|
287 |
this.getTransparencyPanel().setActiveTransparencyControl(true); |
|
288 |
} |
|
289 |
|
|
290 |
/** |
|
291 |
* Inits the jDialog |
|
292 |
*/ |
|
293 |
private void initialize() { |
|
294 |
|
|
295 |
//this.setLayout(new FlowLayout()); |
|
296 |
|
|
297 |
setName("filterRaster"); |
|
298 |
|
|
299 |
this.loadInfoData(); |
|
300 |
super.init(props); |
|
301 |
//this.add(getContentPane()); |
|
302 |
|
|
303 |
this.setSize(486, 318); |
|
304 |
|
|
305 |
//contentPane.getAcceptButton().setEnabled(false); |
|
306 |
this.getAcceptButton().addActionListener(new java.awt.event.ActionListener() { |
|
307 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
|
308 |
acceptButtonActionPerformed(evt); |
|
309 |
closeJDialog(); |
|
310 |
} |
Also available in: Unified diff