Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / histogram / HistogramProcess.java @ 22365

History | View | Annotate | Download (2.95 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 org.gvsig.raster.RasterProcess;
22
import org.gvsig.raster.datastruct.Histogram;
23
import org.gvsig.raster.datastruct.HistogramException;
24
import org.gvsig.raster.hierarchy.IHistogramable;
25

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

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

    
47
        /*
48
         * (non-Javadoc)
49
         * @see org.gvsig.rastertools.RasterProcess#process()
50
         */
51
        public void process() throws InterruptedException {
52
                try {
53
                        // Proceso duro de obtener un histograma. Puede durar bastante tiempo.
54
                        lastHistogram = iHistogramable.getHistogram();
55
                        // Ya tenemos el histograma y lo representamos en la ventana
56
                        if ((externalActions != null) && (lastHistogram != null))
57
                                externalActions.end(lastHistogram);
58
                } catch (HistogramException e) {
59
                        NotificationManager.addError("Error calculando el histograma.", e);
60
                }
61
        }
62
        
63
        /*
64
         * (non-Javadoc)
65
         * @see org.gvsig.raster.RasterProcess#getResult()
66
         */
67
        public Object getResult() {
68
                return lastHistogram;
69
        }
70

    
71
        /*
72
         * (non-Javadoc)
73
         * @see org.gvsig.rastertools.RasterProcess#getLog()
74
         */
75
        public String getLog() {
76
                return PluginServices.getText(this, "calculando_histograma") + "...\n";
77
        }
78

    
79
        /*
80
         * (non-Javadoc)
81
         * @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getPercent()
82
         */
83
        public int getPercent() {
84
                if (iHistogramable != null)
85
                        return iHistogramable.getPercent();
86
                return 0;
87
        }
88

    
89
        /*
90
         * (non-Javadoc)
91
         * @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getTitle()
92
         */
93
        public String getTitle() {
94
                return PluginServices.getText(this, "calculando_histograma");
95
        }
96
}