Statistics
| Revision:

gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.buffer / org.gvsig.raster.lib.buffer.api / src / main / java / org / gvsig / raster / lib / buffer / api / BufferManager.java @ 8781

History | View | Annotate | Download (13.2 KB)

1 5439 fdiaz
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.raster.lib.buffer.api;
24
25 6512 fdiaz
import java.awt.image.BufferedImage;
26 5441 fdiaz
import java.awt.image.DataBuffer;
27
import java.io.File;
28 5537 fdiaz
import java.io.IOException;
29 5525 llmarques
import java.util.List;
30 6302 llmarques
import java.util.Map;
31 5439 fdiaz
32 5453 fdiaz
import org.cresques.cts.IProjection;
33 6512 fdiaz
34 5489 llmarques
import org.gvsig.fmap.geom.primitive.Envelope;
35 5452 dmartinezizquierdo
import org.gvsig.raster.lib.buffer.api.exceptions.BandException;
36 5454 fdiaz
import org.gvsig.raster.lib.buffer.api.exceptions.BufferException;
37 8572 fdiaz
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException;
38 8425 fdiaz
import org.gvsig.raster.lib.buffer.api.operations.Operation;
39
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory;
40 6654 fdiaz
import org.gvsig.tools.dataTypes.CoercionException;
41 8425 fdiaz
import org.gvsig.tools.dynobject.DynObject;
42
import org.gvsig.tools.dynobject.DynStruct;
43
import org.gvsig.tools.operations.OperationException;
44 5441 fdiaz
45 5439 fdiaz
/**
46
 * @author fdiaz
47
 *
48
 */
