gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster_dataaccess_refactoring / org.gvsig.raster.lib / org.gvsig.raster.lib.api / src / main / java / org / gvsig / fmap / dal / coverage / dataset / Buffer.java @ 2308
History | View | Annotate | Download (16.9 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.fmap.dal.coverage.dataset; |
23 |
|
24 |
import java.awt.geom.Rectangle2D; |
25 |
import java.awt.image.DataBuffer; |
26 |
|
27 |
import org.gvsig.fmap.dal.DataSet; |
28 |
import org.gvsig.fmap.dal.coverage.datastruct.Band; |
29 |
import org.gvsig.fmap.dal.coverage.datastruct.NoData; |
30 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
31 |
import org.gvsig.fmap.dal.coverage.process.IncrementableTask; |
32 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
33 |
import org.gvsig.fmap.dal.coverage.store.props.Histogramable; |
34 |
|
35 |
/**
|
36 |
* Interfaz que contiene las operaciones que debe soportar un buffer de datos.
|
37 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
38 |
*
|
39 |
*/
|
40 |
public interface Buffer extends DataSet, Histogramable { |
41 |
public final static int TYPE_UNDEFINED = DataBuffer.TYPE_UNDEFINED; |
42 |
public final static int TYPE_BYTE = DataBuffer.TYPE_BYTE; |
43 |
public final static int TYPE_SHORT = DataBuffer.TYPE_SHORT; |
44 |
public final static int TYPE_USHORT = DataBuffer.TYPE_USHORT; |
45 |
public final static int TYPE_INT = DataBuffer.TYPE_INT; |
46 |
public final static int TYPE_FLOAT = DataBuffer.TYPE_FLOAT; |
47 |
public final static int TYPE_DOUBLE = DataBuffer.TYPE_DOUBLE; |
48 |
public final static int TYPE_IMAGE = -1; |
49 |
|
50 |
public final static int INTERPOLATION_Undefined = 0; |
51 |
public final static int INTERPOLATION_NearestNeighbour = 1; |
52 |
public final static int INTERPOLATION_Bilinear = 2; |
53 |
public final static int INTERPOLATION_InverseDistance = 3; |
54 |
public final static int INTERPOLATION_BicubicSpline = 4; |
55 |
public final static int INTERPOLATION_BSpline = 5; |
56 |
|
57 |
public final static int INCREMENTABLE_INTERPOLATION = 0; |
58 |
public final static int INCREMENTABLE_HISTOGRAM = 1; |
59 |
|
60 |
/*public static int TYPE_UNDEFINED = 32;
|
61 |
public static int TYPE_Byte = 0; //Buffer byte (8)
|
62 |
public static int TYPE_UInt16 = 1; //Buffer short (16)
|
63 |
public static int TYPE_Int16 = 2; //Buffer short (16)
|
64 |
public static int TYPE_UInt32 = 6; //Buffer int (32)
|
65 |
public static int TYPE_Int32 = 3; //Buffer int (32)
|
66 |
public static int TYPE_Float32 = 4; //Buffer float (32)
|
67 |
public static int TYPE_Float64 = 5; //Buffer double (64)
|
68 |
public static int TYPE_CInt16 = 7; //Buffer short (16)
|
69 |
public static int TYPE_CInt32 = 8; //Buffer int (32)
|
70 |
public static int TYPE_CFloat32 = 9; //Buffer float (32)
|
71 |
public static int TYPE_CFloat64 = 10;*/ //Buffer double (64) |
72 |
|
73 |
/**
|
74 |
* Gets the RasterDataStore reference
|
75 |
* @return
|
76 |
*/
|
77 |
public RasterDataStore getStore();
|
78 |
|
79 |
/**
|
80 |
* Sets the RasterDataStore reference
|
81 |
* @param store
|
82 |
*/
|
83 |
public void setStore(RasterDataStore store); |
84 |
|
85 |
/**
|
86 |
* Ancho del raster
|
87 |
* @return Entero con el ancho del raster
|
88 |
*/
|
89 |
public int getWidth(); |
90 |
|
91 |
/**
|
92 |
* Alto del raster
|
93 |
* @return Entero con el alto del raster
|
94 |
*/
|
95 |
public int getHeight(); |
96 |
|
97 |
/**
|
98 |
* Gets the height of a block of data.
|
99 |
* @return
|
100 |
*/
|
101 |
public int getBlockHeight(); |
102 |
|
103 |
/**
|
104 |
* N?mero de bandas
|
105 |
* @return Entero con el n?mero de bandas
|
106 |
*/
|
107 |
public int getBandCount(); |
108 |
|
109 |
/**
|
110 |
* Obtiene el tipo de dato. Los tipos de dato posibles est?n definidos en IRaster.
|
111 |
* @return tipo de datos
|
112 |
*/
|
113 |
public int getDataType(); |
114 |
|
115 |
/**
|
116 |
* Asigna el tipo de dato. Los tipos de dato posibles est?n definidos en IRaster.
|
117 |
* @param dataType Tipo de dato del buffer
|
118 |
*/
|
119 |
public void setDataType(int dataType); |
120 |
|
121 |
/**
|
122 |
* Gets the NoData value of this buffer
|
123 |
* @return
|
124 |
*/
|
125 |
public NoData getNoDataValue();
|
126 |
|
127 |
/**
|
128 |
* Obtiene true si el pixel pasado por par?metro cae dentro de los l?mites
|
129 |
* del rater y false si cae fuera.
|
130 |
* @param x Posici?n X del pixel a averiguar
|
131 |
* @param y Posici?n Y del pixel a averiguar
|
132 |
* @return true si est? dentro y false si cae fuera.
|
133 |
*/
|
134 |
public boolean isInside(int x, int y); |
135 |
|
136 |
/**
|
137 |
* Calcula el m?nimo y el m?ximo del histograma previamente.
|
138 |
* @return double[] con el m?nimo y m?ximo y el segundo minimo y maximo.
|
139 |
* @throws ProcessInterruptedException
|
140 |
*/
|
141 |
public double[] getLimits() throws ProcessInterruptedException; |
142 |
|
143 |
/**
|
144 |
* Sets the NoData value
|
145 |
* @param nd
|
146 |
*/
|
147 |
public void setNoDataValue(NoData nd); |
148 |
|
149 |
/**
|
150 |
* Reserva de memoria para el rasterbuf solo en la banda solicitada
|
151 |
* @param dataType Tipo de dato
|
152 |
* @param width Ancho
|
153 |
* @param height Alto
|
154 |
* @param band N?mero de banda
|
155 |
* @param orig
|
156 |
*/
|
157 |
public void mallocOneBand(int dataType, int width, int height, int band); |
158 |
|
159 |
/**
|
160 |
* Informa de si el buffer tiene la capacidad de intercambio de bandas o
|
161 |
* no la tiene.
|
162 |
* @return Devuelve true si tiene la capacidad de intercambio de bandas y
|
163 |
* false si no la tiene.
|
164 |
*/
|
165 |
public boolean isBandSwitchable(); |
166 |
|
167 |
/**
|
168 |
* Returns true if the current buffer can't be writed
|
169 |
* @return
|
170 |
*/
|
171 |
public boolean isReadOnlyBuffer(); |
172 |
|
173 |
/**
|
174 |
* Returns true if it is a cached buffer
|
175 |
* @return
|
176 |
*/
|
177 |
public boolean isCached(); |
178 |
|
179 |
/**
|
180 |
* Gets a bouding box of this buffer
|
181 |
* @return
|
182 |
*/
|
183 |
public Rectangle2D getDataExtent(); |
184 |
|
185 |
/**
|
186 |
* Sets a bounding box of this buffer
|
187 |
* @param r
|
188 |
*/
|
189 |
public void setDataExtent(Rectangle2D r); |
190 |
|
191 |
/**
|
192 |
* Assigns the band list but only for a read only buffer
|
193 |
* @param bandList
|
194 |
*/
|
195 |
public void addDrawableBands(int[] db); |
196 |
|
197 |
//***********************************************
|
198 |
//Obtiene una linea de datos de todas las bandas
|
199 |
|
200 |
/**
|
201 |
* Obtiene una l?nea de datos con todas las bandas para buffers con tipo
|
202 |
* de dato byte.
|
203 |
* @param line N?mero de l?nea del buffer a recuperar
|
204 |
* @return Array bidimensional conteniendo la l?nea de datos donde la primera
|
205 |
* dimensi?n representa las bandas y la segunda la posici?n en la l?nea
|
206 |
*/
|
207 |
public byte[][] getLineByte(int line); |
208 |
|
209 |
/**
|
210 |
* Obtiene una l?nea de datos con todas las bandas para buffers con tipo
|
211 |
* de dato short.
|
212 |
* @param line N?mero de l?nea del buffer a recuperar
|
213 |
* @return Array bidimensional conteniendo la l?nea de datos donde la primera
|
214 |
* dimensi?n representa las bandas y la segunda la posici?n en la l?nea
|
215 |
*/
|
216 |
public short[][] getLineShort(int line); |
217 |
|
218 |
/**
|
219 |
* Obtiene una l?nea de datos con todas las bandas para buffers con tipo
|
220 |
* de dato int.
|
221 |
* @param line N?mero de l?nea del buffer a recuperar
|
222 |
* @return Array bidimensional conteniendo la l?nea de datos donde la primera
|
223 |
* dimensi?n representa las bandas y la segunda la posici?n en la l?nea
|
224 |
*/
|
225 |
public int[][] getLineInt(int line); |
226 |
|
227 |
/**
|
228 |
* Obtiene una l?nea de datos con todas las bandas para buffers con tipo
|
229 |
* de dato float.
|
230 |
* @param line N?mero de l?nea del buffer a recuperar
|
231 |
* @return Array bidimensional conteniendo la l?nea de datos donde la primera
|
232 |
* dimensi?n representa las bandas y la segunda la posici?n en la l?nea
|
233 |
*/
|
234 |
public float[][] getLineFloat(int line); |
235 |
|
236 |
/**
|
237 |
* Obtiene una l?nea de datos con todas las bandas para buffers con tipo
|
238 |
* de dato double.
|
239 |
* @param line N?mero de l?nea del buffer a recuperar
|
240 |
* @return Array bidimensional conteniendo la l?nea de datos donde la primera
|
241 |
* dimensi?n representa las bandas y la segunda la posici?n en la l?nea
|
242 |
*/
|
243 |
public double[][] getLineDouble(int line); |
244 |
|
245 |
//***********************************************
|
246 |
//Obtiene una linea de datos de una banda
|
247 |
|
248 |
/**
|
249 |
* Obtiene una l?nea de datos de la banda solicitada para buffers con tipo
|
250 |
* de dato byte.
|
251 |
* @param line N?mero de l?nea del buffer a recuperar
|
252 |
* @param band N?mero de banda a recuperar
|
253 |
* @return Array unidimensional que representa la l?nea de datos.
|
254 |
*/
|
255 |
public byte[] getLineFromBandByte(int line, int band); |
256 |
|
257 |
/**
|
258 |
* Obtiene una l?nea de datos de la banda solicitada para buffers con tipo
|
259 |
* de dato short.
|
260 |
* @param line N?mero de l?nea del buffer a recuperar
|
261 |
* @param band N?mero de banda a recuperar
|
262 |
* @return Array unidimensional que representa la l?nea de datos.
|
263 |
*/
|
264 |
public short[] getLineFromBandShort(int line, int band); |
265 |
|
266 |
/**
|
267 |
* Obtiene una l?nea de datos de la banda solicitada para buffers con tipo
|
268 |
* de dato int.
|
269 |
* @param line N?mero de l?nea del buffer a recuperar
|
270 |
* @param band N?mero de banda a recuperar
|
271 |
* @return Array unidimensional que representa la l?nea de datos.
|
272 |
*/
|
273 |
public int[] getLineFromBandInt(int line, int band); |
274 |
|
275 |
/**
|
276 |
* Obtiene una l?nea de datos de la banda solicitada para buffers con tipo
|
277 |
* de dato float.
|
278 |
* @param line N?mero de l?nea del buffer a recuperar
|
279 |
* @param band N?mero de banda a recuperar
|
280 |
* @return Array unidimensional que representa la l?nea de datos.
|
281 |
*/
|
282 |
public float[] getLineFromBandFloat(int line, int band); |
283 |
|
284 |
/**
|
285 |
* Obtiene una l?nea de datos de la banda solicitada para buffers con tipo
|
286 |
* de dato double.
|
287 |
* @param line N?mero de l?nea del buffer a recuperar
|
288 |
* @param band N?mero de banda a recuperar
|
289 |
* @return Array unidimensional que representa la l?nea de datos.
|
290 |
*/
|
291 |
public double[] getLineFromBandDouble(int line, int band); |
292 |
|
293 |
//***********************************************
|
294 |
//Obtiene un elemento de la matriz
|
295 |
|
296 |
public byte getElemByte(int line, int col, int band); |
297 |
|
298 |
public short getElemShort(int line, int col, int band); |
299 |
|
300 |
public int getElemInt(int line, int col, int band); |
301 |
|
302 |
public float getElemFloat(int line, int col, int band); |
303 |
|
304 |
public double getElemDouble(int line, int col, int band); |
305 |
|
306 |
//***********************************************
|
307 |
//Copia un elemento de todas la bandas en el buffer pasado por par?metro
|
308 |
|
309 |
public void getElemByte(int line, int col, byte[] data); |
310 |
|
311 |
public void getElemShort(int line, int col, short[] data); |
312 |
|
313 |
public void getElemInt(int line, int col, int[] data); |
314 |
|
315 |
public void getElemFloat(int line, int col, float[] data); |
316 |
|
317 |
public void getElemDouble(int line, int col, double[] data); |
318 |
|
319 |
//***********************************************
|
320 |
|
321 |
/**
|
322 |
* Sustituye una banda completa copiando los datos de la que se pasa por par?metro
|
323 |
* @param nBand N?mero de banda a sustituir
|
324 |
* @param banda a copiar
|
325 |
*/
|
326 |
public void copyBand(int nBand, Band band); |
327 |
|
328 |
/**
|
329 |
* Sustituye una banda completa que se asigna por referencia
|
330 |
* @param nBand N?mero de banda a sustituir
|
331 |
* @param banda a asignar por referencia
|
332 |
*/
|
333 |
public void assignBand(int nBand, Band band); |
334 |
|
335 |
/**
|
336 |
* Obtiene una banda completa del raster
|
337 |
* @param nBand N?mero de banda
|
338 |
*/
|
339 |
public Band getBand(int nBand); |
340 |
|
341 |
/**
|
342 |
* Obtiene una banda completa del raster
|
343 |
* @param nBand N?mero de banda
|
344 |
*/
|
345 |
public Buffer getBandBuffer(int nBand); |
346 |
|
347 |
//***********************************************
|
348 |
//Asigna una linea de datos a una banda
|
349 |
|
350 |
public void setLineInBandByte(byte[] data, int line, int band); |
351 |
|
352 |
public void setLineInBandShort(short[] data, int line, int band); |
353 |
|
354 |
public void setLineInBandInt(int[] data, int line, int band); |
355 |
|
356 |
public void setLineInBandFloat(float[] data, int line, int band); |
357 |
|
358 |
public void setLineInBandDouble(double[] data, int line, int band); |
359 |
|
360 |
//***********************************************
|
361 |
//Asigna una linea de datos a todas las bandas
|
362 |
|
363 |
public void setLineByte(byte[][] data, int line); |
364 |
|
365 |
public void setLineShort(short[][] data, int line); |
366 |
|
367 |
public void setLineInt(int[][] data, int line); |
368 |
|
369 |
public void setLineFloat(float[][] data, int line); |
370 |
|
371 |
public void setLineDouble(double[][] data, int line); |
372 |
|
373 |
//**********************************************
|
374 |
//Asigna un elemento de la matriz
|
375 |
|
376 |
public void setElem(int line, int col, int band, byte data); |
377 |
|
378 |
public void setElem(int line, int col, int band, short data); |
379 |
|
380 |
public void setElem(int line, int col, int band, int data); |
381 |
|
382 |
public void setElem(int line, int col, int band, float data); |
383 |
|
384 |
public void setElem(int line, int col, int band, double data); |
385 |
|
386 |
//***********************************************
|
387 |
//Asigna un elemento a todas la bandas en el buffer pasado por par?metro
|
388 |
|
389 |
public void setElemByte(int line, int col, byte[] data); |
390 |
|
391 |
public void setElemShort(int line, int col, short[] data); |
392 |
|
393 |
public void setElemInt(int line, int col, int[] data); |
394 |
|
395 |
public void setElemFloat(int line, int col, float[] data); |
396 |
|
397 |
public void setElemDouble(int line, int col, double[] data); |
398 |
|
399 |
//***********************************************
|
400 |
//Inicializa una banda a un valor pasado por par?metro
|
401 |
|
402 |
public void assign(int band, byte value); |
403 |
|
404 |
public void assign(int band, short value); |
405 |
|
406 |
public void assign(int band, int value); |
407 |
|
408 |
public void assign(int band, float value); |
409 |
|
410 |
public void assign(int band, double value); |
411 |
|
412 |
//***********************************************
|
413 |
|
414 |
/**
|
415 |
* Crea un buffer banda inicializado con el valor pasado por par?metro. Las dimensiones
|
416 |
* corresponden a las del buffer existente.
|
417 |
* @param defaultValue Valor con el que se inicializa la banda creada
|
418 |
*/
|
419 |
public Band createBand(byte defaultValue); |
420 |
|
421 |
/**
|
422 |
* Replica la banda de una posici?n sobre otra. Si la banda de destino no existe
|
423 |
* se crea nueva. Si la posici?n de la banda de destino est? intercalada entre bandas
|
424 |
* que ya existen las otras se desplazan hacia abajo, NO se machacan los datos de ninguna.
|
425 |
* Los datos se replican por referencia por lo que al modificar la banda original las
|
426 |
* del resto quedar?n afectadas.
|
427 |
* @param orig. Posici?n de la banda de origen.
|
428 |
* @param dest. Posici?n de la banda destino
|
429 |
*/
|
430 |
public void replicateBand(int orig, int dest); |
431 |
|
432 |
/**
|
433 |
* Clona el buffer actual y devuelve el clone
|
434 |
* @return Buffer clonado
|
435 |
*/
|
436 |
public Buffer cloneBuffer(); |
437 |
|
438 |
/**
|
439 |
* Intercambia dos bandas.
|
440 |
* @param band1 Banda 1 a intercambiar
|
441 |
* @param band2 Banda 2 a intercambiar
|
442 |
*/
|
443 |
public void interchangeBands(int band1, int band2); |
444 |
|
445 |
/**
|
446 |
* Intercambia la posici?n de las bandas. La nueva posici?n viene dada por el vector
|
447 |
* pasado por par?metro. Cada posici?n del vector es una banda del buffer y el contenido de
|
448 |
* esa posici?n es la banda que se dibujar? sobre ese buffer.
|
449 |
* <P>
|
450 |
* Por ejemplo un array con los valores:
|
451 |
* [2, 0, 1] significa que la banda que ocupa ahora la posici?n 2 pasar? a ocupar la 0, la que
|
452 |
* tiene la posici?n 0 pasa a ocupar la 1 y la que tiene la posici?n 1 pasa a ocupar la 2.
|
453 |
* </P>
|
454 |
* @param bands Array con la nueva distribuci?n de bandas
|
455 |
*/
|
456 |
public void switchBands(int[] bands); |
457 |
|
458 |
/**
|
459 |
* Asigna el valor de no valido.
|
460 |
* @param value
|
461 |
*/
|
462 |
public void setNotValidValue(double value); |
463 |
|
464 |
/**
|
465 |
* Obtiene el valor de no valido.
|
466 |
* @return value
|
467 |
*/
|
468 |
public double getNotValidValue(); |
469 |
|
470 |
/**
|
471 |
* Asigna una banda al valor especificado como no valido. Esta banda es com?n para todas las bandas
|
472 |
* del buffer, es decir se asigna por referencia. No tiene el mismo resultado que asignar una banda
|
473 |
* a un valor fijo.
|
474 |
* @param iBand N?mero de banda
|
475 |
*/
|
476 |
public void assignBandToNotValid(int iBand); |
477 |
|
478 |
/**
|
479 |
* Ajusta el ?rea del grid a un ancho y un alto dado en pixeles. Este ajuste se har?
|
480 |
* en relaci?n a un m?todo de interpolaci?n definido en el par?metro.
|
481 |
* @param w Ancho de la nueva imagen.
|
482 |
* @param h Alto de la nueva imagen.
|
483 |
* @param interpolation M?todo de interpolaci?n que se usar? en el ajuste.
|
484 |
*/
|
485 |
public Buffer getAdjustedWindow(int w, int h, int interpolationMethod) throws ProcessInterruptedException; |
486 |
|
487 |
/**
|
488 |
* This call returns an incrementable task that is needed to load the buffer. Usually
|
489 |
* this is a BufferInterpolation class.
|
490 |
* @return
|
491 |
*/
|
492 |
public IncrementableTask getIncrementableTask(int type); |
493 |
|
494 |
public double[][] getAllBandsLimits() throws ProcessInterruptedException; |
495 |
} |