Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.lib / org.gvsig.raster.lib.impl / src / main / java / org / gvsig / raster / impl / buffer / cache / PageBuffer.java @ 2623

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

    
24
import java.awt.geom.Rectangle2D;
25
import java.io.IOException;
26

    
27
import org.gvsig.fmap.dal.DataStore;
28
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
29
import org.gvsig.fmap.dal.coverage.datastruct.Band;
30
import org.gvsig.fmap.dal.coverage.datastruct.NoData;
31
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
32
import org.gvsig.fmap.dal.coverage.process.IncrementableTask;
33
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
34
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer;
35
import org.gvsig.raster.impl.buffer.BufferHistogramComputer;
36
import org.gvsig.raster.impl.buffer.BufferInterpolation;
37
import org.gvsig.raster.impl.process.RasterTask;
38
import org.gvsig.raster.impl.process.RasterTaskQueue;
39
import org.gvsig.tools.exception.BaseException;
40
import org.gvsig.tools.visitor.Visitor;
41

    
42
/**
43
 * Esta clase representa una p?gina de cache.Cada p?gina de cach? est? compuesta por
44
 * varios objetos PageBandBuffer donde cada uno es una p?gina que corresponde a una 
45
 * banda de raster cacheada. 
46
 * 
47
 * @author Nacho Brodin (nachobrodin@gmail.com)
48
 *
49
 */
