Revision 152

View differences:

org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/distribution/distribution.xml
1
<assembly>
2
</assembly>
0 3

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.geoprocess.extension/src/main/resources/config/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<depends plugin-name="org.gvsig.sextante.app.extension" />
4
	<resourceBundle name="text" />
5
	<libraries library-dir="lib" />
6
	<extensions>
7
		<extension class-name="org.gvsig.sextante.app.geoprocess.extension.GeoprocessModule"
8
			active="true" 
9
			priority="1">
10
		</extension>
11
	</extensions>
12
</plugin-config>
0 13

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.geoprocess.extension/src/main/java/org/gvsig/sextante/app/geoprocess/extension/GeoprocessModule.java
1
/* 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.sextante.app.geoprocess.extension;
20

  
21
import javax.swing.Icon;
22

  
23
import org.gvsig.andami.plugins.Extension;
24
import org.gvsig.app.project.documents.view.toc.ITocItem;
25
import org.gvsig.fmap.mapcontext.layers.FLayer;
26

  
27

  
28
/**
29
 *
30
 * 05/02/2008
31
 * @author Nacho Brodin nachobrodin@gmail.com
32
 */
33
public class GeoprocessModule  extends Extension {
34
	//private ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager();
35

  
36
	/*
37
	 * (non-Javadoc)
38
	 * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
39
	 */
40
	public void execute(String actionCommand) {
41
		
42
	}
43

  
44
	/*
45
	 * (non-Javadoc)
46
	 * @see com.iver.andami.plugins.IExtension#initialize()
47
	 */
48
	public void initialize() {
49
	}
50

  
51
	/*
52
	 * (non-Javadoc)
53
	 * @see com.iver.andami.plugins.IExtension#isEnabled()
54
	 */
55
	public boolean isEnabled() {
56
		return true;
57
	}
58

  
59
	/*
60
	 * (non-Javadoc)
61
	 * @see com.iver.andami.plugins.IExtension#isVisible()
62
	 */
63
	public boolean isVisible() {
64
		return true;
65
	}
66

  
67
	/*
68
	 * (non-Javadoc)
69
	 * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
70
	 */
71
	public void execute(ITocItem item, FLayer[] selectedItems) {
72

  
73
	}
74

  
75
	/*
76
	 * (non-Javadoc)
77
	 * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getGroup()
78
	 */
79
	public String getGroup() {
80
		return null;
81
	}
82

  
83
	/*
84
	 * (non-Javadoc)
85
	 * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getIcon()
86
	 */
87
	public Icon getIcon() {
88
		return null;
89
	}
90

  
91
	/*
92
	 * (non-Javadoc)
93
	 * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getOrder()
94
	 */
95
	public int getOrder() {
96
		return 0;
97
	}
98

  
99
	/*
100
	 * (non-Javadoc)
101
	 * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getText()
102
	 */
103
	public String getText() {
104
		return null;
105
	}
106

  
107
	/*
108
	 * (non-Javadoc)
109
	 * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
110
	 */
111
	public boolean isEnabled(ITocItem item, FLayer[] selectedItems) {
112
		return this.isEnabled();
113
	}
114

  
115
	/*
116
	 * (non-Javadoc)
117
	 * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
118
	 */
119
	public boolean isVisible(ITocItem item, FLayer[] selectedItems) {
120
		return this.isVisible();
121
	}
122

  
123
	/*
124
	 * (non-Javadoc)
125
	 * @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getGroupOrder()
126
	 */
127
	public int getGroupOrder() {
128
		return 0;
129
	}
130
}
0 131

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.geoprocess.extension/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
    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.sextante.app.geoprocess.extension</artifactId>
5
    <packaging>jar</packaging>
6
    <name>org.gvsig.sextante.app.geoprocess.extension</name>
7
    <version>0.6.0-SNAPSHOT</version>
8
    <description>gvSIG Geoprocess</description>
9
    <url>http://gvsig-desktop.forge.osor.eu/downloads/pub/projects/gvSIG-desktop/docs/reference/org.gvsig.sextante.app/${project.version}ion}</url>
10

  
11
    <parent>
12
        <groupId>org.gvsig</groupId>
13
        <artifactId>org.gvsig.sextante.app</artifactId>
14
        <version>0.6.0-SNAPSHOT</version>
15
    </parent>
16

  
17
    <dependencies>
18
        <dependency>
19
            <groupId>org.gvsig</groupId>
20
            <artifactId>org.gvsig.sextante.app.algorithm.buffer</artifactId>
21
            <version>0.6.0-SNAPSHOT</version>
22
            <scope>compile</scope>
23
        </dependency>
24
        <dependency>
25
            <groupId>org.gvsig</groupId>
26
            <artifactId>org.gvsig.sextante.app.algorithm.clip</artifactId>
27
            <version>0.6.0-SNAPSHOT</version>
28
            <scope>compile</scope>
29
        </dependency>
30
        <dependency>
31
            <groupId>org.gvsig</groupId>
32
            <artifactId>org.gvsig.sextante.app.algorithm.convexhull</artifactId>
33
            <version>0.6.0-SNAPSHOT</version>
34
            <scope>compile</scope>
35
        </dependency>
36
        <dependency>
37
            <groupId>org.gvsig</groupId>
38
            <artifactId>org.gvsig.sextante.app.algorithm.difference</artifactId>
39
            <version>0.6.0-SNAPSHOT</version>
40
            <scope>compile</scope>
41
        </dependency>
42
        <dependency>
43
            <groupId>org.gvsig</groupId>
44
            <artifactId>org.gvsig.sextante.app.algorithm.dissolve</artifactId>
45
            <version>0.6.0-SNAPSHOT</version>
46
            <scope>compile</scope>
47
        </dependency>
48
        <dependency>
49
            <groupId>org.gvsig</groupId>
50
            <artifactId>org.gvsig.sextante.app.algorithm.intersection</artifactId>
