Revision 20999

View differences:

org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
	<modelVersion>4.0.0</modelVersion>
4
	<artifactId>org.gvsig.raster.reproject.algorithm</artifactId>
5
	<packaging>jar</packaging>
6
	<name>org.gvsig.raster.reproject.algorithm</name>
7
	
8
	<parent>
9
		<groupId>org.gvsig</groupId>
10
		<artifactId>org.gvsig.raster.reproject</artifactId>
11
		<version>2.2.225</version>
12
	</parent>
13
	
14
    <dependencies>
15
		<dependency>
16
			<groupId>org.gvsig</groupId>
17
			<artifactId>org.gvsig.raster.algorithm</artifactId>
18
            <scope>compile</scope>
19
		</dependency>
20
        <dependency>
21
            <groupId>org.gvsig</groupId>
22
            <artifactId>org.gvsig.i18n</artifactId>
23
            <scope>compile</scope>
24
        </dependency>
25
		 <dependency>
26
            <groupId>org.gvsig</groupId>
27
            <artifactId>org.gvsig.ui</artifactId>
28
            <scope>compile</scope>
29
        </dependency>
30
        <dependency>
31
			<groupId>org.gvsig</groupId>
32
			<artifactId>org.gvsig.raster.swing.api</artifactId>
33
			 <scope>compile</scope>
34
		</dependency>
35
	    <dependency>
36
	        <groupId>org.gvsig</groupId>
37
	        <artifactId>org.gvsig.raster.swing.impl</artifactId>
38
	         <scope>runtime</scope>
39
	    </dependency>
40
	    <dependency>
41
            <groupId>org.gvsig</groupId>
42
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
43
            <scope>compile</scope>
44
        </dependency>
45
        <dependency>
46
            <groupId>org.gvsig</groupId>
47
            <artifactId>org.gvsig.tools.lib</artifactId>
48
            <scope>compile</scope>
49
        </dependency>
50
        
51
        <dependency>
52
            <groupId>org.gvsig</groupId>
53
            <artifactId>org.gvsig.projection.api</artifactId>
54
            <scope>compile</scope>
55
        </dependency>
56
        <dependency>
57
            <groupId>org.gvsig</groupId>
58
            <artifactId>org.gvsig.projection.cresques.ui</artifactId>
59
            <scope>compile</scope>
60
        </dependency>
61
        <dependency>
62
            <groupId>org.gvsig</groupId>
63
            <artifactId>org.gvsig.projection.cresques.impl</artifactId>
64
            <scope>runtime</scope>
65
        </dependency>
66
        <dependency>
67
            <groupId>org.gvsig</groupId>
68
            <artifactId>org.gvsig.fmap.dal.api</artifactId>
69
            <scope>compile</scope>
70
        </dependency>
71
        <dependency>
72
            <groupId>org.gvsig</groupId>
73
            <artifactId>org.gvsig.fmap.dal.impl</artifactId>
74
            <scope>compile</scope>
75
        </dependency>
76
	</dependencies>
77
</project>
0 78

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/resources/org/gvsig/raster/reproject/algorithm/i18n/text.properties
1
reprojection
2
origen=Origen
3
dest_proj=CRS de destino
4
src_proj=CRS de origen
5
interpolation=Interpolaci?n
6
yes=Si
7
no=No
8
sizex=Ancho
9
sizey=Alto
10
cellsize=Tama?o de celda
11
output_options=Opciones
12
value=Valor
13
layer=Capa
0 14

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/resources/org/gvsig/raster/reproject/algorithm/i18n/text_en.properties
1
origen=Source
2
dest_proj=CRS of destination
3
src_proj=CRS source
4
interpolation=Interpolation
5
yes=Yes
6
no=No
7
sizex=Width
8
sizey=Height
9
cellsize=Cell size
10
output_options=Options
11
value=Value
12
layer=Layer
0 13

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.raster.reproject.algorithm.RasterReprojectionAlgorithmLibrary
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/RasterReprojectionAlgorithmLibrary.java
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.raster.reproject.algorithm;
25

  
26
import org.gvsig.i18n.Messages;
27
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary;
28
import org.gvsig.raster.reproject.algorithm.swing.api.RasterReprojectionSwingManager;
29
import org.gvsig.raster.reproject.algorithm.swing.impl.DefaultRasterReprojectionSwingManager;
30
import org.gvsig.tools.library.AbstractLibrary;
31
import org.gvsig.tools.library.LibraryException;
32
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
33

  
34
/**
35
 * Initialization of RasterReprojectAlgorithmLibrary library.
36
 * 
37
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
38
 */
39
public class RasterReprojectionAlgorithmLibrary extends AbstractLibrary {
40
	public static final String         PROCESS_LABEL   = "RasterReprojectionProcess";
41
	
42
    @Override
43
    protected void doInitialize() throws LibraryException {
44
        // Nothing to do
45
    }
46

  
47
    @Override
48
    protected void doPostInitialize() throws LibraryException {
49
    	//Registers the process and its parameters
50
    	RasterBaseAlgorithmLibrary.register(PROCESS_LABEL, ReprojectProcess.class);
51
    	ReprojectProcess.registerParameters();
52
    	
53
        Messages.addResourceFamily(
54
            "org.gvsig.raster.reproject.algorithm.i18n.text", 
55
            RasterReprojectionAlgorithmLibrary.class.getClassLoader(), 
56
            RasterReprojectionAlgorithmLibrary.class.getClass().getName());
57
        
58
        RasterReprojectionSwingLocator.registerSwingManager(
59
        		DefaultRasterReprojectionSwingManager.class);
60
        
61
        RasterReprojectionSwingManager manager =
62
        	RasterReprojectionSwingLocator.getSwingManager();
63
        if (manager == null) {
64
            throw new ReferenceNotRegisteredException(
65
            		RasterReprojectionSwingLocator.SWING_MANAGER_NAME,
66
            		RasterReprojectionSwingLocator.getInstance());
67
        }
68
    }
69
}
0 70

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/RasterReprojectionSwingLocator.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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
 */
