root / trunk / libraries / libCq_CMS_praster / src / org / cresques / px / PxRaster.java @ 8026
History | View | Annotate | Download (55.1 KB)
1 | 8026 | nacho | /*
|
---|---|---|---|
2 | * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
||
3 | *
|
||
4 | * Copyright (C) 2004-5.
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
19 | *
|
||
20 | * For more information, contact:
|
||
21 | *
|
||
22 | * cresques@gmail.com
|
||
23 | */
|
||
24 | package org.cresques.px; |
||
25 | |||
26 | import java.awt.Color; |
||
27 | import java.awt.Component; |
||
28 | import java.awt.Graphics2D; |
||
29 | import java.awt.Image; |
||
30 | import java.awt.geom.AffineTransform; |
||
31 | import java.awt.geom.GeneralPath; |
||
32 | import java.awt.geom.NoninvertibleTransformException; |
||
33 | import java.awt.geom.Point2D; |
||
34 | import java.awt.image.BufferedImage; |
||
35 | import java.awt.image.DataBuffer; |
||
36 | import java.awt.image.ImageObserver; |
||
37 | import java.util.ArrayList; |
||
38 | import java.util.Date; |
||
39 | import java.util.Vector; |
||
40 | |||
41 | import org.cresques.cts.ICoordTrans; |
||
42 | import org.cresques.cts.IProjection; |
||
43 | import org.cresques.filter.RasterFilterStack; |
||
44 | import org.cresques.filter.RasterFilterStackManager; |
||
45 | import org.cresques.filter.bands.PaletteFilter; |
||
46 | import org.cresques.filter.bands.PaletteStackManager; |
||
47 | import org.cresques.filter.bands.RasterByteToImageFilter; |
||
48 | import org.cresques.filter.bands.RasterDoubleToImageFilter; |
||
49 | import org.cresques.filter.bands.RasterFloatToImageFilter; |
||
50 | import org.cresques.filter.bands.RasterIntToImageFilter; |
||
51 | import org.cresques.filter.bands.RasterShortToImageFilter; |
||
52 | import org.cresques.filter.bands.RasterToImageFilter; |
||
53 | import org.cresques.filter.enhancement.TransparencyRange; |
||
54 | import org.cresques.geo.Projected; |
||
55 | import org.cresques.geo.ViewPortData; |
||
56 | import org.cresques.io.EcwFile; |
||
57 | import org.cresques.io.GdalFile; |
||
58 | import org.cresques.io.GeoRasterFile; |
||
59 | import org.cresques.io.data.RasterBuf; |
||
60 | import org.cresques.io.datastruct.Statistic; |
||
61 | import org.cresques.io.exceptions.SupersamplingNotSupportedException; |
||
62 | |||
63 | |||
64 | /**
|
||
65 | *
|
||
66 | * @author Luis W. Sevilla (sevilla_lui@gva.es)
|
||
67 | * @author Nacho Brodin (brodin_ign@gva.es)
|
||
68 | *
|
||
69 | */
|
||
70 | public class PxRaster extends PxObj implements Projected { |
||
71 | protected GeoRasterFile[] geoFile = null; |
||
72 | protected ImageObserver component = null; |
||
73 | Vector pts = null; |
||
74 | |||
75 | // Soporte para n bandas, visibles de 3 en 3, en ficheros separados
|
||
76 | //protected GeoRasterFile [] colorBand = null;
|
||
77 | protected int rBand = 1; |
||
78 | |||
79 | // Soporte para n bandas, visibles de 3 en 3, en ficheros separados
|
||
80 | //protected GeoRasterFile [] colorBand = null;
|
||
81 | protected int gBand = 2; |
||
82 | |||
83 | // Soporte para n bandas, visibles de 3 en 3, en ficheros separados
|
||
84 | //protected GeoRasterFile [] colorBand = null;
|
||
85 | protected int bBand = 3; |
||
86 | public Statistic stats = new Statistic(); |
||
87 | int transparente = 0x10ffff80; |
||
88 | String vName = null; |
||
89 | protected boolean pintaMarco = false; //true; |
||
90 | IProjection proj = null;
|
||
91 | protected Extent extentOrig = null; |
||
92 | ICoordTrans rp = null;
|
||
93 | public RasterFilterStack filterStack = new RasterFilterStack(stats); |
||
94 | private BandSwitch bandSwitch = new BandSwitch(); |
||
95 | private boolean firstPxRaster = true; |
||
96 | private final double percentFilterInit = 0.02; |
||
97 | private RasterFilterStackManager stackManager = null; |
||
98 | private Image geoImage = null; |
||
99 | private ViewPortData lastViewPort = null; |
||
100 | |||
101 | /**
|
||
102 | * Constructor.
|
||
103 | * @param component
|
||
104 | */
|
||
105 | public PxRaster(ImageObserver component) { |
||
106 | this.component = component;
|
||
107 | } |
||
108 | |||
109 | /**
|
||
110 | * Contructor para un solo fichero
|
||
111 | * @param proj Proyeccci?n
|
||
112 | * @param fname Nombre del fichero
|
||
113 | * @param component
|
||
114 | */
|
||
115 | public PxRaster(IProjection proj, String fname, ImageObserver component) { |
||
116 | geoFile = new GeoRasterFile[1]; |
||
117 | geoFile[0] = GeoRasterFile.openFile(proj, fname); //loadECW(fname); |
||
118 | geoFile[0].setUpdatable((Component) component); |
||
119 | this.proj = proj;
|
||
120 | this.component = component;
|
||
121 | setExtent(geoFile[0].getExtent());
|
||
122 | setExtentForRequest(geoFile[0].getExtentForRequest());
|
||
123 | geoFile[0].setView(geoFile[0].getExtent()); |
||
124 | extentOrig = extent; |
||
125 | bandSwitch.addFile(geoFile[0]);
|
||
126 | |||
127 | if (geoFile[0].getBandCount() >= 3) { |
||
128 | setBand(GeoRasterFile.RED_BAND, 0);
|
||
129 | setBand(GeoRasterFile.GREEN_BAND, 1);
|
||
130 | setBand(GeoRasterFile.BLUE_BAND, 2);
|
||
131 | } else if (geoFile[0].getBandCount() == 2) { |
||
132 | setBand(GeoRasterFile.RED_BAND, 0);
|
||
133 | setBand(GeoRasterFile.GREEN_BAND, 1);
|
||
134 | setBand(GeoRasterFile.BLUE_BAND, 1);
|
||
135 | } else if (geoFile[0].getBandCount() == 1) { |
||
136 | //setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0);
|
||
137 | setBand(GeoRasterFile.RED_BAND, 0);
|
||
138 | setBand(GeoRasterFile.GREEN_BAND, 0);
|
||
139 | setBand(GeoRasterFile.BLUE_BAND, 0);
|
||
140 | } |
||
141 | } |
||
142 | |||
143 | /**
|
||
144 | * Constructor para multiples ficheros
|
||
145 | */
|
||
146 | public PxRaster(IProjection proj, String[] fnames, ImageObserver component) { |
||
147 | this.proj = proj;
|
||
148 | this.component = component;
|
||
149 | geoFile = new GeoRasterFile[fnames.length];
|
||
150 | |||
151 | for (int i = 0; i < geoFile.length; i++) { |
||
152 | geoFile[i] = GeoRasterFile.openFile(proj, fnames[i]); //loadECW(fname);
|
||
153 | geoFile[i].setUpdatable((Component) component);
|
||
154 | setExtent(geoFile[i].getExtent()); |
||
155 | setExtentForRequest(geoFile[i].getExtentForRequest()); |
||
156 | geoFile[i].setView(geoFile[i].getExtent()); |
||
157 | bandSwitch.addFile(geoFile[i]); |
||
158 | } |
||
159 | |||
160 | //geoFile = geoFile[0];
|
||
161 | extentOrig = extent; |
||
162 | |||
163 | if ((fnames.length >= 3) || (geoFile[0].getBandCount() > 2)) { |
||
164 | setBand(GeoRasterFile.RED_BAND, 0);
|
||
165 | setBand(GeoRasterFile.GREEN_BAND, 1);
|
||
166 | setBand(GeoRasterFile.BLUE_BAND, 2);
|
||
167 | } else {
|
||
168 | setBand(GeoRasterFile.RED_BAND | GeoRasterFile.GREEN_BAND | |
||
169 | GeoRasterFile.BLUE_BAND, 0);
|
||
170 | } |
||
171 | } |
||
172 | |||
173 | public PxRaster(GeoRasterFile eFile, ImageObserver component, Extent view) { |
||
174 | geoFile = new GeoRasterFile[1]; |
||
175 | geoFile[0] = eFile; //loadECW(fname); |
||
176 | geoFile[0].setUpdatable((Component) component); |
||
177 | setProjection(geoFile[0].getProjection());
|
||
178 | this.component = component;
|
||
179 | |||
180 | setExtent(geoFile[0].getExtent());
|
||
181 | setExtentForRequest(geoFile[0].getExtentForRequest());
|
||
182 | if(view != null){ |
||
183 | geoFile[0].setView(view); //geoFile.getExtent()); |
||
184 | extentOrig = extent; |
||
185 | bandSwitch.addFile(eFile); |
||
186 | |||
187 | if (geoFile[0].getBandCount() >= 3) { |
||
188 | setBand(GeoRasterFile.RED_BAND, 0);
|
||
189 | setBand(GeoRasterFile.GREEN_BAND, 1);
|
||
190 | setBand(GeoRasterFile.BLUE_BAND, 2);
|
||
191 | } else if (geoFile[0].getBandCount() == 2) { |
||
192 | setBand(GeoRasterFile.RED_BAND, 0);
|
||
193 | setBand(GeoRasterFile.GREEN_BAND, 1);
|
||
194 | setBand(GeoRasterFile.BLUE_BAND, 1);
|
||
195 | } else if (geoFile[0].getBandCount() == 1) { |
||
196 | //setBand(GeoRasterFile.RED_BAND|GeoRasterFile.GREEN_BAND|GeoRasterFile.BLUE_BAND, 0);
|
||
197 | setBand(GeoRasterFile.RED_BAND, 0);
|
||
198 | setBand(GeoRasterFile.GREEN_BAND, 0);
|
||
199 | setBand(GeoRasterFile.BLUE_BAND, 0);
|
||
200 | } |
||
201 | } |
||
202 | } |
||
203 | |||
204 | /**
|
||
205 | * A?ade un GeoRasterFile al PxRaster
|
||
206 | * @param fileName Nombre del fichero
|
||
207 | */
|
||
208 | public GeoRasterFile addFile(String fileName) { |
||
209 | if (geoFile != null) { |
||
210 | GeoRasterFile[] listFiles = new GeoRasterFile[geoFile.length + 1]; |
||
211 | |||
212 | for (int i = 0; i < geoFile.length; i++) |
||
213 | listFiles[i] = geoFile[i]; |
||
214 | |||
215 | listFiles[geoFile.length] = GeoRasterFile.openFile(proj, fileName); |
||
216 | listFiles[geoFile.length].setUpdatable((Component) component);
|
||
217 | setExtent(listFiles[geoFile.length].getExtent()); |
||
218 | setExtentForRequest(listFiles[geoFile.length].getExtentForRequest()); |
||
219 | listFiles[geoFile.length].setView(listFiles[geoFile.length].getExtent()); |
||
220 | bandSwitch.addFile(listFiles[geoFile.length]); |
||
221 | geoFile = listFiles; |
||
222 | return listFiles[geoFile.length - 1]; |
||
223 | } else {
|
||
224 | System.err.println("PxRaster.addFile(): Imagen no cargada."); |
||
225 | return null; |
||
226 | } |
||
227 | } |
||
228 | |||
229 | /**
|
||
230 | * Devuelve el Extent de un fichero son necesidad de a?adirlo
|
||
231 | * al PxRaster
|
||
232 | * @param fileName
|
||
233 | * @return
|
||
234 | */
|
||
235 | public Extent testExtentFile(String fileName) { |
||
236 | GeoRasterFile grf = GeoRasterFile.openFile(proj, fileName); |
||
237 | |||
238 | return grf.getExtent();
|
||
239 | } |
||
240 | |||
241 | /**
|
||
242 | * Obtiene el valor del pixel del Image en la posici?n wcx,wcy
|
||
243 | * @param wcx Posici?n x
|
||
244 | * @param wcx Posici?n y
|
||
245 | * @return valor de pixel
|
||
246 | */
|
||
247 | public int[] getPixel(double wcx, double wcy) { |
||
248 | if (geoImage != null) { |
||
249 | int ptox = 0; |
||
250 | int ptoy = 0; |
||
251 | |||
252 | try {
|
||
253 | //Extent de la imagen completa
|
||
254 | Extent extOrtofoto = geoFile[0].getExtent();
|
||
255 | |||
256 | //Variables q definen el extent del objeto image
|
||
257 | double minx = 0; |
||
258 | |||
259 | //Variables q definen el extent del objeto image
|
||
260 | double miny = 0; |
||
261 | |||
262 | //Variables q definen el extent del objeto image
|
||
263 | double maxx = 0; |
||
264 | |||
265 | //Variables q definen el extent del objeto image
|
||
266 | double maxy = 0; |
||
267 | |||
268 | if (lastViewPort.getExtent().getMin().getX() < extOrtofoto.minX()) {
|
||
269 | minx = extOrtofoto.minX(); |
||
270 | } else {
|
||
271 | minx = lastViewPort.getExtent().getMin().getX(); |
||
272 | } |
||
273 | |||
274 | if (lastViewPort.getExtent().getMax().getX() > extOrtofoto.maxX()) {
|
||
275 | maxx = extOrtofoto.maxX(); |
||
276 | } else {
|
||
277 | maxx = lastViewPort.getExtent().getMax().getX(); |
||
278 | } |
||
279 | |||
280 | if (lastViewPort.getExtent().getMin().getY() < extOrtofoto.minY()) {
|
||
281 | miny = extOrtofoto.minY(); |
||
282 | } else {
|
||
283 | miny = lastViewPort.getExtent().getMin().getY(); |
||
284 | } |
||
285 | |||
286 | if (lastViewPort.getExtent().getMax().getY() > extOrtofoto.maxY()) {
|
||
287 | maxy = extOrtofoto.maxY(); |
||
288 | } else {
|
||
289 | maxy = lastViewPort.getExtent().getMax().getY(); |
||
290 | } |
||
291 | |||
292 | //Comprobamos que estemos dentro del extent del Image
|
||
293 | if ((wcx < minx) || (wcx > maxx) || (wcy < miny) ||
|
||
294 | (wcy > maxy)) { |
||
295 | int[] res = { -1, -1, -1, -1 }; |
||
296 | |||
297 | return res;
|
||
298 | } |
||
299 | |||
300 | //Pasamos a coordenadas del Image las coordenadas del mundo real
|
||
301 | int w = ((BufferedImage) geoImage).getWidth(); |
||
302 | int h = ((BufferedImage) geoImage).getHeight(); |
||
303 | double wcw = maxx - minx;
|
||
304 | double wch = maxy - miny;
|
||
305 | ptox = (int) (((wcx - minx) * w) / wcw);
|
||
306 | ptoy = (int) (((wcy - miny) * h) / wch);
|
||
307 | |||
308 | //Obtenemos el pto seleccionado del Image y extraemos el RGB
|
||
309 | int px = ((BufferedImage) geoImage).getRGB(ptox, h - ptoy); |
||
310 | int[] values = new int[4]; |
||
311 | values[0] = ((px & 0xff000000) >> 24); |
||
312 | values[1] = ((px & 0x00ff0000) >> 16); |
||
313 | values[2] = ((px & 0x0000ff00) >> 8); |
||
314 | values[3] = (px & 0x000000ff); |
||
315 | |||
316 | return values;
|
||
317 | } catch (ArrayIndexOutOfBoundsException e) { |
||
318 | e.printStackTrace(); |
||
319 | } |
||
320 | } |
||
321 | |||
322 | return null; |
||
323 | } |
||
324 | |||
325 | /**
|
||
326 | * Elimina un GeoRasterFile al PxRaster
|
||
327 | * @param finaName Nombre del fichero
|
||
328 | */
|
||
329 | public GeoRasterFile delFile(String fileName) { |
||
330 | if (geoFile != null) { |
||
331 | Vector grfTemp = new Vector(); |
||
332 | |||
333 | GeoRasterFile grfDelete = null;
|
||
334 | |||
335 | for (int i = 0; i < geoFile.length; i++) { |
||
336 | if (!fileName.endsWith(geoFile[i].getName())) {
|
||
337 | grfTemp.add(geoFile[i]); |
||
338 | }else
|
||
339 | grfDelete = geoFile[i]; |
||
340 | } |
||
341 | |||
342 | GeoRasterFile[] listFiles = new GeoRasterFile[grfTemp.size()]; |
||
343 | |||
344 | for (int i = 0; i < listFiles.length; i++) |
||
345 | listFiles[i] = (GeoRasterFile) grfTemp.get(i); |
||
346 | |||
347 | //Lo eliminamos del bandSwitch
|
||
348 | for (int i = 0; i < geoFile.length; i++) { |
||
349 | if (fileName.endsWith(geoFile[i].getName())) {
|
||
350 | bandSwitch.removeFile(geoFile[i]); |
||
351 | } |
||
352 | } |
||
353 | |||
354 | geoFile = listFiles; |
||
355 | return grfDelete;
|
||
356 | } else {
|
||
357 | System.err.println("PxRaster.addFile(): Imagen no cargada."); |
||
358 | return null; |
||
359 | } |
||
360 | } |
||
361 | |||
362 | /**
|
||
363 | * Obtiene el tama?o de bloque
|
||
364 | * @return
|
||
365 | */
|
||
366 | public int getBlockSize() { |
||
367 | return geoFile[0].getBlockSize(); |
||
368 | } |
||
369 | |||
370 | /**
|
||
371 | *
|
||
372 | * @return
|
||
373 | */
|
||
374 | public GeoRasterFile[] getGeoFiles() { |
||
375 | return geoFile;
|
||
376 | } |
||
377 | |||
378 | public GeoRasterFile getGeoFile() {
|
||
379 | return geoFile[0]; |
||
380 | } |
||
381 | |||
382 | /**
|
||
383 | * Obtiene el n?mero de bandas del PxRaster. Si ls longitud de geoFile es 1 quiere
|
||
384 | * decir que hay un solo fichero que contiene todas las bandas. Si hay m?s de un geoFile
|
||
385 | * el n?mero de bandas ser? la suma de todas las bandas de las im?genes que forman
|
||
386 | * el geoFile
|
||
387 | * @return N?mero de bandas
|
||
388 | */
|
||
389 | public int getBandCount() { |
||
390 | return bandSwitch.getBandCount();
|
||
391 | } |
||
392 | |||
393 | /**
|
||
394 | * Obtiene el tipo de dato del primer GeoRasterFile
|
||
395 | * @return
|
||
396 | */
|
||
397 | public int getDataType() { |
||
398 | if (geoFile != null) { |
||
399 | return geoFile[0].getDataType(); |
||
400 | } else {
|
||
401 | System.err.println("PxRaster.getDataType(): Imagen no cargada."); |
||
402 | } |
||
403 | |||
404 | return 0; |
||
405 | } |
||
406 | |||
407 | /**
|
||
408 | * Obtiene el vector de GeoRasterFile que componen el PxRaster
|
||
409 | * @return vector GeoRasterFile
|
||
410 | */
|
||
411 | public GeoRasterFile[] getFiles() { |
||
412 | return geoFile;
|
||
413 | } |
||
414 | |||
415 | /**
|
||
416 | * Asocia un colorBand al rojo, verde o azul.
|
||
417 | * @param flag cual (o cuales) de las bandas.
|
||
418 | * @param nBand que colorBand
|
||
419 | */
|
||
420 | public void setBand(int flag, int nBand) { |
||
421 | bandSwitch.setBand(flag, nBand); |
||
422 | } |
||
423 | |||
424 | /**
|
||
425 | * Obtiene la posici?n del fichero asignado a la banda
|
||
426 | * que se le pasa por par?metro
|
||
427 | * @return
|
||
428 | */
|
||
429 | public int getPosFile(int flag) { |
||
430 | if (flag == GeoRasterFile.RED_BAND) {
|
||
431 | return bandSwitch.getBandR().getPos();
|
||
432 | } else if (flag == GeoRasterFile.GREEN_BAND) { |
||
433 | return bandSwitch.getBandG().getPos();
|
||
434 | } else if (flag == GeoRasterFile.BLUE_BAND) { |
||
435 | return bandSwitch.getBandB().getPos();
|
||
436 | } else {
|
||
437 | return -1; |
||
438 | } |
||
439 | } |
||
440 | |||
441 | /**
|
||
442 | * Devuelve el colorBand activo en la banda especificada.
|
||
443 | * @param flag banda.
|
||
444 | */
|
||
445 | public int getBand(int flag) { |
||
446 | if (flag == GeoRasterFile.RED_BAND) {
|
||
447 | return bandSwitch.getBandR().getBand();
|
||
448 | } else if (flag == GeoRasterFile.GREEN_BAND) { |
||
449 | return bandSwitch.getBandG().getBand();
|
||
450 | } else if (flag == GeoRasterFile.BLUE_BAND) { |
||
451 | return bandSwitch.getBandB().getBand();
|
||
452 | } else {
|
||
453 | return -1; |
||
454 | } |
||
455 | } |
||
456 | |||
457 | /**
|
||
458 | * @param pm
|
||
459 | */
|
||
460 | public void setDrawBorder(boolean pm) { |
||
461 | pintaMarco = pm; |
||
462 | } |
||
463 | |||
464 | /**
|
||
465 | * Obtiene el nombre del fichero si solo hay uno
|
||
466 | * @return Nombre del fichero
|
||
467 | */
|
||
468 | public String getFName() { |
||
469 | return geoFile[0].getName(); |
||
470 | } |
||
471 | |||
472 | /**
|
||
473 | * Obtiene el nombre del fichero GeoRasterFile seleccionado
|
||
474 | * @param i posici?n del GeoRasterFile
|
||
475 | * @return Nombre del fichero
|
||
476 | */
|
||
477 | public String getFName(int i) { |
||
478 | if (geoFile != null) { |
||
479 | if (i < geoFile.length) {
|
||
480 | return geoFile[i].getName();
|
||
481 | } else {
|
||
482 | return null; |
||
483 | } |
||
484 | } else {
|
||
485 | System.err.println("PxRaster.getFName(): Imagen no cargada."); |
||
486 | |||
487 | return null; |
||
488 | } |
||
489 | } |
||
490 | |||
491 | /**
|
||
492 | * Obtiene una lista de Strings con los nombres de todos los ficheros
|
||
493 | * que tiene el PxRaster
|
||
494 | * @return Lista de nombres
|
||
495 | */
|
||
496 | public String[] getLisName() { |
||
497 | if (geoFile != null) { |
||
498 | String[] list = new String[geoFile.length]; |
||
499 | |||
500 | for (int i = 0; i < geoFile.length; i++) |
||
501 | list[i] = geoFile[i].getName(); |
||
502 | |||
503 | return list;
|
||
504 | } else {
|
||
505 | System.err.println("PxRaster.getListName(): Imagen no cargada."); |
||
506 | |||
507 | return null; |
||
508 | } |
||
509 | } |
||
510 | |||
511 | /**
|
||
512 | * Devuelve la anchura total del fichero, en pixeles.
|
||
513 | * @return ancho en pixeles
|
||
514 | */
|
||
515 | public int getFWidth() { |
||
516 | if (geoFile != null) { |
||
517 | return geoFile[0].getWidth(); |
||
518 | } else {
|
||
519 | System.err.println("PxRaster.getFWidth(): Imagen no cargada."); |
||
520 | |||
521 | return 0; |
||
522 | } |
||
523 | } |
||
524 | |||
525 | /**
|
||
526 | * Devuelve la anchura total del fichero, en pixeles.
|
||
527 | * @return ancho en pixeles
|
||
528 | */
|
||
529 | public int getFWidth(int i) { |
||
530 | if (i < geoFile.length) {
|
||
531 | return geoFile[i].getWidth();
|
||
532 | } else {
|
||
533 | System.err.println("PxRaster.getFWidth(): Imagen no cargada."); |
||
534 | |||
535 | return 0; |
||
536 | } |
||
537 | } |
||
538 | |||
539 | /**
|
||
540 | * Devuelve la altura total del fichero, en pixeles.
|
||
541 | * @return alto en pixeles
|
||
542 | */
|
||
543 | public int getFHeight() { |
||
544 | if (geoFile != null) { |
||
545 | return geoFile[0].getHeight(); |
||
546 | } else {
|
||
547 | System.err.println("PxRaster.getFHeight(): Imagen no cargada."); |
||
548 | |||
549 | return 0; |
||
550 | } |
||
551 | } |
||
552 | |||
553 | /**
|
||
554 | * Devuelve la altura total del fichero, en pixeles.
|
||
555 | * @return alto en pixeles
|
||
556 | */
|
||
557 | public int getFHeight(int i) { |
||
558 | if (i < geoFile.length) {
|
||
559 | return geoFile[i].getHeight();
|
||
560 | } else {
|
||
561 | System.err.println("PxRaster.getFHeight(): Imagen no cargada."); |
||
562 | |||
563 | return 0; |
||
564 | } |
||
565 | } |
||
566 | |||
567 | /**
|
||
568 | * Devuelve el n?mero de ficheros que componen el PxRaster
|
||
569 | * @return N?mero de ficheros
|
||
570 | */
|
||
571 | public int nFiles() { |
||
572 | if (geoFile != null) { |
||
573 | return geoFile.length;
|
||
574 | } else {
|
||
575 | return 0; |
||
576 | } |
||
577 | } |
||
578 | |||
579 | /**
|
||
580 | * Activa o desactiva la transparencia de los ficheros que forman el PxRaster
|
||
581 | * @param t true o false para activar o desactivar transparencia
|
||
582 | */
|
||
583 | public void setTransparency(boolean t) { |
||
584 | if (geoFile != null) { |
||
585 | for (int i = 0; i < geoFile.length; i++) { |
||
586 | geoFile[i].setTransparency(t); |
||
587 | } |
||
588 | } else {
|
||
589 | System.err.println("PxRaster.setTransparency(): Imagen no cargada."); |
||
590 | |||
591 | return;
|
||
592 | } |
||
593 | } |
||
594 | |||
595 | /**
|
||
596 | * Pone la transparencia de los ficheros de la imagen a un valor
|
||
597 | * @param t Valor para la transparencia
|
||
598 | */
|
||
599 | public void setTransparency(int t) { |
||
600 | if (geoFile != null) { |
||
601 | for (int i = 0; i < geoFile.length; i++) { |
||
602 | geoFile[i].setTransparency(t); |
||
603 | } |
||
604 | } else {
|
||
605 | System.err.println("PxRaster.setTransparency(): Imagen no cargada."); |
||
606 | |||
607 | return;
|
||
608 | } |
||
609 | } |
||
610 | |||
611 | /**
|
||
612 | * Obtiene el alpha del primer fichero. Han de ser iguales en todos
|
||
613 | * los ficheros de la imagen.
|
||
614 | * @return alpha
|
||
615 | */
|
||
616 | public int getAlpha() { |
||
617 | if (geoFile != null) { |
||
618 | return geoFile[0].getAlpha(); |
||
619 | } else {
|
||
620 | System.err.println("PxRaster.getAlpha(): Imagen no cargada."); |
||
621 | |||
622 | return 0; |
||
623 | } |
||
624 | } |
||
625 | |||
626 | /**
|
||
627 | * Asigna el extent completo del raster. Este contiene las coordenadas reales tanto
|
||
628 | * para un raster rotado como sin rotar. Este extent coincide con requestExtent
|
||
629 | * cuando el raster no tiene rotaci?n.
|
||
630 | * @param Extent
|
||
631 | */
|
||
632 | public void setExtent(Extent e) { |
||
633 | super.extent = e;
|
||
634 | if(e != null){ |
||
635 | pts = new Vector(); |
||
636 | pts.add(proj.createPoint(e.minX(), e.minY())); |
||
637 | pts.add(proj.createPoint(e.maxX(), e.minY())); |
||
638 | pts.add(proj.createPoint(e.maxX(), e.maxY())); |
||
639 | pts.add(proj.createPoint(e.minX(), e.maxY())); |
||
640 | } |
||
641 | } |
||
642 | |||
643 | /**
|
||
644 | * Asigna el extent sobre el que se ajusta una petici?n para que esta no exceda el
|
||
645 | * extent m?ximo del raster. Para un raster sin rotar ser? igual al extent
|
||
646 | * pero para un raster rotado ser? igual al extent del raster como si no
|
||
647 | * tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la
|
||
648 | * vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing
|
||
649 | * aplicado.
|
||
650 | * @param Extent
|
||
651 | */
|
||
652 | public void setExtentForRequest(Extent e) { |
||
653 | super.requestExtent = e;
|
||
654 | if(e != null){ |
||
655 | pts = new Vector(); |
||
656 | pts.add(proj.createPoint(e.minX(), e.minY())); |
||
657 | pts.add(proj.createPoint(e.maxX(), e.minY())); |
||
658 | pts.add(proj.createPoint(e.maxX(), e.maxY())); |
||
659 | pts.add(proj.createPoint(e.minX(), e.maxY())); |
||
660 | } |
||
661 | } |
||
662 | |||
663 | /**
|
||
664 | * Cambia la vista (viewport) sobre el raster.
|
||
665 | *
|
||
666 | * @param v extent
|
||
667 | * @param vName nombre
|
||
668 | */
|
||
669 | public void setView(Extent v, String vName) { |
||
670 | if (geoFile != null) { |
||
671 | for (int i = 0; i < geoFile.length; i++) { |
||
672 | geoFile[i].setView(v); |
||
673 | } |
||
674 | } else {
|
||
675 | System.err.println("PxRaster.setView(): Imagen no cargada."); |
||
676 | |||
677 | return;
|
||
678 | } |
||
679 | |||
680 | this.vName = vName;
|
||
681 | } |
||
682 | |||
683 | /**
|
||
684 | * Obtiene la escala.
|
||
685 | *
|
||
686 | * @param width
|
||
687 | * @param height
|
||
688 | * @return
|
||
689 | */
|
||
690 | public double[] getScale(int width, int height) { |
||
691 | double[] scale = new double[2]; |
||
692 | |||
693 | if (geoFile != null) { |
||
694 | scale[0] = ((double) width) / geoFile[0].getView().width(); |
||
695 | scale[1] = ((double) height) / geoFile[0].getView().height(); |
||
696 | |||
697 | return scale;
|
||
698 | } else {
|
||
699 | System.err.println("PxRaster.getScale(): Imagen no cargada."); |
||
700 | |||
701 | return null; |
||
702 | } |
||
703 | } |
||
704 | |||
705 | /**
|
||
706 | * Transforma la petici?n que est? en coordenadas de la imagen sin rotar a coordenadas de la imagen rotada
|
||
707 | * para que sea posible el calculo de la caja m?nima de inclusi?n. La coordenada superior izquierda de esta
|
||
708 | * ser? la que se use para posicionar la imagen sobre el graphics aplicandole la transformaci?n de la la vista.
|
||
709 | * @param v
|
||
710 | * @return
|
||
711 | */
|
||
712 | private Point2D coordULRotateRaster(double[] v){ |
||
713 | double vx = v[0]; |
||
714 | double vy = v[1]; |
||
715 | double vx2 = v[2]; |
||
716 | double vy2 = v[3]; |
||
717 | if (geoFile != null) { |
||
718 | double[] transf = geoFile[0].getTransform(); |
||
719 | Point2D ul = new Point2D.Double(vx - requestExtent.minX(), vy2 - requestExtent.maxY()); |
||
720 | Point2D ur = new Point2D.Double(vx2 - requestExtent.minX(), vy2 - requestExtent.maxY()); |
||
721 | Point2D ll = new Point2D.Double(vx - requestExtent.minX(), vy - requestExtent.maxY()); |
||
722 | Point2D lr = new Point2D.Double(vx2 - requestExtent.minX(), vy - requestExtent.maxY()); |
||
723 | |||
724 | if(transf != null && (transf[2] != 0 || transf[4] != 0)){ |
||
725 | double shearX = transf[2] / transf[1]; |
||
726 | double shearY = transf[4] / transf[5]; |
||
727 | AffineTransform at = new AffineTransform(); |
||
728 | at.setToShear(-shearX, -shearY); |
||
729 | |||
730 | at.transform(ul, ul); |
||
731 | at.transform(ur, ur); |
||
732 | at.transform(ll, ll); |
||
733 | at.transform(lr, lr); |
||
734 | |||
735 | ul = new Point2D.Double(ul.getX() + requestExtent.minX(), ul.getY() + requestExtent.maxY()); |
||
736 | ur = new Point2D.Double(ur.getX() + requestExtent.minX(), ur.getY() + requestExtent.maxY()); |
||
737 | ll = new Point2D.Double(ll.getX() + requestExtent.minX(), ll.getY() + requestExtent.maxY()); |
||
738 | lr = new Point2D.Double(lr.getX() + requestExtent.minX(), lr.getY() + requestExtent.maxY()); |
||
739 | |||
740 | vx2 = Math.max(Math.max(ul.getX(), ur.getX()), Math.max(ll.getX(), lr.getX())); |
||
741 | vy2 = Math.max(Math.max(ul.getY(), ur.getY()), Math.max(ll.getY(), lr.getY())); |
||
742 | vx = Math.min(Math.min(ul.getX(), ur.getX()), Math.min(ll.getX(), lr.getX())); |
||
743 | vy = Math.min(Math.min(ul.getY(), ur.getY()), Math.min(ll.getY(), lr.getY())); |
||
744 | } |
||
745 | return ul;
|
||
746 | } |
||
747 | return null; |
||
748 | |||
749 | } |
||
750 | |||
751 | /**
|
||
752 | * Ajusta la extensi?n pasada por par?metro y que corresponde al extent de la vista donde
|
||
753 | * se va a dibujar a los valores m?ximos y m?nimos de la imagen. Esto sirve para que la
|
||
754 | * petici?n al driver nunca sobrepase los l?mites de la imagen tratada aunque la vista
|
||
755 | * donde se dibuje sea de mayor tama?o.
|
||
756 | *
|
||
757 | * Antes de realizar este ajuste hay que transformar la petici?n que puede corresponder a
|
||
758 | * una imagen rotada a las coordenadas de la imagen sin rotar ya que las peticiones al
|
||
759 | * driver hay que hacerlas con estas coordenadas. Para esto trasladamos la petici?n al origen
|
||
760 | * de la imagen (esquina superior izquierda), aplicamos la transformaci?n inversa a las cuatro
|
||
761 | * esquinas obtenidas y volvemos a trasladar a su posici?n original.
|
||
762 | *
|
||
763 | * Se usa la transformaci?n inversa para trasladar un punto del raster rotado al mismo sin
|
||
764 | * rotar y la transformaci?n af?n normal para trasladar un punto sin rotar a uno rotado.
|
||
765 | *
|
||
766 | * @param sz Extent completo de la vista donde se va a dibujar.
|
||
767 | */
|
||
768 | protected double[] calculateNewView(ViewPortData vp) { |
||
769 | Extent sz = vp.getExtent(); |
||
770 | double vx = sz.minX();
|
||
771 | double vy = sz.minY();
|
||
772 | double vx2 = sz.maxX();
|
||
773 | double vy2 = sz.maxY();
|
||
774 | |||
775 | //Trasladamos la petici?n si est? rotada a su posici?n sin rotar
|
||
776 | |||
777 | if (geoFile != null) { |
||
778 | double[] transf = geoFile[0].getTransform(); |
||
779 | Point2D ul = new Point2D.Double(vx - requestExtent.minX(), vy2 - requestExtent.maxY()); |
||
780 | Point2D ur = new Point2D.Double(vx2 - requestExtent.minX(), vy2 - requestExtent.maxY()); |
||
781 | Point2D ll = new Point2D.Double(vx - requestExtent.minX(), vy - requestExtent.maxY()); |
||
782 | Point2D lr = new Point2D.Double(vx2 - requestExtent.minX(), vy - requestExtent.maxY()); |
||
783 | |||
784 | if(transf != null && (transf[2] != 0 || transf[4] != 0)){ |
||
785 | double shearX = transf[2] / transf[1]; |
||
786 | double shearY = transf[4] / transf[5]; |
||
787 | AffineTransform at = new AffineTransform(); |
||
788 | at.setToShear(-shearX, -shearY); |
||
789 | |||
790 | try {
|
||
791 | at.inverseTransform(ul, ul); |
||
792 | at.inverseTransform(ur, ur); |
||
793 | at.inverseTransform(ll, ll); |
||
794 | at.inverseTransform(lr, lr); |
||
795 | } catch (NoninvertibleTransformException e) { |
||
796 | e.printStackTrace(); |
||
797 | } |
||
798 | |||
799 | ul = new Point2D.Double(ul.getX() + requestExtent.minX(), ul.getY() + requestExtent.maxY()); |
||
800 | ur = new Point2D.Double(ur.getX() + requestExtent.minX(), ur.getY() + requestExtent.maxY()); |
||
801 | ll = new Point2D.Double(ll.getX() + requestExtent.minX(), ll.getY() + requestExtent.maxY()); |
||
802 | lr = new Point2D.Double(lr.getX() + requestExtent.minX(), lr.getY() + requestExtent.maxY()); |
||
803 | |||
804 | vx2 = Math.max(Math.max(ul.getX(), ur.getX()), Math.max(ll.getX(), lr.getX())); |
||
805 | vy2 = Math.max(Math.max(ul.getY(), ur.getY()), Math.max(ll.getY(), lr.getY())); |
||
806 | vx = Math.min(Math.min(ul.getX(), ur.getX()), Math.min(ll.getX(), lr.getX())); |
||
807 | vy = Math.min(Math.min(ul.getY(), ur.getY()), Math.min(ll.getY(), lr.getY())); |
||
808 | } |
||
809 | } |
||
810 | |||
811 | if (vx < requestExtent.minX())
|
||
812 | vx = requestExtent.minX(); |
||
813 | |||
814 | if (vy < requestExtent.minY())
|
||
815 | vy = requestExtent.minY(); |
||
816 | |||
817 | if (vx2 > requestExtent.maxX())
|
||
818 | vx2 = requestExtent.maxX(); |
||
819 | |||
820 | if (vy2 > requestExtent.maxY())
|
||
821 | vy2 = requestExtent.maxY(); |
||
822 | |||
823 | if (geoFile != null) { |
||
824 | for (int i = 0; i < geoFile.length; i++) |
||
825 | geoFile[i].setView(new Extent(vx, vy, vx2, vy2));
|
||
826 | } else {
|
||
827 | System.err.println("PxRaster.calculateNewView(): Imagen no cargada."); |
||
828 | } |
||
829 | double[] adjustedExtent = {vx, vy, vx2, vy2}; |
||
830 | return adjustedExtent;
|
||
831 | } |
||
832 | |||
833 | /**
|
||
834 | * Aplica transparencia leyendo los metadatos
|
||
835 | */
|
||
836 | private void setTransparencyByPixel(){ |
||
837 | if(geoFile[0].getMetadata() != null){ |
||
838 | if (stackManager == null){ |
||
839 | TransparencyRange[] noData = geoFile[0].getMetadata().parserNodataInMetadata(); |
||
840 | if(noData != null){ |
||
841 | ArrayList entries = new ArrayList(); |
||
842 | for(int i = 0; i < noData.length; i++) |
||
843 | entries.add(noData[i]); |
||
844 | stackManager = new RasterFilterStackManager(filterStack);
|
||
845 | stackManager.addTransparencyFilter( entries, 0x0, 0xff, 0xff, 0xff); |
||
846 | } |
||
847 | TransparencyRange noDataValue = geoFile[0].getMetadata().parserNodataByBand();
|
||
848 | if(noData == null && noDataValue != null){ |
||
849 | ArrayList entries = new ArrayList(); |
||
850 | entries.add(noDataValue); |
||
851 | stackManager = new RasterFilterStackManager(filterStack);
|
||
852 | stackManager.addTransparencyFilter( entries, 0x0, 0xff, 0xff, 0xff); |
||
853 | } |
||
854 | |||
855 | } |
||
856 | } |
||
857 | } |
||
858 | |||
859 | /**
|
||
860 | * Dibuja el raster sobre el Graphics. Para ello debemos de pasar el viewPort que corresponde a la
|
||
861 | * vista. Este viewPort es ajustado a los tama?os m?ximos y m?nimos de la imagen por la funci?n
|
||
862 | * calculateNewView. Esta funci?n tambi?n asignar? la vista a los drivers. Posteriormente se calcula
|
||
863 | * el alto y ancho de la imagen a dibujar (wImg, hImg), as? como el punto donde se va a pintar dentro
|
||
864 | * del graphics (pt). Finalmente se llama a updateImage del driver para que pinte y una vez dibujado
|
||
865 | * se pasa a trav?s de la funci?n renderizeRaster que es la encargada de aplicar la pila de filtros
|
||
866 | * sobre el Image que ha devuelto el driver.
|
||
867 | *
|
||
868 | * Para calcular en que coordenada pixel (pt) se empezar? a pintar el BufferedImage con el raster le?do
|
||
869 | * se aplica sobre la esquina superior izquierda de esta la matriz de transformaci?n del ViewPortData
|
||
870 | * pasado vp.mat.transform(pt, pt). Si el raster no est? rotado este punto es el resultante de la
|
||
871 | * funci?n calculateNewView que devuelve la petici?n ajustada al extent de la imagen (sin rotar). Si
|
||
872 | * el raster est? rotado necesitaremos para la transformaci?n el resultado de la funci?n coordULRotateRaster.
|
||
873 | * Lo que hace esta ?ltima es colocar la petici?n que ha sido puesta en coordenadas de la imagen sin rotar
|
||
874 | * (para pedir al driver de forma correcta) otra vez en coordenadas de la imagen rotada (para calcular su
|
||
875 | * posici?n de dibujado).
|
||
876 | *
|
||
877 | * Para dibujar sobre el Graphics2D el raster rotado aplicaremos la matriz de transformaci?n con los
|
||
878 | * par?metros de Shear sobre este Graphics de forma inversa. Como hemos movido el fondo tendremos que
|
||
879 | * recalcular ahora el punto donde se comienza a dibujar aplicandole la transformaci?n sobre este
|
||
880 | * at.inverseTransform(pt, pt);. Finalmente volcamos el BufferedImage sobre el Graphics volviendo a dejar
|
||
881 | * el Graphics en su posici?n original al acabar.
|
||
882 | *
|
||
883 | * @param g Graphics sobre el que se pinta
|
||
884 | * @param vp ViewPort de la extensi?n a dibujar
|
||
885 | */
|
||
886 | public synchronized void draw(Graphics2D g, ViewPortData vp) { |
||
887 | geoImage = null;
|
||
888 | |||
889 | long t2;
|
||
890 | long t1 = new Date().getTime(); |
||
891 | lastViewPort = vp; |
||
892 | |||
893 | if ((vp.getExtent().minX() > extent.maxX()) ||
|
||
894 | (vp.getExtent().minY() > extent.maxY()) || |
||
895 | (vp.getExtent().maxX() < extent.minX()) || |
||
896 | (vp.getExtent().maxY() < extent.minY())) { |
||
897 | return;
|
||
898 | } |
||
899 | |||
900 | double[] adjustedExtent = calculateNewView(vp); |
||
901 | Point2D p2d = coordULRotateRaster(adjustedExtent);
|
||
902 | |||
903 | Extent v = geoFile[0].getView();
|
||
904 | double x = v.minX();
|
||
905 | double y = v.minY();
|
||
906 | double w = v.width();
|
||
907 | double h = v.height();
|
||
908 | |||
909 | double scalex = vp.mat.getScaleX();
|
||
910 | double scaley = vp.mat.getScaleY();
|
||
911 | |||
912 | /*int wImg = (int) Math.round(Math.abs(w * scalex));
|
||
913 | int hImg = (int) Math.round(Math.abs(h * scaley));*/
|
||
914 | int wImg = (int) Math.round(Math.abs((adjustedExtent[2] - adjustedExtent[0]) * scalex)); |
||
915 | int hImg = (int) Math.round(Math.abs((adjustedExtent[3] - adjustedExtent[1]) * scaley)); |
||
916 | |||
917 | if ((wImg <= 0) || (hImg <= 0)) |
||
918 | return;
|
||
919 | |||
920 | //Para la transformaci?n usamos el extent que ha ajustado la funci?n calculateNewView y no usamos
|
||
921 | //el getView porque el getView puede haber sufrido una transformaci?n en caso de que exista
|
||
922 | //fichero .rmf. En caso de no existir este fichero ser?a lo mismo aplicar la funci?n:
|
||
923 | //Point2D.Double pt = new Point2D.Double(x, y + h);
|
||
924 | double[] transf = bandSwitch.getBandR().getGeoRasterFile().getTransform(); |
||
925 | Point2D.Double pt = null; |
||
926 | if(transf != null && (transf[2] != 0 || transf[4] != 0)) //Esta rotada |
||
927 | pt = new Point2D.Double(p2d.getX(), p2d.getY()); |
||
928 | else //No est? rotada |
||
929 | pt = new Point2D.Double(adjustedExtent[0], adjustedExtent[3]); |
||
930 | |||
931 | try {
|
||
932 | vp.mat.transform(pt, pt); |
||
933 | |||
934 | setTransparencyByPixel(); |
||
935 | |||
936 | if ((geoFile != null) && geoFile[0] instanceof GdalFile && |
||
937 | (geoFile[0].getDataType() != DataBuffer.TYPE_BYTE)) { |
||
938 | RasterBuf raster = ((GdalFile) geoFile[0]).getRaster(wImg, hImg, rp);
|
||
939 | t2 = new Date().getTime(); |
||
940 | |||
941 | System.out.println("Dibujando PxRaster: " + ((t2 - t1) / 1000D) + ", secs. Filtrando/Renderizando"); |
||
942 | t1 = t2; |
||
943 | |||
944 | filterStack.setInitRasterBuf(raster); |
||
945 | |||
946 | //Si la imagen es de 16 bits lleva un filtro de realce por defecto
|
||
947 | if (stackManager == null){ |
||
948 | stackManager = new RasterFilterStackManager(filterStack);
|
||
949 | stackManager.addEnhancedFilter(false, geoFile[0].getName()); |
||
950 | stackManager.removeFilter(stackManager.getTypeFilter("computeminmax"));
|
||
951 | stackManager.addTailFilter(this.percentFilterInit, 0D, true); |
||
952 | } |
||
953 | |||
954 | //Para imagenes de una banda replicamos esta en el resto del rasterBuf
|
||
955 | if(raster.getBandCount() == 1){ |
||
956 | raster.replicateBand(0, 1); |
||
957 | raster.replicateBand(0, 2); |
||
958 | } |
||
959 | |||
960 | geoImage = renderizeRaster(raster, vp, v); |
||
961 | g.drawImage(geoImage, (int)(pt.getX()), (int)(pt.getY()), component); |
||
962 | } else if((geoFile != null) && (geoFile.length > 1) && |
||
963 | (!bandSwitch.getBandR().getGeoRasterFile().getName().equals(bandSwitch.getBandG().getGeoRasterFile().getName()) || |
||
964 | !bandSwitch.getBandR().getGeoRasterFile().getName().equals(bandSwitch.getBandB().getGeoRasterFile().getName()) || |
||
965 | !bandSwitch.getBandG().getGeoRasterFile().getName().equals(bandSwitch.getBandB().getGeoRasterFile().getName())) |
||
966 | ) { // multiFiles
|
||
967 | System.out.println("Dibujando PxRaster (Multifile) ... Bands " + |
||
968 | geoFile.length); |
||
969 | |||
970 | if (bandSwitch.getBandR().getGeoRasterFile() instanceof EcwFile) { |
||
971 | ((EcwFile) bandSwitch.getBandR().getGeoRasterFile()).setMultifile(true);
|
||
972 | } |
||
973 | |||
974 | if (bandSwitch.getBandG().getGeoRasterFile() instanceof EcwFile) { |
||
975 | ((EcwFile) bandSwitch.getBandG().getGeoRasterFile()).setMultifile(true);
|
||
976 | } |
||
977 | |||
978 | if (bandSwitch.getBandB().getGeoRasterFile() instanceof EcwFile) { |
||
979 | ((EcwFile) bandSwitch.getBandB().getGeoRasterFile()).setMultifile(true);
|
||
980 | } |
||
981 | |||
982 | //TODO:Soluci?n para que no se pinte si hay sharpening. Esto hay que pensarlo mejor
|
||
983 | if (stackManager == null) |
||
984 | stackManager = new RasterFilterStackManager(filterStack);
|
||
985 | if(!filterStack.isActive(stackManager.getTypeFilter("sharpening"))){ |
||
986 | geoImage = bandSwitch.getBandR().getGeoRasterFile().updateImage(wImg, hImg, rp, null, 0, 0); |
||
987 | geoImage = bandSwitch.getBandG().getGeoRasterFile().updateImage(wImg, hImg, rp, geoImage, |
||
988 | bandSwitch.getBandG().getBand(), GeoRasterFile.GREEN_BAND); |
||
989 | geoImage = bandSwitch.getBandB().getGeoRasterFile().updateImage(wImg, hImg, rp, geoImage, |
||
990 | bandSwitch.getBandB().getBand(), GeoRasterFile.BLUE_BAND); |
||
991 | }else{
|
||
992 | geoImage = new BufferedImage(wImg, hImg, BufferedImage.TYPE_INT_RGB); |
||
993 | } |
||
994 | |||
995 | filterStack.setInitRasterBuf(geoImage); |
||
996 | |||
997 | geoImage = renderizeRaster(geoImage, vp, v); |
||
998 | |||
999 | g.drawImage(geoImage, (int)(pt.getX()), (int)(pt.getY()), component); |
||
1000 | } else if ((geoFile != null) ) { // Una solo fichero |
||
1001 | |||
1002 | geoImage = bandSwitch.getBandR().getGeoRasterFile().updateImage(wImg, hImg, rp, null, 0, 0); |
||
1003 | |||
1004 | if(bandSwitch.getBandR().getGeoRasterFile().getPalette() != null){ |
||
1005 | PaletteFilter pf = (PaletteFilter)filterStack.getByType(PaletteStackManager.palette); |
||
1006 | if(pf == null){ |
||
1007 | if (stackManager == null) |
||
1008 | stackManager = new RasterFilterStackManager(filterStack);
|
||
1009 | PaletteStackManager psm = (PaletteStackManager)stackManager.getManagerByClass(PaletteStackManager.class); |
||
1010 | stackManager.getFilterStack().removeFilter(PaletteStackManager.palette); |
||
1011 | |||
1012 | // -----------------------------------------PENDIENTE DE REVSION--------------------------------------------------
|
||
1013 | psm.addPaletteFilter(bandSwitch.getBandR().getGeoRasterFile().getPalette(),false);
|
||
1014 | /*
|
||
1015 | * A la funci?n addPaletteFilter se le pasa el valor false al par?metro interpolate, lo cual no ser? v?lido
|
||
1016 | * si se leen rasters con paletas asociadas que puedan especdifidar si se interpola o no, por ejemplo un rmf
|
||
1017 | * cuando se dote a estos de la posibilidad de almacenar paletas. Para este cas? hay que buscar la forma de saber
|
||
1018 | * en este punto si la paleta asociada al GeoRasterFile se visualiza con o sin interpolaci?n.
|
||
1019 | * ----------------------------------------------------------------------------------------------------------------
|
||
1020 | */
|
||
1021 | } |
||
1022 | } |
||
1023 | |||
1024 | filterStack.setInitRasterBuf(geoImage); |
||
1025 | |||
1026 | geoImage = renderizeRaster(geoImage, vp, v); |
||
1027 | |||
1028 | //Obtenemos los par?metros de shearing
|
||
1029 | if(transf != null){ |
||
1030 | double shearX = transf[2] / transf[1]; |
||
1031 | double shearY = transf[4] / transf[5]; |
||
1032 | |||
1033 | //Aplicamos el shear a la vista
|
||
1034 | AffineTransform at = new AffineTransform(); |
||
1035 | at.setToShear(shearX, shearY); |
||
1036 | g.transform(at); |
||
1037 | |||
1038 | //Aplicamos el shear inverso al punto donde se comienza a dibujar
|
||
1039 | at.inverseTransform(pt, pt); |
||
1040 | |||
1041 | g.drawImage(geoImage, (int) (pt.getX()), (int) (pt.getY()), component); |
||
1042 | g.transform(at.createInverse()); |
||
1043 | }else
|
||
1044 | g.drawImage(geoImage, (int) (pt.getX()), (int) (pt.getY()), component); |
||
1045 | |||
1046 | } else { // no cargada |
||
1047 | System.err.println("Dibujando PxRaster: Foto no cargada."); |
||
1048 | } |
||
1049 | |||
1050 | t2 = new Date().getTime(); |
||
1051 | System.out.println("Dibujando PxRaster: " + ((t2 - t1) / 1000D) + ", secs."); |
||
1052 | }catch (SupersamplingNotSupportedException e) {
|
||
1053 | System.err.println("Supersampling not supported"); |
||
1054 | return;
|
||
1055 | }catch (Exception e) { |
||
1056 | e.printStackTrace(); |
||
1057 | } |
||
1058 | |||
1059 | if (pintaMarco) {
|
||
1060 | drawMarco(g, vp); |
||
1061 | } |
||
1062 | } |
||
1063 | |||
1064 | /**
|
||
1065 | * Aplica la pila de fitros sobre el RasterBuf pasado como par?metro
|
||
1066 | * y lo devuelve en Image
|
||
1067 | * @param raster RasterBuf con la imagen sobre la que se aplicaran filtros
|
||
1068 | * @return Image con la imagen con los filtros puestos
|
||
1069 | */
|
||
1070 | public Image renderizeRaster(RasterBuf raster, ViewPortData vp, Extent e) { |
||
1071 | if (filterStack != null) { |
||
1072 | filterStack.setViewPortData(vp); |
||
1073 | filterStack.setExtent(e); |
||
1074 | filterStack.setStep(geoFile[0].getStepX(), geoFile[0].getStepY()); |
||
1075 | raster = filterStack.execute(raster); |
||
1076 | } |
||
1077 | System.out.println("Image renderizeRaster(RasterBuf raster, ViewPortData vp) "); |
||
1078 | //Aplicamos el filtro para convertir a Image
|
||
1079 | |||
1080 | RasterToImageFilter rti = null;
|
||
1081 | if(getDataType() == RasterBuf.TYPE_BYTE){
|
||
1082 | rti = new RasterByteToImageFilter();
|
||
1083 | }else if(getDataType() == RasterBuf.TYPE_SHORT){ |
||
1084 | rti = new RasterShortToImageFilter();
|
||
1085 | }else if(getDataType() == RasterBuf.TYPE_INT){ |
||
1086 | rti = new RasterIntToImageFilter();
|
||
1087 | }else if(getDataType() == RasterBuf.TYPE_FLOAT){ |
||
1088 | rti = new RasterFloatToImageFilter();
|
||
1089 | }else if(getDataType() == RasterBuf.TYPE_DOUBLE){ |
||
1090 | rti = new RasterDoubleToImageFilter();
|
||
1091 | } |
||
1092 | |||
1093 | |||
1094 | //rti.addParam("raster", raster);
|
||
1095 | if (filterStack.getOutDataType()!= RasterBuf.TYPE_IMAGE){
|
||
1096 | rti.addParam("raster", filterStack.getResult());
|
||
1097 | rti.addParam("alpha", new Integer(this.getAlpha())); |
||
1098 | rti.execute(); |
||
1099 | raster = null;
|
||
1100 | return (Image) rti.getResult("raster"); |
||
1101 | } |
||
1102 | else
|
||
1103 | return (Image)filterStack.getResult(); |
||
1104 | } |
||
1105 | |||
1106 | /**
|
||
1107 | * Aplica la pila de filtros sobre el Image pasado como par?metro y lo devuelve.
|
||
1108 | * Si la salida del ?ltimo filtro es un RasterBuf lo convertir? a Image
|
||
1109 | * @param image Image con la imagen sobre la que se aplicaran filtros
|
||
1110 | * @return Image con la imagen con los filtros puestos
|
||
1111 | */
|
||
1112 | public Image renderizeRaster(Image image, ViewPortData vp, Extent e) { |
||
1113 | if (filterStack != null) { |
||
1114 | filterStack.setViewPortData(vp); |
||
1115 | filterStack.setExtent(e); |
||
1116 | filterStack.setStep(geoFile[0].getStepX(), geoFile[0].getStepY()); |
||
1117 | filterStack.execute(image); |
||
1118 | } |
||
1119 | |||
1120 | if (filterStack.getOutDataType() != RasterBuf.TYPE_IMAGE) {
|
||
1121 | //Aplicamos el filtro para convertir a Image
|
||
1122 | |||
1123 | RasterToImageFilter rti = null;
|
||
1124 | if(getDataType() == RasterBuf.TYPE_BYTE){
|
||
1125 | rti = new RasterByteToImageFilter();
|
||
1126 | }else if(getDataType() == RasterBuf.TYPE_SHORT){ |
||
1127 | rti = new RasterShortToImageFilter();
|
||
1128 | }else if(getDataType() == RasterBuf.TYPE_INT){ |
||
1129 | rti = new RasterIntToImageFilter();
|
||
1130 | }else if(getDataType() == RasterBuf.TYPE_FLOAT){ |
||
1131 | rti = new RasterFloatToImageFilter();
|
||
1132 | }else if(getDataType() == RasterBuf.TYPE_DOUBLE){ |
||
1133 | rti = new RasterDoubleToImageFilter();
|
||
1134 | } |
||
1135 | |||
1136 | //RasterIntToImageFilter rti = new RasterIntToImageFilter();
|
||
1137 | |||
1138 | rti.addParam("raster", (RasterBuf) filterStack.getResult());
|
||
1139 | rti.addParam("alpha", new Integer(this.getAlpha())); |
||
1140 | rti.execute(); |
||
1141 | |||
1142 | return (Image) rti.getResult("raster"); |
||
1143 | } |
||
1144 | return (Image) filterStack.getResult(); |
||
1145 | // return image;
|
||
1146 | } |
||
1147 | |||
1148 | /**
|
||
1149 | *
|
||
1150 | * @param g
|
||
1151 | * @param vp
|
||
1152 | */
|
||
1153 | public void drawMarco(Graphics2D g, ViewPortData vp) { |
||
1154 | // Color color = new Color(255,222,165,128), fillColor = new Color(255,214,132,128);
|
||
1155 | Color color = new Color(128, 128, 128); |
||
1156 | |||
1157 | // Color color = new Color(255,222,165,128), fillColor = new Color(255,214,132,128);
|
||
1158 | Color fillColor = new Color(255, 220, 220, 0x20); |
||
1159 | GeneralPath gp = newGP(vp);
|
||
1160 | g.setColor(fillColor); |
||
1161 | g.fill(gp); |
||
1162 | g.setColor(color); |
||
1163 | g.draw(gp); |
||
1164 | } |
||
1165 | |||
1166 | private GeneralPath newGP(ViewPortData vp) { |
||
1167 | //if (gp != null) return;
|
||
1168 | GeneralPath gp = new GeneralPath(); |
||
1169 | Point2D.Double pt0 = new Point2D.Double(0.0, 0.0); |
||
1170 | Point2D.Double pt1 = new Point2D.Double(0.0, 0.0); |
||
1171 | Point2D.Double pt2 = new Point2D.Double(0.0, 0.0); |
||
1172 | Point2D.Double pt3 = new Point2D.Double(0.0, 0.0); |
||
1173 | vp.mat.transform((Point2D) pts.get(0), pt0); |
||
1174 | vp.mat.transform((Point2D) pts.get(1), pt1); |
||
1175 | vp.mat.transform((Point2D) pts.get(2), pt2); |
||
1176 | vp.mat.transform((Point2D) pts.get(3), pt3); |
||
1177 | |||
1178 | // Aspa desde el extent
|
||
1179 | gp.moveTo((float) pt0.getX(), (float) pt0.getY()); |
||
1180 | gp.lineTo((float) pt2.getX(), (float) pt2.getY()); |
||
1181 | gp.moveTo((float) pt1.getX(), (float) pt1.getY()); |
||
1182 | gp.lineTo((float) pt3.getX(), (float) pt3.getY()); |
||
1183 | |||
1184 | // Extent
|
||
1185 | gp.moveTo((float) pt0.getX(), (float) pt0.getY()); |
||
1186 | gp.lineTo((float) pt1.getX(), (float) pt1.getY()); |
||
1187 | gp.lineTo((float) pt2.getX(), (float) pt2.getY()); |
||
1188 | gp.lineTo((float) pt3.getX(), (float) pt3.getY()); |
||
1189 | |||
1190 | if (extentOrig != extent) {
|
||
1191 | gp.lineTo((float) pt0.getX(), (float) pt0.getY()); |
||
1192 | |||
1193 | Vector pts = new Vector(); |
||
1194 | pts.add(proj.createPoint(extentOrig.minX(), extentOrig.minY())); |
||
1195 | pts.add(proj.createPoint(extentOrig.maxX(), extentOrig.minY())); |
||
1196 | pts.add(proj.createPoint(extentOrig.maxX(), extentOrig.maxY())); |
||
1197 | pts.add(proj.createPoint(extentOrig.minX(), extentOrig.maxY())); |
||
1198 | |||
1199 | vp.mat.transform((Point2D) pts.get(0), pt0); |
||
1200 | vp.mat.transform((Point2D) pts.get(1), pt1); |
||
1201 | vp.mat.transform((Point2D) pts.get(2), pt2); |
||
1202 | vp.mat.transform((Point2D) pts.get(3), pt3); |
||
1203 | gp.moveTo((float) pt0.getX(), (float) pt0.getY()); |
||
1204 | gp.lineTo((float) pt1.getX(), (float) pt1.getY()); |
||
1205 | gp.lineTo((float) pt2.getX(), (float) pt2.getY()); |
||
1206 | gp.lineTo((float) pt3.getX(), (float) pt3.getY()); |
||
1207 | } |
||
1208 | |||
1209 | gp.closePath(); |
||
1210 | |||
1211 | return gp;
|
||
1212 | } |
||
1213 | |||
1214 | public IProjection getProjection() {
|
||
1215 | return proj;
|
||
1216 | } |
||
1217 | |||
1218 | public void setProjection(IProjection p) { |
||
1219 | proj = p; |
||
1220 | } |
||
1221 | |||
1222 | public void reProject(ICoordTrans rp) { |
||
1223 | this.rp = rp.getInverted();
|
||
1224 | System.out.println("PxRaster: reProject()"); |
||
1225 | |||
1226 | //geoFile.reProject(rp);
|
||
1227 | Vector savePts = pts;
|
||
1228 | |||
1229 | pts = new Vector(); |
||
1230 | extent = new Extent();
|
||
1231 | |||
1232 | Point2D ptDest = null; |
||
1233 | |||
1234 | for (int i = 0; i < savePts.size(); i++) { |
||
1235 | ptDest = rp.getPDest().createPoint(0.0, 0.0); |
||
1236 | ptDest = rp.convert((Point2D) savePts.get(i), ptDest);
|
||
1237 | pts.add(ptDest); |
||
1238 | extent.add(ptDest); |
||
1239 | } |
||
1240 | |||
1241 | setProjection(rp.getPDest()); |
||
1242 | } |
||
1243 | |||
1244 | /**
|
||
1245 | * Obtiene el Stack Manager
|
||
1246 | * @return
|
||
1247 | */
|
||
1248 | public RasterFilterStackManager getStackManager() {
|
||
1249 | return this.stackManager; |
||
1250 | } |
||
1251 | |||
1252 | /**
|
||
1253 | * Asigna el Stack Manager
|
||
1254 | * @return
|
||
1255 | */
|
||
1256 | public void setStackManager(RasterFilterStackManager sm) { |
||
1257 | this.stackManager = sm;
|
||
1258 | } |
||
1259 | |||
1260 | /**
|
||
1261 | * Estructura que representa la relaci?n entre un fichero y la banda que se
|
||
1262 | * utiliza de este.
|
||
1263 | * @author Nacho Brodin <brodin_ign@gva.es>
|
||
1264 | */
|
||
1265 | class FileBands { |
||
1266 | GeoRasterFile grf; //Fichero
|
||
1267 | int band; //Banda asinada |
||
1268 | int filePos; //posici?n del fichero |
||
1269 | |||
1270 | /**
|
||
1271 | * @return Returns the band.
|
||
1272 | */
|
||
1273 | public int getBand() { |
||
1274 | return band;
|
||
1275 | } |
||
1276 | |||
1277 | /**
|
||
1278 | * @param band The band to set.
|
||
1279 | */
|
||
1280 | public void setBand(int band) { |
||
1281 | this.band = band;
|
||
1282 | } |
||
1283 | |||
1284 | /**
|
||
1285 | * @return Returns the band.
|
||
1286 | */
|
||
1287 | public int getPos() { |
||
1288 | return filePos;
|
||
1289 | } |
||
1290 | |||
1291 | /**
|
||
1292 | * @param band The band to set.
|
||
1293 | */
|
||
1294 | public void setPos(int pos) { |
||
1295 | this.filePos = pos;
|
||
1296 | } |
||
1297 | |||
1298 | /**
|
||
1299 | * @return Returns the grf.
|
||
1300 | */
|
||
1301 | public GeoRasterFile getGeoRasterFile() {
|
||
1302 | return grf;
|
||
1303 | } |
||
1304 | |||
1305 | /**
|
||
1306 | * @param grf The grf to set.
|
||
1307 | */
|
||
1308 | public void setGeoRasterFile(GeoRasterFile grf) { |
||
1309 | this.grf = grf;
|
||
1310 | } |
||
1311 | } |
||
1312 | |||
1313 | /**
|
||
1314 | * Clase que lleva la gesti?n entre la relaci?n de ficheros representados
|
||
1315 | * por un GeoRasterFile y el n?mero de bandas que contienen. Esto es necesario
|
||
1316 | * para la actualizaci?n de la vista ya que para un Image dado podemos tener
|
||
1317 | * multiples bandas que pueden ser leidas desde diferentes ficheros.
|
||
1318 | *
|
||
1319 | * @author Nacho Brodin <brodin_ign@gva.es>
|
||
1320 | */
|
||
1321 | class BandSwitch { |
||
1322 | private ArrayList geoFiles = new ArrayList(); //Lista de GeoRasterFile con los ficheros raster cargados |
||
1323 | private FileBands[] listBands = new FileBands[3]; |
||
1324 | private boolean debug = false; |
||
1325 | |||
1326 | BandSwitch() { |
||
1327 | for (int i = 0; i < listBands.length; i++) |
||
1328 | listBands[i] = new FileBands();
|
||
1329 | } |
||
1330 | |||
1331 | /**
|
||
1332 | * A?ade un fichero
|
||
1333 | * @param grf
|
||
1334 | */
|
||
1335 | public void addFile(GeoRasterFile grf) { |
||
1336 | geoFiles.add(grf); |
||
1337 | |||
1338 | if (debug) {
|
||
1339 | this.show("addFile"); |
||
1340 | } |
||
1341 | } |
||
1342 | |||
1343 | /**
|
||
1344 | * Elimina un fichero
|
||
1345 | * @param grf
|
||
1346 | */
|
||
1347 | public void removeFile(GeoRasterFile grf) { |
||
1348 | for (int iFile = 0; iFile < geoFiles.size(); iFile++) { |
||
1349 | if (grf.equals(geoFiles.get(iFile))) {
|
||
1350 | geoFiles.remove(iFile); |
||
1351 | iFile--; |
||
1352 | } |
||
1353 | } |
||
1354 | |||
1355 | if (debug) {
|
||
1356 | this.show("removeFile"); |
||
1357 | } |
||
1358 | } |
||
1359 | |||
1360 | /**
|
||
1361 | *
|
||
1362 | * @param flag
|
||
1363 | * @param grf
|
||
1364 | * @param nBand
|
||
1365 | */
|
||
1366 | public void setBand(int flag, GeoRasterFile grf, int nBand) { |
||
1367 | if ((flag & GeoRasterFile.RED_BAND) == GeoRasterFile.RED_BAND) {
|
||
1368 | listBands[0].setBand(nBand);
|
||
1369 | listBands[0].setGeoRasterFile(grf);
|
||
1370 | } else if ((flag & GeoRasterFile.GREEN_BAND) == GeoRasterFile.GREEN_BAND) { |
||
1371 | listBands[1].setBand(nBand);
|
||
1372 | listBands[1].setGeoRasterFile(grf);
|
||
1373 | } else if ((flag & GeoRasterFile.BLUE_BAND) == GeoRasterFile.BLUE_BAND) { |
||
1374 | listBands[2].setBand(nBand);
|
||
1375 | listBands[2].setGeoRasterFile(grf);
|
||
1376 | } else {
|
||
1377 | return;
|
||
1378 | } |
||
1379 | |||
1380 | grf.setBand(flag, nBand); |
||
1381 | } |
||
1382 | |||
1383 | /**
|
||
1384 | * Asigna las bandas
|
||
1385 | * @param flag
|
||
1386 | * @param nBand
|
||
1387 | */
|
||
1388 | public void setBand(int flag, int nBand) { |
||
1389 | int cont = 0; |
||
1390 | |||
1391 | for (int iGrf = 0; iGrf < geoFiles.size(); iGrf++) { |
||
1392 | for (int iBand = 0; |
||
1393 | iBand < ((GeoRasterFile) geoFiles.get(iGrf)).getBandCount(); |
||
1394 | iBand++) { |
||
1395 | if (((flag & GeoRasterFile.RED_BAND) == GeoRasterFile.RED_BAND) &&
|
||
1396 | (cont == nBand)) { |
||
1397 | listBands[0].setGeoRasterFile(((GeoRasterFile) geoFiles.get(iGrf)));
|
||
1398 | listBands[0].setBand(iBand);
|
||
1399 | listBands[0].setPos(iGrf);
|
||
1400 | ((GeoRasterFile) geoFiles.get(iGrf)).setBand(flag, iBand); |
||
1401 | |||
1402 | //System.out.println("==>Asignando banda R FILE="+iGrf+" BANDA="+iBand);
|
||
1403 | } else if (((flag & GeoRasterFile.GREEN_BAND) == GeoRasterFile.GREEN_BAND) && |
||
1404 | (cont == nBand)) { |
||
1405 | listBands[1].setGeoRasterFile(((GeoRasterFile) geoFiles.get(iGrf)));
|
||
1406 | listBands[1].setBand(iBand);
|
||
1407 | listBands[1].setPos(iGrf);
|
||
1408 | ((GeoRasterFile) geoFiles.get(iGrf)).setBand(flag, iBand); |
||
1409 | |||
1410 | //System.out.println("==>Asignando banda G FILE="+iGrf+" BANDA="+iBand);
|
||
1411 | } else if (((flag & GeoRasterFile.BLUE_BAND) == GeoRasterFile.BLUE_BAND) && |
||
1412 | (cont == nBand)) { |
||
1413 | listBands[2].setGeoRasterFile(((GeoRasterFile) geoFiles.get(iGrf)));
|
||
1414 | listBands[2].setBand(iBand);
|
||
1415 | listBands[2].setPos(iGrf);
|
||
1416 | ((GeoRasterFile) geoFiles.get(iGrf)).setBand(flag, iBand); |
||
1417 | |||
1418 | //System.out.println("==>Asignando banda B FILE="+iGrf+" BANDA="+iBand);
|
||
1419 | } |
||
1420 | |||
1421 | cont++; |
||
1422 | } |
||
1423 | } |
||
1424 | |||
1425 | if (debug) {
|
||
1426 | this.show("setBand"); |
||
1427 | } |
||
1428 | } |
||
1429 | |||
1430 | /**
|
||
1431 | * Obtiene el n?mero de bandas
|
||
1432 | * @return
|
||
1433 | */
|
||
1434 | public int getBandCount() { |
||
1435 | int nbandas = 0; |
||
1436 | |||
1437 | for (int iGrf = 0; iGrf < geoFiles.size(); iGrf++) |
||
1438 | nbandas += ((GeoRasterFile) geoFiles.get(iGrf)).getBandCount(); |
||
1439 | |||
1440 | return nbandas;
|
||
1441 | } |
||
1442 | |||
1443 | /**
|
||
1444 | * Obtiene el GeoRasterFile que hay que leer para cargar la banda del rojo
|
||
1445 | * y la banda de este fichero que se utiliza para esta asignaci?n.
|
||
1446 | * @return Estructura FileBand con la relaci?n fichero-banda
|
||
1447 | */
|
||
1448 | public FileBands getBandR() {
|
||
1449 | return listBands[0]; |
||
1450 | } |
||
1451 | |||
1452 | /**
|
||
1453 | * Obtiene el GeoRasterFile que hay que leer para cargar la banda del verde
|
||
1454 | * y la banda de este fichero que se utiliza para esta asignaci?n.
|
||
1455 | * @return Estructura FileBand con la relaci?n fichero-banda
|
||
1456 | */
|
||
1457 | public FileBands getBandG() {
|
||
1458 | return listBands[1]; |
||
1459 | } |
||
1460 | |||
1461 | /**
|
||
1462 | * Obtiene el GeoRasterFile que hay que leer para cargar la banda del azul
|
||
1463 | * y la banda de este fichero que se utiliza para esta asignaci?n.
|
||
1464 | * @return Estructura FileBand con la relaci?n fichero-banda
|
||
1465 | */
|
||
1466 | public FileBands getBandB() {
|
||
1467 | return listBands[2]; |
||
1468 | } |
||
1469 | |||
1470 | public void show(String op) { |
||
1471 | String banda = null; |
||
1472 | System.out.println("** " + op + " **"); |
||
1473 | |||
1474 | for (int i = 0; i < 3; i++) { |
||
1475 | if (i == 0) { |
||
1476 | banda = new String("Rojo"); |
||
1477 | } else if (i == 1) { |
||
1478 | banda = new String("Verde"); |
||
1479 | } else if (i == 2) { |
||
1480 | banda = new String("Azul"); |
||
1481 | } |
||
1482 | |||
1483 | System.out.println("** BANDA IMAGE=" + banda + " FILEPOS=" + |
||
1484 | listBands[i].getBand() + |
||
1485 | " BANDA DEL FICHERO=" +
|
||
1486 | listBands[i].getBand()); |
||
1487 | } |
||
1488 | } |
||
1489 | } |
||
1490 | /**
|
||
1491 | * @return Returns the vName.
|
||
1492 | */
|
||
1493 | public String getVName() { |
||
1494 | return vName;
|
||
1495 | } |
||
1496 | /**
|
||
1497 | * @param name The vName to set.
|
||
1498 | */
|
||
1499 | public void setVName(String name) { |
||
1500 | vName = name; |
||
1501 | } |
||
1502 | |||
1503 | /**
|
||
1504 | * Obtiene el ?ltimo Image volcado en pantalla
|
||
1505 | * @return
|
||
1506 | */
|
||
1507 | public Image getGeoImage() { |
||
1508 | return geoImage;
|
||
1509 | } |
||
1510 | |||
1511 | /**
|
||
1512 | * Obtiene el ?ltimo viewPort de la vista
|
||
1513 | * @return ViewPortData
|
||
1514 | */
|
||
1515 | public ViewPortData getLastViewPort() {
|
||
1516 | return lastViewPort;
|
||
1517 | } |
||
1518 | } |