51
            <version>0.6.0-SNAPSHOT</version>
52
            <scope>compile</scope>
53
        </dependency>
54
        <dependency>
55
            <groupId>org.gvsig</groupId>
56
            <artifactId>org.gvsig.sextante.app.algorithm.merge</artifactId>
57
            <version>0.6.0-SNAPSHOT</version>
58
            <scope>compile</scope>
59
        </dependency>
60
        <dependency>
61
            <groupId>org.gvsig</groupId>
62
            <artifactId>org.gvsig.sextante.app.algorithm.reproject</artifactId>
63
            <version>0.6.0-SNAPSHOT</version>
64
            <scope>compile</scope>
65
        </dependency>
66
        <dependency>
67
            <groupId>org.gvsig</groupId>
68
            <artifactId>org.gvsig.sextante.app.algorithm.spatialjoin</artifactId>
69
            <version>0.6.0-SNAPSHOT</version>
70
            <scope>compile</scope>
71
        </dependency>
72
        <dependency>
73
            <groupId>org.gvsig</groupId>
74
            <artifactId>org.gvsig.sextante.app.algorithm.union</artifactId>
75
            <version>0.6.0-SNAPSHOT</version>
76
            <scope>compile</scope>
77
        </dependency>
78
        <dependency>
79
            <groupId>org.gvsig</groupId>
80
            <artifactId>org.gvsig.sextante.app.algorithm.xyshift</artifactId>
81
            <version>0.6.0-SNAPSHOT</version>
82
            <scope>compile</scope>
83
        </dependency>
84
    </dependencies>
85

  
86
    <profiles>
87
        <profile>
88
            <id>gvsig-install</id>
89
            <activation>
90
                <activeByDefault>true</activeByDefault>
91
            </activation>
92
            <properties>
93
                <!--  gvSIG installation folder -->
94
                <gvsig.install.dir>${basedir}/../../build/product</gvsig.install.dir>
95
            </properties>
96
        </profile>
97
    </profiles>
98
    <properties>
99
    	<package.info.dependencies>required: org.gvsig.sextante.app.extension -ge 0.6</package.info.dependencies>
100
	</properties>
101
</project>
0 102

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.geoprocess.extension/distribution/distribution.xml
1
<assembly>
2
  <id>distribution</id>
3
  
4
  <formats>
5
    <format>dir</format>
6
  </formats>
7
  
8
  <fileSets>
9
    <fileSet>
10
      <directory>src/main/resources/config</directory>
11
	  <outputDirectory>${extension.install.dir.name}</outputDirectory>
12
    </fileSet>
13
  </fileSets>
14
  
15
  <files>
16
    <file>
17
      <source>package.info</source>
18
      <outputDirectory>${extension.install.dir.name}</outputDirectory>
19
    </file>
20
  </files>
21
  
22
  <dependencySets>
23
	<dependencySet>
24
		<outputDirectory>./gvSIG/extensiones/org.gvsig.sextante.app.geoprocess.extension/lib</outputDirectory>
25
		<includes>
26
			<include>org.gvsig:org.gvsig.sextante.app.geoprocess.extension</include>
27
			<include>org.gvsig:org.gvsig.sextante.app.algorithm.base</include>
28
			<include>org.gvsig:org.gvsig.sextante.app.algorithm.buffer</include>
29
			<include>org.gvsig:org.gvsig.sextante.app.algorithm.clip</include>
30
			<include>org.gvsig:org.gvsig.sextante.app.algorithm.convexhull</include>
31
			<include>org.gvsig:org.gvsig.sextante.app.algorithm.difference</include>
32
			<include>org.gvsig:org.gvsig.sextante.app.algorithm.dissolve</include>
33
			<include>org.gvsig:org.gvsig.sextante.app.algorithm.intersection</include>
34
			<include>org.gvsig:org.gvsig.sextante.app.algorithm.merge</include>
35
			<include>org.gvsig:org.gvsig.sextante.app.algorithm.reproject</include>
36
			<include>org.gvsig:org.gvsig.sextante.app.algorithm.spatialjoin</include>
37
			<include>org.gvsig:org.gvsig.sextante.app.algorithm.union</include>
38
			<include>org.gvsig:org.gvsig.sextante.app.algorithm.xyshift</include>
39
		</includes>
40
	</dependencySet>
41
  </dependencySets>
42
</assembly>
0 43

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.geoprocess.extension/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Thu Aug 18 10:21:58 CEST 2011
3
buildNumber=2040
0 4

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Thu Aug 18 10:20:48 CEST 2011
3
buildNumber=2040
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/distribution/distribution.xml
1
<assembly>
2
</assembly>
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.reproject/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Thu Aug 18 10:21:39 CEST 2011
3
buildNumber=2042
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.reproject/src/main/java/org/gvsig/sextante/app/algorithm/reproject/ReprojectOperation.java
1
/*
2
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2010 Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 */
20

  
21
package org.gvsig.sextante.app.algorithm.reproject;
22

  
23
import java.util.Iterator;
24
import java.util.List;
25

  
26
import org.cresques.cts.ICoordTrans;
27
import org.cresques.cts.IProjection;
28
import org.gvsig.fmap.dal.exception.DataException;
29
import org.gvsig.fmap.dal.feature.EditableFeature;
30
import org.gvsig.fmap.dal.feature.Feature;
31
import org.gvsig.fmap.geom.exception.CreateGeometryException;
32
import org.gvsig.sextante.app.algorithm.base.core.GeometryOperation;
33

  
34
import es.unex.sextante.core.Sextante;
35

  
36
/**
37
 * Operation to reproject a Feature
38
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
39
 */