22
package org.gvsig.raster.reproject.algorithm;
23

  
24
import org.gvsig.raster.reproject.algorithm.swing.api.RasterReprojectionSwingManager;
25
import org.gvsig.tools.locator.BaseLocator;
26

  
27
/**
28
 * This locator is the entry point for the Validation swing library,
29
 * providing access to all Validation swing services through the
30
 * {@link RasterReprojectionSwingManager} .
31
 * 
32
 * @author gvSIG team
33
 * @version $Id$
34
 */
35
public class RasterReprojectionSwingLocator extends BaseLocator {
36

  
37
    /**
38
     * Validation swing manager name.
39
     */
40
    public static final String SWING_MANAGER_NAME =
41
        "RasterReproject.swing.manager";
42

  
43
    /**
44
     * Validation swing manager description.
45
     */
46
    public static final String SWING_MANAGER_DESCRIPTION =
47
        "RasterReproject UIManager";
48

  
49
    private static final String LOCATOR_NAME = "RasterReproject.swing.locator";
50

  
51
    /**
52
     * Unique instance.
53
     */
54
    private static final RasterReprojectionSwingLocator INSTANCE =
55
        new RasterReprojectionSwingLocator();
56

  
57
    /**
58
     * Return the singleton instance.
59
     * 
60
     * @return the singleton instance
61
     */
62
    public static RasterReprojectionSwingLocator getInstance() {
63
        return INSTANCE;
64
    }
65

  
66
    /**
67
     * Return the Locator's name
68
     * 
69
     * @return a String with the Locator's name
70
     */
71
    public final String getLocatorName() {
72
        return LOCATOR_NAME;
73
    }
74

  
75
    /**
76
     * Registers the Class implementing the PersistenceManager interface.
77
     * 
78
     * @param clazz
79
     *            implementing the PersistenceManager interface
80
     */
81
    public static void registerSwingManager(
82
        Class<? extends RasterReprojectionSwingManager> clazz) {
83
        getInstance().register(SWING_MANAGER_NAME, SWING_MANAGER_DESCRIPTION,
84
            clazz);
85
    }
86

  
87
    /**
88
     * Gets the instance of the {@link RasterReprojectUIManager} registered.
89
     * 
90
     * @return {@link RasterReprojectUIManager}
91
     */
92
    public static RasterReprojectionSwingManager getSwingManager() {
93
        return (RasterReprojectionSwingManager) getInstance()
94
            .get(SWING_MANAGER_NAME);
95
    }
96

  
97
}
0 98

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/api/ReprojectionPanelDataModel.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.algorithm.swing.api;
23

  
24
import java.util.List;
25

  
26
import org.cresques.cts.IProjection;
27

  
28
/**
29
 * Data model for the reprojection panel
30
 * @author Nacho Brodin (nachobrodin@gmail.com)
31
 */
32
public interface ReprojectionPanelDataModel {
33
	public IProjection getSrcProjection();
34
	
35
	public IProjection getDstProjection();
36
	
37
	public void setSrcProjection(IProjection src);
38
	
39
	public void setDstProjection(IProjection dst);
40
	
41
	public double getCellSize();
42
	
43
	public void setCellSize(double cellSize);
44
	
45
	public void setSize(int w, int h);
46
	
47
	public int[] getSize();
48
	
49
	public List<String> getInterpolationMethodList();
50
	
51
	public void setInterpolationMethodList(List<String> list);
52
	
53
	public int getInterpolationMethodSelected();
54
	
55
	public void setInterpolationMethodSelected(int method);
56
	
57
	public String getLayerName();
58
	
59
	public void setLayerName(String layerName);
60
}
0 61

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/api/RasterReprojectionPanel.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.algorithm.swing.api;
23

  
24
import java.awt.event.ActionListener;
25

  
26
import javax.swing.JComponent;
27

  
28
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
29

  
30
/**
31
 * Panel to reproject raster layers.
32
 * 
33
 * @author Nacho Brodin (nachobrodin@gmail.com)
34
 */
35
public interface RasterReprojectionPanel {
36
	public static final int           BUTTON_ACCEPT   = ButtonsPanel.BUTTON_ACCEPT;
37
	public static final int           BUTTON_CANCEL   = ButtonsPanel.BUTTON_CANCEL;
38
	
39
	/**
40
	 * Adds listener to buttons
41
	 * @param listener
42
	 */
43
	public void addButtonsListener(ActionListener listener);
44
	
45
	/**
46
	 * Returns the ID of the object selected. The IDs are defined as constants
47
	 * in this interface
48
	 * @param obj
49
	 * @return
50
	 */
51
	public int getObjectSelected(Object obj);
52
	
53
	public String getFileSelected();
54
	
55
	public String getDirectorySelected();
56
	
57
	public JComponent getComponent();
58
}
0 59

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/api/RasterReprojectionSwingManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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
 */
