Revision 43867 branches/org.gvsig.desktop-2018a/org.gvsig.desktop.library/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.buffer.impl/src/main/java/org/gvsig/raster/lib/buffer/impl/statistics/DefaultStatistics.java

View differences:

DefaultStatistics.java
27 27
    double[][] varCov;
28 28

  
29 29
    /**
30
     * @param bands
31 30
     *
32 31
     */
33 32
    public DefaultStatistics() {
......
167 166
        }
168 167
        init(bands);
169 168
        try {
170
            status.setRangeOfValues(0, statisticsBands.length * 3);
169
            status.setIndeterminate();
171 170
            status.message("Calculating statistics");
172
            long cont = 0;
173

  
171
            int count = 1;
172
            int maxCount = statisticsBands.length*3;
174 173
            for (int i = 0; i < statisticsBands.length; i++) {
175
                status.setCurValue(cont++);
176
                if (status.isCancelled()) {
174
                status.message("Calculating statistics "+count++ +"/"+maxCount);
175
               if (status.isCancelled()) {
177 176
                    status.abort();
178 177
                    return;
179 178
                }
......
182 181
                }
183 182
            }
184 183
            for (int i = 0; i < statisticsBands.length; i++) {
185
                status.setCurValue(cont++);
184
                status.message("Calculating statistics "+count++ +"/"+maxCount);
186 185
                if (status.isCancelled()) {
187 186
                    status.abort();
188 187
                    return;
189 188
                }
190 189
                for (int j = i; j < statisticsBands.length; j++) {
191
                    this.varCov[i][j] = getCovariance(statisticsBands[i],bands.get(i), statisticsBands[j], bands.get(j));
190
                    this.varCov[i][j] = getCovariance(status,statisticsBands[i],bands.get(i), statisticsBands[j], bands.get(j));
192 191
                }
193 192
            }
194

  
193
            status.setIndeterminate();
195 194
            for (int i = 0; i < statisticsBands.length; i++) {
196
                status.setCurValue(cont++);
195
                status.message("Calculating statistics "+count++ +"/"+maxCount);
197 196
                if (status.isCancelled()) {
198 197
                    status.abort();
199 198
                    return;
......
214 213
        }
215 214
    }
216 215

  
217
    private double getCovariance(StatisticsBand statisticBand1, Band band1, StatisticsBand statisticBand2, Band band2) {
216
    private double getCovariance(SimpleTaskStatus  status, StatisticsBand statisticBand1, Band band1, StatisticsBand statisticBand2, Band band2) {
218 217

  
219 218
        double sigma = 0;
220 219
        int n = 0;
221

  
222
        for (int row = 0; row < band1.getRows(); row++) {
220
        int rowCount = band1.getRows();
221
        status.setRangeOfValues(0, rowCount);
222
        for (int row = 0; row < rowCount; row++) {
223
            status.setCurValue(row);
223 224
            for (int column = 0; column < band1.getColumns(); column++) {
224 225
                Double v1 = band1.getAsDouble(row, column);
225 226
                if (v1 != null) {

Also available in: Unified diff