40
public class ReprojectOperation extends GeometryOperation {
41
	private ICoordTrans                      transf           = null;
42

  
43
	public ReprojectOperation(IProjection srcProj, IProjection dstProj) {
44
		this.transf = srcProj.getCT(dstProj);
45
	}
46

  
47
	/*
48
	 * (non-Javadoc)
49
	 * @see org.gvsig.sextante.app.algorithm.base.core.GeometryOperation#invoke(org.gvsig.fmap.geom.Geometry, org.gvsig.fmap.dal.feature.Feature)
50
	 */
51
	@SuppressWarnings("unchecked")
52
	public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, Feature feature) {
53
		List geomList = feature.getGeometries();
54
		try {
55
			if(geomList == null) {
56
				org.gvsig.fmap.geom.Geometry geom = feature.getDefaultGeometry();
57
				geom.reProject(transf);
58
				EditableFeature editFeat = feature.getEditable();
59
				editFeat.setDefaultGeometry(geom);
60
				persister.addFeature(feature, geom);
61
			} else {
62
				Iterator<org.gvsig.fmap.geom.Geometry> itGeom = geomList.iterator();
63
				EditableFeature editFeat = null;
64
				boolean first = true;
65
				int nGeom = 0;
66
				while(itGeom.hasNext()) {
67
					org.gvsig.fmap.geom.Geometry geom = itGeom.next();
68
					geom.reProject(transf);
69
					editFeat = feature.getEditable();
70
					editFeat.setGeometry(nGeom, geom);
71
					nGeom ++;
72
					if(first) 
73
						persister.addFeature(editFeat, geom);
74
					else 
75
						persister.addGeometryToExistingFeature(editFeat, geom);
76
				}
77
			}
78
		} catch (DataException e) {
79
			Sextante.addErrorToLog(e);
80
		} catch (CreateGeometryException e) {
81
			Sextante.addErrorToLog(e);
82
		}
83
		
84
		return lastEditFeature;
85
	}
86
	
87
	@Override
88
	public void invoke(org.gvsig.fmap.geom.Geometry g, EditableFeature featureInput) {
89
	}
90
}
91

  
0 92

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.reproject/src/main/java/org/gvsig/sextante/app/algorithm/reproject/ReprojectParametersPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2010 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.sextante.app.algorithm.reproject;
20

  
21
import java.awt.Dimension;
22
import java.awt.GridBagConstraints;
23
import java.awt.GridBagLayout;
24
import java.awt.Insets;
25
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27

  
28
import javax.swing.ComboBoxModel;
29
import javax.swing.DefaultComboBoxModel;
30
import javax.swing.JCheckBox;
31
import javax.swing.JComboBox;
32
import javax.swing.JLabel;
33
import javax.swing.JPanel;
34

  
35
import org.cresques.cts.IProjection;
36
import org.gvsig.app.gui.panels.CRSSelectPanel;
37
import org.gvsig.fmap.crs.CRSFactory;
38
import org.gvsig.sextante.app.extension.core.CompositeSourceOutputChannel;
39
import org.gvsig.sextante.app.extension.gui.AlgorithmOutputPanel;
40

  
41
import es.unex.sextante.core.GeoAlgorithm;
42
import es.unex.sextante.core.ObjectAndDescription;
43
import es.unex.sextante.core.OutputObjectsSet;
44
import es.unex.sextante.core.ParametersSet;
45
import es.unex.sextante.core.Sextante;
46
import es.unex.sextante.dataObjects.IVectorLayer;
47
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel;
48
import es.unex.sextante.gui.core.SextanteGUI;
49
import es.unex.sextante.outputs.Output;
50

  
51
/**
52
 * Panel for reproject algorithm
53
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
54
 */
