Revision 43868
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 | ||
---|---|---|
172 | 172 |
int maxCount = statisticsBands.length*3; |
173 | 173 |
for (int i = 0; i < statisticsBands.length; i++) { |
174 | 174 |
status.message("Calculating statistics "+count++ +"/"+maxCount); |
175 |
if (status.isCancelled()) { |
|
176 |
status.abort();
|
|
175 |
if (status.isCancellationRequested()) {
|
|
176 |
status.cancel();
|
|
177 | 177 |
return; |
178 | 178 |
} |
179 | 179 |
if(!statisticsBands[i].isCalculated()){ |
... | ... | |
182 | 182 |
} |
183 | 183 |
for (int i = 0; i < statisticsBands.length; i++) { |
184 | 184 |
status.message("Calculating statistics "+count++ +"/"+maxCount); |
185 |
if (status.isCancelled()) { |
|
186 |
status.abort();
|
|
185 |
if (status.isCancellationRequested()) {
|
|
186 |
status.cancel();
|
|
187 | 187 |
return; |
188 | 188 |
} |
189 | 189 |
for (int j = i; j < statisticsBands.length; j++) { |
... | ... | |
193 | 193 |
status.setIndeterminate(); |
194 | 194 |
for (int i = 0; i < statisticsBands.length; i++) { |
195 | 195 |
status.message("Calculating statistics "+count++ +"/"+maxCount); |
196 |
if (status.isCancelled()) { |
|
197 |
status.abort();
|
|
196 |
if (status.isCancellationRequested()) {
|
|
197 |
status.cancel();
|
|
198 | 198 |
return; |
199 | 199 |
} |
200 | 200 |
for (int j = 0; j < i; j++) { |
... | ... | |
221 | 221 |
status.setRangeOfValues(0, rowCount); |
222 | 222 |
for (int row = 0; row < rowCount; row++) { |
223 | 223 |
status.setCurValue(row); |
224 |
if (status.isCancellationRequested()) { |
|
225 |
status.cancel(); |
|
226 |
return 0; |
|
227 |
} |
|
224 | 228 |
for (int column = 0; column < band1.getColumns(); column++) { |
225 | 229 |
Double v1 = band1.getAsDouble(row, column); |
226 | 230 |
if (v1 != null) { |
... | ... | |
277 | 281 |
|
278 | 282 |
@Override |
279 | 283 |
public String toHTMLString() { |
280 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
284 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
285 |
if( !this.calculated ) { |
|
286 |
return i18n.getTranslation("_Need_calculate_statistics"); |
|
287 |
} |
|
281 | 288 |
|
282 | 289 |
LayerInformationBuilder builder = MapContextLocator.getMapContextManager().createLayerInformationBuilder(); |
283 | 290 |
|
... | ... | |
286 | 293 |
int bandCounter = 0; |
287 | 294 |
for (StatisticsBand statisticsBand : this) { |
288 | 295 |
|
289 |
builder.title().labelkey(i18nManager.getTranslation("_band") + " " + bandCounter);
|
|
296 |
builder.title().labelkey(i18n.getTranslation("_band") + " " + bandCounter); |
|
290 | 297 |
|
291 | 298 |
int dataType = statisticsBand.getDataType(); |
292 | 299 |
builder.property().labelkey("_dataType").value(bufferManager.getBufferTypeName(dataType)); |
... | ... | |
322 | 329 |
|
323 | 330 |
double[] covariance = matrix[bandCounter]; |
324 | 331 |
for (int bandCounter2 = 0; bandCounter2 < covariance.length; bandCounter2++) { |
325 |
builder.property().label(i18nManager.getTranslation("_covariance_with_band") + " " + bandCounter2)
|
|
332 |
builder.property().label(i18n.getTranslation("_covariance_with_band") + " " + bandCounter2) |
|
326 | 333 |
.value(Double.toString(covariance[bandCounter2])); |
327 | 334 |
} |
328 | 335 |
for (int bandCounter2 = 0; bandCounter2 < covariance.length; bandCounter2++) { |
329 | 336 |
Double pearson = covariance[bandCounter2]/(statisticsBand.getVariance()*statisticsBands[bandCounter2].getVariance()); |
330 |
builder.property().label(i18nManager.getTranslation("_pearson_correlation_coefficient_with_band") + " " + bandCounter2)
|
|
337 |
builder.property().label(i18n.getTranslation("_pearson_correlation_coefficient_with_band") + " " + bandCounter2) |
|
331 | 338 |
.value(pearson.isNaN()?"\u2015":pearson.toString()); |
332 | 339 |
} |
333 | 340 |
bandCounter++; |
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/DefaultStatisticsBand.java | ||
---|---|---|
85 | 85 |
|
86 | 86 |
for (int row = 0; row < band.getRows(); row++) { |
87 | 87 |
status.setCurValue(cont++); |
88 |
if (status.isCancelled()) { |
|
89 |
status.abort();
|
|
88 |
if (status.isCancellationRequested()) {
|
|
89 |
status.cancel();
|
|
90 | 90 |
return; |
91 | 91 |
} |
92 | 92 |
for (int column = 0; column < band.getColumns(); column++) { |
... | ... | |
119 | 119 |
histogramOperation.pre(); |
120 | 120 |
for (int row = 0; row < band.getRows(); row++) { |
121 | 121 |
status.setCurValue(cont++); |
122 |
if (status.isCancelled()) { |
|
123 |
status.abort();
|
|
122 |
if (status.isCancellationRequested()) {
|
|
123 |
status.cancel();
|
|
124 | 124 |
return; |
125 | 125 |
} |
126 | 126 |
for (int column = 0; column < band.getColumns(); column++) { |
... | ... | |
137 | 137 |
this.histogramBand = ((HistogramBand) histogramOperation.getResult()); |
138 | 138 |
this.variance = ((Number) varianceOperation.getResult()).doubleValue(); |
139 | 139 |
|
140 |
calculated = true; |
|
141 |
} catch (Exception e) { |
|
142 |
status.abort(); |
|
143 |
throw e; |
|
144 |
} finally { |
|
140 | 145 |
if (isMyStatus) { |
141 | 146 |
status.terminate(); |
142 | 147 |
} else { |
143 | 148 |
status.pop(); |
144 |
} |
|
145 |
calculated = true; |
|
146 |
} catch (Exception e) { |
|
147 |
status.abort(); |
|
148 |
throw e; |
|
149 |
} |
|
149 | 150 |
} |
150 | 151 |
} |
151 | 152 |
|
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.imageio/src/main/java/org/gvsig/fmap/dal/file/imageio/ImageIOStoreProvider.java | ||
---|---|---|
48 | 48 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
49 | 49 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
50 | 50 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
51 |
import org.gvsig.tools.ToolsLocator; |
|
51 | 52 |
import org.gvsig.tools.exception.BaseException; |
53 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
52 | 54 |
|
53 | 55 |
|
54 | 56 |
public class ImageIOStoreProvider |
... | ... | |
163 | 165 |
if (this.isOpen()) { |
164 | 166 |
return; |
165 | 167 |
} |
168 |
SimpleTaskStatus taskStatus = null; |
|
166 | 169 |
try { |
170 |
taskStatus = ToolsLocator.getTaskStatusManager().createDefaultSimpleTaskStatus(this.getName()); |
|
171 |
taskStatus.setIndeterminate(); |
|
172 |
taskStatus.setAutoremove(true); |
|
173 |
taskStatus.message("Loading "+this.getName()+"..."); |
|
174 |
taskStatus.add(); |
|
167 | 175 |
image = ImageIO.read((File) getResource().getParameters().getDynValue(FileResource.NAME)); |
168 | 176 |
open(image.getRaster()); |
169 | 177 |
|
170 | 178 |
} catch (Exception e) { |
179 |
if( taskStatus!=null ) { |
|
180 |
taskStatus.abort(); |
|
181 |
taskStatus = null; |
|
182 |
} |
|
171 | 183 |
try { |
172 | 184 |
throw new OpenException(resource.getName(), e); |
173 | 185 |
} catch (AccessResourceException e1) { |
174 | 186 |
throw new OpenException(getProviderName(), e); |
175 | 187 |
} |
188 |
} finally { |
|
189 |
if( taskStatus!=null ) { |
|
190 |
taskStatus.terminate(); |
|
191 |
taskStatus = null; |
|
192 |
} |
|
176 | 193 |
} |
177 | 194 |
} |
178 | 195 |
|
branches/org.gvsig.desktop-2018a/org.gvsig.desktop.plugin/org.gvsig.raster.app/org.gvsig.raster.app.mainplugin/src/main/java/org/gvsig/raster/app/mainplugin/StatisticsPage.java | ||
---|---|---|
34 | 34 |
private static final long serialVersionUID = 8264136278039978040L; |
35 | 35 |
private StatisticsPanel panel; |
36 | 36 |
private RasterLayer layer; |
37 |
private Thread updateStatisticsThread; |
|
37 | 38 |
|
38 | 39 |
|
39 | 40 |
/** |
... | ... | |
145 | 146 |
/** |
146 | 147 |
* |
147 | 148 |
*/ |
148 |
private void updateStatisticsPanel() { |
|
149 |
Thread thread = new Thread(new Runnable() { |
|
149 |
private synchronized void updateStatisticsPanel() { |
|
150 |
if( updateStatisticsThread!=null ) { |
|
151 |
return; |
|
152 |
} |
|
153 |
this.updateStatisticsThread = new Thread(new Runnable() { |
|
150 | 154 |
@Override |
151 | 155 |
public void run() { |
152 | 156 |
final Statistics statistics = layer.getStatistics(null); |
... | ... | |
156 | 160 |
panel.set(statistics); |
157 | 161 |
} |
158 | 162 |
}); |
163 |
updateStatisticsThread = null; |
|
159 | 164 |
} |
160 | 165 |
}, "Calculate statistics"); |
161 | 166 |
|
162 |
thread.setDaemon(false);
|
|
163 |
thread.start();
|
|
167 |
updateStatisticsThread.setDaemon(false);
|
|
168 |
updateStatisticsThread.start();
|
|
164 | 169 |
} |
165 | 170 |
|
166 | 171 |
} |
Also available in: Unified diff