50
public class PageBuffer implements Buffer {
51
        private PageBandBuffer[]    pageBandBuffer       = null;
52
        private double[]            limits               = null;
53
        private HistogramComputer   histogramComputer    = null;
54
        private BufferInterpolation interp               = null;
55
        
56
        /**
57
         * Constructor
58
         * @param dataType
59
         * @param width
60
         * @param height
61
         * @param bandNr
62
         * @param malloc
63
         */
64
        public PageBuffer(int dataType, int width, int height, int bandNr, boolean malloc, int nHddPags) {
65
                pageBandBuffer = new PageBandBuffer[bandNr];
66
                for (int i = 0; i < pageBandBuffer.length; i++)
67
                        pageBandBuffer[i] = new PageBandBuffer(dataType, width, height, 1, malloc, i);
68
        }
69
        
70
        public boolean isBandSwitchable() {
71
                return false;
72
        }
73
        
74
        /**
75
         * Asigna la lista de paginas de disco
76
         * @param hddList Lista de p?ginas de disco
77
         */
78
        public void setHddPages(HddPage[] hddList) {
79
                for (int i = 0; i < pageBandBuffer.length; i++)
80
                        pageBandBuffer[i].setHddPages(hddList);
81
        }
82
        
83
        /**
84
         * Carga una p?gina especificada en el par?metro nPag con los datos necesarios.
85
         * Para esto recorre todas las bandas de la p?gina llamando al load de cada una.
86
         *   
87
         * @param nPag N?mero de p?gina a cargar
88
         */
89
        public void loadPage(int nPag) {
90
                for (int i = 0; i < pageBandBuffer.length; i++) {
91
                        try {
92
                                pageBandBuffer[i].loadPage(nPag);
93
                        } catch (ProcessInterruptedException e) {
94
                                //Cuando se cancela la carga de una p?gina salimos al acabar la p?gina anterior
95
                                break; 
96
                        }
97
                }
98
        }
99
        
100
        /**
101
         * Salva una p?gina especificada en el par?metro nPag a disco. 
102
         * Para esto recorre todas las bandas de la p?gina llamando al save de cada una.
103
         *   
104
         * @param nPag N?mero de p?gina a salvar
105
         * @throws IOException
106
         */
107
        public void savePage(int nPag) throws IOException {
108
                for (int i = 0; i < pageBandBuffer.length; i++)
109
                        pageBandBuffer[i].savePage(nPag);
110
        }
111
        
112
        public void assign(int band, byte value) {
113
                pageBandBuffer[band].assign(0, value);
114
        }
115

    
116
        public void assign(int band, short value) {
117
                pageBandBuffer[band].assign(0, value);
118
        }
119

    
120
        public void assign(int band, int value) {
121
                pageBandBuffer[band].assign(0, value);
122
        }
123

    
124
        public void assign(int band, float value) {
125
                pageBandBuffer[band].assign(0, value);
126
        }
127

    
128
        public void assign(int band, double value) {
129
                pageBandBuffer[band].assign(0, value);
130
        }
131

    
132
        public void assignBand(int nBand, Band band) {
133
        }
134

    
135
        public void assignBandToNotValid(int Band) {
136
        }
137

    
138
        public Buffer cloneBuffer() {
139
                return null;
140
        }
141

    
142
        public void copyBand(int nBand, Band band) {
143
        }
144

    
145
        public Band createBand(byte defaultValue) {
146
                return null;
147
        }
148

    
149
        public Band getBand(int nBand) {
150
                return null;
151
        }
152

    
153
        public Buffer getBandBuffer(int nBand) {
154
                return null;
155
        }
156

    
157
        public int getBandCount() {
158
                return pageBandBuffer[0].getBandCount();
159
        }
160
        
161
        public int getDataType() {
162
                return pageBandBuffer[0].getDataType();
163
        }
164

    
165
        public void setDataType(int dataType) {
166
        
167
        }
168
        
169
        public int getBlockHeight() {
170
                return pageBandBuffer[0].getHeight();
171
        }
172
        
173
        public int getHeight() {
174
                return pageBandBuffer[0].getHeight();
175
        }
176
        
177
        public int getWidth() {
178
                return pageBandBuffer[0].getWidth();
179
        }
180

    
181
        public NoData getNoDataValue() {
182
                return pageBandBuffer[0].getNoDataValue();
183
        }
184

    
185
        public double getNotValidValue() {
186
                return pageBandBuffer[0].getNotValidValue();
187
        }
188
        
189
        public byte getElemByte(int line, int col, int band) {
190
                return pageBandBuffer[band].getElemByte(line, col, 0);
191
        }
192

    
193
        public short getElemShort(int line, int col, int band) {
194
                return pageBandBuffer[band].getElemShort(line, col, 0);
195
        }
196
        
197
        public int getElemInt(int line, int col, int band) {
198
                return pageBandBuffer[band].getElemInt(line, col, 0);
199
        }
200

    
201
        public float getElemFloat(int line, int col, int band) {
202
                return pageBandBuffer[band].getElemFloat(line, col, 0);
203
        }
204
        
205
        public double getElemDouble(int line, int col, int band) {
206
                return pageBandBuffer[band].getElemDouble(line, col, 0);
207
        }
208

    
209
        public void getElemByte(int line, int col, byte[] data) {
210
                for (int i = 0; i < pageBandBuffer.length; i++) 
211
                        data[i] = pageBandBuffer[i].getElemByte(line, col, 0);
212
        }
213
        
214
        public void getElemShort(int line, int col, short[] data) {
215
                for (int i = 0; i < pageBandBuffer.length; i++) 
216
                        data[i] = pageBandBuffer[i].getElemShort(line, col, 0);
217
        }
218

    
219
        public void getElemInt(int line, int col, int[] data) {
220
                for (int i = 0; i < pageBandBuffer.length; i++) 
221
                        data[i] = pageBandBuffer[i].getElemInt(line, col, 0);
222
        }
223

    
224
        public void getElemFloat(int line, int col, float[] data) {
225
                for (int i = 0; i < pageBandBuffer.length; i++) 
226
                        data[i] = pageBandBuffer[i].getElemFloat(line, col, 0);
227
        }
228

    
229
        public void getElemDouble(int line, int col, double[] data) {
230
                for (int i = 0; i < pageBandBuffer.length; i++) 
231
                        data[i] = pageBandBuffer[i].getElemDouble(line, col, 0);
232
        }
233
        
234
        public byte[][] getLineByte(int line) {
235
                byte[][] b = new byte[pageBandBuffer.length][];
236
                for (int i = 0; i < pageBandBuffer.length; i++) 
237
                        b[i] = pageBandBuffer[i].getLineByte(line)[0];
238
                return b;
239
        }
240

    
241
        public double[][] getLineDouble(int line) {
242
                double[][] d = new double[pageBandBuffer.length][];
243
                for (int i = 0; i < pageBandBuffer.length; i++) 
244
                        d[i] = pageBandBuffer[i].getLineDouble(line)[0];
245
                return d;
246
        }
247

    
248
        public float[][] getLineFloat(int line) {
249
                float[][] f = new float[pageBandBuffer.length][];
250
                for (int i = 0; i < pageBandBuffer.length; i++) 
251
                        f[i] = pageBandBuffer[i].getLineFloat(line)[0];
252
                return f;
253
        }
254

    
255
        public int[][] getLineInt(int line) {
256
                int[][] in = new int[pageBandBuffer.length][];
257
                for (int i = 0; i < pageBandBuffer.length; i++) 
258
                        in[i] = pageBandBuffer[i].getLineInt(line)[0];
259
                return in;
260
        }
261

    
262
        public short[][] getLineShort(int line) {
263
                short[][] s = new short[pageBandBuffer.length][];
264
                for (int i = 0; i < pageBandBuffer.length; i++) 
265
                        s[i] = pageBandBuffer[i].getLineShort(line)[0];
266
                return s;
267
        }
268
        
269
        public byte[] getLineFromBandByte(int line, int band) {
270
                return pageBandBuffer[band].getLineFromBandByte(line, 0);
271
        }
272

    
273
        public double[] getLineFromBandDouble(int line, int band) {
274
                return pageBandBuffer[band].getLineFromBandDouble(line, 0);
275
        }
276

    
277
        public float[] getLineFromBandFloat(int line, int band) {
278
                return pageBandBuffer[band].getLineFromBandFloat(line, 0);
279
        }
280

    
281
        public int[] getLineFromBandInt(int line, int band) {
282
                return pageBandBuffer[band].getLineFromBandInt(line, 0);
283
        }
284

    
285
        public short[] getLineFromBandShort(int line, int band) {
286
                return pageBandBuffer[band].getLineFromBandShort(line, 0);
287
        }
288
        
289
        public void interchangeBands(int band1, int band2) {
290
        }
291

    
292
        public void mallocOneBand(int dataType, int width, int height, int band) {
293
        }
294

    
295
        public void replicateBand(int orig, int dest) {
296
        }
297

    
298
        public void setElem(int line, int col, int band, byte data) {
299
                pageBandBuffer[band].setElem(line, col, 0, data);
300
        }
301

    
302
        public void setElem(int line, int col, int band, short data) {
303
                pageBandBuffer[band].setElem(line, col, 0, data);
304
        }
305

    
306
        public void setElem(int line, int col, int band, int data) {
307
                pageBandBuffer[band].setElem(line, col, 0, data);
308
        }
309

    
310
        public void setElem(int line, int col, int band, float data) {
311
                pageBandBuffer[band].setElem(line, col, 0, data);
312
        }
313

    
314
        public void setElem(int line, int col, int band, double data) {
315
                pageBandBuffer[band].setElem(line, col, 0, data);
316
        }
317
        
318
        public void setElemByte(int line, int col, byte[] data) {
319
                byte[] b = new byte[1];
320
                for (int i = 0; i < pageBandBuffer.length; i++) {
321
                        b[0] = data[i];
322
                        pageBandBuffer[i].setElemByte(line, col, b);
323
                }
324
        }
325

    
326
        public void setElemDouble(int line, int col, double[] data) {
327
                double[] b = new double[1];
328
                for (int i = 0; i < pageBandBuffer.length; i++) {
329
                        b[0] = data[i];
330
                        pageBandBuffer[i].setElemDouble(line, col, b);
331
                }
332
        }
333

    
334
        public void setElemFloat(int line, int col, float[] data) {
335
                float[] b = new float[1];
336
                for (int i = 0; i < pageBandBuffer.length; i++) {
337
                        b[0] = data[i];
338
                        pageBandBuffer[i].setElemFloat(line, col, b);
339
                }
340
        }
341

    
342
        public void setElemInt(int line, int col, int[] data) {
343
                int[] b = new int[1];
344
                for (int i = 0; i < pageBandBuffer.length; i++) {
345
                        b[0] = data[i];
346
                        pageBandBuffer[i].setElemInt(line, col, b);
347
                }
348
        }
349

    
350
        public void setElemShort(int line, int col, short[] data) {
351
                short[] b = new short[1];
352
                for (int i = 0; i < pageBandBuffer.length; i++) {
353
                        b[0] = data[i];
354
                        pageBandBuffer[i].setElemShort(line, col, b);
355
                }
356
        }
357
        
358
        public void setLineByte(byte[][] data, int line) {
359
                byte[][] bAux = new byte[1][];
360
                for (int i = 0; i < pageBandBuffer.length; i++) {
361
                        bAux[0] = data[i];
362
                        pageBandBuffer[i].setLineByte(bAux, line);
363
                }
364
        }
365

    
366
        public void setLineDouble(double[][] data, int line) {
367
                double[][] bAux = new double[1][];
368
                for (int i = 0; i < pageBandBuffer.length; i++) {
369
                        bAux[0] = data[i];
370
                        pageBandBuffer[i].setLineDouble(bAux, line);
371
                }
372
        }
373

    
374
        public void setLineFloat(float[][] data, int line) {
375
                float[][] bAux = new float[1][];
376
                for (int i = 0; i < pageBandBuffer.length; i++) {
377
                        bAux[0] = data[i];
378
                        pageBandBuffer[i].setLineFloat(bAux, line);
379
                }
380
        }
381
        
382
        public void setLineInt(int[][] data, int line) {
383
                int[][] bAux = new int[1][];
384
                for (int i = 0; i < pageBandBuffer.length; i++) {
385
                        bAux[0] = data[i];
386
                        pageBandBuffer[i].setLineInt(bAux, line);
387
                }
388
        }
389

    
390
        public void setLineShort(short[][] data, int line) {
391
                short[][] bAux = new short[1][];
392
                for (int i = 0; i < pageBandBuffer.length; i++) {
393
                        bAux[0] = data[i];
394
                        pageBandBuffer[i].setLineShort(bAux, line);
395
                }
396
        }
397

    
398
        public void setLineInBandByte(byte[] data, int line, int band) {
399
                pageBandBuffer[band].setLineInBandByte(data, line, 0);
400
        }
401

    
402
        public void setLineInBandDouble(double[] data, int line, int band) {
403
                pageBandBuffer[band].setLineInBandDouble(data, line, 0);
404
        }
405

    
406
        public void setLineInBandFloat(float[] data, int line, int band) {
407
                pageBandBuffer[band].setLineInBandFloat(data, line, 0);
408
        }
409

    
410
        public void setLineInBandInt(int[] data, int line, int band) {
411
                pageBandBuffer[band].setLineInBandInt(data, line, 0);
412
        }
413

    
414
        public void setLineInBandShort(short[] data, int line, int band) {
415
                pageBandBuffer[band].setLineInBandShort(data, line, 0);
416
        }
417

    
418
        public void setNoDataValue(NoData nd) {
419
                for (int i = 0; i < pageBandBuffer.length; i++)
420
                        pageBandBuffer[0].setNoDataValue(nd);
421
        }
422

    
423
        public void setNotValidValue(double value) {
424
        }
425

    
426
        public void switchBands(int[] bands) {
427
        }
428

    
429
        public double getMinimum() {
430
                if(limits == null)
431
                        try {
432
                                limits = getLimits();
433
                        } catch (ProcessInterruptedException e) {
434
                                return 0;
435
                        }
436
                return limits[0];
437
        }
438

    
439
        public double getMaximum() {
440
                if(limits == null)
441
                        try {
442
                                limits = getLimits();
443
                        } catch (ProcessInterruptedException e) {
444
                                return 0;
445
                        }
446
                return limits[1];
447
        }
448
        
449
        public double[] getLimits() throws ProcessInterruptedException {
450
                RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + "");
451
                double max = Double.NEGATIVE_INFINITY;
452
                double secondMax = max;
453
                double min = Double.MAX_VALUE;
454
                double secondMin = min;
455
                double value = 0;
456

    
457
                switch (getDataType()) {
458
                        case Buffer.TYPE_BYTE:
459
                                for (int i = 0; i < getBandCount(); i++) {
460
                                        for (int r = 0; r < getHeight(); r++) {
461
                                                for (int c = 0; c < getWidth(); c++) {
462
                                                        value = (double) (getElemByte(r, c, i) & 0xff);
463
                                                        if (value > max) {
464
                                                                if (max != value)
465
                                                                        secondMax = max;
466
                                                                max = value;
467
                                                        }
468
                                                        if (value < min) {
469
                                                                if (min != value)
470
                                                                        secondMin = min;
471
                                                                min = value;
472
                                                        }
473
                                                }
474
                                                if (task.getEvent() != null)
475
                                                        task.manageEvent(task.getEvent());
476
                                        }
477
                                }
478
                                break;
479
                        case Buffer.TYPE_SHORT:
480
                                for (int i = 0; i < getBandCount(); i++) {
481
                                        for (int r = 0; r < getHeight(); r++) {
482
                                                for (int c = 0; c < getWidth(); c++) {
483
                                                        value = (double) getElemShort(r, c, i);
484
                                                        if (value > max) {
485
                                                                if (max != value)
486
                                                                        secondMax = max;
487
                                                                max = value;
488
                                                        }
489
                                                        if (value < min) {
490
                                                                if (min != value)
491
                                                                        secondMin = min;
492
                                                                min = value;
493
                                                        }
494
                                                }
495
                                                if (task.getEvent() != null)
496
                                                        task.manageEvent(task.getEvent());
497
                                        }
498
                                }
499
                                break;
500
                        case Buffer.TYPE_INT:
501
                                for (int i = 0; i < getBandCount(); i++) {
502
                                        for (int r = 0; r < getHeight(); r++) {
503
                                                for (int c = 0; c < getWidth(); c++) {
504
                                                        value = (double) getElemInt(r, c, i);
505
                                                        if (value > max) {
506
                                                                if (max != value)
507
                                                                        secondMax = max;
508
                                                                max = value;
509
                                                        }
510
                                                        if (value < min) {
511
                                                                if (min != value)
512
                                                                        secondMin = min;
513
                                                                min = value;
514
                                                        }
515
                                                }
516
                                                if (task.getEvent() != null)
517
                                                        task.manageEvent(task.getEvent());
518
                                        }
519
                                }
520
                                break;
521
                        case Buffer.TYPE_FLOAT:
522
                                for (int i = 0; i < getBandCount(); i++) {
523
                                        for (int r = 0; r < getHeight(); r++) {
524
                                                for (int c = 0; c < getWidth(); c++) {
525
                                                        value = (double) getElemFloat(r, c, i);
526
                                                        if (value > max) {
527
                                                                if (max != value)
528
                                                                        secondMax = max;
529
                                                                max = value;
530
                                                        }
531
                                                        if (value < min) {
532
                                                                if (min != value)
533
                                                                        secondMin = min;
534
                                                                min = value;
535
                                                        }
536
                                                }
537
                                                if (task.getEvent() != null)
538
                                                        task.manageEvent(task.getEvent());
539
                                        }
540
                                }
541
                                break;
542
                        case Buffer.TYPE_DOUBLE:
543
                                for (int i = 0; i < getBandCount(); i++) {
544
                                        for (int r = 0; r < getHeight(); r++) {
545
                                                for (int c = 0; c < getWidth(); c++) {
546
                                                        value = getElemDouble(r, c, i);
547
                                                        if (value > max) {
548
                                                                if (max != value)
549
                                                                        secondMax = max;
550
                                                                max = value;
551
                                                        }
552
                                                        if (value < min) {
553
                                                                if (min != value)
554
                                                                        secondMin = min;
555
                                                                min = value;
556
                                                        }
557
                                                }
558
                                                if (task.getEvent() != null)
559
                                                        task.manageEvent(task.getEvent());
560
                                        }
561
                                }
562
                                break;
563
                }
564
                // Si no existe un secondMax lo igualo al maximo existente
565
                if (secondMax == Double.NEGATIVE_INFINITY)
566
                        secondMax = max;
567
                // Si no existe un secondMin lo igualo al minimo existente
568
                if (secondMin == Double.MAX_VALUE)
569
                        secondMin = min;
570

    
571
                double[] values = new double[2];
572
                values[0] = min;
573
                values[1] = max;
574
                values[2] = secondMin;
575
                values[3] = secondMax;
576
                return values;
577
        }