55
public class ReprojectParametersPanel extends GeoAlgorithmParametersPanel implements ActionListener {
56
	private static final long                serialVersionUID       = 1L;
57
	private GeoAlgorithm                     m_Algorithm            = null;
58
	private JComboBox                        layersCombo            = null;
59
	private JCheckBox                        selectionOnly          = null;
60
	//private AlgorithmOutputPanel             output                 = null;
61
	private JLabel                           projLabel              = null;
62
	private CRSSelectPanel                   projectionSrcSelector  = null;
63
	private IProjection                      targetLayerProjection  = null;
64
	private AlgorithmOutputPanel             algorithmOutputPanel   = null;
65
	public ReprojectParametersPanel() {
66
		super();
67
	}
68

  
69
    public void init(GeoAlgorithm algorithm) {
70
    	m_Algorithm = algorithm;
71
    	initGUI();
72
    	init();
73
    }
74

  
75
	private void initGUI() {
76
		GridBagLayout gbl = new GridBagLayout();
77
		this.setLayout(gbl);
78
		
79
		GridBagConstraints gbc = new GridBagConstraints();
80
		gbc.fill = GridBagConstraints.HORIZONTAL;
81
		gbc.weightx = 1.0;
82
		gbc.gridx = 0;
83
		gbc.gridy = 0;
84
		gbc.insets = new Insets(15, 5, 15, 0);
85
		this.add(getComboPanel(Sextante.getText("Input_layer"), getLayersCombo()), gbc);
86
		
87
		gbc.gridy = 1;
88
		gbc.insets = new Insets(0, 5, 15, 0);
89
		this.add(getSelectionCheck(), gbc);
90
		
91
		gbc.gridy = 2;
92
		this.add(getCurrentProjLabel(), gbc);
93
		
94
		gbc.gridy = 3;
95
		this.add(getProjectionSelector(), gbc);
96
		
97
		gbc.gridy = 4;
98
		gbc.fill = GridBagConstraints.BOTH;
99
		gbc.weighty = 1.0;
100
		gbc.weightx = 1.0;
101
		this.add(new JPanel(), gbc);
102
		
103
		gbc.gridy = 5;
104
		gbc.fill = GridBagConstraints.HORIZONTAL;
105
		gbc.weighty = 0.0;
106
		this.add(getAlgorithmOutputPanel(), gbc);
107
	}
108
	
109
	/**
110
	 * Gets the output panel
111
	 * @return
112
	 */
113
	private AlgorithmOutputPanel getAlgorithmOutputPanel() {
114
		if(algorithmOutputPanel == null)
115
		    algorithmOutputPanel = new AlgorithmOutputPanel();
116
		return algorithmOutputPanel;
117
	}
118
	
119
	/**
120
	 * Gets a new JPanel with the text and JComboBox 
121
	 * @param text
122
	 * @param combo
123
	 * @return
124
	 */
125
	public JPanel getComboPanel(String text, JComboBox combo) {
126
		JPanel panel = new JPanel();
127
		GridBagLayout gbl = new GridBagLayout();
128
		panel.setLayout(gbl);
129

  
130
		GridBagConstraints gbc = new GridBagConstraints();
131
		gbc.fill = GridBagConstraints.NONE;
132
		gbc.weightx = 0;
133
		gbc.gridx = 0;
134
		gbc.insets = new Insets(0, 2, 0, 50);
135
		JLabel label = new JLabel(text);
136
		label.setPreferredSize(new Dimension(80, 18));
137
		panel.add(label, gbc);
138

  
139
		gbc.fill = GridBagConstraints.HORIZONTAL;
140
		gbc.weightx = 1.0;
141
		gbc.gridx = 1;
142
		gbc.anchor = GridBagConstraints.EAST;
143
		gbc.insets = new Insets(0, 2, 0, 0);
144
		panel.add(combo, gbc);
145
		return panel;
146
	}
147
	
148
	/**
149
	 * Gets a ComboBox
150
	 * @return
151
	 */
152
	public JComboBox getLayersCombo() {
153
		if(layersCombo == null) {
154
			layersCombo = new JComboBox();
155
			layersCombo.setPreferredSize(new Dimension(0, 18));
156
			ComboBoxModel comboModel = new DefaultComboBoxModel(getLayerList());
157
			layersCombo.setModel(comboModel);
158
			layersCombo.addActionListener(this);
159
		}
160
		return layersCombo;
161
	}
162
	
163
	
164
	/**
165
	 * Gets a CheckBox
166
	 * @return
167
	 */
168
	public JCheckBox getSelectionCheck() {
169
		if(selectionOnly == null) {
170
			selectionOnly = new JCheckBox(Sextante.getText("Selected_geometries"));
171
		}
172
		return selectionOnly;
173
	}
174
	
175
	/**
176
	 * Panel with the projection selector
177
	 * @return
178
	 */
179
	private CRSSelectPanel getProjectionSelector() {
180
		if (projectionSrcSelector == null) {
181
			targetLayerProjection = CRSFactory.getCRS("EPSG:23030");
182
			projectionSrcSelector = CRSSelectPanel.getPanel(targetLayerProjection);
183
			projectionSrcSelector.getJLabel().setText(Sextante.getText("Proyeccion_Destino"));
184
			projectionSrcSelector.setPreferredSize(new java.awt.Dimension(330,35));
185
			projectionSrcSelector.addActionListener(new java.awt.event.ActionListener() {
186
				public void actionPerformed(java.awt.event.ActionEvent e) {
187
					if (projectionSrcSelector.isOkPressed()) {
188
						targetLayerProjection = projectionSrcSelector.getCurProj();
189
					}
190
				}
191
			});
192
		}
193
		projectionSrcSelector.setTransPanelActive(true);
194
		return projectionSrcSelector;
195
	}
196
	
197
	/**
198
	 * Gets the label with the current projection
199
	 * @return
200
	 */
201
	public JLabel getCurrentProjLabel() {
202
		if(projLabel == null)
203
			projLabel = new JLabel();
204
		return projLabel;
205
	}
206
	
207
	//------------------------------------------------------------
208
	
209
	/**
210
	 * Initialize actions
211
	 */
212
	private void init() {
213
		IVectorLayer layer = getSelectedVectorLayer();
214
		IProjection currentProj = (IProjection)layer.getCRS();
215
		getCurrentProjLabel().setText("Proj: " + currentProj.getAbrev());
216
	}
217
	
218
	/*
219
	 * (non-Javadoc)
220
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
221
	 */
222
	public void actionPerformed(ActionEvent e) {
223
		if(e.getSource() ==  getLayersCombo()) {
224

  
225
		}
226
	}
227
	
228
	@Override
229
	public boolean assignParameters() {
230
		try {
231
			ParametersSet params = m_Algorithm.getParameters();
232
			params.getParameter(ReprojectAlgorithm.LAYER).setParameterValue(getSelectedVectorLayer());
233
			params.getParameter(ReprojectAlgorithm.SELECTED_GEOM).setParameterValue(getSelectionCheck().isSelected());
234
			String proj = getProjectionSelector().getCurProj().getAbrev();
235
			params.getParameter(ReprojectAlgorithm.DST_PROJECTION).setParameterValue(proj);
236
			
237
			OutputObjectsSet ooSet = m_Algorithm.getOutputObjects();
238
			Output out = ooSet.getOutput(ReprojectAlgorithm.RESULT);
239
			out.setOutputChannel(new CompositeSourceOutputChannel(getAlgorithmOutputPanel().getOutputParameters()));
240
			return true;
241
		} catch (Exception e) {
242
			Sextante.addErrorToLog(e);
243
			return false;
244
		}
245
	}
246

  
247
	@Override
248
	public void setOutputValue(String arg0, String arg1) {
249
		
250
	}
251

  
252
	@Override
253
	public void setParameterValue(String arg0, String arg1) {
254
		
255
	}
256
	
257
	/**
258
	 * Gets the input layer list
259
	 * @return
260
	 */
261
	private ObjectAndDescription[] getLayerList() {
262
		IVectorLayer[] layers = SextanteGUI.getInputFactory()
263
					.getVectorLayers(IVectorLayer.SHAPE_TYPE_WRONG);
264
		ObjectAndDescription[] oad = new ObjectAndDescription[layers.length];
265
		for (int i = 0; i < layers.length; i++)
266
			oad[i] = new ObjectAndDescription(layers[i].getName(), layers[i]);
267
		return oad;
268
	}
269
	
270
	/**
271
	 * Gets the selected vector layer in the JComboBox
272
	 * @return
273
	 */
274
	private IVectorLayer getSelectedVectorLayer() {
275
		if(layersCombo.getSelectedItem() != null)
276
			return (IVectorLayer)((ObjectAndDescription)layersCombo.getSelectedItem()).getObject();
277
		return null;
278
	}
279
	
280
	/**
281
	 * Gets the field list of the selected layer
282
	 * @return
283
	 */
284
	public String[] getFieldList() {
285
		IVectorLayer layer = getSelectedVectorLayer();
286
		String[] data = new String[layer.getFieldCount()];
287
		for (int i = 0; i < layer.getFieldCount(); i++) 
288
			data[i] = layer.getFieldName(i);
289
		return data;
290
	}
291
}
0 292

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.reproject/src/main/java/org/gvsig/sextante/app/algorithm/reproject/ReprojectLibrary.java
1
/*
2
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
3
 *
4
 * Copyright (C) 2010 Generalitat Valenciana.
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 */
21
package org.gvsig.sextante.app.algorithm.reproject;
22

  
23
import es.unex.sextante.core.Sextante;
24
import es.unex.sextante.gui.core.SextanteGUI;
25

  
26
import org.gvsig.i18n.Messages;
27
import org.gvsig.sextante.app.algorithm.base.core.AlgorithmAbstractLibrary;
28
import org.gvsig.tools.library.LibraryException;
29

  
30
/**
31
 * Initialization of ReprojectLibrary library. 
32
 * 
33
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
34
 */