22
package org.gvsig.raster.reproject.algorithm.swing.api;
23

  
24

  
25

  
26
/**
27
 * This class is responsible of the management of the library's swing user
28
 * interface. It is the swing library's main entry point, and provides all the
29
 * services to manage library swing components.
30
 * 
31
 * @see JValidationServicePanel
32
 * @author gvSIG team
33
 * @version $Id$
34
 */
35
public interface RasterReprojectionSwingManager {
36
	/**
37
	 * Creates a new panel to reproject a raster layer
38
	 * @param fileNameManagement
39
	 * @param dataModel
40
	 * @return
41
	 */
42
	public RasterReprojectionPanel createRasterReprojectPanel(
43
			ReprojectionPanelDataModel dataModel);
44
}
0 45

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/impl/RasterReprojectionPanelImpl.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.algorithm.swing.impl;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27
import java.awt.Insets;
28
import java.awt.event.ActionEvent;
29
import java.awt.event.ActionListener;
30
import java.awt.event.KeyEvent;
31
import java.awt.event.KeyListener;
32
import java.util.List;
33

  
34
import javax.swing.BorderFactory;
35
import javax.swing.JComponent;
36
import javax.swing.JLabel;
37
import javax.swing.JPanel;
38

  
39
import org.gvsig.app.gui.panels.CRSSelectPanel;
40
import org.gvsig.app.gui.panels.CRSSelectPanelFactory;
41
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
42
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
43
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
44
import org.gvsig.i18n.Messages;
45
import org.gvsig.raster.reproject.algorithm.swing.api.RasterReprojectionPanel;
46
import org.gvsig.raster.reproject.algorithm.swing.api.ReprojectionPanelDataModel;
47
import org.gvsig.raster.swing.RasterSwingLocator;
48
import org.gvsig.raster.swing.newlayer.CreateNewLayerPanel;
49

  
50
/**
51
 * Panel para la reproyecci๏ฟฝn de capas cargadas.
52
 * 
53
 * @author Nacho Brodin (nachobrodin@gmail.com)
54
 */
