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 @ 6327

History | View | Annotate | Download (9.55 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.DataBuffer;
26
import java.io.File;
27
import java.io.IOException;
28
import java.util.List;
29
import java.util.Map;
30

    
31
import org.cresques.cts.IProjection;
32
import org.gvsig.fmap.geom.primitive.Envelope;
33
import org.gvsig.raster.lib.buffer.api.exceptions.BandException;
34
import org.gvsig.raster.lib.buffer.api.exceptions.BufferException;
35

    
36
/**
37
 * @author fdiaz
38
 *
39
 */
40
public interface BufferManager {
41

    
42
    public final static int TYPE_UNDEFINED = DataBuffer.TYPE_UNDEFINED;
43
    public final static int TYPE_BYTE = DataBuffer.TYPE_BYTE;
44
    public final static int TYPE_SHORT = DataBuffer.TYPE_SHORT;
45
    public final static int TYPE_USHORT = DataBuffer.TYPE_USHORT;
46
    public final static int TYPE_INT = DataBuffer.TYPE_INT;
47
    public final static int TYPE_FLOAT = DataBuffer.TYPE_FLOAT;
48
    public final static int TYPE_DOUBLE = DataBuffer.TYPE_DOUBLE;
49

    
50
    /**
51
     * Creates a NoData object.
52
     *
53
     * @param value
54
     * @param defaultValue
55
     *
56
     * @return NoData
57
     */
58
    public NoData createNoData(Number value, Number defaultValue);
59

    
60
    /**
61
     * Creates {@link BandInfo} with information about one band.
62
     * 
63
     * @param band
64
     *            Band of this {@link BandInfo}
65
     * @param name
66
     *            Band name
67
     * @param description
68
     *            Description of band
69
     * @param dataType
70
     *            Data type of band. See {@link BufferManager} to check types.
71
     * @param values
72
     *            A key-value map with information properties about band
73
     * @return BandInfo
74
     */
75
    public BandInfo createBandInfo(int band, String name, String description, int dataType,
76
        List<Map.Entry<Object, Object>> values);
77

    
78
    /**
79
     * Creates a {@link Band}. If {@link PageManager} is null, the band will be
80
     * in
81
     * memory, otherwise, the band will be paginated using page manager.
82
     *
83
     * @param dataType
84
     *            Type of band. Check {@link BufferManager} to see what types
85
     *            are available
86
     * @param rows
87
     *            Band rows
88
     * @param columns
89
     *            Band columns
90
     * @param noData
91
     *            {@link NoData} of band. If It is null, a undefined NoData will
92
     *            be set.
93
     * @param pageManager
94
     *            Page manager to paginate band. It page manager is null, band
95
     *            will be in memory.
96
     * @return Band A empty band.
97
     * @throws BandException
98
     *             If there are problems creating the band.
99
     * @see BufferManager#createNoData(Number, Number)
100
     * @see BufferManager#createBandInfo(String, String, List)
101
     * @see BufferManager#createSimpleBandPageManager(File, int, int, int)
102
     */
103
    public Band createBand(int dataType, int rows, int columns, NoData noData,
104
        PageManager pageManager) throws BandException;
105

    
106
    /**
107
     * Creates a memory buffer.
108
     *
109
     * @param rows
110
     *            Rows of buffer. All buffer bands will have the same rows as
111
     *            buffer.
112
     * @param columns
113
     *            Columns of buffer. All buffer bands will have the same
114
     *            columns as buffer.
115
     * @param bandDataTypes
116
     *            Types of buffer bands, see {@link BufferManager} to get types.
117
     *            The length of array indicates number of buffer bands.
118
     * @param projection
119
     *            Projection of buffer.
120
     * @return Buffer
121
     * @throws BufferException
122
     *             If there is any problem creating buffer.
123
     */
124
    Buffer createBuffer(int rows, int columns, int[] bandDataTypes, IProjection projection)
125
        throws BufferException;
126

    
127
    /**
128
     * Creates a memory buffer.
129
     *
130
     * @param rows
131
     *            Rows of buffer. All buffer bands will have the same rows as
132
     *            buffer.
133
     * @param columns
134
     *            Columns of buffer. All buffer bands will have the same
135
     *            columns as buffer.
136
     * @param bandDataTypes
137
     *            Types of buffer bands, see {@link BufferManager} to get types.
138
     *            The length of array indicates number of buffer bands.
139
     * @param bandNodata
140
     *            {@link NoData} of each band. It can be null. If there are
141
     *            bands without NoData object, a undefined NoData will be set.
142
     * @param projection
143
     *            Projection of buffer.
144
     * @return Buffer
145
     * @throws BufferException
146
     *             If there is any problem creating buffer.
147
     */
148
    Buffer createBuffer(int rows, int columns, int[] bandDataTypes, NoData[] bandNodata,
149
        IProjection projection) throws BufferException;
150

    
151
    /**
152
     * Creates a memory buffer.
153
     *
154
     * @param rows
155
     *            Rows of buffer. All buffer bands will have the same rows as
156
     *            buffer.
157
     * @param columns
158
     *            Columns of buffer. All buffer bands will have the same
159
     *            columns as buffer.
160
     * @param bandDataTypes
161
     *            Types of buffer bands, see {@link BufferManager} to get types.
162
     *            The length of array indicates number of buffer bands.
163
     * @param bandNodata
164
     *            {@link NoData} of each band. If there are bands without NoData
165
     *            object, a undefined NoData will be set. It can be
166
     *            <code>null</code>.
167
     * @param projection
168
     *            Projection of buffer.
169
     * @param envelope
170
     *            Envelope of data. It can be <code>null</code>.
171
     * @return Buffer
172
     * @throws BufferException
173
     *             If there is any problem creating buffer.
174
     */
175
    Buffer createBuffer(int rows, int columns, int[] bandDataTypes, NoData[] bandNodata,
176
        IProjection projection, Envelope envelope) throws BufferException;
177

    
178
    /**
179
     * Creates a buffer. Buffer bands will be paginated using
180
     * {@link BandPageManager}.
181
     *
182
     * @param rows
183
     *            Rows of buffer. All buffer bands will have the same rows as
184
     *            buffer.
185
     * @param columns
186
     *            Columns of buffer. All buffer bands will have the same
187
     *            columns as buffer.
188
     * @param bandDataTypes
189
     *            Types of buffer bands, see {@link BufferManager} to get types.
190
     *            The length of array indicates number of buffer bands.
191
     * @param bandNoData
192
     *            {@link NoData} of each band. If there are bands without NoData
193
     *            object, a undefined NoData will be set. It can be
194
     *            <code>null</code>.
195
     * @param projection
196
     *            Projection of buffer.
197
     * @param envelope
198
     *            Envelope of data. It can be <code>null</code>.
199
     * @param pageManagers
200
     *            Page manager list to paginate data bands. If there are bands
201
     *            without page manager,
202
     *            they will be loaded at memory.
203
     * @return Buffer
204
     * @throws BufferException
205
     *             If there is any problem creating buffer.
206
     */
207
    public Buffer createBuffer(int rows, int columns, int[] bandDataTypes, NoData[] bandNoData,
208
        IProjection projection, Envelope envelope, List<PageManager> pageManagers)
209
        throws BufferException;
210

    
211
    /**
212
     * Creates a clipping of a buffer. The returned clipping will be like a view
213
     * of the original buffer. It not reserve additional memory. It will only be
214
     * a walkway to access an area of the buffer.
215
     *
216
     * @param buffer
217
     * @param envelope
218
     * @return a clip buffer
219
     * @throws BufferException
220
     */
221
    public Buffer createClippedBuffer(Buffer buffer, Envelope envelope) throws BufferException;
222

    
223
    /**
224
     * @param file
225
     * @param rows
226
     * @param columns
227
     * @param dataType
228
     * @return BandPageManager
229
     * @throws IOException
230
     */
231
    public PageManager createSimpleBandPageManager(File file, int rows, int columns, int dataType)
232
        throws IOException;
233

    
234
    /**
235
     *
236
     * @param files
237
     * @param rows
238
     * @param columns
239
     * @param dataType
240
     * @return A list of page managers
241
     * @throws IOException
242
     */
243
    public List<PageManager> createSimpleBandPageManagerList(File[] files, int rows, int columns,
244
        int[] dataType) throws IOException;
245

    
246
    /**
247
     * @param dataType
248
     *            Data tpye
249
     * @return Data type size in bytes
250
     */
251
    public int getDataTypeSize(int dataType);
252

    
253
    /**
254
     * Creates a clipping of a band. The returned clipping will be like a view
255
     * of the original band. It not reserve additional memory. It will only be
256
     * a walkway to access an area of the band.
257
     *
258
     * @param buffer
259
     * @param band
260
     * @return Band
261
     * @throws BandException
262
     */
263
    public Band createClippedBand(Buffer buffer, Band band) throws BandException;
264

    
265
}