Revision 11068
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/histogram/HistogramProcess.java | ||
---|---|---|
37 | 37 |
this.iHistogramable = iHistogramable; |
38 | 38 |
this.hpl = hpl; |
39 | 39 |
} |
40 |
|
|
40 |
|
|
41 | 41 |
public void start() { |
42 | 42 |
blinker = new Thread(this); |
43 | 43 |
blinker.start(); |
... | ... | |
48 | 48 |
notify(); |
49 | 49 |
} |
50 | 50 |
|
51 |
/* |
|
52 |
* (non-Javadoc) |
|
53 |
* @see java.lang.Runnable#run() |
|
54 |
*/ |
|
51 | 55 |
public void run() { |
52 | 56 |
try { |
57 |
iHistogramable.setCanceled(false); |
|
53 | 58 |
Histogram histogram = iHistogramable.getHistogram(); |
54 |
hpl.setNewHistogram(histogram); |
|
59 |
if (histogram != null) hpl.setNewHistogram(histogram);
|
|
55 | 60 |
} catch (HistogramException e) { |
56 | 61 |
e.printStackTrace(); |
57 | 62 |
} |
... | ... | |
60 | 65 |
incrementableTask = null; |
61 | 66 |
} |
62 | 67 |
|
68 |
/* |
|
69 |
* Definir el IncrementableTask |
|
70 |
*/ |
|
63 | 71 |
public void setIncrementableTask(IncrementableTask value) { |
64 | 72 |
incrementableTask = value; |
73 |
incrementableTask.addIncrementableListener(this); |
|
65 | 74 |
} |
66 | 75 |
|
67 | 76 |
/* |
... | ... | |
96 | 105 |
return "Calculando histograma"; |
97 | 106 |
} |
98 | 107 |
|
108 |
/* |
|
109 |
* (non-Javadoc) |
|
110 |
* @see org.gvsig.gui.beans.incrementabletask.IncrementableListener#actionCanceled(org.gvsig.gui.beans.incrementabletask.IncrementableEvent) |
|
111 |
*/ |
|
99 | 112 |
public void actionCanceled(IncrementableEvent e) { |
100 |
// TODO Implementar la forma de cancelar el proceso
|
|
113 |
iHistogramable.setCanceled(true);
|
|
101 | 114 |
} |
102 | 115 |
|
116 |
/* |
|
117 |
* (non-Javadoc) |
|
118 |
* @see org.gvsig.gui.beans.incrementabletask.IncrementableListener#actionResumed(org.gvsig.gui.beans.incrementabletask.IncrementableEvent) |
|
119 |
*/ |
|
103 | 120 |
public void actionResumed(IncrementableEvent e) { |
104 | 121 |
} |
105 | 122 |
|
123 |
/* |
|
124 |
* (non-Javadoc) |
|
125 |
* @see org.gvsig.gui.beans.incrementabletask.IncrementableListener#actionSuspended(org.gvsig.gui.beans.incrementabletask.IncrementableEvent) |
|
126 |
*/ |
|
106 | 127 |
public void actionSuspended(IncrementableEvent e) { |
107 | 128 |
} |
108 | 129 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/histogram/ui/HistogramPanel.java | ||
---|---|---|
436 | 436 |
|
437 | 437 |
public void refreshBands() { |
438 | 438 |
//En caso de que el histograma se monte a partir de los datos de la vista ponemos RGB en el combo |
439 |
int bandCount = getHistogramPanelListener().getHistogram().getNumBands(); |
|
439 |
int bandCount = getHistogramPanelListener().getLastHistogram().getNumBands();
|
|
440 | 440 |
if ((getJComboBoxOrigen().getSelectedIndex() == 0) && (bandCount == 3)) { |
441 | 441 |
setRGBInBandList(); |
442 | 442 |
} else { |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/histogram/HistogramPanelListener.java | ||
---|---|---|
90 | 90 |
Color.gray, |
91 | 91 |
Color.magenta, |
92 | 92 |
Color.yellow, |
93 |
Color.orange}; |
|
94 |
|
|
93 |
Color.orange, |
|
94 |
Color.pink, |
|
95 |
Color.lightGray}; |
|
96 |
|
|
95 | 97 |
public HistogramPanelListener(HistogramPanel p){ |
96 | 98 |
histogramPanel = p; |
97 | 99 |
} |
98 |
|
|
100 |
|
|
99 | 101 |
public void setControlListeners(){ |
100 | 102 |
histogramPanel.getGraphicContainer().addValueChangedListener(this); |
101 | 103 |
} |
102 |
|
|
104 |
|
|
105 |
/** |
|
106 |
* Actualizar cuadro de estad?sticas |
|
107 |
*/ |
|
103 | 108 |
private void updateStatistic() { |
104 | 109 |
int first = (int) histogramPanel.getBoxesValues()[1]; |
105 | 110 |
int end = (int) histogramPanel.getBoxesValues()[0]; |
106 | 111 |
|
107 |
histogramPanel.setStatistic(lastHistogram.getBasicStats((int) first, (int) end, showBands));
|
|
112 |
histogramPanel.setStatistic(getLastHistogram().getBasicStats((int) first, (int) end, showBands));
|
|
108 | 113 |
} |
109 | 114 |
|
115 |
/** |
|
116 |
* Tratamiento de todos los eventos visuales. |
|
117 |
*/ |
|
110 | 118 |
public void actionPerformed(ActionEvent e) { |
111 | 119 |
if (!eventsEnabled) return; |
112 | 120 |
//-------------------------------------- |
... | ... | |
178 | 186 |
DbaseFileHeaderNIO myHeader; |
179 | 187 |
Value[] record; |
180 | 188 |
|
181 |
long histogram[][]= lastHistogram.getHistogram();
|
|
189 |
long histogram[][]= getLastHistogram().getHistogram();
|
|
182 | 190 |
int numBands = histogram.length; |
183 | 191 |
int numRecors = histogram[0].length; |
184 | 192 |
|
... | ... | |
245 | 253 |
} |
246 | 254 |
} |
247 | 255 |
|
256 |
/** |
|
257 |
* Actualizar la variable de las bandas visibles y su componente visual. |
|
258 |
*/ |
|
248 | 259 |
private void refreshBands() { |
249 | 260 |
histogramPanel.refreshBands(); |
250 |
showBands = new boolean[getHistogram().getNumBands()]; |
|
261 |
showBands = new boolean[getLastHistogram().getNumBands()];
|
|
251 | 262 |
for (int i = 0; i < showBands.length; i++) |
252 | 263 |
showBands[i] = true; |
253 | 264 |
} |
254 | 265 |
|
266 |
/** |
|
267 |
* Lanza los dos threads para procesar el histograma y visualizar la |
|
268 |
* ventana de incremento |
|
269 |
*/ |
|
255 | 270 |
public void showHistogram() { |
256 | 271 |
if (histogramPanel.getJComboBoxOrigen().getSelectedIndex() < 0) return; |
257 | 272 |
|
... | ... | |
264 | 279 |
histogramProcess.start(); |
265 | 280 |
incrementableTask.start(); |
266 | 281 |
} |
267 |
|
|
282 |
|
|
268 | 283 |
/** |
269 | 284 |
* A?ade o elimina una banda de la visualizaci?n. Si la banda se est? visualizando |
270 | 285 |
* se elimina y si no entonces se muestra |
... | ... | |
275 | 290 |
showBands[band] = !showBands[band]; |
276 | 291 |
} |
277 | 292 |
|
293 |
/** |
|
294 |
* Actualiza la grafica con los datos que ya teniamos del histograma. |
|
295 |
*/ |
|
278 | 296 |
private void updateGraphic() { |
279 |
long[][] auxHistogram = lastHistogram.getHistogramByType(Histogram.getType(histogramPanel.getJComboBoxTipo().getSelectedIndex()));
|
|
297 |
long[][] auxHistogram = getLastHistogram().getHistogramByType(Histogram.getType(histogramPanel.getJComboBoxTipo().getSelectedIndex()));
|
|
280 | 298 |
if (auxHistogram == null) return; |
281 | 299 |
|
282 | 300 |
int first = (int) histogramPanel.getBoxesValues()[1]; |
... | ... | |
300 | 318 |
newHistogram[numBand][j-first] = (int) auxHistogram[iBand][j]; |
301 | 319 |
bandNames[numBand] = iBand + ""; |
302 | 320 |
|
303 |
histogramPanel.getGraphicContainer().setBandColor(numBand, bandsColor[iBand]); |
|
321 |
histogramPanel.getGraphicContainer().setBandColor(numBand, bandsColor[iBand % bandsColor.length]);
|
|
304 | 322 |
|
305 | 323 |
numBand++; |
306 | 324 |
} |
... | ... | |
309 | 327 |
updateStatistic(); |
310 | 328 |
} |
311 | 329 |
|
330 |
/** |
|
331 |
* Definir el nuevo histograma, metodo pu?blico para ser invocado desde |
|
332 |
* histogramProcess |
|
333 |
* @param histograma nuevo |
|
334 |
*/ |
|
312 | 335 |
public void setNewHistogram(Histogram value) { |
313 | 336 |
histogramPanel.panelInizialited = false; |
314 | 337 |
eventsEnabled = false; |
... | ... | |
324 | 347 |
histogramPanel.panelInizialited = true; |
325 | 348 |
} |
326 | 349 |
|
327 |
public Histogram getHistogram() { |
|
350 |
/** |
|
351 |
* Obtener ?ltimo histograma |
|
352 |
* @return Histogram |
|
353 |
*/ |
|
354 |
public Histogram getLastHistogram() { |
|
328 | 355 |
return lastHistogram; |
329 | 356 |
} |
330 | 357 |
|
358 |
/** |
|
359 |
* Eventos de los BoxValues |
|
360 |
*/ |
|
331 | 361 |
public void actionValueChanged(GraphicEvent e) { |
332 | 362 |
updateGraphic(); |
333 | 363 |
} |
334 | 364 |
|
335 |
private WritableByteChannel getWriteChannel(String path)throws IOException { |
|
365 |
/** |
|
366 |
* Proceso para guardar una estadistica en un fichero. |
|
367 |
* @param path |
|
368 |
* @return |
|
369 |
* @throws IOException |
|
370 |
*/ |
|
371 |
private WritableByteChannel getWriteChannel(String path) throws IOException { |
|
336 | 372 |
WritableByteChannel channel; |
337 | 373 |
|
338 | 374 |
File f = new File(path); |
trunk/extensions/extRasterTools-SE/src/org/gvsig/fmap/layers/FLyrRasterSE.java | ||
---|---|---|
41 | 41 |
import org.gvsig.fmap.drivers.GenericRasterDriver; |
42 | 42 |
import org.gvsig.fmap.drivers.GeoRasterDriver; |
43 | 43 |
import org.gvsig.raster.dataaccess.DataSource; |
44 |
import org.gvsig.raster.dataset.IBuffer; |
|
45 | 44 |
import org.gvsig.raster.dataset.RasterDriverException; |
46 | 45 |
import org.gvsig.raster.dataset.RasterMultiDataset; |
47 | 46 |
import org.gvsig.raster.dataset.properties.DatasetMetadata; |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/progresspanel/ProgressPanel.java | ||
---|---|---|
52 | 52 |
private JScrollPane jScrollPane = null; |
53 | 53 |
private JTextPane jTextPane = null; |
54 | 54 |
private LogControl text = new LogControl(); |
55 |
|
|
56 |
private boolean showPause = true; |
|
55 | 57 |
|
56 | 58 |
/** |
57 | 59 |
* Constructor |
... | ... | |
60 | 62 |
initialize(); |
61 | 63 |
} |
62 | 64 |
|
65 |
public ProgressPanel(boolean showPause) { |
|
66 |
this.showPause = showPause; |
|
67 |
initialize(); |
|
68 |
} |
|
69 |
|
|
63 | 70 |
/** |
64 | 71 |
* This method initializes this |
65 | 72 |
* |
... | ... | |
140 | 147 |
} |
141 | 148 |
|
142 | 149 |
public void showPause(boolean visible) { |
143 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_RESTART).setVisible(!visible); |
|
144 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_PAUSE).setVisible(visible); |
|
150 |
if (showPause) { |
|
151 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_RESTART).setVisible(!visible); |
|
152 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_PAUSE).setVisible(visible); |
|
153 |
} else { |
|
154 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_RESTART).setVisible(false); |
|
155 |
getButtonsPanel().getButton(ButtonsPanel.BUTTON_PAUSE).setVisible(false); |
|
156 |
} |
|
145 | 157 |
} |
146 | 158 |
|
147 | 159 |
public ButtonsPanel getButtonsPanel() { |
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/incrementabletask/IncrementableTask.java | ||
---|---|---|
105 | 105 |
|
106 | 106 |
private ProgressPanel getProgressPanel() { |
107 | 107 |
if (progressPanel == null) { |
108 |
progressPanel = new ProgressPanel(); |
|
108 |
progressPanel = new ProgressPanel(false);
|
|
109 | 109 |
progressPanel.addButtonPressedListener(this); |
110 | 110 |
progressPanel.addWindowListener( new WindowAdapter() { |
111 | 111 |
public void windowClosing(WindowEvent e) |
trunk/libraries/libRaster/src/org/gvsig/raster/util/ICancellable.java | ||
---|---|---|
35 | 35 |
/** |
36 | 36 |
* Cancelar un proceso |
37 | 37 |
*/ |
38 |
public void cancel();
|
|
38 |
public void setCanceled(boolean value);
|
|
39 | 39 |
} |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/RasterDataset.java | ||
---|---|---|
816 | 816 |
} |
817 | 817 |
|
818 | 818 |
public void resetPercent() { |
819 |
if (histogram != null) |
|
820 |
histogram.resetPercent(); |
|
819 |
if (histogram != null) histogram.resetPercent(); |
|
821 | 820 |
} |
821 |
|
|
822 | 822 |
public int getPercent() { |
823 |
if (histogram != null) |
|
824 |
return histogram.getPercent(); |
|
823 |
if (histogram != null) return histogram.getPercent(); |
|
825 | 824 |
return 0; |
826 | 825 |
} |
827 |
} |
|
826 |
|
|
827 |
public void setCanceled(boolean value) { |
|
828 |
if (histogram != null) histogram.setCanceled(value); |
|
829 |
} |
|
830 |
|
|
831 |
public boolean isCanceled() { |
|
832 |
if (histogram != null) return histogram.isCanceled(); |
|
833 |
return false; |
|
834 |
} |
|
835 |
} |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/properties/DatasetHistogram.java | ||
---|---|---|
51 | 51 |
private RasterDataset dataset = null; |
52 | 52 |
|
53 | 53 |
private int percent = 0; |
54 |
private boolean canceled = false; |
|
54 | 55 |
|
55 | 56 |
/** |
56 | 57 |
* Constructor |
... | ... | |
115 | 116 |
byte[] bLine = (byte[])obj; |
116 | 117 |
for (int k = 0; k < bLine.length; k++) |
117 | 118 |
histogram.incrementPxValue(band, (bLine[k] & 0xff)); |
119 |
if (isCanceled()) return null; |
|
118 | 120 |
percent = ((band * dataset.getHeight() + line) * 100) / (dataset.getBandCount() * dataset.getHeight()); |
119 | 121 |
} |
120 | 122 |
} |
... | ... | |
183 | 185 |
public int getPercent() { |
184 | 186 |
return percent; |
185 | 187 |
} |
188 |
|
|
189 |
public void setCanceled(boolean value) { |
|
190 |
canceled = value; |
|
191 |
} |
|
192 |
|
|
193 |
public boolean isCanceled() { |
|
194 |
return canceled; |
|
195 |
} |
|
186 | 196 |
} |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/properties/DatasetListHistogram.java | ||
---|---|---|
47 | 47 |
private RasterMultiDataset multiDataset = null; |
48 | 48 |
|
49 | 49 |
/** |
50 |
* Variable para saber si se ha parado el proceso |
|
51 |
*/ |
|
52 |
private boolean canceled = false; |
|
53 |
|
|
54 |
/** |
|
55 | 50 |
* Constructor |
56 | 51 |
* @param dataset |
57 | 52 |
*/ |
... | ... | |
81 | 76 |
int nBands = 0; |
82 | 77 |
Histogram[] hList = new Histogram[multiDataset.getDatasetCount()]; |
83 | 78 |
for (int i = 0; i < hList.length; i++) { |
84 |
if (canceled) return null; |
|
85 | 79 |
multiDataset.getDataset(i).getHistogram().setClasses(classes); |
86 | 80 |
hList[i] = multiDataset.getDataset(i).getHistogram().getHistogram(); |
81 |
if (isCanceled() || (hList[i] == null)) return null; |
|
87 | 82 |
nBands += hList[i].getNumBands(); |
88 | 83 |
} |
89 | 84 |
|
... | ... | |
126 | 121 |
/** |
127 | 122 |
* Metodo para poder cancelar el proceso. |
128 | 123 |
*/ |
129 |
public void cancel() { |
|
130 |
canceled = true; |
|
124 |
public void setCanceled(boolean value) { |
|
125 |
for (int i = 0; i < multiDataset.getDatasetCount(); i++) { |
|
126 |
multiDataset.getDataset(i).setCanceled(value); |
|
127 |
} |
|
131 | 128 |
} |
132 | 129 |
|
133 | 130 |
/** |
... | ... | |
135 | 132 |
* @return boolean |
136 | 133 |
*/ |
137 | 134 |
public boolean isCanceled() { |
138 |
return canceled; |
|
135 |
boolean cancel = false; |
|
136 |
for (int i = 0; i < multiDataset.getDatasetCount(); i++) { |
|
137 |
if (multiDataset.getDataset(i).isCanceled()) { |
|
138 |
cancel = true; |
|
139 |
break; |
|
140 |
} |
|
141 |
} |
|
142 |
return cancel; |
|
139 | 143 |
} |
140 | 144 |
} |
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/RasterMultiDataset.java | ||
---|---|---|
874 | 874 |
|
875 | 875 |
/* |
876 | 876 |
* (non-Javadoc) |
877 |
* @see org.gvsig.raster.util.ICancellable#cancel()
|
|
877 |
* @see org.gvsig.raster.util.ICancellable#isCanceled()
|
|
878 | 878 |
*/ |
879 |
public void cancel() { |
|
880 |
if (histogram != null) histogram.cancel(); |
|
879 |
public boolean isCanceled() { |
|
880 |
if (histogram != null) return histogram.isCanceled(); |
|
881 |
return false; |
|
881 | 882 |
} |
882 | 883 |
|
883 | 884 |
/* |
884 | 885 |
* (non-Javadoc) |
885 |
* @see org.gvsig.raster.util.ICancellable#isCanceled()
|
|
886 |
* @see org.gvsig.raster.util.ICancellable#setCanceled(boolean)
|
|
886 | 887 |
*/ |
887 |
public boolean isCanceled() { |
|
888 |
if (histogram != null) return histogram.isCanceled(); |
|
889 |
return false; |
|
888 |
public void setCanceled(boolean value) { |
|
889 |
if (histogram != null) histogram.setCanceled(value); |
|
890 | 890 |
} |
891 | 891 |
} |
trunk/libraries/libRaster/src/org/gvsig/raster/dataaccess/buffer/RasterBuffer.java | ||
---|---|---|
444 | 444 |
|
445 | 445 |
/* |
446 | 446 |
* (non-Javadoc) |
447 |
* @see org.gvsig.raster.util.ICancellable#cancel()
|
|
447 |
* @see org.gvsig.raster.util.ICancellable#setCanceled(boolean)
|
|
448 | 448 |
*/ |
449 |
public void cancel() {
|
|
450 |
canceled = true;
|
|
449 |
public void setCanceled(boolean value) {
|
|
450 |
canceled = value;
|
|
451 | 451 |
} |
452 | 452 |
} |
trunk/libraries/libRaster/src/org/gvsig/raster/dataaccess/cache/PageBuffer.java | ||
---|---|---|
474 | 474 |
|
475 | 475 |
/* |
476 | 476 |
* (non-Javadoc) |
477 |
* @see org.gvsig.raster.util.ICancellable#cancel()
|
|
477 |
* @see org.gvsig.raster.util.ICancellable#isCanceled()
|
|
478 | 478 |
*/ |
479 |
public void cancel() {
|
|
480 |
canceled = true;
|
|
479 |
public boolean isCanceled() {
|
|
480 |
return canceled;
|
|
481 | 481 |
} |
482 | 482 |
|
483 | 483 |
/* |
484 | 484 |
* (non-Javadoc) |
485 |
* @see org.gvsig.raster.util.ICancellable#isCanceled()
|
|
485 |
* @see org.gvsig.raster.util.ICancellable#setCanceled(boolean)
|
|
486 | 486 |
*/ |
487 |
public boolean isCanceled() {
|
|
488 |
return canceled;
|
|
487 |
public void setCanceled(boolean value) {
|
|
488 |
canceled = value;
|
|
489 | 489 |
} |
490 | 490 |
} |
Also available in: Unified diff