578
        
579
        public double[][] getAllBandsLimits() throws ProcessInterruptedException {
580
                RasterTask task = RasterTaskQueue.get(Thread.currentThread().getId() + "");
581
                double max[] = new double[getBandCount()];
582
                double min[] = new double[getBandCount()];
583
                double value = 0;
584

    
585
                for (int i = 0; i < getBandCount(); i++) {
586
                        max[i] = Double.NEGATIVE_INFINITY;
587
                        min[i] = Double.MAX_VALUE;
588
                }
589

    
590
                switch (getDataType()) {
591
                        case Buffer.TYPE_BYTE:
592
                                for (int i = 0; i < getBandCount(); i++) {
593
                                        for (int r = 0; r < getHeight(); r++) {
594
                                                for (int c = 0; c < getWidth(); c++) {
595
                                                        value = (double) (getElemByte(r, c, i) & 0xff);
596
                                                        if (value > max[i])
597
                                                                max[i] = value;
598
                                                        if (value < min[i])
599
                                                                min[i] = value;
600
                                                }
601
                                                if (task.getEvent() != null)
602
                                                        task.manageEvent(task.getEvent());
603
                                        }
604
                                }
605
                                break;
606
                        case Buffer.TYPE_SHORT:
607
                                for (int i = 0; i < getBandCount(); i++) {
608
                                        for (int r = 0; r < getHeight(); r++) {
609
                                                for (int c = 0; c < getWidth(); c++) {
610
                                                        value = (double) getElemShort(r, c, i);
611
                                                        if (value > max[i])
612
                                                                max[i] = value;
613
                                                        if (value < min[i])
614
                                                                min[i] = value;
615
                                                }
616
                                                if (task.getEvent() != null)
617
                                                        task.manageEvent(task.getEvent());
618
                                        }
619
                                }
620
                                break;
621
                        case Buffer.TYPE_INT:
622
                                for (int i = 0; i < getBandCount(); i++) {
623
                                        for (int r = 0; r < getHeight(); r++) {
624
                                                for (int c = 0; c < getWidth(); c++) {
625
                                                        value = (double) getElemInt(r, c, i);
626
                                                        if (value > max[i])
627
                                                                max[i] = value;
628
                                                        if (value < min[i])
629
                                                                min[i] = value;
630
                                                }
631
                                                if (task.getEvent() != null)
632
                                                        task.manageEvent(task.getEvent());
633
                                        }
634
                                }
635
                                break;
636
                        case Buffer.TYPE_FLOAT:
637
                                for (int i = 0; i < getBandCount(); i++) {
638
                                        for (int r = 0; r < getHeight(); r++) {
639
                                                for (int c = 0; c < getWidth(); c++) {
640
                                                        value = (double) getElemFloat(r, c, i);
641
                                                        if (value > max[i])
642
                                                                max[i] = value;
643
                                                        if (value < min[i])
644
                                                                min[i] = value;
645
                                                }
646
                                                if (task.getEvent() != null)
647
                                                        task.manageEvent(task.getEvent());
648
                                        }
649
                                }
650
                                break;
651
                        case Buffer.TYPE_DOUBLE:
652
                                for (int i = 0; i < getBandCount(); i++) {
653
                                        for (int r = 0; r < getHeight(); r++) {
654
                                                for (int c = 0; c < getWidth(); c++) {
655
                                                        value = getElemDouble(r, c, i);
656
                                                        if (value > max[i])
657
                                                                max[i] = value;
658
                                                        if (value < min[i])
659
                                                                min[i] = value;
660
                                                }
661
                                                if (task.getEvent() != null)
662
                                                        task.manageEvent(task.getEvent());
663
                                        }
664
                                }
665
                                break;
666
                }
667
                double[][] values = new double[2][getBandCount()];
668

    
669
                for (int i = 0; i < getBandCount(); i++) {
670
                        values[0][i] = min[i];
671
                        values[1][i] = max[i];
672
                }
673
                return values;
674
        }
