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 |
/* 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.io.File; |
28 |
import java.io.IOException; |
29 |
import java.util.List; |
30 |
import java.util.Map; |
31 |
|
32 |
import org.cresques.cts.IProjection; |
33 |
|
34 |
import org.gvsig.fmap.geom.primitive.Envelope; |
35 |
import org.gvsig.raster.lib.buffer.api.exceptions.BandException; |
36 |
import org.gvsig.raster.lib.buffer.api.exceptions.BufferException; |
37 |
import org.gvsig.raster.lib.buffer.api.exceptions.BufferOperationException; |
38 |
import org.gvsig.raster.lib.buffer.api.operations.Operation; |
39 |
import org.gvsig.raster.lib.buffer.api.operations.OperationFactory; |
40 |
import org.gvsig.tools.dataTypes.CoercionException; |
41 |
import org.gvsig.tools.dynobject.DynObject; |
42 |
import org.gvsig.tools.dynobject.DynStruct; |
43 |
import org.gvsig.tools.operations.OperationException; |
44 |
|
45 |
/**
|
46 |
* @author fdiaz
|
47 |
*
|
48 |
*/
|
49 |
public interface BufferManager { |
50 |
|
51 |
public final static int TYPE_UNDEFINED = DataBuffer.TYPE_UNDEFINED; |
52 |
public final static int TYPE_BYTE = DataBuffer.TYPE_BYTE; |
53 |
public final static int TYPE_USHORT = DataBuffer.TYPE_USHORT; |
54 |
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 |
|
59 |
/**
|
60 |
* Creates a NoData object.
|
61 |
*
|
62 |
* @param value
|
63 |
* @param defaultValue
|
64 |
*
|
65 |
* @return NoData
|
66 |
*/
|
67 |
public NoData createNoData(Number value, Number defaultValue); |
68 |
|
69 |
/**
|
70 |
* Creates {@link BandInfo} with information about one band.
|
71 |
*
|
72 |
* @param band
|
73 |
* Band of this {@link BandInfo}
|
74 |
* @param name
|
75 |
* Band name
|
76 |
* @param description
|
77 |
* Description of band
|
78 |
* @param dataType
|
79 |
* Data type of band. See {@link BufferManager} to check types.
|
80 |
* @param values
|
81 |
* A key-value map with information properties about band
|
82 |
* @return BandInfo
|
83 |
*/
|
84 |
public BandInfo createBandInfo(int band, String name, String description, int dataType, |
85 |
List<Map.Entry<Object, Object>> values); |
86 |
|
87 |
/**
|
88 |
* 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 |
*
|
92 |
* @param dataType
|
93 |
* Type of band. Check {@link BufferManager} to see what types
|
94 |
* are available
|
95 |
* @param rows
|
96 |
* Band rows
|
97 |
* @param columns
|
98 |
* Band columns
|
99 |
* @param noData
|
100 |
* {@link NoData} of band. If It is null, a undefined NoData will
|
101 |
* be set.
|
102 |
* @param pageManager
|
103 |
* Page manager to paginate band. It page manager is null, band
|
104 |
* will be in memory.
|
105 |
* @return Band A empty band.
|
106 |
* @throws BandException
|
107 |
* 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 |
*/
|
112 |
public Band createBand(int dataType, int rows, int columns, NoData noData, |
113 |
PageManager pageManager) throws BandException;
|
114 |
|
115 |
/**
|
116 |
* Creates a memory buffer.
|
117 |
*
|
118 |
* @param rows
|
119 |
* Rows of buffer. All buffer bands will have the same rows as
|
120 |
* buffer.
|
121 |
* @param columns
|
122 |
* Columns of buffer. All buffer bands will have the same
|
123 |
* columns as buffer.
|
124 |
* @param bandDataTypes
|
125 |
* Types of buffer bands, see {@link BufferManager} to get types.
|
126 |
* The length of array indicates number of buffer bands.
|
127 |
* @param projection
|
128 |
* Projection of buffer.
|
129 |
* @return Buffer
|
130 |
* @throws BufferException
|
131 |
* If there is any problem creating buffer.
|
132 |
*/
|
133 |
Buffer createBuffer(int rows, int columns, int[] bandDataTypes, IProjection projection) |
134 |
throws BufferException;
|
135 |
|
136 |
/**
|
137 |
* Creates a memory buffer.
|
138 |
*
|
139 |
* @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 |
Buffer createBuffer(int rows, int columns, int[] bandDataTypes, NoData[] bandNodata, |
158 |
IProjection projection) throws BufferException;
|
159 |
|
160 |
/**
|
161 |
* Creates a memory buffer.
|
162 |
*
|
163 |
* @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 |
Buffer createBuffer(int rows, int columns, int[] bandDataTypes, NoData[] bandNodata, |
185 |
IProjection projection, Envelope envelope) throws BufferException;
|
186 |
|
187 |
/**
|
188 |
* Creates a buffer. Buffer bands will be paginated using
|
189 |
* {@link BandPageManager}.
|
190 |
*
|
191 |
* @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 |
* @param bandNoData
|
201 |
* {@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 |
* @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 |
* @return Buffer
|
213 |
* @throws BufferException
|
214 |
* If there is any problem creating buffer.
|
215 |
*/
|
216 |
public Buffer createBuffer(int rows, int columns, int[] bandDataTypes, NoData[] bandNoData, |
217 |
IProjection projection, Envelope envelope, List<PageManager> pageManagers)
|
218 |
throws BufferException;
|
219 |
|
220 |
/**
|
221 |
* 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 |
* 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 |
* 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 |
* @param file
|
257 |
* @param rows
|
258 |
* @param columns
|
259 |
* @param dataType
|
260 |
* @return BandPageManager
|
261 |
* @throws IOException
|
262 |
*/
|
263 |
public PageManager createSimpleBandPageManager(File file, int rows, int columns, int dataType) |
264 |
throws IOException; |
265 |
|
266 |
/**
|
267 |
*
|
268 |
* @param files
|
269 |
* @param rows
|
270 |
* @param columns
|
271 |
* @param dataType
|
272 |
* @return A list of page managers
|
273 |
* @throws IOException
|
274 |
*/
|
275 |
public List<PageManager> createSimpleBandPageManagerList(File[] files, int rows, int columns, |
276 |
int[] dataType) throws IOException; |
277 |
|
278 |
/**
|
279 |
* @param dataType
|
280 |
* Data tpye
|
281 |
* @return Data type size in bytes
|
282 |
*/
|
283 |
public int getDataTypeSize(int dataType); |
284 |
|
285 |
/**
|
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 |
* @throws BandException
|
294 |
*/
|
295 |
public Band createClippedBand(Buffer buffer, Band band) throws BandException; |
296 |
|
297 |
/**
|
298 |
* 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 |
* 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 |
* 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 |
* 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 |
/**
|
347 |
* 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 |
* Return type's name
|
360 |
*
|
361 |
* @param type
|
362 |
* @return
|
363 |
*/
|
364 |
public String getTypeName(int type); |
365 |
|
366 |
public Object coerce(int dataType, Object value) throws CoercionException; |
367 |
|
368 |
List<Buffer> createOneBufferPerBand(Buffer buffer, boolean paginated) throws BufferException; |
369 |
|
370 |
/**
|
371 |
* @param rows
|
372 |
* @param columns
|
373 |
* @param envelope
|
374 |
* @return
|
375 |
*/
|
376 |
public BufferDimensions createBufferDimensions(int rows, int columns, Envelope envelope); |
377 |
|
378 |
/**
|
379 |
* @param folder
|
380 |
*/
|
381 |
public void setLastFolderUsedToSaveRaster(File folder); |
382 |
|
383 |
/**
|
384 |
* @return
|
385 |
*/
|
386 |
public File getLastFolderUsedToSaveRaster(); |
387 |
|
388 |
public Kernel createKernel(double[][] k); |
389 |
|
390 |
public Kernel createKernel(double[][] k, double divisor); |
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 |
} |