Statistics
| Revision:

gvsig-raster / org.gvsig.raster.cache / trunk / org.gvsig.raster.cache / org.gvsig.raster.cache.lib.api / src / main / java / org / gvsig / raster / cache / buffer / BufferCacheManager.java @ 1023

History | View | Annotate | Download (8.5 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.raster.cache.buffer;
23

    
24
import java.io.IOException;
25

    
26
import org.gvsig.raster.cache.buffer.histogram.BufferHistogram;
27
import org.gvsig.raster.cache.buffer.task.TaskEventManager;
28

    
29

    
30

    
31

    
32

    
33
/**
34
 * This class is responsible of the management of the library's business logic.
35
 * It is the library's main entry point, and provides all the services to manage
36
 * {@link BufferCacheService}s.
37
 * 
38
 * @author Nacho Brodin (nachobrodin@gmail.com)
39
 * @version $Id$
40
 */
41
public interface BufferCacheManager {
42
        public static int                      DONT_FORCE                 = 0;
43
        public static int                      MEMORY_BUFFER              = 1;
44
        public static int                      BAND_CACHE                 = 2;
45
        public static int                      BAND_VERT_CACHE            = 3;
46
        public static int                      READ_ONLY_CACHE            = 4;
47
        
48
        /**
49
         * Valor noData por defecto para la librer?a. En caso de no tener un valor asociado
50
         * al raster se usar? este.
51
         */
52
        public static double            defaultNoDataValue       = -99999;
53
        public static boolean           noDataValueEnable        = false;
54
        
55
        //*****************************************************
56
        //BUFFER API
57
        //*****************************************************
58
        
59
        /**
60
         * Genera instancias del buffer de datos adecuado al tama?o del raster. Si no hay muchos datos
61
         * (menos de cacheMemorySize) crear? un buffer en memoria. Si hay m?s de esta cantidad
62
         * entonces crearemos un buffer cacheado (RasterCache). A partir de la cantidad se?alada
63
         * por multicacheMemorySize haremos un buffer cacheado donde cada p?gina no ocupa todo
64
         * el ancho del raster ya que este ser? muy grande. La gesti?n de una cache donde cada
65
         * pagina ha de partir una l?nea lleva una complejidad a?adida.
66
         *  
67
         * @param params Par?metros de la carga
68
         * @return Objeto RasterBuffer
69
         */
70
        public Buffer createBuffer(BufferParam params);
71
        
72
        /**
73
         * Genera una instancia del buffer de solo lectura. Este buffer consta de una cache y unos apuntadores
74
         * a las p?ginas en disco. Cuando se accede a los datos se carga en memoria la p?gina pedida.
75
         *  
76
         * @param  file 
77
         *         File to read data
78
         */
79
        public Buffer createReadOnlyBuffer(String file);
80
        
81
        /**
82
         * Creates an instance of a memory buffer
83
         * 
84
         * @param dataType Tipo de dato
85
         * @param width Ancho
86
         * @param height Alto
87
         * @param bandNr Banda
88
         * @param flag En caso de buffers de memoria este flag a true significa que se reserva la memoria
89
         * para el buffer de forma normal y si est? a false no se reserva por lo que la reserva deber? ser
90
         * posterior. 
91
         */
92
        public Buffer createMemoryBuffer(int dataType, int width, int height, int bandNr, boolean malloc);
93
        
94
        /**
95
         * Creates an instance of a memory buffer
96
         * 
97
         * @param params
98
         *        Parameters to instantiate this buffer
99
         */
100
        public Buffer createMemoryBuffer(BufferParam params);
101
        
102
        /**
103
         * Creates a new instance of an interpolation object.
104
         * @param buf IRasterBuffer
105
         * @return IBufferInterpolation
106
         */
107
        public BufferInterpolation createInterpolation(Buffer buf);
108
        
109
        /**
110
         * Builds a new parameter object
111
         * @param  x
112
         *         Upper left X position 
113
         * @param  y
114
         *         Upper left X position
115
         * @param  w
116
         *         Width
117
         * @param  h
118
         *         Height
119
         */
120
        public BufferParam createBufferParams(int w, int h);
121
        
122
        /**
123
         * Creates a parameter object for building a buffer. The buffer type is read-write.
124
         * This type could be changed after the creation of a {@link BufferParam} object.
125
         * @param  w
126
         *         Width
127
         * @param  h
128
         *         Height
129
         * @param  bandCount
130
         *                    Number of bands
131
         * @param  dataType
132
         *         Type of data        
133
         */
134
        public BufferParam createBufferParams(int w, int h, int bandCount, int dataType);
135
        
136
        /**
137
         * Creates a parameter object for building a buffer. For this call the buffer type 
138
         * is read-only and the source will be a multifile. 
139
         * @param files
140
         *        File list in disk
141
         * @param x
142
         *        initial pixel
143
         * @param y
144
         *        initial pixel
145
         * @param w
146
         *        Width in pixels
147
         * @param h
148
         *        Height in pixels
149
         * @param bands
150
         *        bands to render
151
         * @return {@link BufferParam}
152
         * @throws IOException 
153
         */
154
        public BufferParam createBufferParams(String[] files, int x, int y, int w, int h, int[] bands) throws IOException;
155
        
156
        /**
157
         * Creates a parameter object for building a buffer. For this call the buffer type 
158
         * is read-only. 
159
         * @param file
160
         *        File in disk
161
         * @param x
162
         *        initial pixel
163
         * @param y
164
         *        initial pixel
165
         * @param w
166
         *        Width in pixels
167
         * @param h
168
         *        Height in pixels
169
         * @param bands
170
         *        bands to render
171
         * @return {@link BufferParam}
172
         * @throws IOException 
173
         */
174
        public BufferParam createBufferParams(String file, int x, int y, int w, int h, int[] bands) throws IOException;
175
        
176
        /**
177
         * Creates a parameter object for building a buffer. For this call the buffer type 
178
         * is read-only. 
179
         * @param file
180
         *        File in disk
181
         * @param x
182
         *        initial pixel
183
         * @param y
184
         *        initial pixel
185
         * @param w
186
         *        Width in pixels
187
         * @param h
188
         *        Height in pixels
189
         * @param bands
190
         *        bands to render
191
         * @return {@link BufferParam}
192
         * @throws IOException 
193
         */
194
        public BufferParam createBufferParams(String file, int x, int y, int w, int h) throws IOException;
195
        
196
        //*****************************************************
197
        //NODATA API
198
        //*****************************************************
199
        
200
        /**
201
         * Builds a new NoData object
202
         * @param noData
203
         *        value to assign to all bands
204
         * @param nativeNoData
205
         *        The native is the original value
206
         *        saved in the head of the file or its metadata.
207
         * @param fileName
208
         *        Name of file owner of this nodata value. This string is useful to
209
         *        save the rmf file
210
         * @param bandCount
211
         *        Number of bands of the file
212
         * @return NoData
213
         */
214
        public BufferNoData createNoData(Number noData, Number nativeNoData, String fileName, int bandCount);
215
        
216
        /**
217
         * Builds a new NoData for DEMs
218
         * @param noData
219
         *        value to assign to all bands
220
         * @param nativeNoData
221
         *        The native is the original value
222
         *        saved in the head of the file or its metadata.
223
         * @param fileName
224
         *        Name of file owner of this nodata value. This string is useful to
225
         *        save the rmf file
226
         * @return NoData
227
         */
228
        public BufferNoData createNoData(Number noData, Number nativeNoData, String fileName);
229
        
230
        /**
231
         * Builds a new NoData for DEMs
232
         * @param dataType
233
         *        dataType of this NoData
234
         * @param bandCount
235
         *        Number of bands
236
         * @return NoData
237
         */
238
        public BufferNoData createDefaultNoData(int bandCount, int dataType);
239
        
240
        //*****************************************************
241
        //HISTOGRAM API
242
        //*****************************************************
243
        
244
        /**
245
         * Creates a empty histogram
246
         * @param nBands
247
         * @param min
248
         * @param max
249
         * @param dataType
250
         * @param numberOfClasses
251
         * @return
252
         */
253
        public BufferHistogram createHistogram(int nBands, double[] min, double[] max, int dataType, int numberOfClasses);
254
        
255
        /**
256
         * Creates a empty histogram
257
         * @param nBands
258
         * @param min
259
         * @param max
260
         * @param dataType
261
         * @param numberOfClasses
262
         * @return
263
         */
264
        public BufferHistogram createHistogram(int nBands, int nClasses, double[] min, double[] max);
265
        
266
        //*****************************************************
267
        //TASK API
268
        //*****************************************************
269
        
270
        /**
271
         * Gets a register task. To get a task it will use the current thread ID
272
         * @return TaskEventManager
273
         */
274
        public TaskEventManager getTask();
275
        
276
        /**
277
         * Registers the object as a task using the current thread ID. It returns
278
         * a TaskEventManager
279
         * @param process
280
         * @return
281
         */
282
        public TaskEventManager createTask(Object process);
283
}