Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / overviews / OverviewsProcess.java @ 18573

History | View | Annotate | Download (3.66 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.overviews;
20

    
21
import org.apache.log4j.Logger;
22
import org.gvsig.addo.BuildingOverviewsException;
23
import org.gvsig.addo.IOverviewIncrement;
24
import org.gvsig.addo.Jaddo;
25
import org.gvsig.addo.WritingException;
26
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
27
import org.gvsig.raster.Configuration;
28
import org.gvsig.raster.RasterProcess;
29

    
30
import com.iver.andami.PluginServices;
31

    
32
/**
33
 * Proceso para la generaci?n de overviews.
34
 *
35
 * 10/12/2007
36
 * @author Nacho Brodin nachobrodin@gmail.com
37
 */
38
public class OverviewsProcess extends RasterProcess implements IOverviewIncrement {
39
        private FLyrRasterSE       rasterSE            = null;
40
        private int                value = 0;
41
        private int                resamplingAlg       = Jaddo.AVERAGE;
42
        private int[]              overviews           = new int[]{2, 4, 8, 16};
43

    
44
        /*
45
         * (non-Javadoc)
46
         * @see org.gvsig.rastertools.RasterProcess#init()
47
         */
48
        public void init() {
49
                rasterSE = getLayerParam("layer");
50
                
51
                int overviewsRate = 2;
52
                int nOverviews = 4;
53
                overviewsRate = Configuration.getValue("overviews_rate", new Integer(overviewsRate)).intValue();
54
                nOverviews = Configuration.getValue("overviews_number", new Integer(nOverviews)).intValue();
55
                resamplingAlg = Configuration.getValue("overviews_resampling_algorithm", new Integer(resamplingAlg)).intValue();
56

    
57
                //Leemos de la configuraci?n los valores de algoritmo a usar,
58
                //n?mero de overviews a generar y proporci?n de la primera overview
59

    
60
                overviews = new int[nOverviews];
61
                for (int i = 0; i < nOverviews; i++)
62
                        overviews[i] = overviewsRate * (i + 1);
63
        }
64

    
65
        /**
66
         * M?todo donde se ejecutar? el Thread, aqu? se generaran las
67
         * overviews
68
         */
69
        public void process() {
70
                insertLineLog(PluginServices.getText(this, "overviews_generating"));
71

    
72
                Jaddo build = new Jaddo();
73
                build.setIncrementListener(this);
74
                try {
75
                        for (int i = 0; i < rasterSE.getFileCount(); i++) {
76
                                insertLineLog(" Dataset: " + i);
77
                                build.buildOverviews(resamplingAlg, rasterSE.getFileName()[i], overviews);
78
                        }
79
                } catch (BuildingOverviewsException e) {
80
                        Logger.getLogger(this.getClass().getName()).debug("No se han podido generar las overviews", e);
81
                } catch (WritingException e) {
82
                        Logger.getLogger(this.getClass().getName()).debug("No se han podido generar las overviews", e);
83
                }
84
        }
85

    
86
        /*
87
         * (non-Javadoc)
88
         * @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getPercent()
89
         */
90
        public int getPercent() {
91
                return value;
92
        }
93

    
94
        /*
95
         * (non-Javadoc)
96
         * @see org.gvsig.addo.IOverviewIncrement#setPercent(int)
97
         */
98
        public void setPercent(int value) {
99
                this.value = value;
100
        }
101

    
102
        /*
103
         * (non-Javadoc)
104
         * @see org.gvsig.gui.beans.incrementabletask.IIncrementable#getTitle()
105
         */
106
        public String getTitle() {
107
                return PluginServices.getText(this, "incremento_overview");
108
        }
109
}