49
public interface BufferManager {
50
51 5489 llmarques
    public final static int TYPE_UNDEFINED = DataBuffer.TYPE_UNDEFINED;
52
    public final static int TYPE_BYTE = DataBuffer.TYPE_BYTE;
53 6547 fdiaz
    public final static int TYPE_USHORT = DataBuffer.TYPE_USHORT;
54 5489 llmarques
    public final static int TYPE_SHORT = DataBuffer.TYPE_SHORT;
55
    public final static int TYPE_INT = DataBuffer.TYPE_INT;
56
    public final static int TYPE_FLOAT = DataBuffer.TYPE_FLOAT;
57
    public final static int TYPE_DOUBLE = DataBuffer.TYPE_DOUBLE;
58 5441 fdiaz
59 5439 fdiaz
    /**
60 5441 fdiaz
     * Creates a NoData object.
61 5515 fdiaz
     *
62 5441 fdiaz
     * @param value
63
     * @param defaultValue
64 5439 fdiaz
     *
65 5450 fdiaz
     * @return NoData
66 5439 fdiaz
     */
67 5441 fdiaz
    public NoData createNoData(Number value, Number defaultValue);
68 6327 llmarques
69 6302 llmarques
    /**
70
     * Creates {@link BandInfo} with information about one band.
71 6385 fdiaz
     *
72 6327 llmarques
     * @param band
73 6302 llmarques
     *            Band of this {@link BandInfo}
74
     * @param name
75
     *            Band name
76
     * @param description
77
     *            Description of band
78 6327 llmarques
     * @param dataType
79
     *            Data type of band. See {@link BufferManager} to check types.
80 6302 llmarques
     * @param values
81
     *            A key-value map with information properties about band
82
     * @return BandInfo
83
     */
84 6327 llmarques
    public BandInfo createBandInfo(int band, String name, String description, int dataType,
85 6302 llmarques
        List<Map.Entry<Object, Object>> values);
86 5439 fdiaz
87
    /**
88 6302 llmarques
     * Creates a {@link Band}. If {@link PageManager} is null, the band will be
89
     * in
90
     * memory, otherwise, the band will be paginated using page manager.
91 5439 fdiaz
     *
92 5441 fdiaz
     * @param dataType
93 6302 llmarques
     *            Type of band. Check {@link BufferManager} to see what types
94
     *            are available
95 5450 fdiaz
     * @param rows
96 6302 llmarques
     *            Band rows
97 5450 fdiaz
     * @param columns
98 6302 llmarques
     *            Band columns
99 5450 fdiaz
     * @param noData
100 6302 llmarques
     *            {@link NoData} of band. If It is null, a undefined NoData will
101
     *            be set.
102 5441 fdiaz
     * @param pageManager
103 6302 llmarques
     *            Page manager to paginate band. It page manager is null, band
104
     *            will be in memory.
105
     * @return Band A empty band.
106 5450 fdiaz
     * @throws BandException
107 6302 llmarques
     *             If there are problems creating the band.
108
     * @see BufferManager#createNoData(Number, Number)
109
     * @see BufferManager#createBandInfo(String, String, List)
110
     * @see BufferManager#createSimpleBandPageManager(File, int, int, int)
111 5441 fdiaz
     */
112 6327 llmarques
    public Band createBand(int dataType, int rows, int columns, NoData noData,
113
        PageManager pageManager) throws BandException;
114 5441 fdiaz
115
    /**
116 5489 llmarques
     * Creates a memory buffer.
117 5515 fdiaz
     *
118 5450 fdiaz
     * @param rows
119 5489 llmarques
     *            Rows of buffer. All buffer bands will have the same rows as
120
     *            buffer.
121 5450 fdiaz
     * @param columns
122 5489 llmarques
     *            Columns of buffer. All buffer bands will have the same
123
     *            columns as buffer.
124 5441 fdiaz
     * @param bandDataTypes
125 5489 llmarques
     *            Types of buffer bands, see {@link BufferManager} to get types.
126
     *            The length of array indicates number of buffer bands.
127 5454 fdiaz
     * @param projection
128 5489 llmarques
     *            Projection of buffer.
129 5450 fdiaz
     * @return Buffer
130 5489 llmarques
     * @throws BufferException
131
     *             If there is any problem creating buffer.
132 5441 fdiaz
     */
133 6327 llmarques
    Buffer createBuffer(int rows, int columns, int[] bandDataTypes, IProjection projection)
134
        throws BufferException;
135 5439 fdiaz
136 5489 llmarques
    /**
137
     * Creates a memory buffer.
138 5515 fdiaz
     *
139 5489 llmarques
     * @param rows
140
     *            Rows of buffer. All buffer bands will have the same rows as
141
     *            buffer.
142
     * @param columns
143
     *            Columns of buffer. All buffer bands will have the same
144
     *            columns as buffer.
145
     * @param bandDataTypes
146
     *            Types of buffer bands, see {@link BufferManager} to get types.
147
     *            The length of array indicates number of buffer bands.
148
     * @param bandNodata
149
     *            {@link NoData} of each band. It can be null. If there are
150
     *            bands without NoData object, a undefined NoData will be set.
151
     * @param projection
152
     *            Projection of buffer.
153
     * @return Buffer
154
     * @throws BufferException
155
     *             If there is any problem creating buffer.
156
     */
157 6327 llmarques
    Buffer createBuffer(int rows, int columns, int[] bandDataTypes, NoData[] bandNodata,
158
        IProjection projection) throws BufferException;
159 5442 fdiaz
160 5441 fdiaz
    /**
161 5489 llmarques
     * Creates a memory buffer.
162 5515 fdiaz
     *
163 5489 llmarques
     * @param rows
164
     *            Rows of buffer. All buffer bands will have the same rows as
165
     *            buffer.
166
     * @param columns
167
     *            Columns of buffer. All buffer bands will have the same
168
     *            columns as buffer.
169
     * @param bandDataTypes
170
     *            Types of buffer bands, see {@link BufferManager} to get types.
171
     *            The length of array indicates number of buffer bands.
172
     * @param bandNodata
173
     *            {@link NoData} of each band. If there are bands without NoData
174
     *            object, a undefined NoData will be set. It can be
175
     *            <code>null</code>.
176
     * @param projection
177
     *            Projection of buffer.
178
     * @param envelope
179
     *            Envelope of data. It can be <code>null</code>.
180
     * @return Buffer
181
     * @throws BufferException
182
     *             If there is any problem creating buffer.
183
     */
184 6327 llmarques
    Buffer createBuffer(int rows, int columns, int[] bandDataTypes, NoData[] bandNodata,
185
        IProjection projection, Envelope envelope) throws BufferException;
186
187 5489 llmarques
    /**
188
     * Creates a buffer. Buffer bands will be paginated using
189
     * {@link BandPageManager}.
190 5515 fdiaz
     *
191 5489 llmarques
     * @param rows
192
     *            Rows of buffer. All buffer bands will have the same rows as
193
     *            buffer.
194
     * @param columns
195
     *            Columns of buffer. All buffer bands will have the same
196
     *            columns as buffer.
197
     * @param bandDataTypes
198
     *            Types of buffer bands, see {@link BufferManager} to get types.
199
     *            The length of array indicates number of buffer bands.
200 6302 llmarques
     * @param bandNoData
201 5489 llmarques
     *            {@link NoData} of each band. If there are bands without NoData
202
     *            object, a undefined NoData will be set. It can be
203
     *            <code>null</code>.
204
     * @param projection
205
     *            Projection of buffer.
206
     * @param envelope
207
     *            Envelope of data. It can be <code>null</code>.
208 5525 llmarques
     * @param pageManagers
209
     *            Page manager list to paginate data bands. If there are bands
210
     *            without page manager,
211
     *            they will be loaded at memory.
212 5489 llmarques
     * @return Buffer
213
     * @throws BufferException
214
     *             If there is any problem creating buffer.
215
     */
216 6302 llmarques
    public Buffer createBuffer(int rows, int columns, int[] bandDataTypes, NoData[] bandNoData,
217
        IProjection projection, Envelope envelope, List<PageManager> pageManagers)
218
        throws BufferException;
219 5489 llmarques
220
    /**
221 6385 fdiaz
     * Creates a buffer from another buffer.
222
     * If paginated parameter is false the buffer bands will be in memory.
223
     * If paginated parameter is true the buffer bands will be paginated using a simple band page manager.
224
     *
225
     * @param buffer
226
     * @param paginated
227
     * @return Buffer
228
     * @throws BufferException
229
     */
230
    public Buffer createBuffer(Buffer buffer, boolean paginated) throws BufferException;
231
232
    /**
233 6894 fdiaz
     * Create one buffer from another by changing the type. The returned buffer will be like a view
234
     * of the original buffer. It not reserve additional memory.
235
     *
236
     * @param buffer
237
     * @param type
238
     * @return a converted type buffer
239
     * @throws BufferException
240
     */
241
    public Buffer createConvertedTypeBuffer(Buffer buffer, int type) throws BufferException;
242
243
    /**
244
     * Creates a buffer from clipping of a buffer. The returned clipping will be like a view
245 5541 fdiaz
     * of the original buffer. It not reserve additional memory. It will only be
246
     * a walkway to access an area of the buffer.
247
     *
248
     * @param buffer
249
     * @param envelope
250
     * @return a clip buffer
251
     * @throws BufferException
252
     */
253
    public Buffer createClippedBuffer(Buffer buffer, Envelope envelope) throws BufferException;
254
255
    /**
256 5441 fdiaz
     * @param file
257 5450 fdiaz
     * @param rows
258
     * @param columns
259 5441 fdiaz
     * @param dataType
260 5450 fdiaz
     * @return BandPageManager
261 5537 fdiaz
     * @throws IOException
262 5441 fdiaz
     */
263 6327 llmarques
    public PageManager createSimpleBandPageManager(File file, int rows, int columns, int dataType)
264
        throws IOException;
265 5537 fdiaz
266 5525 llmarques
    /**
267 5537 fdiaz
     *
268 5541 fdiaz
     * @param files
269 5525 llmarques
     * @param rows
270
     * @param columns
271
     * @param dataType
272 5541 fdiaz
     * @return A list of page managers
273 5537 fdiaz
     * @throws IOException
274 5525 llmarques
     */
275 6327 llmarques
    public List<PageManager> createSimpleBandPageManagerList(File[] files, int rows, int columns,
276
        int[] dataType) throws IOException;
277 5515 fdiaz
278
    /**
279 5525 llmarques
     * @param dataType
280
     *            Data tpye
281 5520 llmarques
     * @return Data type size in bytes
282 5515 fdiaz
     */
283
    public int getDataTypeSize(int dataType);
284
285 5541 fdiaz
    /**
286
     * Creates a clipping of a band. The returned clipping will be like a view
287
     * of the original band. It not reserve additional memory. It will only be
288
     * a walkway to access an area of the band.
289
     *
290
     * @param buffer
291
     * @param band
292
     * @return Band
293 6327 llmarques
     * @throws BandException
294 5541 fdiaz
     */
295
    public Band createClippedBand(Buffer buffer, Band band) throws BandException;
296
297 6512 fdiaz
    /**
298 6894 fdiaz
     * Create one band from another by changing the type. The returned clipping will be like a view
299
     * of the original band. It not reserve additional memory.
300
     *
301
     * @param buffer
302
     * @param band
303
     * @param type
304
     * @return Band
305
     * @throws BandException
306
     */
307
    public Band createConvertedTypeBand(Buffer buffer, Band band, int type) throws BandException;
308
309
    /**
310 6512 fdiaz
     * Creates a Buffer from a BufferedImage
311
     *
312
     * @param img
313
     * @param projection
314
     * @param envelope
315
     *
316
     * @return Buffer
317
     * @throws BufferException
318
     */
319
    public Buffer createBuffer(BufferedImage img, IProjection projection, Envelope envelope) throws BufferException;
320
321
    /**
322 6894 fdiaz
     * Creates a Buffer from a BufferedImage
323
     *
324
     * @param img
325
     * @param projection
326
     * @param envelope
327
     * @param paginated
328
     *
329
     * @return Buffer
330
     * @throws BufferException
331
     */
332
    public Buffer createBuffer(BufferedImage img, IProjection projection, Envelope envelope, boolean paginated) throws BufferException;
333
334
    /**
335 6512 fdiaz
     * Creates a forced RGBA Buffer from a BufferedImage
336
     *
337
     * @param img
338
     * @param projection
339
     * @param envelope
340
     *
341
     * @return Buffer
342
     * @throws BufferException
343
     */
344
    public Buffer createRGBABuffer(BufferedImage img, IProjection projection, Envelope envelope) throws BufferException;
345
346 6654 fdiaz
    /**
347 8781 fdiaz
     * Creates a forced RGB Buffer from a BufferedImage
348
     *
349
     * @param img
350
     * @param projection
351
     * @param envelope
352
     *
353
     * @return Buffer
354
     * @throws BufferException
355
     */
356
    public Buffer createRGBBuffer(BufferedImage img, IProjection projection, Envelope envelope) throws BufferException;
357
358
    /**
359 6654 fdiaz
     * Return type's name
360
     *
361
     * @param type
362
     * @return
363
     */
364
    public String getTypeName(int type);
365 6512 fdiaz
366 6654 fdiaz
    public Object coerce(int dataType, Object value) throws CoercionException;
367 6672 fdiaz
368
    List<Buffer> createOneBufferPerBand(Buffer buffer, boolean paginated) throws BufferException;
369 6677 fdiaz
370
    /**
371
     * @param rows
372
     * @param columns
373
     * @param envelope
374
     * @return
375
     */
376
    public BufferDimensions createBufferDimensions(int rows, int columns, Envelope envelope);
377 6790 fdiaz
378
    /**
379
     * @param folder
380
     */
381
    public void setLastFolderUsedToSaveRaster(File folder);
382
383
    /**
384
     * @return
385
     */
386
    public File getLastFolderUsedToSaveRaster();
387
388 8573 fdiaz
    public Kernel createKernel(double[][] k);
389 8425 fdiaz
390 8573 fdiaz
    public Kernel createKernel(double[][] k, double divisor);
391 8425 fdiaz
392 8573 fdiaz
393
394
395
396
397 5439 fdiaz
}