675

    
676
        public HistogramComputer getHistogramComputer() {
677
                if(histogramComputer == null)
678
                        histogramComputer = new BufferHistogramComputer(this);
679
                return histogramComputer;
680
        }
681

    
682
        public boolean isInside(int x, int y) {
683
                 if (x < 0 || y < 0 || x >= getWidth() || y >= getHeight())
684
                                return false;
685
                        return true;
686
        }
687
        
688
        public boolean isReadOnlyBuffer() {
689
                return false;
690
        }
691
        
692
        public boolean isCached() {
693
                return false;
694
        }
695
        
696
        public IncrementableTask getIncrementableTask(int type) {
697
                switch (type) {
698
                case INCREMENTABLE_INTERPOLATION:
699
                        return getBufferInterpolation();
700
                case INCREMENTABLE_HISTOGRAM:
701
                        return getHistogramComputer();
702
                }
703
                return null;
704
        }
705
        
706
        /**
707
         * Gets the buffer interpolation
708
         * @return
709
         */
710
        private BufferInterpolation getBufferInterpolation() {
711
                if(interp == null)
712
                        interp = new BufferInterpolation(this);
713
                return interp;
714
        }
715
        
716
        public Buffer getAdjustedWindow(int w, int h, int interpolationMethod) throws ProcessInterruptedException {
717
                getBufferInterpolation();
718
                if (w == getWidth() && h == getHeight())
719
                        return this;
720
                Buffer rasterBuf = null;
721
                switch (interpolationMethod) {
722
                        case Buffer.INTERPOLATION_NearestNeighbour:
723
                                rasterBuf = interp.adjustRasterNearestNeighbourInterpolation(w, h);
724
                                break;
725
                        case Buffer.INTERPOLATION_Bilinear:
726
                                rasterBuf = interp.adjustRasterBilinearInterpolation(w, h);
727
                                break;
728
                        case Buffer.INTERPOLATION_InverseDistance:
729
                                rasterBuf = interp.adjustRasterInverseDistanceInterpolation(w, h);
730
                                break;
731
                        case Buffer.INTERPOLATION_BicubicSpline:
732
                                rasterBuf = interp.adjustRasterBicubicSplineInterpolation(w, h);
733
                                break;
734
                        case Buffer.INTERPOLATION_BSpline:
735
                                rasterBuf = interp.adjustRasterBSplineInterpolation(w, h);
736
                                break;
737
                }
738
                if (rasterBuf != null)
739
                        return rasterBuf;
740
                else
741
                        return this;
742
        }
