Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / reproject / ReprojectProcess.java @ 21698

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

    
21
import javax.swing.SwingUtilities;
22

    
23
import org.cresques.cts.IProjection;
24
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
25
import org.gvsig.raster.RasterProcess;
26
import org.gvsig.raster.util.RasterToolsUtil;
27

    
28
import com.iver.andami.PluginServices;
29
/**
30
 * Proceso para la generaci?n de capas reproyectadas.
31
 *
32
 * 10/12/2007
33
 * @author Nacho Brodin nachobrodin@gmail.com
34
 */
35
public class ReprojectProcess extends RasterProcess {
36
        private FLyrRasterSE lyr       = null;
37
        private String       filename  = null;
38
        private IProjection  proj      = null;
39
        private IProjection  projsrc   = null;
40
        private Reproject    reproject = null;
41
        private long         milis     = 0;
42
        
43
        /*
44
         * (non-Javadoc)
45
         * @see org.gvsig.rastertools.RasterProcess#init()
46
         */
47
        public void init() {
48
                lyr = getLayerParam("layer");
49
                filename = getStringParam("path");
50
                proj = (IProjection)getParam("projection");
51
                projsrc = (IProjection)getParam("srcprojection");
52
        }
53

    
54
        /**
55
         * M?todo donde se ejecutar? el Thread, aqu? se reproyecta el raster.
56
         */
57
        public void process() throws InterruptedException {
58
                long t1 = new java.util.Date().getTime();
59
                insertLineLog(PluginServices.getText(this, "reprojecting"));
60
                reproject = new Reproject(lyr, filename);
61
                try {
62
                        reproject.warp(proj, projsrc);
63

    
64
                        long t2 = new java.util.Date().getTime();
65
                        milis = t2 - t1;
66
                        
67
                        SwingUtilities.invokeLater(new Runnable() {
68
                                public void run() {
69
                                        if (externalActions != null) {
70
                                                externalActions.end(new Object[]{filename, new Long(milis)});
71
                                        }
72
                                }
73
                        });
74
                } catch (ReprojectException e) {
75
                        if (incrementableTask != null)
76
                                incrementableTask.processFinalize();
77
                        RasterToolsUtil.messageBoxError("error_reprojecting", this, e);
78
                }
79
        }
80

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

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