55
public class RasterReprojectionPanelImpl extends DefaultButtonsPanel implements ActionListener, RasterReprojectionPanel, KeyListener {
56
	private static final long          serialVersionUID      = -1011688195806336071L;
57
	private CRSSelectPanel             projectionSrcSelector = null;
58
	private CRSSelectPanel             projectionDstSelector = null;
59
	private InterpolationPanel         interpolationPanel    = null;
60
	private OutputLayerOptionsPanel    layerOptions          = null;
61
	private CreateNewLayerPanel        newLayerPanel         = null;
62
	private ReprojectionPanelDataModel dataModel             = null;
63
	private JLabel                     layerName             = null;
64

  
65
	/**
66
	 * Constructor
67
	 * @throws RasterDriverException 
68
	 */
69
	public RasterReprojectionPanelImpl(
70
			ReprojectionPanelDataModel dataModel) {
71
		super(ButtonsPanel.BUTTONS_ACCEPTCANCEL);
72
		this.dataModel = dataModel;
73
		init();
74
		loadPanelFromDataModel();
75
		getInterpolationPanel().getComboInterpolationMethod().addActionListener(this);
76
		getInterpolationPanel().getRadioYes().addActionListener(this);
77
		getInterpolationPanel().getRadioNo().addActionListener(this);
78
	}
79
	
80
	private void loadPanelFromDataModel() {
81
		getLayerOptionsPanel().getTextFieldCellSize().setText(dataModel.getCellSize() + "");
82
		getLayerOptionsPanel().getTextFieldSizeX().setText(dataModel.getSize()[0] + "");
83
		getLayerOptionsPanel().getTextFieldSizeY().setText(dataModel.getSize()[1] + "");
84
		getLayerName().setText("<html><b>" + dataModel.getLayerName() + "</b></html>");
85
		List<String> list = dataModel.getInterpolationMethodList();
86
		for (int i = 0; i < list.size(); i++) {
87
			getInterpolationPanel().getComboInterpolationMethod().addItem(list.get(i));	
88
		}
89
		
90
		if(dataModel.getInterpolationMethodSelected() < 0) {
91
			getInterpolationPanel().getRadioYes().setSelected(false);
92
			getInterpolationPanel().getRadioNo().setSelected(true);
93
		} else {
94
			getInterpolationPanel().getRadioYes().setSelected(true);
95
			getInterpolationPanel().getRadioNo().setSelected(false);
96
			getInterpolationPanel().getComboInterpolationMethod().setEnabled(true);
97
		}
98
	}
99
	
100
	/**
101
	 * Inicializaci๏ฟฝn de los componentes gr๏ฟฝficos.
102
	 * @throws RasterDriverException 
103
	 */
104
	private void init() {
105
		GridBagConstraints gridBagConstraints;
106

  
107
		setLayout(new GridBagLayout());
108
		
109
		int posy = 0;
110
		
111
		gridBagConstraints = new GridBagConstraints();
112
		gridBagConstraints.fill = GridBagConstraints.BOTH;
113
		gridBagConstraints.gridx = 0;
114
		gridBagConstraints.gridy = posy;
115
		gridBagConstraints.weightx = 1.0;
116
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
117
		JPanel panelFile = new JPanel();
118
		panelFile.setLayout(new BorderLayout());
119
		panelFile.setBorder(BorderFactory.createTitledBorder(Messages.getText("origen")));
120
		panelFile.add(getLayerName(), BorderLayout.CENTER);
121
		add(panelFile, gridBagConstraints);
122
		
123
		posy++;
124
		gridBagConstraints = new GridBagConstraints();
125
		gridBagConstraints.fill = GridBagConstraints.BOTH;
126
		gridBagConstraints.gridx = 0;
127
		gridBagConstraints.gridy = posy;
128
		gridBagConstraints.weightx = 1.0;
129
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
130
		add(getProjectionSrcSelector(), gridBagConstraints);
131

  
132
		posy++;
133
		gridBagConstraints = new GridBagConstraints();
134
		gridBagConstraints.fill = GridBagConstraints.BOTH;
135
		gridBagConstraints.gridx = 0;
136
		gridBagConstraints.gridy = posy;
137
		gridBagConstraints.weightx = 1.0;
138
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
139
		add(getProjectionDstSelector(), gridBagConstraints);
140
		
141
		posy++;
142
		gridBagConstraints = new GridBagConstraints();
143
		gridBagConstraints.fill = GridBagConstraints.BOTH;
144
		gridBagConstraints.gridx = 0;
145
		gridBagConstraints.gridy = posy;
146
		gridBagConstraints.weightx = 1.0;
147
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
148
		add(getInterpolationPanel(), gridBagConstraints);
149
		
150
		posy++;
151
		gridBagConstraints = new GridBagConstraints();
152
		gridBagConstraints.fill = GridBagConstraints.BOTH;
153
		gridBagConstraints.gridx = 0;
154
		gridBagConstraints.gridy = posy;
155
		gridBagConstraints.weightx = 1.0;
156
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
157
		add(getLayerOptionsPanel(), gridBagConstraints);
158
		
159
		posy++;
160
		gridBagConstraints = new GridBagConstraints();
161
		gridBagConstraints.fill = GridBagConstraints.BOTH;
162
		gridBagConstraints.gridx = 0;
163
		gridBagConstraints.gridy = posy;
164
		gridBagConstraints.weightx = 1.0;
165
		gridBagConstraints.insets = new Insets(2, 2, 2, 2);
166
		add((JComponent)getCreateNewLayerPanel(), gridBagConstraints);
167

  
168
		// Insertamos un panel vacio
169
		posy++;
170
		gridBagConstraints = new GridBagConstraints();
171
		gridBagConstraints.gridx = 0;
172
		gridBagConstraints.gridy = posy;
173
		gridBagConstraints.weighty = 1.0;
174
		gridBagConstraints.insets = new Insets(0, 0, 0, 0);
175
		JPanel emptyPanel = new JPanel();
176
		add(emptyPanel, gridBagConstraints);
177
	}
178
	
179
	private JLabel getLayerName() {
180
		if(layerName == null)
181
			layerName = new JLabel();
182
		return layerName;
183
	}
184
	
185
	public CreateNewLayerPanel getCreateNewLayerPanel() {
186
		if(newLayerPanel == null) {
187
			newLayerPanel = RasterSwingLocator.getSwingManager().createNewLayerPanel();
188
			//newLayerPanel = new CreateNewLayerPanelImpl(fileNameManagement);
189
		}
190
		return newLayerPanel;
191
	}
192
	
193
	public InterpolationPanel getInterpolationPanel() {
194
		if(interpolationPanel == null) {
195
			interpolationPanel = new InterpolationPanel();
196
		}
197
		return interpolationPanel;
198
	}
199
	
200
	public OutputLayerOptionsPanel getLayerOptionsPanel() {
201
		if(layerOptions == null) {
202
			layerOptions = new OutputLayerOptionsPanel();
203
			layerOptions.getTextFieldCellSize().addKeyListener(this);
204
		}
205
		return layerOptions;
206
	}
207

  
208
	/**
209
	 * Obtiene el bot๏ฟฝn que lanza el panel de selecci๏ฟฝn de proyecciones.
210
	 * @return
211
	 * @throws RasterDriverException 
212
	 */
213
	private CRSSelectPanel getProjectionSrcSelector() {
214
		if (projectionSrcSelector == null) {
215
			projectionSrcSelector = CRSSelectPanelFactory.getPanel(dataModel.getSrcProjection());
216
			projectionSrcSelector.setTransPanelActive(true);
217
			projectionSrcSelector.setPreferredSize(null);
218
			projectionSrcSelector.addActionListener(new ActionListener() {
219
				public void actionPerformed(ActionEvent e) {
220
					if (projectionSrcSelector.isOkPressed()) {
221
						dataModel.setSrcProjection(projectionSrcSelector.getCurProj());
222
						try {
223
							updateSize();
224
							getLayerOptionsPanel().getTextFieldCellSize().setText(dataModel.getCellSize() + "");
225
						} catch (Exception exc) {
226
						}
227
					}
228
				}
229
			});
230
			projectionSrcSelector.setBorder(BorderFactory.createTitledBorder(Messages.getText("src_proj")));
231
		}
232
		return projectionSrcSelector;
233
	}
234
	
235
	/**
236
	 * Obtiene el bot๏ฟฝn que lanza el panel de selecci๏ฟฝn de proyecciones.
237
	 * @return
238
	 */
239
	private CRSSelectPanel getProjectionDstSelector() {
240
		if (projectionDstSelector == null) {
241
			projectionDstSelector = CRSSelectPanel.getPanel(dataModel.getDstProjection());
242
			projectionDstSelector.setTransPanelActive(true);
243
			projectionDstSelector.setPreferredSize(null);
244
			projectionDstSelector.addActionListener(new ActionListener() {
245
				public void actionPerformed(ActionEvent e) {
246
					if (projectionDstSelector.isOkPressed()) {
247
						dataModel.setDstProjection(projectionDstSelector.getCurProj());
248
						try {
249
							updateSize();
250
							getLayerOptionsPanel().getTextFieldCellSize().setText(dataModel.getCellSize() + "");
251
						} catch (Exception exc) {
252
						}
253
					}
254
				}
255
			});
256
			projectionDstSelector.setBorder(BorderFactory.createTitledBorder(Messages.getText("dest_proj")));
257
		}
258
		return projectionDstSelector;
259
	}
260

  
261
	public void keyPressed(KeyEvent e) {
262
		
263
	}
264

  
265
	public void keyReleased(KeyEvent e) {
266
		try {
267
			Double d = new Double(getLayerOptionsPanel().getTextFieldCellSize().getText());
268
			dataModel.setCellSize(d.doubleValue());
269
			updateSize();
270
		} catch (Exception exc) {
271
		}
272
	}
273

  
274
	private void updateSize() {
275
		getLayerOptionsPanel().getTextFieldSizeX().setText(dataModel.getSize()[0] + "");
276
		getLayerOptionsPanel().getTextFieldSizeY().setText(dataModel.getSize()[1] + "");
277
	}
278
	
279
	public void keyTyped(KeyEvent e) {
280
		
281
	}
282

  
283
	public void addButtonsListener(ActionListener listener) {
284
		getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(listener);
285
		getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(listener);
286
	}
287
	
288
	public int getObjectSelected(Object obj) {
289
		if(obj == getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT))
290
			return BUTTON_ACCEPT;
291
		if(obj == getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL))