35
public class ReprojectLibrary extends AlgorithmAbstractLibrary {
36

  
37
	@Override
38
	protected void doInitialize() throws LibraryException {
39
		
40
	}
41

  
42
	@Override
43
	protected void doPostInitialize() throws LibraryException {
44
		Messages.addResourceFamily(
45
				"org.gvsig.sextante.app.algorithm.reproject.reproject",
46
				ReprojectLibrary.class.getClassLoader(),
47
				ReprojectLibrary.class.getClass().getName());
48
		setLanguageStrings("org.gvsig.sextante.app.algorithm.reproject.reproject");
49
		Sextante.addGeoProcess(ReprojectAlgorithm.class, text);
50
		SextanteGUI.addCustomParametersPanel(ReprojectAlgorithm.class, ReprojectParametersPanel.class, null);
51
	}
52

  
53
}
0 54

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.reproject/src/main/java/org/gvsig/sextante/app/algorithm/reproject/ReprojectAlgorithm.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2010 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.sextante.app.algorithm.reproject;
20

  
21
import org.cresques.cts.IProjection;
22
import org.gvsig.fmap.crs.CRSFactory;
23
import org.gvsig.fmap.dal.exception.DataException;
24
import org.gvsig.fmap.dal.feature.FeatureSet;
25
import org.gvsig.fmap.dal.feature.FeatureStore;
26
import org.gvsig.fmap.dal.feature.FeatureType;
27
import org.gvsig.sextante.app.extension.core.gvGeoAlgorithm;
28
import org.gvsig.sextante.app.extension.core.gvVectorLayer;
29

  
30
import es.unex.sextante.core.Sextante;
31
import es.unex.sextante.dataObjects.IVectorLayer;
32
import es.unex.sextante.exceptions.GeoAlgorithmExecutionException;
33
import es.unex.sextante.exceptions.RepeatedParameterNameException;
34
import es.unex.sextante.outputs.OutputVectorLayer;
35

  
36
/**
37
 * Reproject algorithm
38
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
39
 */
40
public class ReprojectAlgorithm extends gvGeoAlgorithm {
41
	public static final String        RESULT            = "RESULT";
42
	public static final String        LAYER             = "LAYER";
43
	public static final String        SELECTED_GEOM     = "SELECTED_GEOM";
44
	public static final String        DST_PROJECTION    = "DST_PROJECTION";
45
	
46
	/*
47
	 * (non-Javadoc)
48
	 * @see es.unex.sextante.core.GeoAlgorithm#defineCharacteristics()
49
	 */
50
	public void defineCharacteristics() {
51
		setName(Sextante.getText("Reproject"));
52
		setGroup(Sextante.getText("gvSIG_Algorithms"));
53
		setGeneratesUserDefinedRasterOutput(false);
54
		
55
		try {
56
			m_Parameters.addInputVectorLayer(LAYER, 
57
												Sextante.getText("Input_layer"), 
58
												IVectorLayer.SHAPE_TYPE_WRONG, 
59
												true);
60
			m_Parameters.addBoolean(SELECTED_GEOM, 
61
									Sextante.getText("Selected_geometries"), 
62
									false);
63
			m_Parameters.addString(DST_PROJECTION, Sextante.getText("Projection"));
64
			addOutputVectorLayer(RESULT,
65
								Sextante.getText("Reproject"),
66
								OutputVectorLayer.SHAPE_TYPE_UNDEFINED);
67
		} catch (RepeatedParameterNameException e) {
68
			Sextante.addErrorToLog(e);
69
		}
70
	}
71
	
72
	/*
73
	 * (non-Javadoc)
74
	 * @see es.unex.sextante.core.GeoAlgorithm#processAlgorithm()
75
	 */
76
	public boolean processAlgorithm() throws GeoAlgorithmExecutionException {
77
		IVectorLayer layer = m_Parameters.getParameterValueAsVectorLayer(LAYER);
78
		boolean selectedGeom = m_Parameters.getParameterValueAsBoolean(SELECTED_GEOM);
79
		String dstProj = m_Parameters.getParameterValueAsString(DST_PROJECTION);
80
		
81
		FeatureStore storeLayer = null;
82
		if(layer instanceof gvVectorLayer)
83
			storeLayer = ((gvVectorLayer)layer).getFeatureStore();
84
		else
85
			return false;
86
		
87
		try {
88
			FeatureSet features = null;
89
			features = storeLayer.getFeatureSet();
90
			FeatureType featureType = features.getDefaultFeatureType();
91
			FeatureStore outFeatStore = buildOutPutStore(featureType, layer.getShapeType(), Sextante.getText("Reproject"), RESULT);
92
			IProjection projOutput = CRSFactory.getCRS(dstProj);
93
			ReprojectOperation operation = new ReprojectOperation(((IProjection)layer.getCRS()), projOutput);
94
			operation.setProgressModel(this);
95
			operation.computesFeatureOperation(storeLayer, outFeatStore, attrNames, selectedGeom, true);
96
		} catch (DataException e) {
97
			Sextante.addErrorToLog(e);
98
			return false;
99
		}
100
		return true;
101
	}
102
}
0 103

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.reproject/src/main/resources/org/gvsig/sextante/app/algorithm/reproject/reproject_en.properties
1
gvSIG_Algorithms=gvSIG algorithms
2
Reproject=Reproject
3
Input_layer=Input cover
4
Selected_geometries=Selected geometries
5
Projection=Projection
0 6

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.reproject/src/main/resources/org/gvsig/sextante/app/algorithm/reproject/reproject_es.properties
1
gvSIG_Algorithms=Algoritmos gvSIG
2
Reproject=Reproyecci?n
3
Input_layer=Capa de entrada
4
Selected_geometries=Geometrias seleccionadas
5
Projection=Proyecci?n
0 6

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.reproject/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.sextante.app.algorithm.reproject.ReprojectLibrary
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.reproject/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4
  <modelVersion>4.0.0</modelVersion>
