Statistics
| Revision:

gvsig-geoprocess / org.gvsig.geoprocess / trunk / org.gvsig.geoprocess / org.gvsig.geoprocess.lib / org.gvsig.geoprocess.lib.sextante / src / main / java / org / gvsig / geoprocess / lib / sextante / SextanteGeoProcessLibrary.java @ 237

History | View | Annotate | Download (3.26 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007,2012 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 */
21
package org.gvsig.geoprocess.lib.sextante;
22

    
23
import java.awt.Frame;
24
import java.io.File;
25
import java.util.HashMap;
26

    
27
import es.unex.sextante.core.Sextante;
28
import es.unex.sextante.gui.core.SextanteGUI;
29

    
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.fmap.dal.DALLibrary;
32
import org.gvsig.fmap.dal.coverage.RasterLibrary;
33
import org.gvsig.fmap.mapcontext.MapContextLibrary;
34
import org.gvsig.fmap.mapcontrol.MapControlLibrary;
35
import org.gvsig.geoprocess.lib.api.GeoProcessLibrary;
36
import org.gvsig.geoprocess.lib.api.GeoProcessLocator;
37
import org.gvsig.geoprocess.lib.sextante.core.DefaultInputFactory;
38
import org.gvsig.geoprocess.lib.sextante.core.DefaultOutputFactory;
39
import org.gvsig.geoprocess.lib.sextante.core.DefaultPostProcessTaskFactory;
40
import org.gvsig.raster.fmap.FmapRasterLibrary;
41
import org.gvsig.tools.library.AbstractLibrary;
42
import org.gvsig.tools.library.LibraryException;
43

    
44
/**
45
 * GeoProcess API implementation based on the sextante library.
46
 * 
47
 * @author gvSIG Team
48
 * @version $Id$
49
 */
50
public class SextanteGeoProcessLibrary extends AbstractLibrary {
51

    
52
    @Override
53
    public void doRegistration() {
54
        registerAsImplementationOf(GeoProcessLibrary.class);
55
        require(DALLibrary.class);
56
        require(MapContextLibrary.class);
57
        require(MapControlLibrary.class);
58
        require(FmapRasterLibrary.class);
59
        require(RasterLibrary.class);
60
    }
61

    
62
    @Override
63
    protected void doInitialize() throws LibraryException {
64
        // Nothing to do
65
    }
66

    
67
    @Override
68
    protected void doPostInitialize() throws LibraryException {
69
        Sextante.initialize();
70

    
71
        // Sextante API uses collection implementations :(
72
        HashMap<String, String> map = new HashMap<String, String>();
73
        map.put("isFirstTimeUsingSextante", Boolean.FALSE.toString());
74

    
75
        SextanteGUI.setSextantePath(System.getProperty("user.dir")
76
            + File.separator + "gvSIG" + File.separator + "extensiones"
77
            + File.separator + "org.gvsig.geoprocess.app.mainplugin");
78
        SextanteGUI.initialize();
79
        SextanteGUI.setCustomDefaultSettings(map);
80
        SextanteGUI.setMainFrame(((Frame) PluginServices.getMainFrame()));
81
        SextanteGUI.setOutputFactory(new DefaultOutputFactory());
82
        SextanteGUI.setInputFactory(new DefaultInputFactory());
83
        SextanteGUI.setPostProcessTaskFactory(new DefaultPostProcessTaskFactory());
84

    
85
        GeoProcessLocator
86
            .registerGeoProcessManager(SextanteGeoProcessManager.class);
87
    }
88

    
89
}