292
			return BUTTON_CANCEL;
293
		return -1;
294
	}
295
	
296
	public JComponent getComponent() {
297
		return this;
298
	}
299

  
300
	public String getFileSelected() {
301
		return getCreateNewLayerPanel().getFileSelected();
302
	}
303
	
304
	public String getDirectorySelected() {
305
		return getCreateNewLayerPanel().getDirectorySelected();
306
	}
307

  
308
	public void actionPerformed(ActionEvent e) {
309
		if(e.getSource() == getInterpolationPanel().getComboInterpolationMethod()) {
310
			dataModel.setInterpolationMethodSelected(getInterpolationPanel().getComboInterpolationMethod().getSelectedIndex());
311
		}
312
		
313
		if(e.getSource() == getInterpolationPanel().getRadioYes()) {
314
			dataModel.setInterpolationMethodSelected(getInterpolationPanel().getComboInterpolationMethod().getSelectedIndex());
315
		}
316
		
317
		if(e.getSource() == getInterpolationPanel().getRadioNo()) {
318
			dataModel.setInterpolationMethodSelected(-1);
319
		}
320
	}
321
}
0 322

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/impl/InterpolationPanel.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.algorithm.swing.impl;
23

  
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.awt.Insets;
27
import java.awt.event.ActionEvent;
28
import java.awt.event.ActionListener;
29

  
30
import javax.swing.BorderFactory;
31
import javax.swing.ButtonGroup;
32
import javax.swing.JComboBox;
33
import javax.swing.JPanel;
34
import javax.swing.JRadioButton;
35

  
36
import org.cresques.Messages;
37
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
38

  
39
/**
40
 * Panel para la reproyecci?n de capas cargadas.
41
 * 
42
 * @author Nacho Brodin (nachobrodin@gmail.com)
43
 */
