Statistics
| Revision:

root / trunk / libraries / libRaster / src / org / gvsig / raster / dataset / IBuffer.java @ 27361

History | View | Annotate | Download (16.7 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 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
package org.gvsig.raster.dataset;
20

    
21
import java.awt.image.DataBuffer;
22

    
23
import org.gvsig.raster.buffer.IBand;
24
import org.gvsig.raster.hierarchy.IHistogramable;
25

    
26
/**
27
 * Interfaz que contiene las operaciones que debe soportar un buffer de datos.
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 *
30
 */
31
public interface IBuffer extends IHistogramable{
32
    public final static int TYPE_UNDEFINED = DataBuffer.TYPE_UNDEFINED;
33
    public final static int TYPE_BYTE = DataBuffer.TYPE_BYTE;
34
    public final static int TYPE_SHORT = DataBuffer.TYPE_SHORT;
35
    public final static int TYPE_USHORT = DataBuffer.TYPE_USHORT;
36
    public final static int TYPE_INT = DataBuffer.TYPE_INT;
37
    public final static int TYPE_FLOAT = DataBuffer.TYPE_FLOAT;
38
    public final static int TYPE_DOUBLE = DataBuffer.TYPE_DOUBLE;
39
    public final static int TYPE_IMAGE = -1;
40
    
41
        /*public static int TYPE_UNDEFINED = 32;
42
        public static int TYPE_Byte = 0;                //Buffer byte (8)
43
        public static int TYPE_UInt16 = 1;                //Buffer short (16)
44
        public static int TYPE_Int16 = 2;                //Buffer short (16)
45
        public static int TYPE_UInt32 = 6;                //Buffer int (32)
46
        public static int TYPE_Int32 = 3;                //Buffer int (32)
47
        public static int TYPE_Float32 = 4;                //Buffer float (32)
48
        public static int TYPE_Float64 = 5;                //Buffer double (64)
49
        public static int TYPE_CInt16 = 7;                //Buffer short (16)
50
        public static int TYPE_CInt32 = 8;                //Buffer int (32)
51
        public static int TYPE_CFloat32 = 9;        //Buffer float (32)
52
        public static int TYPE_CFloat64 = 10;*/        //Buffer double (64)
53
    
54
    /**
55
     * Ancho del raster
56
     * @return Entero con el ancho del raster
57
     */
58
    public int getWidth();
59

    
60
    /**
61
     * Alto del raster
62
     * @return Entero con el alto del raster
63
     */
64
    public int getHeight();
65

    
66
    /**
67
     * N?mero de bandas
68
     * @return Entero con el n?mero de bandas
69
     */
70
    public int getBandCount();
71

    
72
    /**
73
     * Obtiene el tipo de dato. Los tipos de dato posibles est?n definidos en IRaster.
74
     * @return tipo de datos
75
     */
76
        public int getDataType();
77
        
78
        /**
79
         * Asigna el tipo de dato. Los tipos de dato posibles est?n definidos en IRaster.
80
         * @param dataType Tipo de dato del buffer
81
         */
82
        public void setDataType(int dataType);
83
        
84
    /**
85
     * Obtiene el valor NoData del buffer
86
     * @return Valor NoData del buffer
87
     */
88
    public double getNoDataValue();
89
    
90
    /**
91
     * Obtiene el valor NoData del buffer
92
     * @return Valor NoData del buffer
93
     */
94
    public byte getByteNoDataValue();
95
    
96
    /**
97
     * Obtiene el valor NoData del buffer
98
     * @return Valor NoData del buffer
99
     */
100
    public short getShortNoDataValue();
101
    
102
    /**
103
     * Obtiene el valor NoData del buffer
104
     * @return Valor NoData del buffer
105
     */
106
    public int getIntNoDataValue();
107
    
108
    /**
109
     * Obtiene el valor NoData del buffer
110
     * @return Valor NoData del buffer
111
     */
112
    public float getFloatNoDataValue();
113
    
114
    /**
115
     * Obtiene true si el pixel pasado por par?metro cae dentro de los l?mites
116
     * del rater y false si cae fuera. 
117
     * @param x Posici?n X del pixel a averiguar
118
     * @param y Posici?n Y del pixel a averiguar
119
     * @return true si est? dentro y false si cae fuera.
120
     */
121
    public boolean isInside(int x, int y);
122
    
123
                /**
124
                 * Calcula el m?nimo y el m?ximo del histograma previamente.
125
                 * @return double[] con el m?nimo y m?ximo y el segundo minimo y maximo.
126
                 * @throws InterruptedException 
127
                 */
128
                public double[] getLimits() throws InterruptedException;
129
    
130
    /**
131
     * Asigna el valor NoData 
132
     * @param nd Valor NoData
133
     */
134
    public void setNoDataValue(double nd);
135
    
136
    /**
137
     * Reserva de memoria para el rasterbuf solo en la banda solicitada
138
     * @param dataType Tipo de dato
139
     * @param width Ancho
140
     * @param height Alto
141
     * @param band N?mero de banda
142
     * @param orig
143
     */
144
    public void mallocOneBand(int dataType, int width, int height, int band);
145
    
146
    /**
147
     * Informa de si el buffer tiene la capacidad de intercambio de bandas o
148
     * no la tiene.
149
     * @return Devuelve true si tiene la capacidad de intercambio de bandas y 
150
     * false si no la tiene.
151
     */
152
    public boolean isBandSwitchable();
153
    
154
        /**
155
         * Libera el buffer de memoria
156
         */
157
        public void free();
158

    
159
    //***********************************************
160
    //Obtiene una linea de datos de todas las bandas
161
    
162
        /**
163
         * Obtiene una l?nea de datos con todas las bandas para buffers con tipo
164
         * de dato byte.
165
         * @param line N?mero de l?nea del buffer a recuperar
166
         * @return Array bidimensional conteniendo la l?nea de datos donde la primera
167
         * dimensi?n representa las bandas y la segunda la posici?n en la l?nea
168
         * @throws InterruptedException 
169
         */    
170
    public byte[][] getLineByte(int line) throws InterruptedException;
171

    
172
    /**
173
         * Obtiene una l?nea de datos con todas las bandas para buffers con tipo
174
         * de dato short.
175
         * @param line N?mero de l?nea del buffer a recuperar
176
         * @return Array bidimensional conteniendo la l?nea de datos donde la primera
177
         * dimensi?n representa las bandas y la segunda la posici?n en la l?nea
178
     * @throws InterruptedException 
179
         */  
180
    public short[][] getLineShort(int line) throws InterruptedException;
181

    
182
    /**
183
         * Obtiene una l?nea de datos con todas las bandas para buffers con tipo
184
         * de dato int.
185
         * @param line N?mero de l?nea del buffer a recuperar
186
         * @return Array bidimensional conteniendo la l?nea de datos donde la primera
187
         * dimensi?n representa las bandas y la segunda la posici?n en la l?nea
188
     * @throws InterruptedException 
189
         */  
190
    public int[][] getLineInt(int line) throws InterruptedException;
191
        
192
    /**
193
         * Obtiene una l?nea de datos con todas las bandas para buffers con tipo
194
         * de dato float.
195
         * @param line N?mero de l?nea del buffer a recuperar
196
         * @return Array bidimensional conteniendo la l?nea de datos donde la primera
197
         * dimensi?n representa las bandas y la segunda la posici?n en la l?nea
198
     * @throws InterruptedException 
199
         */  
200
    public float[][] getLineFloat(int line) throws InterruptedException;
201
    
202
    /**
203
         * Obtiene una l?nea de datos con todas las bandas para buffers con tipo
204
         * de dato double.
205
         * @param line N?mero de l?nea del buffer a recuperar
206
         * @return Array bidimensional conteniendo la l?nea de datos donde la primera
207
         * dimensi?n representa las bandas y la segunda la posici?n en la l?nea
208
     * @throws InterruptedException 
209
         */  
210
    public double[][] getLineDouble(int line) throws InterruptedException;
211
    
212
    //***********************************************
213
    //Obtiene una linea de datos de una banda
214
    
215
    /**
216
     * Obtiene una l?nea de datos de la banda solicitada para buffers con tipo
217
         * de dato byte.
218
     * @param line N?mero de l?nea del buffer a recuperar
219
     * @param band N?mero de banda a recuperar
220
     * @return Array unidimensional que representa la l?nea de datos.
221
     * @throws InterruptedException 
222
     */
223
    public byte[] getLineFromBandByte(int line, int band) throws InterruptedException;
224

    
225
    /**
226
     * Obtiene una l?nea de datos de la banda solicitada para buffers con tipo
227
         * de dato short.
228
     * @param line N?mero de l?nea del buffer a recuperar
229
     * @param band N?mero de banda a recuperar
230
     * @return Array unidimensional que representa la l?nea de datos.
231
     * @throws InterruptedException 
232
     */
233
    public short[] getLineFromBandShort(int line, int band) throws InterruptedException;
234

    
235
    /**
236
     * Obtiene una l?nea de datos de la banda solicitada para buffers con tipo
237
         * de dato int.
238
     * @param line N?mero de l?nea del buffer a recuperar
239
     * @param band N?mero de banda a recuperar
240
     * @return Array unidimensional que representa la l?nea de datos.
241
     * @throws InterruptedException 
242
     */
243
    public int[] getLineFromBandInt(int line, int band) throws InterruptedException;
244
        
245
    /**
246
     * Obtiene una l?nea de datos de la banda solicitada para buffers con tipo
247
         * de dato float.
248
     * @param line N?mero de l?nea del buffer a recuperar
249
     * @param band N?mero de banda a recuperar
250
     * @return Array unidimensional que representa la l?nea de datos.
251
     * @throws InterruptedException 
252
     */
253
    public float[] getLineFromBandFloat(int line, int band) throws InterruptedException;
254
    
255
    /**
256
     * Obtiene una l?nea de datos de la banda solicitada para buffers con tipo
257
         * de dato double.
258
     * @param line N?mero de l?nea del buffer a recuperar
259
     * @param band N?mero de banda a recuperar
260
     * @return Array unidimensional que representa la l?nea de datos.
261
     * @throws InterruptedException 
262
     */
263
    public double[] getLineFromBandDouble(int line, int band) throws InterruptedException;
264
    
265
    //***********************************************    
266
    //Obtiene un elemento de la matriz
267
    
268
    public byte getElemByte(int line, int col, int band) throws InterruptedException;
269
    
270
    public short getElemShort(int line, int col, int band) throws InterruptedException;
271
    
272
    public int getElemInt(int line, int col, int band) throws InterruptedException;
273
    
274
    public float getElemFloat(int line, int col, int band) throws InterruptedException;
275
    
276
    public double getElemDouble(int line, int col, int band) throws InterruptedException;
277
    
278
    //***********************************************
279
    //Copia un elemento de todas la bandas en el buffer pasado por par?metro
280
    
281
    public void getElemByte(int line, int col, byte[] data) throws InterruptedException;
282
    
283
    public void getElemShort(int line, int col, short[] data) throws InterruptedException;
284
    
285
    public void getElemInt(int line, int col, int[] data) throws InterruptedException;
286
    
287
    public void getElemFloat(int line, int col, float[] data) throws InterruptedException;
288
    
289
    public void getElemDouble(int line, int col, double[] data) throws InterruptedException;
290
    
291
    //***********************************************
292
    
293
    /**
294
     * Sustituye una banda completa copiando los datos de la que se pasa por par?metro
295
     * @param nBand N?mero de banda a sustituir
296
     * @param banda a copiar
297
     */
298
    public void copyBand(int nBand, IBand band);
299
    
300
    /**
301
     * Sustituye una banda completa que se asigna por referencia
302
     * @param nBand N?mero de banda a sustituir
303
     * @param banda a asignar por referencia
304
     * @throws InterruptedException 
305
     */
306
    public void assignBand(int nBand, IBand band) throws InterruptedException;
307
    
308
    /**
309
     * Obtiene una banda completa del raster
310
     * @param nBand N?mero de banda 
311
     */
312
    public IBand getBand(int nBand);
313
    
314
    /**
315
     * Obtiene una banda completa del raster
316
     * @param nBand N?mero de banda 
317
     */
318
    public IBuffer getBandBuffer(int nBand);
319
        
320
    //***********************************************
321
    //Asigna una linea de datos a una banda
322
    
323
    public void setLineInBandByte(byte[] data, int line, int band) throws InterruptedException;
324

    
325
    public void setLineInBandShort(short[] data, int line, int band) throws InterruptedException;
326

    
327
    public void setLineInBandInt(int[] data, int line, int band) throws InterruptedException;
328
        
329
    public void setLineInBandFloat(float[] data, int line, int band) throws InterruptedException;
330
    
331
    public void setLineInBandDouble(double[] data, int line, int band) throws InterruptedException;
332
    
333
    //***********************************************
334
    //Asigna una linea de datos a todas las bandas
335
    
336
    public void setLineByte(byte[][] data, int line) throws InterruptedException;
337

    
338
    public void setLineShort(short[][] data, int line) throws InterruptedException;
339

    
340
    public void setLineInt(int[][] data, int line) throws InterruptedException;
341
        
342
    public void setLineFloat(float[][] data, int line) throws InterruptedException;
343
    
344
    public void setLineDouble(double[][] data, int line) throws InterruptedException;
345
    
346
    //**********************************************    
347
    //Asigna un elemento de la matriz
348
    
349
    public void setElem(int line, int col, int band, byte data) throws InterruptedException;
350
    
351
    public void setElem(int line, int col, int band, short data) throws InterruptedException;
352
    
353
    public void setElem(int line, int col, int band, int data) throws InterruptedException;
354
    
355
    public void setElem(int line, int col, int band, float data) throws InterruptedException;
356
    
357
    public void setElem(int line, int col, int band, double data) throws InterruptedException;
358
    
359
    //***********************************************
360
    //Asigna un elemento a todas la bandas en el buffer pasado por par?metro
361
    
362
    public void setElemByte(int line, int col, byte[] data) throws InterruptedException;
363
    
364
    public void setElemShort(int line, int col, short[] data) throws InterruptedException;
365
    
366
    public void setElemInt(int line, int col, int[] data) throws InterruptedException;
367

    
368
    public void setElemFloat(int line, int col, float[] data) throws InterruptedException;
369
    
370
    public void setElemDouble(int line, int col, double[] data) throws InterruptedException;
371
    
372
    //***********************************************
373
    //Inicializa una banda a un valor pasado por par?metro
374
    
375
    public void assign(int band, byte value) throws InterruptedException;
376
    
377
    public void assign(int band, short value) throws InterruptedException;
378
    
379
    public void assign(int band, int value) throws InterruptedException;
380

    
381
    public void assign(int band, float value) throws InterruptedException;
382
    
383
    public void assign(int band, double value) throws InterruptedException;
384
    
385
    //***********************************************
386
   
387
    /**
388
     * Crea un buffer banda inicializado con el valor pasado por par?metro. Las dimensiones
389
     * corresponden a las del buffer existente.
390
     * @param defaultValue Valor con el que se inicializa la banda creada
391
     * @throws InterruptedException 
392
     */
393
    public IBand createBand(byte defaultValue) throws InterruptedException;
394
    
395
    /**
396
     * Replica la banda de una posici?n sobre otra. Si la banda de destino no existe
397
     * se crea nueva. Si la posici?n de la banda de destino est? intercalada entre bandas 
398
     * que ya existen las otras se desplazan hacia abajo, NO se machacan los datos de ninguna.
399
     * Los datos se replican por referencia por lo que al modificar la banda original las
400
     * del resto quedar?n afectadas.   
401
     * @param orig. Posici?n de la banda de origen. 
402
     * @param dest. Posici?n de la banda destino
403
     */   
404
    public void replicateBand(int orig, int dest);
405
    
406
    /**
407
     * Clona el buffer actual y devuelve el clone
408
     * @return Buffer clonado
409
     */
410
    public IBuffer cloneBuffer();
411
    
412
    /**
413
     * Intercambia dos bandas.
414
     * @param band1 Banda 1 a intercambiar 
415
     * @param band2 Banda 2 a intercambiar
416
     * @throws InterruptedException 
417
     */
418
    public void interchangeBands(int band1, int band2) throws InterruptedException;
419
    
420
    /**
421
     * Intercambia la posici?n de las bandas. La nueva posici?n viene dada por el vector
422
     * pasado por par?metro. Cada posici?n del vector es una banda del buffer y el contenido de 
423
     * esa posici?n es la banda que se dibujar? sobre ese buffer.
424
         * <P> 
425
     * Por ejemplo un array con los valores:
426
     * [2, 0, 1] significa que la banda que ocupa ahora la posici?n 2 pasar? a ocupar la 0, la que 
427
     * tiene la posici?n 0 pasa a ocupar la 1 y la que tiene la posici?n 1 pasa a ocupar la 2.
428
     * </P>
429
     * @param bands  Array con la nueva distribuci?n de bandas
430
     */
431
    public void switchBands(int[] bands);
432
    
433
    /**
434
     * Asigna el valor de no valido.
435
     * @param value
436
     */
437
    public void setNotValidValue(double value);
438
    
439
    /**
440
     * Obtiene el valor de no valido.
441
     * @return value
442
     */
443
    public double getNotValidValue();
444
    
445
    /**
446
     * Asigna una banda al valor especificado como no valido. Esta banda es com?n para todas las bandas
447
     * del buffer, es decir se asigna por referencia. No tiene el mismo resultado que asignar una banda
448
     * a un valor fijo.
449
     * @param iBand N?mero de banda
450
     */
451
    public void assignBandToNotValid(int iBand);
452
}