5
  <artifactId>org.gvsig.sextante.app.algorithm.reproject</artifactId>
6
  <packaging>jar</packaging>
7
  <name>org.gvsig.sextante.app.algorithm.reproject</name>
8
	
9
	<parent>
10
		<groupId>org.gvsig</groupId>
11
		<artifactId>org.gvsig.sextante.app.algorithm</artifactId>
12
		<version>0.6.0-SNAPSHOT</version>
13
	</parent>
14
	
15
	<dependencies>
16
		<dependency>
17
		    <groupId>org.gvsig</groupId>
18
   			<artifactId>org.gvsig.sextante.app.algorithm.base</artifactId>
19
   			<version>0.6.0-SNAPSHOT</version>
20
            <scope>compile</scope>
21
   		</dependency>
22
   		<dependency>
23
			<groupId>org.geotools</groupId>
24
			<artifactId>gt2-main</artifactId>
25
            <scope>compile</scope>
26
		</dependency>
27
	</dependencies>
28
	
29
</project>
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.reproject/distribution/distribution.xml
1
<assembly>
2
</assembly>
0 3

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.spatialjoin/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Thu Aug 18 10:21:53 CEST 2011
3
buildNumber=2042
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.spatialjoin/src/main/java/org/gvsig/sextante/app/algorithm/spatialjoin/SpatialJoinParametersPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2010 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.sextante.app.algorithm.spatialjoin;
20

  
21
import java.awt.Dimension;
22
import java.awt.GridBagConstraints;
23
import java.awt.GridBagLayout;
24
import java.awt.Insets;
25
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27

  
28
import javax.swing.ComboBoxModel;
29
import javax.swing.DefaultComboBoxModel;
30
import javax.swing.JCheckBox;
31
import javax.swing.JComboBox;
32
import javax.swing.JLabel;
33
import javax.swing.JPanel;
34

  
35
import org.gvsig.gui.beans.table.TableContainer;
36
import org.gvsig.gui.beans.table.exceptions.NotInitializeException;
37
import org.gvsig.sextante.app.extension.core.CompositeSourceOutputChannel;
38
import org.gvsig.sextante.app.extension.gui.AlgorithmOutputPanel;
39

  
40
import es.unex.sextante.core.GeoAlgorithm;
41
import es.unex.sextante.core.ObjectAndDescription;
42
import es.unex.sextante.core.OutputObjectsSet;
43
import es.unex.sextante.core.ParametersSet;
44
import es.unex.sextante.core.Sextante;
45
import es.unex.sextante.dataObjects.IVectorLayer;
46
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel;
47
import es.unex.sextante.gui.core.SextanteGUI;
48
import es.unex.sextante.outputs.Output;
49

  
50
/**
51
 * Panel for dissolve algorithm
52
 * @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a>
53
 */