44
public class InterpolationPanel extends JPanel implements ActionListener {
45
	private static final long      serialVersionUID      = 1;
46
	private ButtonGroup            group                 = null;
47
	private JRadioButton           radioNo               = null;
48
	private JRadioButton           radioYes              = null;
49
	private JComboBox              comboInterpMethods    = null;
50
	
51
	/**
52
	 * Constructor
53
	 * @throws RasterDriverException 
54
	 */
55
	public InterpolationPanel() {
56
		init();
57
	}
58
	
59
	/**
60
	 * Inicializaci?n de los componentes gr?ficos.
61
	 * @throws RasterDriverException 
62
	 */
63
	private void init() {
64
		group = new ButtonGroup();
65
		group.add(getRadioYes());
66
		group.add(getRadioNo());
67
		
68
		setBorder(BorderFactory.createTitledBorder(Messages.getText("interpolation")));
69
		
70
		GridBagConstraints gridBagConstraints;
71
		setLayout(new GridBagLayout());
72
		gridBagConstraints = new GridBagConstraints();
73
		gridBagConstraints.fill = GridBagConstraints.BOTH;
74
		gridBagConstraints.gridx = 0;
75
		gridBagConstraints.gridy = 0;
76
		gridBagConstraints.weightx = 1.0;
77
		gridBagConstraints.insets = new Insets(0, 5, 0, 5);
78
		
79
		add(getRadioNo(), gridBagConstraints);
80
		
81
		gridBagConstraints.gridy = 1;
82
		add(getRadioYes(), gridBagConstraints);
83
		
84
		gridBagConstraints.gridy = 2;
85
		gridBagConstraints.insets = new Insets(0, 25, 0, 5);
86
		add(getComboInterpolationMethod(), gridBagConstraints);
87
	}
88

  
89
	public JRadioButton getRadioYes() {
90
		if(radioYes == null) {
91
			radioYes = new JRadioButton(Messages.getText("yes"));
92
			radioYes.setSelected(false);
93
			radioYes.addActionListener(this);
94
		}
95
		return radioYes;
96
	}
97
	
98
	public JRadioButton getRadioNo() {
99
		if(radioNo == null) {
100
			radioNo = new JRadioButton(Messages.getText("no"));
101
			radioNo.setSelected(true);
102
			radioNo.addActionListener(this);
103
		}
104
		return radioNo;
105
	}
106
	
107
	public JComboBox getComboInterpolationMethod() {
108
		if(comboInterpMethods == null) {
109
			comboInterpMethods = new JComboBox();
110
			comboInterpMethods.setEnabled(false);
111
		}
112
		return comboInterpMethods;
113
	}
114

  
115
	public void actionPerformed(ActionEvent e) {
116
		if(e.getSource() == getRadioNo()) {
117
			getComboInterpolationMethod().setEnabled(false);
118
		}
119
		if(e.getSource() == getRadioYes()) {
120
			getComboInterpolationMethod().setEnabled(true);
121
		}
122
	}
123

  
124
}
0 125

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/impl/OutputLayerOptionsPanel.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.algorithm.swing.impl;
23

  
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.awt.Insets;
27

  
28
import javax.swing.BorderFactory;
29
import javax.swing.JLabel;
30
import javax.swing.JPanel;
31
import javax.swing.JTextField;
32

  
33
import org.cresques.Messages;
34
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
35

  
36
/**
37
 * Panel para la reproyecci?n de capas cargadas.
38
 * 
39
 * @author Nacho Brodin (nachobrodin@gmail.com)
40
 */
41
public class OutputLayerOptionsPanel extends JPanel {
42
	private static final long      serialVersionUID     = 1;
43
	private JTextField             textFieldCellSize    = null;
44
	private JTextField             textFieldSizeX       = null;
45
	private JTextField             textFieldSizeY       = null;
46
	private JLabel                 labelSizeX           = null;
47
	private JLabel                 labelSizeY           = null;
48
	private JLabel                 labelCellSize        = null;
49
	
50
	/**
51
	 * Constructor
52
	 * @throws RasterDriverException 
53
	 */
54
	public OutputLayerOptionsPanel() {
55
		init();
56
	}
57
	
58
	/**
59
	 * Inicializaci?n de los componentes gr?ficos.
60
	 * @throws RasterDriverException 
61
	 */
62
	private void init() {
63
		setBorder(BorderFactory.createTitledBorder(Messages.getText("output_options")));
64
		
65
		GridBagConstraints gridBagConstraints;
66
		setLayout(new GridBagLayout());
67
		gridBagConstraints = new GridBagConstraints();
68
		gridBagConstraints.fill = GridBagConstraints.BOTH;
69
		gridBagConstraints.weightx = 1.0;
70
		gridBagConstraints.insets = new Insets(0, 5, 2, 5);
71
		
72
		//FILA 0
73
		gridBagConstraints.fill = GridBagConstraints.NONE;
74
		gridBagConstraints.weightx = 0;
75
		gridBagConstraints.gridx = 0;
76
		gridBagConstraints.gridy = 0;
77
		add(getLabelCellSize(), gridBagConstraints);
78
		
79
		gridBagConstraints.fill = GridBagConstraints.BOTH;
80
		gridBagConstraints.weightx = 1.0;
81
		gridBagConstraints.gridx = 1;
82
		gridBagConstraints.gridy = 0;
83
		gridBagConstraints.gridwidth = 3;
84
		add(getTextFieldCellSize(), gridBagConstraints);
85
		gridBagConstraints.gridwidth = 1;
86
		
87
		//FILA 1
88
		gridBagConstraints.fill = GridBagConstraints.NONE;
89
		gridBagConstraints.weightx = 0;
90
		gridBagConstraints.gridx = 0;
91
		gridBagConstraints.gridy = 1;
92
		add(getLabelSizeX(), gridBagConstraints);
93
		
94
		gridBagConstraints.fill = GridBagConstraints.BOTH;
95
		gridBagConstraints.weightx = 1.0;
96
		gridBagConstraints.gridx = 1;
97
		gridBagConstraints.gridy = 1;
98
		add(getTextFieldSizeX(), gridBagConstraints);
99
		
100
		gridBagConstraints.fill = GridBagConstraints.NONE;
101
		gridBagConstraints.weightx = 0;
102
		gridBagConstraints.gridx = 2;
103
		gridBagConstraints.gridy = 1;
104
		add(getLabelSizeY(), gridBagConstraints);
105
		
106
		gridBagConstraints.fill = GridBagConstraints.BOTH;
107
		gridBagConstraints.weightx = 1.0;
108
		gridBagConstraints.gridx = 3;
109
		gridBagConstraints.gridy = 1;
110
		add(getTextFieldSizeY(), gridBagConstraints);
111
	}
112
	
113
	public JTextField getTextFieldCellSize() {
114
		if(textFieldCellSize == null)
115
			textFieldCellSize = new JTextField();
116
		return textFieldCellSize;
117
	}
118

  
119
	public JTextField getTextFieldSizeX() {
120
		if(textFieldSizeX == null) {
121
			textFieldSizeX = new JTextField();
122
			textFieldSizeX.setEditable(false);
123
		}
124
		return textFieldSizeX;
125
	}
126

  
127
	public JTextField getTextFieldSizeY() {
128
		if(textFieldSizeY == null) {
129
			textFieldSizeY = new JTextField();
130
			textFieldSizeY.setEditable(false);
131
		}
132
		return textFieldSizeY;
133
	}
134

  
135
	public JLabel getLabelSizeX() {
136
		if(labelSizeX == null)
137
			labelSizeX = new JLabel(Messages.getText("sizex"));
138
		return labelSizeX;
139
	}
140

  
141
	public JLabel getLabelSizeY() {
142
		if(labelSizeY == null)
143
			labelSizeY = new JLabel(Messages.getText("sizey"));
144
		return labelSizeY;
145
	}
146

  
147
	public JLabel getLabelCellSize() {
148
		if(labelCellSize == null)
149
			labelCellSize = new JLabel(Messages.getText("cellsize"));
150
		return labelCellSize;
151
	}
152

  
153
}
0 154

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/swing/impl/DefaultRasterReprojectionSwingManager.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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
 */
