Statistics
| Revision:

root / trunk / libraries / libRaster / src / org / gvsig / raster / driver / IBuffer.java @ 10740

History | View | Annotate | Download (10.3 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.driver;
20

    
21
import java.awt.image.DataBuffer;
22

    
23
import org.gvsig.raster.dataaccess.buffer.IBand;
24

    
25
/**
26
 * Interfaz que contiene las operaciones que debe soportar un buffer de datos.
27
 * @author Nacho Brodin (nachobrodin@gmail.com)
28
 *
29
 */
30
public interface IBuffer {
31
    public final static int TYPE_UNDEFINED = DataBuffer.TYPE_UNDEFINED;
32
    public final static int TYPE_BYTE = DataBuffer.TYPE_BYTE;
33
    public final static int TYPE_SHORT = DataBuffer.TYPE_SHORT;
34
    public final static int TYPE_USHORT = DataBuffer.TYPE_USHORT;
35
    public final static int TYPE_INT = DataBuffer.TYPE_INT;
36
    public final static int TYPE_FLOAT = DataBuffer.TYPE_FLOAT;
37
    public final static int TYPE_DOUBLE = DataBuffer.TYPE_DOUBLE;
38
    public final static int TYPE_IMAGE = -1;
39
    
40
    /**
41
     * Ancho del raster
42
     * @return Entero con el ancho del raster
43
     */
44
    public int getWidth();
45

    
46
    /**
47
     * Alto del raster
48
     * @return Entero con el alto del raster
49
     */
50
    public int getHeight();
51

    
52
    /**
53
     * N?mero de bandas
54
     * @return Entero con el n?mero de bandas
55
     */
56
    public int getBandCount();
57

    
58
    /**
59
     * Obtiene el tipo de dato. Los tipos de dato posibles est?n definidos en IRaster.
60
     * @return tipo de datos
61
     */
62
        public int getDataType();
63
        
64
        /**
65
         * Asigna el tipo de dato. Los tipos de dato posibles est?n definidos en IRaster.
66
         * @param dataType Tipo de dato del buffer
67
         */
68
        public void setDataType(int dataType);
69
        
70
    /**
71
     * Obtiene el valor NoData del buffer
72
     * @return Valor NoData del buffer
73
     */
74
    public double getNoDataValue();
75
    
76
    /**
77
     * Obtiene el valor NoData del buffer
78
     * @return Valor NoData del buffer
79
     */
80
    public byte getByteNoDataValue();
81
    
82
    /**
83
     * Obtiene el valor NoData del buffer
84
     * @return Valor NoData del buffer
85
     */
86
    public short getShortNoDataValue();
87
    
88
    /**
89
     * Obtiene el valor NoData del buffer
90
     * @return Valor NoData del buffer
91
     */
92
    public int getIntNoDataValue();
93
    
94
    /**
95
     * Obtiene el valor NoData del buffer
96
     * @return Valor NoData del buffer
97
     */
98
    public float getFloatNoDataValue();
99
    
100
    /**
101
     * Asigna el valor NoData 
102
     * @param nd Valor NoData
103
     */
104
    public void setNoDataValue(double nd);
105
    
106
    /**
107
     * Reserva de memoria para el rasterbuf solo en la banda solicitada
108
     * @param dataType Tipo de dato
109
     * @param width Ancho
110
     * @param height Alto
111
     * @param band N?mero de banda
112
     * @param orig
113
     */
114
    public void mallocOneBand(int dataType, int width, int height, int band);
115

    
116
        //***********************************************
117
    //Obtiene una linea de datos con todas las bandas
118
    
119
    public byte[][] getLineByte(int line);
120

    
121
    public short[][] getLineShort(int line);
122

    
123
    public int[][] getLineInt(int line);
124
        
125
    public float[][] getLineFloat(int line);
126
    
127
    public double[][] getLineDouble(int line);
128
    
129
    //***********************************************
130
    //Obtiene una linea de datos de una banda
131
    
132
    public byte[] getLineFromBandByte(int line, int band);
133

    
134
    public short[] getLineFromBandShort(int line, int band);
135

    
136
    public int[] getLineFromBandInt(int line, int band);
137
        
138
    public float[] getLineFromBandFloat(int line, int band);
139
    
140
    public double[] getLineFromBandDouble(int line, int band);
141
    
142
    //***********************************************    
143
    //Obtiene un elemento de la matriz
144
    
145
    public byte getElemByte(int line, int col, int band);
146
    
147
    public short getElemShort(int line, int col, int band);
148
    
149
    public int getElemInt(int line, int col, int band);
150
    
151
    public float getElemFloat(int line, int col, int band);
152
    
153
    public double getElemDouble(int line, int col, int band);
154
    
155
    //***********************************************
156
    //Copia un elemento de todas la bandas en el buffer pasado por par?metro
157
    
158
    public void getElemByte(int line, int col, byte[] data);
159
    
160
    public void getElemShort(int line, int col, short[] data);
161
    
162
    public void getElemInt(int line, int col, int[] data);
163
    
164
    public void getElemFloat(int line, int col, float[] data);
165
    
166
    public void getElemDouble(int line, int col, double[] data);
167
    
168
    //***********************************************
169
    
170
    /**
171
     * Sustituye una banda completa copiando los datos de la que se pasa por par?metro
172
     * @param nBand N?mero de banda a sustituir
173
     * @param banda a copiar
174
     */
175
    public void copyBand(int nBand, IBand band);
176
    
177
    /**
178
     * Sustituye una banda completa que se asigna por referencia
179
     * @param nBand N?mero de banda a sustituir
180
     * @param banda a asignar por referencia
181
     */
182
    public void assignBand(int nBand, IBand band);
183
    
184
    /**
185
     * Obtiene una banda completa del raster
186
     * @param nBand N?mero de banda 
187
     */
188
    public IBand getBand(int nBand);
189
    
190
    /**
191
     * Obtiene una banda completa del raster
192
     * @param nBand N?mero de banda 
193
     */
194
    public IBuffer getBandBuffer(int nBand);
195
        
196
    //***********************************************
197
    //Asigna una linea de datos a una banda
198
    
199
    public void setLineInBandByte(byte[] data, int line, int band);
200

    
201
    public void setLineInBandShort(short[] data, int line, int band);
202

    
203
    public void setLineInBandInt(int[] data, int line, int band);
204
        
205
    public void setLineInBandFloat(float[] data, int line, int band);
206
    
207
    public void setLineInBandDouble(double[] data, int line, int band);
208
    
209
    //***********************************************
210
    //Asigna una linea de datos a todas las bandas
211
    
212
    public void setLineByte(byte[][] data, int line);
213

    
214
    public void setLineShort(short[][] data, int line);
215

    
216
    public void setLineInt(int[][] data, int line);
217
        
218
    public void setLineFloat(float[][] data, int line);
219
    
220
    public void setLineDouble(double[][] data, int line);
221
    
222
    //**********************************************    
223
    //Asigna un elemento de la matriz
224
    
225
    public void setElem(int line, int col, int band, byte data);
226
    
227
    public void setElem(int line, int col, int band, short data);
228
    
229
    public void setElem(int line, int col, int band, int data);
230
    
231
    public void setElem(int line, int col, int band, float data);
232
    
233
    public void setElem(int line, int col, int band, double data);
234
    
235
    //***********************************************
236
    //Asigna un elemento a todas la bandas en el buffer pasado por par?metro
237
    
238
    public void setElemByte(int line, int col, byte[] data);
239
    
240
    public void setElemShort(int line, int col, short[] data);
241
    
242
    public void setElemInt(int line, int col, int[] data);
243

    
244
    public void setElemFloat(int line, int col, float[] data);
245
    
246
    public void setElemDouble(int line, int col, double[] data);
247
    
248
    //***********************************************
249
    //Inicializa una banda a un valor pasado por par?metro
250
    
251
    public void assign(int band, byte value);
252
    
253
    public void assign(int band, short value);
254
    
255
    public void assign(int band, int value);
256

    
257
    public void assign(int band, float value);
258
    
259
    public void assign(int band, double value);
260
    
261
    //***********************************************
262
   
263
    /**
264
     * Crea un buffer banda inicializado con el valor pasado por par?metro. Las dimensiones
265
     * corresponden a las del buffer existente.
266
     * @param defaultValue Valor con el que se inicializa la banda creada
267
     */
268
    public IBand createBand(byte defaultValue);
269
    
270
    /**
271
     * Replica la banda de una posici?n sobre otra. Si la banda de destino no existe
272
     * se crea nueva. Si la posici?n de la banda de destino est? intercalada entre bandas 
273
     * que ya existen las otras se desplazan hacia abajo, NO se machacan los datos de ninguna.
274
     * Los datos se replican por referencia por lo que al modificar la banda original las
275
     * del resto quedar?n afectadas.   
276
     * @param orig. Posici?n de la banda de origen. 
277
     * @param dest. Posici?n de la banda destino
278
     */   
279
    public void replicateBand(int orig, int dest);
280
    
281
    /**
282
     * Clona el buffer actual y devuelve el clone
283
     * @return Buffer clonado
284
     */
285
    public IBuffer cloneBuffer();
286
    
287
    /**
288
     * Intercambia dos bandas.
289
     * @param band1 Banda 1 a intercambiar 
290
     * @param band2 Banda 2 a intercambiar
291
     */
292
    public void interchangeBands(int band1, int band2);
293
    
294
    /**
295
     * Intercambia la posici?n de las bandas. La nueva posici?n viene dada por el vector
296
     * pasado por par?metro. Cada posici?n del vector es una banda del buffer y el contenido de 
297
     * esa posici?n es la banda que se dibujar? sobre ese buffer.
298
         * <P> 
299
     * Por ejemplo un array con los valores:
300
     * [2, 0, 1] significa que la banda que ocupa ahora la posici?n 2 pasar? a ocupar la 0, la que 
301
     * tiene la posici?n 0 pasa a ocupar la 1 y la que tiene la posici?n 1 pasa a ocupar la 2.
302
     * </P>
303
     * @param bands  Array con la nueva distribuci?n de bandas
304
     */
305
    public void switchBands(int[] bands);
306
    
307
    /**
308
     * Asigna el valor de no valido.
309
     * @param value
310
     */
311
    public void setNotValidValue(double value);
312
    
313
    /**
314
     * Obtiene el valor de no valido.
315
     * @return value
316
     */
317
    public double getNotValidValue();
318
    
319
    /**
320
     * Asigna una banda al valor especificado como no valido. Esta banda es com?n para todas las bandas
321
     * del buffer, es decir se asigna por referencia. No tiene el mismo resultado que asignar una banda
322
     * a un valor fijo.
323
     * @param iBand N?mero de banda
324
     */
325
    public void assignBandToNotValid(int iBand);
326
}