54
public class SpatialJoinParametersPanel extends GeoAlgorithmParametersPanel implements ActionListener {
55
	private static final long                serialVersionUID   = 1L;
56
	private GeoAlgorithm                     m_Algorithm        = null;
57
	private JComboBox                        layersCombo        = null;
58
	private JComboBox                        layersJoinCombo    = null;
59
	private JCheckBox                        selectionOnly      = null;
60
	private JCheckBox                        nearest       = null;
61
	private AlgorithmOutputPanel             output             = null;
62
	private final String[]                   columnNames        = { "Min", "Max", "Sum", "Avg", "Field ID" };
63
	private final int[]                      columnWidths       = { 35, 35, 35, 35, 334 };
64
	private TableContainer                   table              = null;
65
 	
66
	public SpatialJoinParametersPanel() {
67
		super();
68
	}
69

  
70
    public void init(GeoAlgorithm algorithm) {
71
    	m_Algorithm = algorithm;
72
    	initGUI();
73
    }
74

  
75
	private void initGUI() {
76
		GridBagLayout gbl = new GridBagLayout();
77
		this.setLayout(gbl);
78
		
79
		GridBagConstraints gbc = new GridBagConstraints();
80
		gbc.fill = GridBagConstraints.HORIZONTAL;
81
		gbc.weightx = 1.0;
82
		gbc.gridx = 0;
83
		gbc.gridy = 0;
84
		gbc.insets = new Insets(0, 0, 8, 0);
85
		this.add(getComboPanel(Sextante.getText("input_layers"), getLayers1Combo()), gbc);
86
		
87
		gbc.gridy = 1;
88
		this.add(getComboPanel(Sextante.getText("input_layers_join"), getLayers2Combo()), gbc);
89
		
90
		gbc.gridy = 2;
91
		this.add(getSelectionCheck(), gbc);
92
		
93
		gbc.gridy = 3;
94
		this.add(getNearestCheck(), gbc);
95
		
96
		gbc.gridy = 4;
97
		this.add(new JLabel(Sextante.getText("summary_function")), gbc);
98
		
99
		gbc.gridy = 5;
100
		gbc.fill = GridBagConstraints.BOTH;
101
		gbc.insets = new Insets(0, 0, 12, 0);
102
		gbc.weighty = 1.0;
103
		this.add(getRadioButtonTable(), gbc);
104
		
105
		gbc.gridy = 6;
106
		gbc.fill = GridBagConstraints.HORIZONTAL;
107
		gbc.weighty = 0.0;
108
		this.add(getAlgorithmOutputPanel(), gbc);
109
		
110
		initTable();
111
		getRadioButtonTable().setVisible(false);
112
	}
113
	
114
	/**
115
	 * Gets the output panel
116
	 * @return
117
	 */
118
	private AlgorithmOutputPanel getAlgorithmOutputPanel() {
119
		if(output == null)
120
			output = new AlgorithmOutputPanel();
121
		return output;
122
	}
123
	
124
	/**
125
	 * Gets a new JPanel with the text and JComboBox 
126
	 * @param text
127
	 * @param combo
128
	 * @return
129
	 */
130
	public JPanel getComboPanel(String text, JComboBox combo) {
131
		JPanel panel = new JPanel();
132
		GridBagLayout gbl = new GridBagLayout();
133
		panel.setLayout(gbl);
134

  
135
		GridBagConstraints gbc = new GridBagConstraints();
136
		gbc.fill = GridBagConstraints.NONE;
137
		gbc.weightx = 0;
138
		gbc.gridx = 0;
139
		gbc.insets = new Insets(0, 2, 0, 5);
140
		JLabel label = new JLabel(text);
141
		label.setPreferredSize(new Dimension(180, 18));
142
		panel.add(label, gbc);
143

  
144
		gbc.fill = GridBagConstraints.HORIZONTAL;
145
		gbc.weightx = 1.0;
146
		gbc.gridx = 1;
147
		gbc.anchor = GridBagConstraints.EAST;
148
		gbc.insets = new Insets(0, 2, 0, 0);
149
		panel.add(combo, gbc);
150
		return panel;
151
	}
152
	
153
	/**
154
	 * Gets a ComboBox
155
	 * @return
156
	 */
157
	public JComboBox getLayers1Combo() {
158
		if(layersCombo == null) {
159
			layersCombo = new JComboBox();
160
			layersCombo.setPreferredSize(new Dimension(0, 18));
161
			ComboBoxModel comboModel = new DefaultComboBoxModel(getLayerList());
162
			layersCombo.setModel(comboModel);
163
			layersCombo.addActionListener(this);
164
		}
165
		return layersCombo;
166
	}
167
	
168
	/**
169
	 * Gets a ComboBox
170
	 * @return
171
	 */
172
	public JComboBox getLayers2Combo() {
173
		if(layersJoinCombo == null) {
174
			layersJoinCombo = new JComboBox();
175
			layersJoinCombo.setPreferredSize(new Dimension(0, 18));
176
			ComboBoxModel comboModel = new DefaultComboBoxModel(getLayerList());
177
			layersJoinCombo.setModel(comboModel);
178
			layersJoinCombo.addActionListener(this);
179
		}
180
		return layersJoinCombo;
181
	}
182
	
183
	/**
184
	 * Gets a CheckBox
185
	 * @return
186
	 */
187
	public JCheckBox getSelectionCheck() {
188
		if(selectionOnly == null) {
189
			selectionOnly = new JCheckBox(Sextante.getText("selected_geometries"));
190
		}
191
		return selectionOnly;
192
	}
193
	
194
	/**
195
	 * Gets a CheckBox
196
	 * @return
197
	 */
198
	public JCheckBox getNearestCheck() {
199
		if(nearest == null) {
200
			nearest = new JCheckBox(Sextante.getText("use_the_nearest"));
201
			nearest.setSelected(true);
202
			nearest.addActionListener(this);
203
		}
204
		return nearest;
205
	}
206

  
207
	/**
208
	 * Gets the summary table
209
	 * @return TableContainer
210
	 */
211
	public TableContainer getRadioButtonTable() {
212
		if (table == null) {
213
			table = new TableContainer(columnNames, columnWidths, null);
214
			table.setModel("ARGBBandSelectorModel");
215
			table.setControlVisible(false);
216
			table.initialize();
217
		}
218
		return table;
219
	}
220
	
221
	//------------------------------------------------------------
222
	
223
	/*
224
	 * (non-Javadoc)
225
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
226
	 */
227
	@SuppressWarnings("unchecked")
228
	public void actionPerformed(ActionEvent e) {
229
		if(e.getSource() == getNearestCheck()) {
230
			if(!getNearestCheck().isSelected())
231
				getRadioButtonTable().setVisible(true);
232
			else
233
				getRadioButtonTable().setVisible(false);
234
		}
235
		
236
		if(e.getSource() ==  getLayers2Combo()) {
237
			initTable();
238
			
239
			//If the second layer has not numerical fields only the nearest method can be applied
240
			IVectorLayer lyr = getSelectedVectorLayer2();
241
			Class[] types = lyr.getFieldTypes();
242
			boolean hasNumericField = false;
243
			for (int i = 0; i < types.length; i++) {
244
				if(types[i] == Integer.class 
245
						|| types[i] == Double.class 
246
						|| types[i] == Float.class 
247
						|| types[i] == Short.class) {
248
					hasNumericField = true;
249
					break;
250
				}
251
			}
252
			if(!hasNumericField)
253
				getNearestCheck().setSelected(true);
254
		}
255
	}
256
	
257
	/**
258
	 * Adds to the table one entry for each field
259
	 */
260
	private void initTable() {
261
		try {
262
			getRadioButtonTable().removeAllRows();
263
			for (int i = 0; i < getSelectedVectorLayer().getFieldCount(); i++)
264
				addTableRow(getSelectedVectorLayer().getFieldName(i));
265
		} catch (NotInitializeException e) {
266
			Sextante.addErrorToLog(e);
267
		}
268
	}
269

  
270
	/**
271
	 * A?ade una banda a la tabla bandas de la imagen asignandole un nombre y
272
	 * valor a los checkbox
273
	 * @param bandName Nombre de la banda
274
	 * @throws NotInitializeException 
275
	 */
276
	private void addTableRow(String fieldName) throws NotInitializeException {
277
		Object[] row = {	new Boolean(false), 
278
							new Boolean(false), 
279
							new Boolean(false), 
280
							new Boolean(false), 
281
							fieldName };
282
		getRadioButtonTable().addRow(row);
283
	}
284
	
285
	@Override
286
	public boolean assignParameters() {
287
		try {
288
			ParametersSet params = m_Algorithm.getParameters();
289
			params.getParameter(SpatialJoinAlgorithm.LAYER1).setParameterValue(getSelectedVectorLayer());
290
			params.getParameter(SpatialJoinAlgorithm.LAYER2).setParameterValue(getSelectedVectorLayer2());
291
			params.getParameter(SpatialJoinAlgorithm.SELECTED_GEOM).setParameterValue(getSelectionCheck().isSelected());
292
			params.getParameter(SpatialJoinAlgorithm.NEAREST).setParameterValue(getNearestCheck().isSelected());
293
			params.getParameter(SpatialJoinAlgorithm.FUNCTION_LIST).setParameterValue(getValues());
294
			
295
			OutputObjectsSet ooSet = m_Algorithm.getOutputObjects();
296
			Output out = ooSet.getOutput(SpatialJoinAlgorithm.RESULT);
297
			AlgorithmOutputPanel fsp = getAlgorithmOutputPanel();
298
			out.setOutputChannel(new CompositeSourceOutputChannel(fsp.getOutputParameters()));
299
			
300
			return true;
301
		} catch (Exception e) {
302
			Sextante.addErrorToLog(e);
303
			return false;
304
		}
305
	}
306

  
307
	@Override
308
	public void setOutputValue(String arg0, String arg1) {
309
		
310
	}
311

  
312
	@Override
313
	public void setParameterValue(String arg0, String arg1) {
314
		
315
	}
316
	
317
	/**
318
	 * Gets the input layer list
319
	 * @return
320
	 */
321
	private ObjectAndDescription[] getLayerList() {
322
		IVectorLayer[] layers = SextanteGUI.getInputFactory()
323
					.getVectorLayers(IVectorLayer.SHAPE_TYPE_POLYGON);
324
		ObjectAndDescription[] oad = new ObjectAndDescription[layers.length];
325
		for (int i = 0; i < layers.length; i++)
326
			oad[i] = new ObjectAndDescription(layers[i].getName(), layers[i]);
327
		return oad;
328
	}
329
	
330
	/**
331
	 * Gets the selected vector layer in the JComboBox
332
	 * @return
333
	 */
334
	private IVectorLayer getSelectedVectorLayer() {
335
		if(layersCombo.getSelectedItem() != null)
336
			return (IVectorLayer)((ObjectAndDescription)layersCombo.getSelectedItem()).getObject();
337
		return null;
338
	}
339
	
340
	/**
341
	 * Gets the selected vector layer in the JComboBox
342
	 * @return
343
	 */
344
	private IVectorLayer getSelectedVectorLayer2() {
345
		if(layersJoinCombo.getSelectedItem() != null)
346
			return (IVectorLayer)((ObjectAndDescription)layersJoinCombo.getSelectedItem()).getObject();
347
		return null;
348
	}
349
	
350
	/**
351
	 * Gets the field list of the selected layer
352
	 * @return
353
	 */
354
	public String[] getFieldList() {
355
		IVectorLayer layer = getSelectedVectorLayer2();
356
		String[] data = new String[layer.getFieldCount()];
357
		for (int i = 0; i < layer.getFieldCount(); i++) 
358
			data[i] = layer.getFieldName(i);
359
		return data;
360
	}
361
	
362
	/**
363
	 * Formats the content of the table
364
	 * @return
365
	 */
366
	private String getValues() {
367
    	String str = "";
368
    	try {
369
			for (int i = 0; i < getRadioButtonTable().getRowCount(); i++) {
370
				str = str + (String)getRadioButtonTable().getModel().getValueAt(i, 4) + ",";
371
				for (int j = 0; j < getRadioButtonTable().getModel().getColumnCount() - 1; j++)
372
					if(((Boolean)getRadioButtonTable().getModel().getValueAt(i, j)).booleanValue())
373
						str = str + SpatialJoinAlgorithm.Summary[j] + ",";
374
				str = str.substring(0, str.length() - 1) + ";";
375
			}
376
		} catch (NotInitializeException e) {
377
			Sextante.addErrorToLog(e);
378
		}
379
    	return str.substring(0, str.length() - 1);
380
    }
381

  
382
}
0 383

  
org.gvsig.sextante/tags/gvSIG_v2_0_0_Build_2032/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.spatialjoin/src/main/java/org/gvsig/sextante/app/algorithm/spatialjoin/IntersectsSpatialJoinOperation.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2010 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.sextante.app.algorithm.spatialjoin;
20

  
21
import java.util.List;
22

  
23
import org.gvsig.fmap.dal.DataTypes;
24
import org.gvsig.fmap.dal.exception.DataException;
25
import org.gvsig.fmap.dal.feature.EditableFeature;
26
import org.gvsig.fmap.dal.feature.Feature;
27
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff