Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extRasterTools-SE / src / org / gvsig / rastertools / histogram / HistogramProcess.java @ 30056

History | View | Annotate | Download (3.08 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 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;
20

    
21
import javax.swing.SwingUtilities;
22

    
23
import org.gvsig.andami.PluginServices;
24
import org.gvsig.andami.messages.NotificationManager;
25
import org.gvsig.raster.RasterProcess;
26
import org.gvsig.raster.datastruct.Histogram;
27
import org.gvsig.raster.datastruct.HistogramException;
28
import org.gvsig.raster.hierarchy.IHistogramable;
29

    
30
/**
31
 * Clase para calcular histogramas. Esta clase implementa IIncrementable para
32
 * poder ser usado con una ventana de incremento <code>IncrementableTask</code>
33
 *
34
 * @version 23/04/2007
35
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
36
 */
37
public class HistogramProcess extends RasterProcess {
38
        private IHistogramable iHistogramable = null;
39
        private Histogram      lastHistogram  = null;
40

    
41
        /*
42
         * (non-Javadoc)
43
         * @see org.gvsig.rastertools.RasterProcess#init()
44
         */
45
        public void init() {
46
                iHistogramable = (IHistogramable) getParam("histogramable");
47
        }
48

    
49
        /*
50
         * (non-Javadoc)
51
         * @see org.gvsig.rastertools.RasterProcess#process()
52
         */
53
        public void process() throws InterruptedException {
54
                try {
55
                        // Proceso duro de obtener un histograma. Puede durar bastante tiempo.
56
                        lastHistogram = iHistogramable.getHistogram();
57
                        // Ya tenemos el histograma y lo representamos en la ventana
58

    
59
                        SwingUtilities.invokeLater(new Runnable() {
60
                                public void run() {
61
                                        if ((externalActions != null) && (lastHistogram != null))
62
                                                externalActions.end(lastHistogram);
63
                                }
64
                        });
65
                        
66
                } catch (HistogramException e) {
67
                        NotificationManager.addError("Error calculando el histograma.", e);
68
                }
69
        }
70
        
71
        /*
72
         * (non-Javadoc)
73
         * @see org.gvsig.raster.RasterProcess#getResult()
74
         */
75
        public Object getResult() {
76
                return lastHistogram;
77
        }
78

    
79
        /*
80
         * (non-Javadoc)
81
         * @see org.gvsig.rastertools.RasterProcess#getLog()
82
         */
83
        public String getLog() {
84
                return PluginServices.getText(this, "calculando_histograma") + "...\n";
85
        }
86

    
87
        /*
88
         * (non-Javadoc)
89
         * @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getPercent()
90
         */
91
        public int getPercent() {
92
                if (iHistogramable != null)
93
                        return iHistogramable.getPercent();
94
                return 0;
95
        }
96

    
97
        /*
98
         * (non-Javadoc)
99
         * @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getTitle()
100
         */
101
        public String getTitle() {
102
                return PluginServices.getText(this, "calculando_histograma");
103
        }
104
}