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