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

History | View | Annotate | Download (21.6 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.HistogramException;
32
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
33
import org.gvsig.fmap.dal.coverage.process.IncrementableTask;
34
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
35
import org.gvsig.fmap.dal.coverage.store.props.HistogramComputer;
36
import org.gvsig.raster.impl.buffer.BufferHistogramComputer;
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
        
55
        /**
56
         * Constructor
57
         * @param dataType
58
         * @param width
59
         * @param height
60
         * @param bandNr
61
         * @param malloc
62
         */
63
        public PageBuffer(int dataType, int width, int height, int bandNr, boolean malloc, int nHddPags) {
64
                pageBandBuffer = new PageBandBuffer[bandNr];
65
                for (int i = 0; i < pageBandBuffer.length; i++)
66
                        pageBandBuffer[i] = new PageBandBuffer(dataType, width, height, 1, malloc, i);
67
        }
68
        
69
        /*
70
         * (non-Javadoc)
71
         * @see org.gvsig.raster.driver.Buffer#isBandSwitchable()
72
         */
73
        public boolean isBandSwitchable() {
74
                return false;
75
        }
76
        
77
        /**
78
         * Asigna la lista de paginas de disco
79
         * @param hddList Lista de p?ginas de disco
80
         */
81
        public void setHddPages(HddPage[] hddList) {
82
                for (int i = 0; i < pageBandBuffer.length; i++)
83
                        pageBandBuffer[i].setHddPages(hddList);
84
        }
85
        
86
        /**
87
         * Carga una p?gina especificada en el par?metro nPag con los datos necesarios.
88
         * Para esto recorre todas las bandas de la p?gina llamando al load de cada una.
89
         *   
90
         * @param nPag N?mero de p?gina a cargar
91
         */
92
        public void loadPage(int nPag) {
93
                for (int i = 0; i < pageBandBuffer.length; i++) {
94
                        try {
95
                                pageBandBuffer[i].loadPage(nPag);
96
                        } catch (ProcessInterruptedException e) {
97
                                //Cuando se cancela la carga de una p?gina salimos al acabar la p?gina anterior
98
                                break; 
99
                        }
100
                }
101
        }
102
        
103
        /**
104
         * Salva una p?gina especificada en el par?metro nPag a disco. 
105
         * Para esto recorre todas las bandas de la p?gina llamando al save de cada una.
106
         *   
107
         * @param nPag N?mero de p?gina a salvar
108
         * @throws IOException
109
         */
110
        public void savePage(int nPag) throws IOException {
111
                for (int i = 0; i < pageBandBuffer.length; i++)
112
                        pageBandBuffer[i].savePage(nPag);
113
        }
114
        
115
        public void assign(int band, byte value) {
116
                pageBandBuffer[band].assign(0, value);
117
        }
118

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

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

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

    
131
        public void assign(int band, double value) {
132
                pageBandBuffer[band].assign(0, value);
133
        }
134

    
135
        public void assignBand(int nBand, Band band) {
136
        }
137

    
138
        public void assignBandToNotValid(int Band) {
139
        }
140

    
141
        public Buffer cloneBuffer() {
142
                return null;
143
        }
144

    
145
        public void copyBand(int nBand, Band band) {
146
        }
147

    
148
        public Band createBand(byte defaultValue) {
149
                return null;
150
        }
151

    
152
        public Band getBand(int nBand) {
153
                return null;
154
        }
155

    
156
        public Buffer getBandBuffer(int nBand) {
157
                return null;
158
        }
159

    
160
        public int getBandCount() {
161
                return pageBandBuffer[0].getBandCount();
162
        }
163
        
164
        public int getDataType() {
165
                return pageBandBuffer[0].getDataType();
166
        }
167

    
168
        public void setDataType(int dataType) {
169
        
170
        }
171
        
172
        /*
173
         * (non-Javadoc)
174
         * @see org.gvsig.fmap.dal.coverage.dataset.Buffer#getBlockHeight()
175
         */
176
        public int getBlockHeight() {
177
                return pageBandBuffer[0].getHeight();
178
        }
179
        
180
        public int getHeight() {
181
                return pageBandBuffer[0].getHeight();
182
        }
183
        
184
        public int getWidth() {
185
                return pageBandBuffer[0].getWidth();
186
        }
187

    
188
        public NoData getNoDataValue() {
189
                return pageBandBuffer[0].getNoDataValue();
190
        }
191

    
192
        public double getNotValidValue() {
193
                return pageBandBuffer[0].getNotValidValue();
194
        }
195
        
196
        public byte getElemByte(int line, int col, int band) {
197
                return pageBandBuffer[band].getElemByte(line, col, 0);
198
        }
199

    
200
        public short getElemShort(int line, int col, int band) {
201
                return pageBandBuffer[band].getElemShort(line, col, 0);
202
        }
203
        
204
        public int getElemInt(int line, int col, int band) {
205
                return pageBandBuffer[band].getElemInt(line, col, 0);
206
        }
207

    
208
        public float getElemFloat(int line, int col, int band) {
209
                return pageBandBuffer[band].getElemFloat(line, col, 0);
210
        }
211
        
212
        public double getElemDouble(int line, int col, int band) {
213
                return pageBandBuffer[band].getElemDouble(line, col, 0);
214
        }
215

    
216
        
217

    
218

    
219
        public void getElemByte(int line, int col, byte[] data) {
220
                for (int i = 0; i < pageBandBuffer.length; i++) 
221
                        data[i] = pageBandBuffer[i].getElemByte(line, col, 0);
222
        }
223
        
224
        public void getElemShort(int line, int col, short[] data) {
225
                for (int i = 0; i < pageBandBuffer.length; i++) 
226
                        data[i] = pageBandBuffer[i].getElemShort(line, col, 0);
227
        }
228

    
229
        public void getElemInt(int line, int col, int[] data) {
230
                for (int i = 0; i < pageBandBuffer.length; i++) 
231
                        data[i] = pageBandBuffer[i].getElemInt(line, col, 0);
232
        }
233

    
234
        public void getElemFloat(int line, int col, float[] data) {
235
                for (int i = 0; i < pageBandBuffer.length; i++) 
236
                        data[i] = pageBandBuffer[i].getElemFloat(line, col, 0);
237
        }
238

    
239
        public void getElemDouble(int line, int col, double[] data) {
240
                for (int i = 0; i < pageBandBuffer.length; i++) 
241
                        data[i] = pageBandBuffer[i].getElemDouble(line, col, 0);
242
        }
243
        
244
        
245
        public byte[][] getLineByte(int line) {
246
                byte[][] b = new byte[pageBandBuffer.length][];
247
                for (int i = 0; i < pageBandBuffer.length; i++) 
248
                        b[i] = pageBandBuffer[i].getLineByte(line)[0];
249
                return b;
250
        }
251

    
252
        public double[][] getLineDouble(int line) {
253
                double[][] d = new double[pageBandBuffer.length][];
254
                for (int i = 0; i < pageBandBuffer.length; i++) 
255
                        d[i] = pageBandBuffer[i].getLineDouble(line)[0];
256
                return d;
257
        }
258

    
259
        public float[][] getLineFloat(int line) {
260
                float[][] f = new float[pageBandBuffer.length][];
261
                for (int i = 0; i < pageBandBuffer.length; i++) 
262
                        f[i] = pageBandBuffer[i].getLineFloat(line)[0];
263
                return f;
264
        }
265

    
266
        public int[][] getLineInt(int line) {
267
                int[][] in = new int[pageBandBuffer.length][];
268
                for (int i = 0; i < pageBandBuffer.length; i++) 
269
                        in[i] = pageBandBuffer[i].getLineInt(line)[0];
270
                return in;
271
        }
272

    
273
        public short[][] getLineShort(int line) {
274
                short[][] s = new short[pageBandBuffer.length][];
275
                for (int i = 0; i < pageBandBuffer.length; i++) 
276
                        s[i] = pageBandBuffer[i].getLineShort(line)[0];
277
                return s;
278
        }
279
        
280
        
281
        
282
        public byte[] getLineFromBandByte(int line, int band) {
283
                return pageBandBuffer[band].getLineFromBandByte(line, 0);
284
        }
285

    
286
        public double[] getLineFromBandDouble(int line, int band) {
287
                return pageBandBuffer[band].getLineFromBandDouble(line, 0);
288
        }
289

    
290
        public float[] getLineFromBandFloat(int line, int band) {
291
                return pageBandBuffer[band].getLineFromBandFloat(line, 0);
292
        }
293

    
294
        public int[] getLineFromBandInt(int line, int band) {
295
                return pageBandBuffer[band].getLineFromBandInt(line, 0);
296
        }
297

    
298
        public short[] getLineFromBandShort(int line, int band) {
299
                return pageBandBuffer[band].getLineFromBandShort(line, 0);
300
        }
301

    
302
        
303
        
304
        
305
        public void interchangeBands(int band1, int band2) {
306
        }
307

    
308
        public void mallocOneBand(int dataType, int width, int height, int band) {
309
        }
310

    
311
        public void replicateBand(int orig, int dest) {
312
        }
313

    
314

    
315

    
316
        public void setElem(int line, int col, int band, byte data) {
317
                pageBandBuffer[band].setElem(line, col, 0, data);
318
        }
319

    
320
        public void setElem(int line, int col, int band, short data) {
321
                pageBandBuffer[band].setElem(line, col, 0, data);
322
        }
323

    
324
        public void setElem(int line, int col, int band, int data) {
325
                pageBandBuffer[band].setElem(line, col, 0, data);
326
        }
327

    
328
        public void setElem(int line, int col, int band, float data) {
329
                pageBandBuffer[band].setElem(line, col, 0, data);
330
        }
331

    
332
        public void setElem(int line, int col, int band, double data) {
333
                pageBandBuffer[band].setElem(line, col, 0, data);
334
        }
335

    
336

    
337
        
338
        public void setElemByte(int line, int col, byte[] data) {
339
                byte[] b = new byte[1];
340
                for (int i = 0; i < pageBandBuffer.length; i++) {
341
                        b[0] = data[i];
342
                        pageBandBuffer[i].setElemByte(line, col, b);
343
                }
344
        }
345

    
346
        public void setElemDouble(int line, int col, double[] data) {
347
                double[] b = new double[1];
348
                for (int i = 0; i < pageBandBuffer.length; i++) {
349
                        b[0] = data[i];
350
                        pageBandBuffer[i].setElemDouble(line, col, b);
351
                }
352
        }
353

    
354
        public void setElemFloat(int line, int col, float[] data) {
355
                float[] b = new float[1];
356
                for (int i = 0; i < pageBandBuffer.length; i++) {
357
                        b[0] = data[i];
358
                        pageBandBuffer[i].setElemFloat(line, col, b);
359
                }
360
        }
361

    
362
        public void setElemInt(int line, int col, int[] data) {
363
                int[] b = new int[1];
364
                for (int i = 0; i < pageBandBuffer.length; i++) {
365
                        b[0] = data[i];
366
                        pageBandBuffer[i].setElemInt(line, col, b);
367
                }
368
        }
369

    
370
        public void setElemShort(int line, int col, short[] data) {
371
                short[] b = new short[1];
372
                for (int i = 0; i < pageBandBuffer.length; i++) {
373
                        b[0] = data[i];
374
                        pageBandBuffer[i].setElemShort(line, col, b);
375
                }
376
        }
377
        
378
        public void setLineByte(byte[][] data, int line) {
379
                byte[][] bAux = new byte[1][];
380
                for (int i = 0; i < pageBandBuffer.length; i++) {
381
                        bAux[0] = data[i];
382
                        pageBandBuffer[i].setLineByte(bAux, line);
383
                }
384
        }
385

    
386
        public void setLineDouble(double[][] data, int line) {
387
                double[][] bAux = new double[1][];
388
                for (int i = 0; i < pageBandBuffer.length; i++) {
389
                        bAux[0] = data[i];
390
                        pageBandBuffer[i].setLineDouble(bAux, line);
391
                }
392
        }
393

    
394
        public void setLineFloat(float[][] data, int line) {
395
                float[][] bAux = new float[1][];
396
                for (int i = 0; i < pageBandBuffer.length; i++) {
397
                        bAux[0] = data[i];
398
                        pageBandBuffer[i].setLineFloat(bAux, line);
399
                }
400
        }
401
        
402
        public void setLineInt(int[][] data, int line) {
403
                int[][] bAux = new int[1][];
404
                for (int i = 0; i < pageBandBuffer.length; i++) {
405
                        bAux[0] = data[i];
406
                        pageBandBuffer[i].setLineInt(bAux, line);
407
                }
408
        }
409

    
410
        public void setLineShort(short[][] data, int line) {
411
                short[][] bAux = new short[1][];
412
                for (int i = 0; i < pageBandBuffer.length; i++) {
413
                        bAux[0] = data[i];
414
                        pageBandBuffer[i].setLineShort(bAux, line);
415
                }
416
        }
417

    
418
        public void setLineInBandByte(byte[] data, int line, int band) {
419
                pageBandBuffer[band].setLineInBandByte(data, line, 0);
420
        }
421

    
422
        public void setLineInBandDouble(double[] data, int line, int band) {
423
                pageBandBuffer[band].setLineInBandDouble(data, line, 0);
424
        }
425

    
426
        public void setLineInBandFloat(float[] data, int line, int band) {
427
                pageBandBuffer[band].setLineInBandFloat(data, line, 0);
428
        }
429

    
430
        public void setLineInBandInt(int[] data, int line, int band) {
431
                pageBandBuffer[band].setLineInBandInt(data, line, 0);
432
        }
433

    
434
        public void setLineInBandShort(short[] data, int line, int band) {
435
                pageBandBuffer[band].setLineInBandShort(data, line, 0);
436
        }
437

    
438
        public void setNoDataValue(NoData nd) {
439
                for (int i = 0; i < pageBandBuffer.length; i++)
440
                        pageBandBuffer[0].setNoDataValue(nd);
441
        }
442

    
443
        public void setNotValidValue(double value) {
444
        }
445

    
446
        public void switchBands(int[] bands) {
447
        }
448

    
449
        /*
450
         * (non-Javadoc)
451
         * @see org.gvsig.fmap.dal.coverage.store.props.Histogram#getMinimum()
452
         */
453
        public double getMinimum() {
454
                if(limits == null)
455
                        try {
456
                                limits = getLimits();
457
                        } catch (ProcessInterruptedException e) {
458
                                return 0;
459
                        }
460
                return limits[0];
461
        }
462

    
463
        /*
464
         * (non-Javadoc)
465
         * @see org.gvsig.fmap.dal.coverage.store.props.Histogram#getMaximum()
466
         */
467
        public double getMaximum() {
468
                if(limits == null)
469
                        try {
470
                                limits = getLimits();
471
                        } catch (ProcessInterruptedException e) {
472
                                return 0;
473
                        }
474
                return limits[1];
475
        }
476
        
477
        /*
478
         * (non-Javadoc)
479
         * @see org.gvsig.fmap.dal.coverage.dataset.Buffer#getLimits()
480
         */
481
        public double[] getLimits() throws ProcessInterruptedException {
482
                RasterTask task = RasterTaskQueue.get(Thread.currentThread().toString());
483
                double max = Double.NEGATIVE_INFINITY;
484
                double secondMax = max;
485
                double min = Double.MAX_VALUE;
486
                double secondMin = min;
487
                double value = 0;
488

    
489
                switch (getDataType()) {
490
                        case Buffer.TYPE_BYTE:
491
                                for (int i = 0; i < getBandCount(); i++) {
492
                                        for (int r = 0; r < getHeight(); r++) {
493
                                                for (int c = 0; c < getWidth(); c++) {
494
                                                        value = (double) (getElemByte(r, c, i) & 0xff);
495
                                                        if (value > max) {
496
                                                                if (max != value)
497
                                                                        secondMax = max;
498
                                                                max = value;
499
                                                        }
500
                                                        if (value < min) {
501
                                                                if (min != value)
502
                                                                        secondMin = min;
503
                                                                min = value;
504
                                                        }
505
                                                }
506
                                                if (task.getEvent() != null)
507
                                                        task.manageEvent(task.getEvent());
508
                                        }
509
                                }
510
                                break;
511
                        case Buffer.TYPE_SHORT:
512
                                for (int i = 0; i < getBandCount(); i++) {
513
                                        for (int r = 0; r < getHeight(); r++) {
514
                                                for (int c = 0; c < getWidth(); c++) {
515
                                                        value = (double) getElemShort(r, c, i);
516
                                                        if (value > max) {
517
                                                                if (max != value)
518
                                                                        secondMax = max;
519
                                                                max = value;
520
                                                        }
521
                                                        if (value < min) {
522
                                                                if (min != value)
523
                                                                        secondMin = min;
524
                                                                min = value;
525
                                                        }
526
                                                }
527
                                                if (task.getEvent() != null)
528
                                                        task.manageEvent(task.getEvent());
529
                                        }
530
                                }
531
                                break;
532
                        case Buffer.TYPE_INT:
533
                                for (int i = 0; i < getBandCount(); i++) {
534
                                        for (int r = 0; r < getHeight(); r++) {
535
                                                for (int c = 0; c < getWidth(); c++) {
536
                                                        value = (double) getElemInt(r, c, i);
537
                                                        if (value > max) {
538
                                                                if (max != value)
539
                                                                        secondMax = max;
540
                                                                max = value;
541
                                                        }
542
                                                        if (value < min) {
543
                                                                if (min != value)
544
                                                                        secondMin = min;
545
                                                                min = value;
546
                                                        }
547
                                                }
548
                                                if (task.getEvent() != null)
549
                                                        task.manageEvent(task.getEvent());
550
                                        }
551
                                }
552
                                break;
553
                        case Buffer.TYPE_FLOAT:
554
                                for (int i = 0; i < getBandCount(); i++) {
555
                                        for (int r = 0; r < getHeight(); r++) {
556
                                                for (int c = 0; c < getWidth(); c++) {
557
                                                        value = (double) getElemFloat(r, c, i);
558
                                                        if (value > max) {
559
                                                                if (max != value)
560
                                                                        secondMax = max;
561
                                                                max = value;
562
                                                        }
563
                                                        if (value < min) {
564
                                                                if (min != value)
565
                                                                        secondMin = min;
566
                                                                min = value;
567
                                                        }
568
                                                }
569
                                                if (task.getEvent() != null)
570
                                                        task.manageEvent(task.getEvent());
571
                                        }
572
                                }
573
                                break;
574
                        case Buffer.TYPE_DOUBLE:
575
                                for (int i = 0; i < getBandCount(); i++) {
576
                                        for (int r = 0; r < getHeight(); r++) {
577
                                                for (int c = 0; c < getWidth(); c++) {
578
                                                        value = getElemDouble(r, c, i);
579
                                                        if (value > max) {
580
                                                                if (max != value)
581
                                                                        secondMax = max;
582
                                                                max = value;
583
                                                        }
584
                                                        if (value < min) {
585
                                                                if (min != value)
586
                                                                        secondMin = min;
587
                                                                min = value;
588
                                                        }
589
                                                }
590
                                                if (task.getEvent() != null)
591
                                                        task.manageEvent(task.getEvent());
592
                                        }
593
                                }
594
                                break;
595
                }
596
                // Si no existe un secondMax lo igualo al maximo existente
597
                if (secondMax == Double.NEGATIVE_INFINITY)
598
                        secondMax = max;
599
                // Si no existe un secondMin lo igualo al minimo existente
600
                if (secondMin == Double.MAX_VALUE)
601
                        secondMin = min;
602

    
603
                double[] values = new double[2];
604
                values[0] = min;
605
                values[1] = max;
606
                values[2] = secondMin;
607
                values[3] = secondMax;
608
                return values;
609
        }
610
        
611
        /*
612
         * (non-Javadoc)
613
         * @see org.gvsig.fmap.dal.coverage.dataset.Buffer#getAllBandsLimits()
614
         */
615
        public double[][] getAllBandsLimits() throws ProcessInterruptedException {
616
                RasterTask task = RasterTaskQueue.get(Thread.currentThread().toString());
617
                double max[] = new double[getBandCount()];
618
                double min[] = new double[getBandCount()];
619
                double value = 0;
620

    
621
                for (int i = 0; i < getBandCount(); i++) {
622
                        max[i] = Double.NEGATIVE_INFINITY;
623
                        min[i] = Double.MAX_VALUE;
624
                }
625

    
626
                switch (getDataType()) {
627
                        case Buffer.TYPE_BYTE:
628
                                for (int i = 0; i < getBandCount(); i++) {
629
                                        for (int r = 0; r < getHeight(); r++) {
630
                                                for (int c = 0; c < getWidth(); c++) {
631
                                                        value = (double) (getElemByte(r, c, i) & 0xff);
632
                                                        if (value > max[i])
633
                                                                max[i] = value;
634
                                                        if (value < min[i])
635
                                                                min[i] = value;
636
                                                }
637
                                                if (task.getEvent() != null)
638
                                                        task.manageEvent(task.getEvent());
639
                                        }
640
                                }
641
                                break;
642
                        case Buffer.TYPE_SHORT:
643
                                for (int i = 0; i < getBandCount(); i++) {
644
                                        for (int r = 0; r < getHeight(); r++) {
645
                                                for (int c = 0; c < getWidth(); c++) {
646
                                                        value = (double) getElemShort(r, c, i);
647
                                                        if (value > max[i])
648
                                                                max[i] = value;
649
                                                        if (value < min[i])
650
                                                                min[i] = value;
651
                                                }
652
                                                if (task.getEvent() != null)
653
                                                        task.manageEvent(task.getEvent());
654
                                        }
655
                                }
656
                                break;
657
                        case Buffer.TYPE_INT:
658
                                for (int i = 0; i < getBandCount(); i++) {
659
                                        for (int r = 0; r < getHeight(); r++) {
660
                                                for (int c = 0; c < getWidth(); c++) {
661
                                                        value = (double) getElemInt(r, c, i);
662
                                                        if (value > max[i])
663
                                                                max[i] = value;
664
                                                        if (value < min[i])
665
                                                                min[i] = value;
666
                                                }
667
                                                if (task.getEvent() != null)
668
                                                        task.manageEvent(task.getEvent());
669
                                        }
670
                                }
671
                                break;
672
                        case Buffer.TYPE_FLOAT:
673
                                for (int i = 0; i < getBandCount(); i++) {
674
                                        for (int r = 0; r < getHeight(); r++) {
675
                                                for (int c = 0; c < getWidth(); c++) {
676
                                                        value = (double) getElemFloat(r, c, i);
677
                                                        if (value > max[i])
678
                                                                max[i] = value;
679
                                                        if (value < min[i])
680
                                                                min[i] = value;
681
                                                }
682
                                                if (task.getEvent() != null)
683
                                                        task.manageEvent(task.getEvent());
684
                                        }
685
                                }
686
                                break;
687
                        case Buffer.TYPE_DOUBLE:
688
                                for (int i = 0; i < getBandCount(); i++) {
689
                                        for (int r = 0; r < getHeight(); r++) {
690
                                                for (int c = 0; c < getWidth(); c++) {
691
                                                        value = getElemDouble(r, c, i);
692
                                                        if (value > max[i])
693
                                                                max[i] = value;
694
                                                        if (value < min[i])
695
                                                                min[i] = value;
696
                                                }
697
                                                if (task.getEvent() != null)
698
                                                        task.manageEvent(task.getEvent());
699
                                        }
700
                                }
701
                                break;
702
                }
703
                double[][] values = new double[2][getBandCount()];
704

    
705
                for (int i = 0; i < getBandCount(); i++) {
706
                        values[0][i] = min[i];
707
                        values[1][i] = max[i];
708
                }
709
                return values;
710
        }
711

    
712
        /*
713
         * (non-Javadoc)
714
         * @see org.gvsig.fmap.dal.coverage.store.props.Histogramable#getHistogramComputer()
715
         */
716
        public HistogramComputer getHistogramComputer() 
717
                throws HistogramException, InterruptedException {
718
                if(histogramComputer == null)
719
                        histogramComputer = new BufferHistogramComputer(this);
720
                return histogramComputer;
721
        }
722

    
723
        /*
724
         * (non-Javadoc)
725
         * @see org.gvsig.raster.dataset.Buffer#isInside(int, int)
726
         */
727
        public boolean isInside(int x, int y) {
728
                 if (x < 0 || y < 0 || x >= getWidth() || y >= getHeight())
729
                                return false;
730
                        return true;
731
        }
732
        
733
        /*
734
         * (non-Javadoc)
735
         * @see org.gvsig.fmap.dal.coverage.dataset.Buffer#isReadOnlyBuffer()
736
         */
737
        public boolean isReadOnlyBuffer() {
738
                return false;
739
        }
740
        
741
        /*
742
         * (non-Javadoc)
743
         * @see org.gvsig.fmap.dal.coverage.dataset.Buffer#isCached()
744
         */
745
        public boolean isCached() {
746
                return false;
747
        }
748
        
749
        /*
750
         * (non-Javadoc)
751
         * @see org.gvsig.fmap.dal.coverage.dataset.Buffer#getIncrementableTask()
752
         */
753
        public IncrementableTask getIncrementableTask() {
754
                return null;
755
        }
756
        
757
        /**
758
         * Libera el buffer de memoria
759
         */
760
        public void free() {
761
                if(pageBandBuffer != null)
762
                        for (int i = 0; i < pageBandBuffer.length; i++) 
763
                                pageBandBuffer[i].free();
764
        }
765
        
766
        /*
767
         * (non-Javadoc)
768
         * @see org.gvsig.fmap.dal.coverage.buffer.Buffer#getAdjustedWindow(int, int, int)
769
         */
770
        public Buffer getAdjustedWindow(int w, int h, int interpolationMethod) throws ProcessInterruptedException {
771
                return null;
772
        }
773

    
774
        public Rectangle2D getDataExtent() {
775
                // TODO Auto-generated method stub
776
                return null;
777
        }
778

    
779
        public void setDataExtent(Rectangle2D r) {
780
                // TODO Auto-generated method stub
781
        }
782
        
783
        public RasterDataStore getStore() {
784
                return null;
785
        }
786

    
787
        public void setStore(RasterDataStore store) {
788
        }
789
        
790
        public void addDrawableBands(int[] db) {}
791
        
792
        //****************************************************
793
        //*********Implementing DataSet methods***************
794
        //****************************************************
795

    
796
        /*
797
         * (non-Javadoc)
798
         * @see org.gvsig.fmap.dal.DataSet#isFromStore(org.gvsig.fmap.dal.DataStore)
799
         */
800
        public boolean isFromStore(DataStore store) {
801
                // TODO Auto-generated method stub
802
                return false;
803
        }
804

    
805
        //****************************************************
806
        //*********Implementing Visitable methods*************
807
        //****************************************************
808
        
809
        /*
810
         * (non-Javadoc)
811
         * @see org.gvsig.tools.visitor.Visitable#accept(org.gvsig.tools.visitor.Visitor)
812
         */
813
        public void accept(Visitor visitor) throws BaseException {
814
                // TODO Auto-generated method stub
815
                
816
        }
817
        
818
        //****************************************************
819
        //*********Implementing Disposable methods************
820
        //****************************************************
821
        
822
        /*
823
         * (non-Javadoc)
824
         * @see org.gvsig.tools.dispose.Disposable#dispose()
825
         */
826
        public void dispose() {
827
                free();
828
        }
829
}