Statistics
| Revision:

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

History | View | Annotate | Download (2.74 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.datastruct.Histogram;
22
import org.gvsig.raster.datastruct.HistogramException;
23
import org.gvsig.raster.hierarchy.IHistogramable;
24
import org.gvsig.rastertools.RasterProcess;
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
        IHistogramable iHistogramable = null;
37

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

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

    
62
        /*
63
         * (non-Javadoc)
64
         * @see org.gvsig.rastertools.RasterProcess#getLog()
65
         */
66
        public String getLog() {
67
                return PluginServices.getText(this, "calculando_histograma") + "...\n";
68
        }
69

    
70
        /*
71
         * (non-Javadoc)
72
         * @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getPercent()
73
         */
74
        public int getPercent() {
75
                if (iHistogramable != null)
76
                        return iHistogramable.getPercent();
77
                return 0;
78
        }
79

    
80
        /*
81
         * (non-Javadoc)
82
         * @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getTitle()
83
         */
84
        public String getTitle() {
85
                return PluginServices.getText(this, "calculando_histograma");
86
        }
87
}