root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / histogram / ui / HistogramIncrement.java @ 10819
History | View | Annotate | Download (2.97 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.rastertools.histogram.ui; |
20 |
|
21 |
import org.cresques.i18n.Messages; |
22 |
import org.gvsig.gui.beans.progressPanel.ProgressPanel; |
23 |
import org.gvsig.rastertools.histogram.Histogram; |
24 |
/**
|
25 |
* <code>HistogramIncrement</code>. Ventana de incremento para la construcci?n
|
26 |
* del histograma
|
27 |
*
|
28 |
* @version 20/03/2007
|
29 |
* @author Nacho Brodin (brodin_ign@gva.es)
|
30 |
* @author Borja Sanchez Zamorano (borja.sanchez@iver.es)
|
31 |
*/
|
32 |
public class HistogramIncrement extends Thread { |
33 |
private HistogramPanelListener histogramPanelListener = null; |
34 |
|
35 |
private ProgressPanel window = new ProgressPanel(); |
36 |
|
37 |
/**
|
38 |
* Constructor del <code>HistogramIncrement</code>.
|
39 |
* @param hpl Se le pasa el objecto de {@link HistogramPanelListener}
|
40 |
*/
|
41 |
public HistogramIncrement(HistogramPanelListener hpl){
|
42 |
this.setHistogramPanelListener(hpl);
|
43 |
} |
44 |
|
45 |
/**
|
46 |
* Muestra la ventana de incremento con el porcentaje de la construcci?n del
|
47 |
* histograma.
|
48 |
*/
|
49 |
public void showWindow(){ |
50 |
window.setTitle("Actualizando datos");
|
51 |
window.showLog(true);
|
52 |
window.show(); |
53 |
|
54 |
if(this.isAlive()) |
55 |
this.resume();
|
56 |
else
|
57 |
this.start();
|
58 |
} |
59 |
|
60 |
/**
|
61 |
* Este thread va leyendo el porcentaje hasta que se completa el histograma.
|
62 |
*/
|
63 |
public synchronized void run(){ |
64 |
while(true){ |
65 |
Histogram hist = this.getHistogramPanelListener().getHistogram();
|
66 |
while (hist.getPercent() < 100){ |
67 |
window.setLabel(Messages.getText("calculando ...") + hist.getPercent() +"%"); |
68 |
window.setPercent(hist.getPercent()); |
69 |
try {
|
70 |
sleep(100);
|
71 |
} catch (InterruptedException e) { |
72 |
e.printStackTrace(); |
73 |
} |
74 |
} |
75 |
//Cerramos la ventana
|
76 |
window.hide(); |
77 |
window = null;
|
78 |
|
79 |
//Mostramos el resultado
|
80 |
this.getHistogramPanelListener().readFullHistogramFromThread();
|
81 |
|
82 |
this.suspend();
|
83 |
} |
84 |
} |
85 |
|
86 |
/**
|
87 |
* M?todo para obtener el {@link HistogramPanelListener}
|
88 |
* @return <code>HistogramPanelListener</code>
|
89 |
*/
|
90 |
public HistogramPanelListener getHistogramPanelListener() {
|
91 |
return histogramPanelListener;
|
92 |
} |
93 |
|
94 |
/**
|
95 |
* Definir el {@link HistogramPanelListener}
|
96 |
* @param hpl {@link HistogramPanelListener}
|
97 |
*/
|
98 |
public void setHistogramPanelListener(HistogramPanelListener hpl) { |
99 |
histogramPanelListener = hpl; |
100 |
} |
101 |
} |