743

    
744
        public Rectangle2D getDataExtent() {
745
                return null;
746
        }
747

    
748
        public void setDataExtent(Rectangle2D r) {
749
        }
750
        
751
        public RasterDataStore getStore() {
752
                return null;
753
        }
754

    
755
        public void setStore(RasterDataStore store) {
756
        }
757
        
758
        public void addDrawableBands(int[] db) {}
759
        
760
        //****************************************************
761
        //*********Implementing DataSet methods***************
762
        //****************************************************
763

    
764
        public boolean isFromStore(DataStore store) {
765
                return false;
766
        }
767

    
768
        //****************************************************
769
        //*********Implementing Visitable methods*************
770
        //****************************************************
771
        
772
        public void accept(Visitor visitor) throws BaseException {
773
                
774
        }
775
        
776
        //****************************************************
777
        //*********Implementing Disposable methods************
778
        //****************************************************
779
        
780
        public void dispose() {
781
                if(pageBandBuffer != null) {
782
                        for (int i = 0; i < pageBandBuffer.length; i++) { 
783
                                pageBandBuffer[i].dispose();
784
                        }
785
                }
786
                try {
787
                        finalize();
788
                } catch (Throwable e) {
789
                }
790
        }
791
        
792
        protected void finalize() throws Throwable {
793
                limits               = null;
794
                histogramComputer    = null;
795
                if(pageBandBuffer != null) {
796
                        for (int i = 0; i < pageBandBuffer.length; i++) { 
797
                                pageBandBuffer[i] = null;
798
                        }
799
                        pageBandBuffer = null;
800
                }
801
                limits = null;
802
                super.finalize();
803
        }
804
}