22
package org.gvsig.raster.reproject.algorithm.swing.impl;
23

  
24
import org.gvsig.raster.reproject.algorithm.swing.api.RasterReprojectionPanel;
25
import org.gvsig.raster.reproject.algorithm.swing.api.RasterReprojectionSwingManager;
26
import org.gvsig.raster.reproject.algorithm.swing.api.ReprojectionPanelDataModel;
27

  
28
/**
29
 * Default implementation of the {@link RasterReprojectionSwingManager}.
30
 * 
31
 * @author gvSIG Team
32
 * @version $Id$
33
 */
34
public class DefaultRasterReprojectionSwingManager implements RasterReprojectionSwingManager {
35

  
36
	public RasterReprojectionPanel createRasterReprojectPanel(ReprojectionPanelDataModel dataModel) {
37
		return new RasterReprojectionPanelImpl(dataModel);
38
	}
39

  
40
}
0 41

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/ReprojectException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.algorithm;
23

  
24

  
25
/**
26
 * This exception is thrown if happen problems processing data with this algorithm.
27
 * 
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 *
30
 */
31
public class ReprojectException extends Exception {
32
	private static final long serialVersionUID = -3022090543908771484L;
33
	
34
	public ReprojectException(String msg){
35
		super(msg);
36
	}
37
	
38
	public ReprojectException(String msg, Throwable e){
39
		super(msg, e);
40
	}
41
}
0 42

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/ReprojectProcess.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.algorithm;
23

  
24
import org.cresques.cts.IProjection;
25
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
26
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
27
import org.gvsig.i18n.Messages;
28
import org.gvsig.raster.algorithm.process.DataProcess;
29

  
30
/**
31
 * Process to reproject layers. The size of the new image and the pixel size can
32
 * be passed by parameter. If some of these values are zero everyone are calculated
33
 * automatically
34
 *
35
 * 10/12/2007
36
 * @author Nacho Brodin nachobrodin@gmail.com
37
 */
