Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / saveraster / operations / SaveRasterActions.java @ 18824

History | View | Annotate | Download (2.87 KB)

1 16207 nbrodin
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 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.saveraster.operations;
20
21
import java.io.File;
22
23
import javax.swing.JFrame;
24
25 18538 nbrodin
import org.gvsig.raster.IProcessActions;
26 16207 nbrodin
import org.gvsig.raster.util.RasterNotLoadException;
27
import org.gvsig.raster.util.RasterToolsUtil;
28
import org.gvsig.raster.util.RasterUtilities;
29
import org.gvsig.rastertools.saveraster.ui.info.EndInfoPanel;
30
31
import com.iver.andami.PluginServices;
32
/**
33
 * Acciones que ejecuta el proceso de salvado.
34
 *
35
 * @version 26/09/2007
36
 * @author Nacho Brodin (nachobrodin@gmail.com)
37
 */
38
public class SaveRasterActions implements IProcessActions {
39
        /*
40
         * (non-Javadoc)
41
         * @see org.gvsig.rastertools.IProcessActions#end(java.lang.Object)
42
         */
43
        public void end(Object params) {
44
                if(        params instanceof Object[] &&
45
                        ((Object[])params).length == 2 &&
46
                        ((Object[])params)[0] instanceof String &&
47
                        ((Object[])params)[1] instanceof Long) {
48
49
                        String fName = (String)((Object[])params)[0];
50
                        long milis = ((Long)((Object[])params)[1]).longValue();
51
52
                        if(RasterToolsUtil.messageBoxYesOrNot("cargar_toc", this)) {
53
                                try {
54
                                        RasterToolsUtil.loadLayer(null, fName, null);
55
                                } catch (RasterNotLoadException e) {
56
                                        RasterToolsUtil.messageBoxError("error_load_layer", this, e);
57
                                }
58
                        }
59
                        setEndInfo(fName, milis);
60
                }
61
        }
62
63
        /**
64
         * Lanza la ventana de informaci?n cuando acaba el proceso de
65
         * guardado
66
         * @param fName Nombre del archivo
67
         * @param milis Tiempo que ha tardado el proceso en milisegundos
68
         */
69
        private void setEndInfo(String fName, long milis){
70
                String compression;
71
                File f = new File(fName);
72
                if (fName.endsWith("ecw") ||
73
                                fName.endsWith("jp2") ||
74
                                fName.endsWith("jpg") ||
75
                                fName.endsWith("jpeg"))
76
                        compression = "Yes";
77
                else
78
                        compression = "No";
79
80
                EndInfoPanel info = new EndInfoPanel();
81
                info.addFile(fName, RasterUtilities.formatTime(milis), RasterUtilities.formatFileSize(f.length()), compression);
82
83
                JFrame endJFrame = new JFrame(PluginServices.getText(this, "Stats"));
84
                endJFrame.setResizable(false);
85
                endJFrame.setAlwaysOnTop(true);
86
                endJFrame.add(info);
87
        }
88
89
        public void interrupted() {}
90
}