Revision 11042 trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/histogram/HistogramProcess.java
HistogramProcess.java | ||
---|---|---|
19 | 19 |
package org.gvsig.rastertools.histogram; |
20 | 20 |
|
21 | 21 |
import org.gvsig.gui.beans.incrementabletask.IIncrementable; |
22 |
import org.gvsig.gui.beans.incrementabletask.IncrementableEvent; |
|
23 |
import org.gvsig.gui.beans.incrementabletask.IncrementableListener; |
|
24 |
import org.gvsig.gui.beans.incrementabletask.IncrementableTask; |
|
22 | 25 |
import org.gvsig.raster.util.Histogram; |
23 | 26 |
import org.gvsig.raster.util.HistogramException; |
24 | 27 |
import org.gvsig.raster.util.IHistogramable; |
25 | 28 |
|
26 |
public class HistogramProcess extends Thread implements IIncrementable {
|
|
29 |
public class HistogramProcess implements Runnable, IIncrementable, IncrementableListener {
|
|
27 | 30 |
IHistogramable iHistogramable = null; |
28 |
Histogram histogram = null; |
|
29 |
|
|
30 |
public HistogramProcess(IHistogramable iHistogramable) { |
|
31 |
HistogramPanelListener hpl = null; |
|
32 |
|
|
33 |
IncrementableTask incrementableTask = null; |
|
34 |
private volatile Thread blinker; |
|
35 |
|
|
36 |
public HistogramProcess(IHistogramable iHistogramable, HistogramPanelListener hpl) { |
|
31 | 37 |
this.iHistogramable = iHistogramable; |
32 |
this.start();
|
|
38 |
this.hpl = hpl;
|
|
33 | 39 |
} |
34 | 40 |
|
41 |
public void start() { |
|
42 |
blinker = new Thread(this); |
|
43 |
blinker.start(); |
|
44 |
} |
|
45 |
|
|
46 |
public synchronized void stop() { |
|
47 |
blinker = null; |
|
48 |
notify(); |
|
49 |
} |
|
50 |
|
|
35 | 51 |
public void run() { |
36 | 52 |
try { |
37 |
histogram = iHistogramable.getHistogram(); |
|
53 |
Histogram histogram = iHistogramable.getHistogram(); |
|
54 |
hpl.setNewHistogram(histogram); |
|
38 | 55 |
} catch (HistogramException e) { |
39 | 56 |
e.printStackTrace(); |
40 | 57 |
} |
58 |
while (!incrementableTask.getStarted()); |
|
59 |
while (incrementableTask.isAlive()); |
|
60 |
incrementableTask.Hide(); |
|
61 |
incrementableTask = null; |
|
41 | 62 |
} |
42 | 63 |
|
43 |
public Histogram getLastHistogram() {
|
|
44 |
return histogram;
|
|
64 |
public void setIncrementableTask(IncrementableTask value) {
|
|
65 |
incrementableTask = value;
|
|
45 | 66 |
} |
67 |
|
|
46 | 68 |
/* |
47 | 69 |
* (non-Javadoc) |
48 | 70 |
* @see org.gvsig.gui.beans.IncrementableTask.IIncrementable#getLabel() |
... | ... | |
74 | 96 |
public String getTitle() { |
75 | 97 |
return "Calculando histograma"; |
76 | 98 |
} |
99 |
|
|
100 |
public void actionCanceled(IncrementableEvent e) { |
|
101 |
// TODO Implementar la forma de cancelar el proceso |
|
102 |
} |
|
103 |
|
|
104 |
public void actionResumed(IncrementableEvent e) { |
|
105 |
} |
|
106 |
|
|
107 |
public void actionSuspended(IncrementableEvent e) { |
|
108 |
} |
|
77 | 109 |
} |
Also available in: Unified diff