38
public class ReprojectProcess extends DataProcess {
39
	public static String[]    INTERP_METHODS  = new String[]{"Nearest", "Bilinear", "InverseDistance"};
40
	
41
	public static String      RASTER_STORE    = "RasterStore";
42
	public static String      PATH            = "Path";
43
	public static String      DST_PROJECTION  = "DST_Projection";
44
	public static String      SRC_PROJECTION  = "SRC_Projection";
45
	public static String      SIZEX           = "SizeX";
46
	public static String      SIZEY           = "SizeY";
47
	public static String      CELLSIZE        = "CellSize";
48
	public static String      FILENAME        = "FileName";
49
	public static String      INTERPOLATION   = "Interpolation";
50
	
51
	private RasterDataStore   store          = null;
52
	private String            filename       = null;
53
	private IProjection       projdst        = null;
54
	private IProjection       projsrc        = null;
55
	private Reproject         reproject      = null;
56
	private int               w              = 0;
57
	private int               h              = 0;
58
	private double            cellSize       = 0;
59
	private int               interpolation  = 0;
60
	
61
	public static void registerParameters() {
62
		registerInputParameter(RASTER_STORE, RasterDataStore.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL);
63
		registerInputParameter(PATH, String.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL);
64
		registerInputParameter(DST_PROJECTION, IProjection.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL);
65
		registerInputParameter(SRC_PROJECTION, IProjection.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL);
66
		registerInputParameter(SIZEX, Integer.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL);
67
		registerInputParameter(SIZEY, Integer.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL);
68
		registerInputParameter(CELLSIZE, Double.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL);
69
		registerInputParameter(INTERPOLATION, Integer.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL); 
70
		
71
		registerOutputParameter(FILENAME, String.class, RasterReprojectionAlgorithmLibrary.PROCESS_LABEL);
72
	}
73
	
74
	public void init() {
75
		store = getParam(RASTER_STORE) != null ? (RasterDataStore)getParam(RASTER_STORE) : null;
76
		filename = getStringParam(PATH);
77
		projdst = getParam(DST_PROJECTION) != null ? (IProjection) getParam(DST_PROJECTION) : null;
78
		projsrc = getParam(SRC_PROJECTION) != null ? (IProjection) getParam(SRC_PROJECTION) : null; 
79
		w = getIntParam(SIZEX);
80
		h = getIntParam(SIZEY);
81
		cellSize = getDoubleParam(CELLSIZE);
82
		interpolation = getIntParam(INTERPOLATION);
83
	}
84
	
85
	/**
86
	 * M?todo donde se ejecutar? el Thread, aqu? se reproyecta el raster.
87
	 */
88
	public void process() throws ProcessInterruptedException {
89
		insertLineLog(Messages.getText("reprojecting"));
90
		
91
		store = store.newNotTiledDataStore();
92
		
93
		reproject = new Reproject(store, filename, interpolation, this);
94
		try {
95
			int result = reproject.warp(projdst, projsrc, w, h, cellSize);
96
			if(result != 0) {
97
				if (incrementableTask != null) {
98
					incrementableTask.processFinalize();
99
					setProgressActive(false);
100
				}
101
				messageBoxError("transformation_not_possible", this);
102
				return;
103
			}
104

  
105
			addOutputValue(FILENAME, filename);
106
		} catch (ReprojectException e) {
107
			if (incrementableTask != null)
108
				incrementableTask.processFinalize();
109
			messageBoxError("error_reprojecting", this, e);
110
		}
111
	}
112
	
113
	public String getTitle() {
114
		return Messages.getText("reprojecting");
115
	}
116
}
0 117

  
org.gvsig.raster.reproject/tags/org.gvsig.raster.reproject-2.2.225/org.gvsig.raster.reproject.algorithm/src/main/java/org/gvsig/raster/reproject/algorithm/Reproject.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
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
*/
22
package org.gvsig.raster.reproject.algorithm;
23

  
24
import java.awt.geom.Point2D;
25
import java.io.File;
26

  
27
import org.apache.commons.io.FileUtils;
28
import org.apache.commons.io.FilenameUtils;
29
import org.cresques.cts.ICRSFactory;
30
import org.cresques.cts.ICoordTrans;
31
import org.cresques.cts.IProjection;
32
import org.slf4j.Logger;
33
import org.slf4j.LoggerFactory;
34

  
35
import org.gvsig.fmap.dal.coverage.RasterLocator;
36
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
37
import org.gvsig.fmap.dal.coverage.dataset.BufferParam;
38
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
39
import org.gvsig.fmap.dal.coverage.datastruct.NoData;
40
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
41
import org.gvsig.fmap.dal.coverage.exception.QueryException;
42
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
43
import org.gvsig.fmap.dal.coverage.store.RasterQuery;
44
import org.gvsig.raster.algorithm.process.DataProcess;
45
import org.gvsig.raster.algorithm.util.Interpolation;
46

  
47

  
48
/**
49
 * Reprojects a RasterDataStore.
50
 *
51
 * @version 30/04/2008
52
 * @author Nacho Brodin nachobrodin@gmail.com
53
 */
54
public class Reproject {
55
	private RasterDataStore   store                 = null;
56
	private String            pathDest              = null;
57
	private int               interpolationMethod   = 0;
58
	private Interpolation     interpolation         = null;
59
	private DataProcess     process               = null;
60

  
61
    private static final Logger logger = LoggerFactory.getLogger(Reproject.class);
62

  
63
	/**
64
	 * Constructor de la clase.
65
	 * @param store
66
	 * @param lyr
67
	 * @param pathDest Ruta de destino
68
	 * @param inter
69
	 * @param process
70
	 */
71
	public Reproject(RasterDataStore store, String pathDest, int inter, DataProcess process) {
72
		this.store = store;
73
		this.pathDest = pathDest;
74
		this.interpolationMethod = inter;
75
		this.process = process;
76
	}
77

  
78
	/**
79
	 * M?todo para la transformaci?n del raster.
80
	 * @param destinationSrs Proyecci?n destino
81
	 * @param sourceSrs
82
	 * @param w
83
	 * @param h
84
	 * @param cellSize
85
	 * @return
86
	 * @throws ReprojectException
87
	 */
88
	public int warp(IProjection destinationSrs, IProjection sourceSrs, int w, int h, double cellSize) throws ReprojectException {
89
		if (store == null)
90
			throw new ReprojectException("Capa no valida.");
91
		if (!store.isReproyectable())
92
			throw new ReprojectException("Esta capa no se puede reproyectar.");
93
		if (destinationSrs == null || destinationSrs.getAbrev() == null)
94
			throw new ReprojectException("Proyecci?n de destino no valida.");
95

  
96

  
97
		File file = new File(pathDest);
98
		if (!file.getParentFile().canWrite())
99
			throw new ReprojectException("Ruta de destino no valida.");
100

  
101
		ICoordTrans transf = sourceSrs.getCT(destinationSrs);
102
		Extent bbox = store.getExtent();
103
		Point2D ul = new Point2D.Double(bbox.getULX(), bbox.getULY());
104
		Point2D lr = new Point2D.Double(bbox.getLRX(), bbox.getLRY());
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff