Revision 962

View differences:

org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/pom.xml
155 155
				<artifactId>org.gvsig.geoprocess.algorithm.splitlines</artifactId>
156 156
				<version>2.2.76-SNAPSHOT</version>
157 157
			</dependency>
158
      <dependency>
159
        <groupId>org.gvsig</groupId>
160
        <artifactId>org.gvsig.geoprocess.algorithm.dispersepoints</artifactId>
161
        <version>2.2.76-SNAPSHOT</version>
162
      </dependency>
158 163
			<dependency>
159 164
				<groupId>org.japura</groupId>
160 165
				<artifactId>org.japura</artifactId>
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.app/org.gvsig.geoprocess.app.algorithm/src/main/assembly/gvsig-plugin-package.xml
28 28
      <useProjectArtifact>false</useProjectArtifact>
29 29
	  <useTransitiveDependencies>false</useTransitiveDependencies>
30 30
      <outputDirectory>lib</outputDirectory>
31
      <includes> 
31
      <includes>
32 32
			<include>org.gvsig:org.gvsig.geoprocess.algorithm.base</include>
33 33
			<include>org.gvsig:org.gvsig.geoprocess.algorithm.buffer</include>
34 34
			<include>org.gvsig:org.gvsig.geoprocess.algorithm.clip</include>
......
46 46
			<include>org.gvsig:org.gvsig.geoprocess.algorithm.xyshift</include>
47 47
			<include>org.gvsig:org.gvsig.geoprocess.algorithm.lateralbuffer</include>
48 48
			<include>org.gvsig:org.gvsig.geoprocess.algorithm.splitlines</include>
49
      <include>org.gvsig:org.gvsig.geoprocess.algorithm.dispersepoints</include>
49 50
	  </includes>
50 51
	</dependencySet>
51 52
  </dependencySets>
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.app/org.gvsig.geoprocess.app.algorithm/pom.xml
104 104
            <scope>compile</scope>
105 105
        </dependency>
106 106
        <dependency>
107
            <groupId>org.gvsig</groupId>
108
            <artifactId>org.gvsig.geoprocess.algorithm.dispersepoints</artifactId>
109
            <scope>compile</scope>
110
        </dependency>
111
        <dependency>
107 112
        	<groupId>org.gvsig</groupId>
108 113
        	<artifactId>org.gvsig.andami</artifactId>
109 114
        	<scope>compile</scope>
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/pom.xml
129 129
		<module>org.gvsig.geoprocess.algorithm.groupby</module>
130 130
		<module>org.gvsig.geoprocess.algorithm.lateralbuffer</module>
131 131
		<module>org.gvsig.geoprocess.algorithm.splitlines</module>
132
    <module>org.gvsig.geoprocess.algorithm.dispersepoints</module>
132 133
	</modules>
133 134
</project>
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/resources/org/gvsig/geoprocess/algorithm/dispersepoints/dispersepoints.properties
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

  
25
basic_vect_algorithms=Capas vectoriales
26
input_layer=Capa de entrada
27
_disperse_points=Dispersar puntos
28
_scatter_radius=Radio de dispersi\u00f3n
29
_match_distance=Distancia de concordancia
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/resources/org/gvsig/geoprocess/algorithm/dispersepoints/dispersepoints_en.properties
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

  
25
basic_vect_algorithms=Vector layers tools
26
Input_layer=Input cover
27
_disperse_points=Disperse points
28
_scatter_radius=Scatter radius
29
_match_distance=Match distance
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/resources/help/DispersePointsAlgorithm.xml
1
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
2
<!--
3

  
4
  gvSIG. Desktop Geographic Information System.
5

  
6
  Copyright ? 2007-2017 gvSIG Association
7

  
8
  This program is free software; you can redistribute it and/or
9
  modify it under the terms of the GNU General Public License
10
  as published by the Free Software Foundation; either version 2
11
  of the License, or (at your option) any later version.
12

  
13
  This program is distributed in the hope that it will be useful,
14
  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
  GNU General Public License for more details.
17

  
18
  You should have received a copy of the GNU General Public License
19
  along with this program; if not, write to the Free Software
20
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
  MA  02110-1301, USA.
22

  
23
  For any additional information, do not hesitate to contact us
24
  at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26

  
27
-->
28
	<help>
29
		<element name="DESCRIPTION" text="Este geoproceso, permite dispersar los puntos de una capa que se superponen alrededor de un punto central. Dada una capa de puntos, una distancia de concordancia y un radio de dispersi?n, este algoritmo se recorre la capa de origen buscando grupos de puntos cuya distancia sea menor o igual a la distancia de concordancia y los dispersa, seg?n el radio de dispersi?n, alrededor del centro de dicho grupo, generando una nueva capa de puntos con el resultado." description="Descripci&#243;n" type="0">
30
			<!-- <image description="" file="spatialjoindesc.png">
31
			</image> -->
32
		</element>
33
		<element name="ADDITIONAL_INFO" text="" description="Informaci&#243;n adicional" type="0">
34
		</element>
35
		<element name="EXTENSION_AUTHOR" text="Francisco D?az" description="Algoritmo creado por" type="0">
36
		</element>
37
		<element name="HELP_AUTHOR" text="" description="Ayuda creada por" type="0">
38
		</element>
39
		<element name="USER_NOTES" text="" description="Notas de usuario" type="0">
40
		</element>
41
		<element name="LAYER" text="" description="Capa de entrada" type="3">
42
		</element>
43
		<element name="SELECTED_GEOM" text="" description="Geometrias seleccionadas" type="3">
44
		</element>
45
		<element name="SCATTER_RADIUS" text="" description="Radio de dispersi&#243;n" type="3">
46
		</element>
47
		<element name="MATCH_DISTANCE" text="" description="Distancia de concordancia" type="3">
48
		</element>
49
		<element name="OUTPUT_DESCRIPTION" text="" description="Descripci&#243;n" type="2">
50
		</element>
51
		<element name="RESULT" text="" description="Disperse Points" type="2">
52
		</element>
53
	</help>
54
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/resources/help/DispersePointsAlgorithm_en.xml
1
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
2
<!--
3

  
4
  gvSIG. Desktop Geographic Information System.
5

  
6
  Copyright ? 2007-2017 gvSIG Association
7

  
8
  This program is free software; you can redistribute it and/or
9
  modify it under the terms of the GNU General Public License
10
  as published by the Free Software Foundation; either version 2
11
  of the License, or (at your option) any later version.
12

  
13
  This program is distributed in the hope that it will be useful,
14
  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
  GNU General Public License for more details.
17

  
18
  You should have received a copy of the GNU General Public License
19
  along with this program; if not, write to the Free Software
20
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
  MA  02110-1301, USA.
22

  
23
  For any additional information, do not hesitate to contact us
24
  at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26

  
27
-->
28
	<help>
29
		<element name="DESCRIPTION" text="Este geoproceso, permite dispersar los puntos de una capa que se superponen alrededor de un punto central. Dada una capa de puntos, una distancia de concordancia y un radio de dispersi?n, este algoritmo se recorre la capa de origen buscando grupos de puntos cuya distancia sea menor o igual a la distancia de concordancia y los dispersa alrededor del centro de dicho grupo, generando una nueva capa de puntos con el resultado." description="Descripci&#243;n" type="0">
30
			<!-- <image description="" file="spatialjoindesc.png">
31
			</image> -->
32
		</element>
33
		<element name="ADDITIONAL_INFO" text="" description="Informaci&#243;n adicional" type="0">
34
		</element>
35
		<element name="EXTENSION_AUTHOR" text="Francisco D?az" description="Algoritmo creado por" type="0">
36
		</element>
37
		<element name="HELP_AUTHOR" text="" description="Ayuda creada por" type="0">
38
		</element>
39
		<element name="USER_NOTES" text="" description="Notas de usuario" type="0">
40
		</element>
41
		<element name="LAYER" text="" description="Capa de entrada" type="3">
42
		</element>
43
		<element name="SELECTED_GEOM" text="" description="Geometrias seleccionadas" type="3">
44
		</element>
45
		<element name="SCATTER_RADIUS" text="" description="Radio de dispersi&#243;n" type="3">
46
		</element>
47
		<element name="MATCH_DISTANCE" text="" description="Distancia de concordancia" type="3">
48
		</element>
49
		<element name="OUTPUT_DESCRIPTION" text="" description="Descripci&#243;n" type="2">
50
		</element>
51
		<element name="RESULT" text="" description="Disperse Points" type="2">
52
		</element>
53
	</help>
54
<?xml version='1.0' encoding='ISO-8859-1' standalone='yes' ?>
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.geoprocess.algorithm.dispersepoints.DispersePointsLibrary
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/java/org/gvsig/geoprocess/algorithm/dispersepoints/DispersePointsParametersPanelController.java
1
package org.gvsig.geoprocess.algorithm.dispersepoints;
2

  
3
import java.awt.event.ActionEvent;
4
import java.awt.event.ActionListener;
5
import java.awt.event.ItemEvent;
6
import java.awt.event.ItemListener;
7
import java.util.Locale;
8

  
9
import javax.swing.ComboBoxModel;
10
import javax.swing.DefaultComboBoxModel;
11

  
12
import es.unex.sextante.core.GeoAlgorithm;
13
import es.unex.sextante.core.ObjectAndDescription;
14
import es.unex.sextante.dataObjects.IVectorLayer;
15
import es.unex.sextante.exceptions.WrongInputException;
16
import es.unex.sextante.gui.core.SextanteGUI;
17
import es.unex.sextante.gui.exceptions.LayerCannotBeOverwrittenException;
18
import es.unex.sextante.gui.exceptions.OverwrittingNotAllowedException;
19

  
20
import org.slf4j.Logger;
21
import org.slf4j.LoggerFactory;
22

  
23
import org.gvsig.tools.ToolsLocator;
24
import org.gvsig.tools.i18n.I18nManager;
25

  
26

  
27
/**
28
 * @author fdiaz
29
 *
30
 */
31
public class DispersePointsParametersPanelController extends DispersePointsParametersPanelView {
32

  
33
    /**
34
     *
35
     */
36
    private static final long serialVersionUID = -616874811240067305L;
37
    @SuppressWarnings("unused")
38
    private static final Logger LOG = LoggerFactory
39
        .getLogger(DispersePointsParametersPanelController.class);
40
    private IVectorLayer inputLayer;
41

  
42

  
43

  
44
    /**
45
     * @param mapContext
46
     * @param explorer
47
     * @param filters
48
     */
49
    public DispersePointsParametersPanelController() {
50
        super();
51
    }
52

  
53
    private void translate() {
54
        I18nManager i18nManager = ToolsLocator.getI18nManager();
55
        lblInputPointLayer.setText(i18nManager.getTranslation(lblInputPointLayer.getText()));
56
        lblInputPointLayer.setToolTipText(i18nManager.getTranslation(lblInputPointLayer.getToolTipText()));
57

  
58
        cmbInputLayer.setToolTipText(i18nManager.getTranslation(cmbInputLayer.getToolTipText()));
59

  
60
        lblScatterRadius.setText(i18nManager.getTranslation(lblScatterRadius.getText()));
61
        lblScatterRadius.setToolTipText(i18nManager.getTranslation(lblScatterRadius.getToolTipText()));
62

  
63
        txtScatterRadius.setToolTipText(i18nManager.getTranslation(txtScatterRadius.getToolTipText()));
64
        txtMatchDistance.setToolTipText(i18nManager.getTranslation(txtMatchDistance.getToolTipText()));
65
    }
66

  
67
    /**
68
     * @param locale
69
    *
70
    */
71
    public void setLocate(Locale locale) {
72
        Locale l = super.getLocale();
73
        if (!l.equals(locale)) {
74
            translate();
75
        }
76
        super.setLocale(locale);
77
    }
78

  
79
    private void initComponents() {
80

  
81
        ComboBoxModel comboModel = new DefaultComboBoxModel(getLayerList());
82
        this.cmbInputLayer.setModel(comboModel);
83
        this.cmbInputLayer.addActionListener(new ActionListener() {
84

  
85
            @Override
86
            public void actionPerformed(ActionEvent e) {
87
                doChangeInputLayer();
88
            }
89
        });
90

  
91
        this.cmbInputLayer.addItemListener(new ItemListener() {
92

  
93
            @Override
94
            public void itemStateChanged(ItemEvent e) {
95
                doChangeInputLayer();
96
                // TODO Auto-generated method stub
97
            }
98
        });
99
//
100
//        this.btnProperties.addActionListener(new ActionListener() {
101
//            public void actionPerformed(ActionEvent e) {
102
//                doOpenProperties();
103
//            }
104
//        });
105
//
106
//        this.btnRemove.addActionListener(new ActionListener() {
107
//            public void actionPerformed(ActionEvent e) {
108
//                doRemove();
109
//            }
110
//        });
111
//
112
//        this.btnUp.addActionListener(new ActionListener() {
113
//            public void actionPerformed(ActionEvent e) {
114
//                doUp();
115
//            }
116
//        });
117
//
118
//        this.btnDown.addActionListener(new ActionListener() {
119
//            public void actionPerformed(ActionEvent e) {
120
//                doDown();
121
//            }
122
//        });
123
//
124
//        I18nManager i18nManager = ToolsLocator.getI18nManager();
125
//
126
//        this.tableFiles.setModel(new FilesystemExplorerWizardTableModel());
127
//        this.tableFiles.getColumn(
128
//            i18nManager.getTranslation(FilesystemExplorerWizardTableModel.COLUMN_STORE_PARAMETERS_NAME))
129
//            .setCellRenderer(new FilesystemStoreParameteresCellRenderer(mapContext));
130
//        TableColumn columnTiled = this.tableFiles.getColumn(
131
//            i18nManager.getTranslation(FilesystemExplorerWizardTableModel.COLUMN_TILED_NAME));
132
//        columnTiled.setMaxWidth(80);
133
//        columnTiled.setCellRenderer(new TiledCellRenderer());
134
//        this.tableFiles.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
135
//        this.tableFiles.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
136
//
137
//            public void valueChanged(ListSelectionEvent e) {
138
//                handleSelectionEvent(e);
139
//            }
140
//        });
141
    }
142

  
143

  
144
    /**
145
     *
146
     */
147
    protected void doChangeInputLayer() {
148
        if(cmbInputLayer.getSelectedItem() != null)
149
        inputLayer = (IVectorLayer)((ObjectAndDescription)cmbInputLayer.getSelectedItem()).getObject();
150
    }
151

  
152
    protected void updateComponents() {
153
//        btnUp.setEnabled(selectedIndex > 0 && selectedIndex < tableFiles.getRowCount());
154
//        btnDown.setEnabled(selectedIndex >= 0 && selectedIndex < (tableFiles.getRowCount() - 1));
155
//        btnProperties.setEnabled(selectedIndex >= 0 && selectedIndex < tableFiles.getRowCount());
156
//        btnRemove.setEnabled(selectedIndex >= 0 && selectedIndex < tableFiles.getRowCount());
157
    }
158

  
159
    /* (non-Javadoc)
160
     * @see es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel#init(es.unex.sextante.core.GeoAlgorithm)
161
     */
162
    @Override
163
    public void init(GeoAlgorithm algorithm) {
164
        // TODO Auto-generated method stub
165

  
166
    }
167

  
168
    /* (non-Javadoc)
169
     * @see es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel#assignParameters()
170
     */
171
    @Override
172
    public void assignParameters() throws WrongInputException, OverwrittingNotAllowedException,
173
        LayerCannotBeOverwrittenException {
174
        // TODO Auto-generated method stub
175

  
176
    }
177

  
178
    /* (non-Javadoc)
179
     * @see es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel#setParameterValue(java.lang.String, java.lang.String)
180
     */
181
    @Override
182
    public void setParameterValue(String sParameterName, String sValue) {
183
        // TODO Auto-generated method stub
184

  
185
    }
186

  
187
    /* (non-Javadoc)
188
     * @see es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel#setOutputValue(java.lang.String, java.lang.String)
189
     */
190
    @Override
191
    public void setOutputValue(String sOutputName, String sValue) {
192
        // TODO Auto-generated method stub
193

  
194
    }
195

  
196
    /**
197
     * Gets the input layer list
198
     * @return
199
     */
200
    private ObjectAndDescription[] getLayerList() {
201
        IVectorLayer[] layers = SextanteGUI.getInputFactory()
202
                    .getVectorLayers(IVectorLayer.SHAPE_TYPE_POINT);
203
        ObjectAndDescription[] oad = new ObjectAndDescription[layers.length];
204
        for (int i = 0; i < layers.length; i++)
205
            oad[i] = new ObjectAndDescription(layers[i].getName(), layers[i]);
206
        return oad;
207
    }
208

  
209

  
210
}
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/java/org/gvsig/geoprocess/algorithm/dispersepoints/DispersePointsParametersPanelView.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<object classname="com.jeta.forms.store.memento.FormPackage">
4
 <at name="fileversion">
5
  <object classname="com.jeta.forms.store.memento.FormsVersion2">
6
   <at name="major">2</at>
7
   <at name="minor">0</at>
8
   <at name="sub">0</at>
9
  </object>
10
 </at>
11
 <at name="form">
12
  <object classname="com.jeta.forms.store.memento.FormMemento">
13
   <super classname="com.jeta.forms.store.memento.ComponentMemento">
14
    <at name="cellconstraints">
15
     <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
16
      <at name="column">1</at>
17
      <at name="row">1</at>
18
      <at name="colspan">1</at>
19
      <at name="rowspan">1</at>
20
      <at name="halign">default</at>
21
      <at name="valign">default</at>
22
      <at name="insets" object="insets">0,0,0,0</at>
23
     </object>
24
    </at>
25
    <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
26
   </super>
27
   <at name="id">K819caaeH15d43913ebaFQ8000</at>
28
   <at name="rowspecs">CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:2DLU:NONE</at>
29
   <at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE</at>
30
   <at name="components">
31
    <object classname="java.util.LinkedList">
32
     <item >
33
      <at name="value">
34
       <object classname="com.jeta.forms.store.memento.BeanMemento">
35
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
36
         <at name="cellconstraints">
37
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
38
           <at name="column">2</at>
39
           <at name="row">2</at>
40
           <at name="colspan">1</at>
41
           <at name="rowspan">1</at>
42
           <at name="halign">default</at>
43
           <at name="valign">default</at>
44
           <at name="insets" object="insets">0,0,0,0</at>
45
          </object>
46
         </at>
47
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
48
        </super>
49
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
50
        <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
51
        <at name="beanproperties">
52
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
53
          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
54
          <at name="properties">
55
           <object classname="com.jeta.forms.store.support.PropertyMap">
56
            <at name="border">
57
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
58
              <super classname="com.jeta.forms.store.properties.BorderProperty">
59
               <at name="name">border</at>
60
              </super>
61
              <at name="borders">
62
               <object classname="java.util.LinkedList">
63
                <item >
64
                 <at name="value">
65
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
66
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
67
                    <at name="name">border</at>
68
                   </super>
69
                  </object>
70
                 </at>
71
                </item>
72
               </object>
73
              </at>
74
             </object>
75
            </at>
76
            <at name="name">lblInputPointLayer</at>
77
            <at name="width">102</at>
78
            <at name="text">_input_point_layer</at>
79
            <at name="fill">
80
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
81
              <at name="name">fill</at>
82
             </object>
83
            </at>
84
            <at name="toolTipText">_input_point_layer</at>
85
            <at name="height">14</at>
86
           </object>
87
          </at>
88
         </object>
89
        </at>
90
       </object>
91
      </at>
92
     </item>
93
     <item >
94
      <at name="value">
95
       <object classname="com.jeta.forms.store.memento.BeanMemento">
96
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
97
         <at name="cellconstraints">
98
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
99
           <at name="column">4</at>
100
           <at name="row">2</at>
101
           <at name="colspan">1</at>
102
           <at name="rowspan">1</at>
103
           <at name="halign">default</at>
104
           <at name="valign">default</at>
105
           <at name="insets" object="insets">0,0,0,0</at>
106
          </object>
107
         </at>
108
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
109
        </super>
110
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
111
        <at name="beanclass">javax.swing.JComboBox</at>
112
        <at name="beanproperties">
113
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
114
          <at name="classname">javax.swing.JComboBox</at>
115
          <at name="properties">
116
           <object classname="com.jeta.forms.store.support.PropertyMap">
117
            <at name="border">
118
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
119
              <super classname="com.jeta.forms.store.properties.BorderProperty">
120
               <at name="name">border</at>
121
              </super>
122
              <at name="borders">
123
               <object classname="java.util.LinkedList">
124
                <item >
125
                 <at name="value">
126
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
127
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
128
                    <at name="name">border</at>
129
                   </super>
130
                  </object>
131
                 </at>
132
                </item>
133
               </object>
134
              </at>
135
             </object>
136
            </at>
137
            <at name="name">cmbInputLayer</at>
138
            <at name="width">819</at>
139
            <at name="items">
140
             <object classname="com.jeta.forms.store.properties.ItemsProperty">
141
              <at name="name">items</at>
142
             </object>
143
            </at>
144
            <at name="toolTipText">_input_layer</at>
145
            <at name="height">20</at>
146
           </object>
147
          </at>
148
         </object>
149
        </at>
150
       </object>
151
      </at>
152
     </item>
153
     <item >
154
      <at name="value">
155
       <object classname="com.jeta.forms.store.memento.BeanMemento">
156
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
157
         <at name="cellconstraints">
158
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
159
           <at name="column">2</at>
160
           <at name="row">6</at>
161
           <at name="colspan">1</at>
162
           <at name="rowspan">1</at>
163
           <at name="halign">default</at>
164
           <at name="valign">default</at>
165
           <at name="insets" object="insets">0,0,0,0</at>
166
          </object>
167
         </at>
168
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
169
        </super>
170
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
171
        <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
172
        <at name="beanproperties">
173
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
174
          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
175
          <at name="properties">
176
           <object classname="com.jeta.forms.store.support.PropertyMap">
177
            <at name="border">
178
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
179
              <super classname="com.jeta.forms.store.properties.BorderProperty">
180
               <at name="name">border</at>
181
              </super>
182
              <at name="borders">
183
               <object classname="java.util.LinkedList">
184
                <item >
185
                 <at name="value">
186
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
187
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
188
                    <at name="name">border</at>
189
                   </super>
190
                  </object>
191
                 </at>
192
                </item>
193
               </object>
194
              </at>
195
             </object>
196
            </at>
197
            <at name="name">lblScatterRadius</at>
198
            <at name="width">102</at>
199
            <at name="text">_scatter_radius</at>
200
            <at name="fill">
201
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
202
              <at name="name">fill</at>
203
             </object>
204
            </at>
205
            <at name="toolTipText">scatter_radius</at>
206
            <at name="height">14</at>
207
           </object>
208
          </at>
209
         </object>
210
        </at>
211
       </object>
212
      </at>
213
     </item>
214
     <item >
215
      <at name="value">
216
       <object classname="com.jeta.forms.store.memento.BeanMemento">
217
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
218
         <at name="cellconstraints">
219
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
220
           <at name="column">4</at>
221
           <at name="row">6</at>
222
           <at name="colspan">1</at>
223
           <at name="rowspan">1</at>
224
           <at name="halign">default</at>
225
           <at name="valign">default</at>
226
           <at name="insets" object="insets">0,0,0,0</at>
227
          </object>
228
         </at>
229
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
230
        </super>
231
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
232
        <at name="beanclass">javax.swing.JFormattedTextField</at>
233
        <at name="beanproperties">
234
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
235
          <at name="classname">javax.swing.JFormattedTextField</at>
236
          <at name="properties">
237
           <object classname="com.jeta.forms.store.support.PropertyMap">
238
            <at name="border">
239
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
240
              <super classname="com.jeta.forms.store.properties.BorderProperty">
241
               <at name="name">border</at>
242
              </super>
243
              <at name="borders">
244
               <object classname="java.util.LinkedList">
245
                <item >
246
                 <at name="value">
247
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
248
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
249
                    <at name="name">border</at>
250
                   </super>
251
                  </object>
252
                 </at>
253
                </item>
254
               </object>
255
              </at>
256
             </object>
257
            </at>
258
            <at name="name">txtScatterRadius</at>
259
            <at name="width">819</at>
260
            <at name="toolTipText">_scatter_radius</at>
261
            <at name="height">20</at>
262
           </object>
263
          </at>
264
         </object>
265
        </at>
266
       </object>
267
      </at>
268
     </item>
269
     <item >
270
      <at name="value">
271
       <object classname="com.jeta.forms.store.memento.BeanMemento">
272
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
273
         <at name="cellconstraints">
274
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
275
           <at name="column">2</at>
276
           <at name="row">4</at>
277
           <at name="colspan">1</at>
278
           <at name="rowspan">1</at>
279
           <at name="halign">default</at>
280
           <at name="valign">default</at>
281
           <at name="insets" object="insets">0,0,0,0</at>
282
          </object>
283
         </at>
284
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
285
        </super>
286
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
287
        <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
288
        <at name="beanproperties">
289
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
290
          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
291
          <at name="properties">
292
           <object classname="com.jeta.forms.store.support.PropertyMap">
293
            <at name="border">
294
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
295
              <super classname="com.jeta.forms.store.properties.BorderProperty">
296
               <at name="name">border</at>
297
              </super>
298
              <at name="borders">
299
               <object classname="java.util.LinkedList">
300
                <item >
301
                 <at name="value">
302
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
303
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
304
                    <at name="name">border</at>
305
                   </super>
306
                  </object>
307
                 </at>
308
                </item>
309
               </object>
310
              </at>
311
             </object>
312
            </at>
313
            <at name="name"></at>
314
            <at name="width">102</at>
315
            <at name="text">_match_distance</at>
316
            <at name="fill">
317
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
318
              <at name="name">fill</at>
319
             </object>
320
            </at>
321
            <at name="toolTipText">_match_distance</at>
322
            <at name="height">14</at>
323
           </object>
324
          </at>
325
         </object>
326
        </at>
327
       </object>
328
      </at>
329
     </item>
330
     <item >
331
      <at name="value">
332
       <object classname="com.jeta.forms.store.memento.BeanMemento">
333
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
334
         <at name="cellconstraints">
335
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
336
           <at name="column">4</at>
337
           <at name="row">4</at>
338
           <at name="colspan">1</at>
339
           <at name="rowspan">1</at>
340
           <at name="halign">default</at>
341
           <at name="valign">default</at>
342
           <at name="insets" object="insets">0,0,0,0</at>
343
          </object>
344
         </at>
345
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
346
        </super>
347
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
348
        <at name="beanclass">javax.swing.JFormattedTextField</at>
349
        <at name="beanproperties">
350
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
351
          <at name="classname">javax.swing.JFormattedTextField</at>
352
          <at name="properties">
353
           <object classname="com.jeta.forms.store.support.PropertyMap">
354
            <at name="border">
355
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
356
              <super classname="com.jeta.forms.store.properties.BorderProperty">
357
               <at name="name">border</at>
358
              </super>
359
              <at name="borders">
360
               <object classname="java.util.LinkedList">
361
                <item >
362
                 <at name="value">
363
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
364
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
365
                    <at name="name">border</at>
366
                   </super>
367
                  </object>
368
                 </at>
369
                </item>
370
               </object>
371
              </at>
372
             </object>
373
            </at>
374
            <at name="name">txtMatchDistance</at>
375
            <at name="width">819</at>
376
            <at name="toolTipText">_match_distance</at>
377
            <at name="height">20</at>
378
           </object>
379
          </at>
380
         </object>
381
        </at>
382
       </object>
383
      </at>
384
     </item>
385
     <item >
386
      <at name="value">
387
       <object classname="com.jeta.forms.store.memento.BeanMemento">
388
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
389
         <at name="cellconstraints">
390
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
391
           <at name="column">2</at>
392
           <at name="row">8</at>
393
           <at name="colspan">3</at>
394
           <at name="rowspan">1</at>
395
           <at name="halign">default</at>
396
           <at name="valign">default</at>
397
           <at name="insets" object="insets">0,0,0,0</at>
398
          </object>
399
         </at>
400
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
401
        </super>
402
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
403
        <at name="beanclass">javax.swing.JPanel</at>
404
        <at name="beanproperties">
405
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
406
          <at name="classname">javax.swing.JPanel</at>
407
          <at name="properties">
408
           <object classname="com.jeta.forms.store.support.PropertyMap">
409
            <at name="name">pnlOutputPanel</at>
410
            <at name="width">932</at>
411
            <at name="height">12</at>
412
           </object>
413
          </at>
414
         </object>
415
        </at>
416
       </object>
417
      </at>
418
     </item>
419
    </object>
420
   </at>
421
   <at name="properties">
422
    <object classname="com.jeta.forms.store.memento.PropertiesMemento">
423
     <at name="classname">com.jeta.forms.gui.form.GridView</at>
424
     <at name="properties">
425
      <object classname="com.jeta.forms.store.support.PropertyMap">
426
       <at name="border">
427
        <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
428
         <super classname="com.jeta.forms.store.properties.BorderProperty">
429
          <at name="name">border</at>
430
         </super>
431
         <at name="borders">
432
          <object classname="java.util.LinkedList"/>
433
         </at>
434
        </object>
435
       </at>
436
       <at name="name"></at>
437
       <at name="fill">
438
        <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
439
         <at name="name">fill</at>
440
        </object>
441
       </at>
442
       <at name="scollBars">
443
        <object classname="com.jeta.forms.store.properties.ScrollBarsProperty">
444
         <at name="name">scollBars</at>
445
         <at name="verticalpolicy">21</at>
446
         <at name="horizontalpolicy">31</at>
447
        </object>
448
       </at>
449
      </object>
450
     </at>
451
    </object>
452
   </at>
453
   <at name="cellpainters">
454
    <object classname="com.jeta.forms.store.support.Matrix">
455
     <at name="rows">
456
      <object classname="[Ljava.lang.Object;" size="9">
457
       <at name="item" index="0">
458
        <object classname="[Ljava.lang.Object;" size="5"/>
459
       </at>
460
       <at name="item" index="1">
461
        <object classname="[Ljava.lang.Object;" size="5"/>
462
       </at>
463
       <at name="item" index="2">
464
        <object classname="[Ljava.lang.Object;" size="5"/>
465
       </at>
466
       <at name="item" index="3">
467
        <object classname="[Ljava.lang.Object;" size="5"/>
468
       </at>
469
       <at name="item" index="4">
470
        <object classname="[Ljava.lang.Object;" size="5"/>
471
       </at>
472
       <at name="item" index="5">
473
        <object classname="[Ljava.lang.Object;" size="5"/>
474
       </at>
475
       <at name="item" index="6">
476
        <object classname="[Ljava.lang.Object;" size="5"/>
477
       </at>
478
       <at name="item" index="7">
479
        <object classname="[Ljava.lang.Object;" size="5"/>
480
       </at>
481
       <at name="item" index="8">
482
        <object classname="[Ljava.lang.Object;" size="5"/>
483
       </at>
484
      </object>
485
     </at>
486
    </object>
487
   </at>
488
   <at name="rowgroups">
489
    <object classname="com.jeta.forms.store.memento.FormGroupSet">
490
     <at name="groups">
491
      <object classname="java.util.HashMap"/>
492
     </at>
493
    </object>
494
   </at>
495
   <at name="colgroups">
496
    <object classname="com.jeta.forms.store.memento.FormGroupSet">
497
     <at name="groups">
498
      <object classname="java.util.HashMap"/>
499
     </at>
500
    </object>
501
   </at>
502
  </object>
503
 </at>
504
</object>
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/java/org/gvsig/geoprocess/algorithm/dispersepoints/DispersePointsParametersPanelView.java
1
package org.gvsig.geoprocess.algorithm.dispersepoints;
2

  
3
import com.jeta.open.i18n.I18NUtils;
4
import com.jgoodies.forms.layout.CellConstraints;
5
import com.jgoodies.forms.layout.FormLayout;
6

  
7
import es.unex.sextante.gui.algorithm.GeoAlgorithmParametersPanel;
8

  
9
import java.awt.BorderLayout;
10
import java.awt.ComponentOrientation;
11
import java.awt.Container;
12
import java.awt.Dimension;
13

  
14
import javax.swing.Box;
15
import javax.swing.ImageIcon;
16
import javax.swing.JComboBox;
17
import javax.swing.JFormattedTextField;
18
import javax.swing.JFrame;
19
import javax.swing.JLabel;
20
import javax.swing.JPanel;
21

  
22

  
23
public abstract class DispersePointsParametersPanelView extends GeoAlgorithmParametersPanel
24
{
25
   JLabel lblInputPointLayer = new JLabel();
26
   JComboBox cmbInputLayer = new JComboBox();
27
   JLabel lblScatterRadius = new JLabel();
28
   JFormattedTextField txtScatterRadius = new JFormattedTextField();
29
   JFormattedTextField txtMatchDistance = new JFormattedTextField();
30
   JPanel pnlOutputPanel = new JPanel();
31

  
32
   /**
33
    * Default constructor
34
    */
35
   public DispersePointsParametersPanelView()
36
   {
37
      initializePanel();
38
   }
39

  
40
   /**
41
    * Adds fill components to empty cells in the first row and first column of the grid.
42
    * This ensures that the grid spacing will be the same as shown in the designer.
43
    * @param cols an array of column indices in the first row where fill components should be added.
44
    * @param rows an array of row indices in the first column where fill components should be added.
45
    */
46
   void addFillComponents( Container panel, int[] cols, int[] rows )
47
   {
48
      Dimension filler = new Dimension(10,10);
49

  
50
      boolean filled_cell_11 = false;
51
      CellConstraints cc = new CellConstraints();
52
      if ( cols.length > 0 && rows.length > 0 )
53
      {
54
         if ( cols[0] == 1 && rows[0] == 1 )
55
         {
56
            /** add a rigid area  */
57
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
58
            filled_cell_11 = true;
59
         }
60
      }
61

  
62
      for( int index = 0; index < cols.length; index++ )
63
      {
64
         if ( cols[index] == 1 && filled_cell_11 )
65
         {
66
            continue;
67
         }
68
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
69
      }
70

  
71
      for( int index = 0; index < rows.length; index++ )
72
      {
73
         if ( rows[index] == 1 && filled_cell_11 )
74
         {
75
            continue;
76
         }
77
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
78
      }
79

  
80
   }
81

  
82
   /**
83
    * Helper method to load an image file from the CLASSPATH
84
    * @param imageName the package and name of the file to load relative to the CLASSPATH
85
    * @return an ImageIcon instance with the specified image file
86
    * @throws IllegalArgumentException if the image resource cannot be loaded.
87
    */
88
   public ImageIcon loadImage( String imageName )
89
   {
90
      try
91
      {
92
         ClassLoader classloader = getClass().getClassLoader();
93
         java.net.URL url = classloader.getResource( imageName );
94
         if ( url != null )
95
         {
96
            ImageIcon icon = new ImageIcon( url );
97
            return icon;
98
         }
99
      }
100
      catch( Exception e )
101
      {
102
         e.printStackTrace();
103
      }
104
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
105
   }
106

  
107
   /**
108
    * Method for recalculating the component orientation for
109
    * right-to-left Locales.
110
    * @param orientation the component orientation to be applied
111
    */
112
   public void applyComponentOrientation( ComponentOrientation orientation )
113
   {
114
      // Not yet implemented...
115
      // I18NUtils.applyComponentOrientation(this, orientation);
116
      super.applyComponentOrientation(orientation);
117
   }
118

  
119
   public JPanel createPanel()
120
   {
121
      JPanel jpanel1 = new JPanel();
122
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:2DLU:NONE");
123
      CellConstraints cc = new CellConstraints();
124
      jpanel1.setLayout(formlayout1);
125

  
126
      lblInputPointLayer.setName("lblInputPointLayer");
127
      lblInputPointLayer.setText("_input_point_layer");
128
      lblInputPointLayer.setToolTipText("_input_point_layer");
129
      jpanel1.add(lblInputPointLayer,cc.xy(2,2));
130

  
131
      cmbInputLayer.setName("cmbInputLayer");
132
      cmbInputLayer.setToolTipText("_input_layer");
133
      jpanel1.add(cmbInputLayer,cc.xy(4,2));
134

  
135
      lblScatterRadius.setName("lblScatterRadius");
136
      lblScatterRadius.setText("_scatter_radius");
137
      lblScatterRadius.setToolTipText("scatter_radius");
138
      jpanel1.add(lblScatterRadius,cc.xy(2,6));
139

  
140
      txtScatterRadius.setName("txtScatterRadius");
141
      txtScatterRadius.setToolTipText("_scatter_radius");
142
      jpanel1.add(txtScatterRadius,cc.xy(4,6));
143

  
144
      JLabel jlabel1 = new JLabel();
145
      jlabel1.setText("_match_distance");
146
      jlabel1.setToolTipText("_match_distance");
147
      jpanel1.add(jlabel1,cc.xy(2,4));
148

  
149
      txtMatchDistance.setName("txtMatchDistance");
150
      txtMatchDistance.setToolTipText("_match_distance");
151
      jpanel1.add(txtMatchDistance,cc.xy(4,4));
152

  
153
      pnlOutputPanel.setName("pnlOutputPanel");
154
      jpanel1.add(pnlOutputPanel,cc.xywh(2,8,3,1));
155

  
156
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9 });
157
      return jpanel1;
158
   }
159

  
160
   /**
161
    * Initializer
162
    */
163
   protected void initializePanel()
164
   {
165
      setLayout(new BorderLayout());
166
      add(createPanel(), BorderLayout.CENTER);
167
   }
168

  
169

  
170
}
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/java/org/gvsig/geoprocess/algorithm/dispersepoints/DispersePointsOperation.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2017 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.geoprocess.algorithm.dispersepoints;
24

  
25
import java.util.ArrayList;
26
import java.util.Collection;
27
import java.util.HashSet;
28
import java.util.Iterator;
29
import java.util.List;
30
import java.util.ListIterator;
31
import java.util.Set;
32

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

  
35
import org.gvsig.fmap.dal.exception.DataException;
36
import org.gvsig.fmap.dal.feature.EditableFeature;
37
import org.gvsig.fmap.dal.feature.Feature;
38
import org.gvsig.fmap.dal.feature.FeatureReference;
39
import org.gvsig.fmap.geom.Geometry;
40
import org.gvsig.fmap.geom.Geometry.SUBTYPES;
41
import org.gvsig.fmap.geom.GeometryLocator;
42
import org.gvsig.fmap.geom.GeometryManager;
43
import org.gvsig.fmap.geom.SpatialIndex;
44
import org.gvsig.fmap.geom.exception.CreateGeometryException;
45
import org.gvsig.fmap.geom.primitive.Point;
46
import org.gvsig.geoprocess.algorithm.base.core.GeometryOperation;
47
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess;
48

  
49
/**
50
 * Disperse points operation
51
 *
52
 * @author fdiaz</a>
53
 */
54
public class DispersePointsOperation extends GeometryOperation {
55

  
56
    private SpatialIndex index;
57
    private double scatterRadius;
58
    private double matchDistance;
59
    private List<Set<FeatureReference>> groups;
60

  
61
    /**
62
     * Builds an instance of this operation.
63
     *
64
     * @param index
65
     * @param scatterRadius
66
     * @param matchDistance
67
     * @param p
68
     *
69
     */
70
    public DispersePointsOperation(SpatialIndex index, double scatterRadius, double matchDistance,
71
        AbstractSextanteGeoProcess p) {
72
        super(p);
73
        this.index = index;
74
        this.scatterRadius = scatterRadius;
75
        this.matchDistance = matchDistance;
76
        this.groups = new ArrayList<Set<FeatureReference>>();
77

  
78
    }
79

  
80
    public EditableFeature invoke(org.gvsig.fmap.geom.Geometry g, Feature feature) {
81
        // final MutableObject<Feature> foundFeature = new
82
        // MutableObject<Feature>(null);
83
        boolean addedFeature = false;
84
        if (g == null)
85
            return lastEditFeature;
86

  
87
        try {
88

  
89
            FeatureReference reference = feature.getReference();
90
            if (!isVisited(reference)) {
91
                Set<FeatureReference> group = new HashSet<FeatureReference>();
92
                // Iterator<?> iterator = index.queryNearest(g);
93
                Iterator<?> iterator = index.query(g.buffer(matchDistance));
94
                while (iterator.hasNext()) {
95
                    FeatureReference ref = (FeatureReference) iterator.next();
96
                    if (!isVisited(ref)) {
97
                        Feature feat = ref.getFeature().getCopy();
98
                        Geometry g2 = feat.getDefaultGeometry();
99
                        double dist = g.distance(g2);
100
                        if (dist <= matchDistance) {
101
                            group.add(ref);
102
                        }
103
                    }
104
                }
105
                groups.add(group);
106
                if (group.size() == 1) {
107
                    buildFeature(feature, g);
108
                } else {
109
                    buildFeatures(group);
110
                }
111
            }
112

  
113
        } catch (Exception e) {
114
            Sextante.addErrorToLog(e);
115
        }
116

  
117
        return lastEditFeature;
118
    }
119

  
120
    /**
121
     * @param group
122
     * @throws DataException
123
     * @throws CreateGeometryException
124
     */
125
    private void buildFeatures(Set<FeatureReference> group) throws CreateGeometryException, DataException {
126
        if (group.isEmpty()) {
127
            return;
128
        }
129

  
130
        GeometryManager geomManager = GeometryLocator.getGeometryManager();
131

  
132
        int points = group.size();
133
        Point center = getCenter(group);
134

  
135
        double step = 2 * Math.PI / points;
136
        int i = 0;
137

  
138
        for (FeatureReference ref : group) {
139
            Feature feature = ref.getFeature().getCopy();
140
            buildFeature(feature,
141
                geomManager.createPoint(
142
                    center.getX() + (Math.cos(i * step) * this.scatterRadius),
143
                    center.getY() + (Math.sin(i * step) * this.scatterRadius),
144
                    SUBTYPES.GEOM2D));
145

  
146
            i++;
147
        }
148
    }
149

  
150
    /**
151
     * @param group
152
     * @return
153
     * @throws DataException
154
     * @throws CreateGeometryException
155
     */
156
    private Point getCenter(Set<FeatureReference> group) throws DataException, CreateGeometryException {
157
        double x = 0;
158
        double y = 0;
159
        GeometryManager geomManager = GeometryLocator.getGeometryManager();
160
        for (FeatureReference ref : group) {
161
            Point point = (Point) ref.getFeature().getDefaultGeometry();
162
            x += point.getX();
163
            y += point.getY();
164
        }
165
        int size = group.size();
166
        return geomManager.createPoint(x / size, y / size, SUBTYPES.GEOM2D);
167
    }
168

  
169
    /*
170
     * (non-Javadoc)
171
     *
172
     * @see
173
     * org.gvsig.geoprocess.algorithm.base.core.GeometryOperation#invoke(org
174
     * .gvsig.fmap.geom.Geometry, org.gvsig.fmap.dal.feature.EditableFeature)
175
     */
176
    public void invoke(org.gvsig.fmap.geom.Geometry g, EditableFeature feature) {
177
        invoke(g, (Feature) feature);
178
    }
179

  
180
    /**
181
     * Builds a feature and adds it to the output file
182
     *
183
     * @param feat
184
     * @param value
185
     * @param g
186
     * @throws DataException
187
     */
188
    private void buildFeature(Feature feat, org.gvsig.fmap.geom.Geometry g) throws DataException {
189
        EditableFeature outFeat = persister.getOutputFeatureStore().createNewFeature();
190
        int sizeFeat = feat.getType().size() - 1;
191

  
192
        for (int i = 0; i < sizeFeat; i++)
193
            outFeat.set(i, feat.get(i));
194

  
195
        try {
196
            persister.addFeature(outFeat, g);
197
        } catch (CreateGeometryException e) {
198
            Sextante.addErrorToLog(e);
199
        }
200
    }
201

  
202
    private boolean isVisited(FeatureReference ref) {
203
        for (Set<FeatureReference> group : groups) {
204
            if (group.contains(ref)) {
205
                return true;
206
            }
207
        }
208
        return false;
209
    }
210
}
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/java/org/gvsig/geoprocess/algorithm/dispersepoints/DispersePointsLibrary.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.geoprocess.algorithm.dispersepoints;
25

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

  
30
public class DispersePointsLibrary extends AlgorithmAbstractLibrary {
31

  
32
    @Override
33
    protected void doInitialize() throws LibraryException {
34

  
35
    }
36

  
37
    @Override
38
    protected void doPostInitialize() throws LibraryException {
39
        Messages.addResourceFamily(
40
            "org.gvsig.geoprocess.algorithm.dispersepoints.dispersepoints",
41
            DispersePointsLibrary.class.getClassLoader(),
42
            DispersePointsLibrary.class.getClass().getName());
43
        registerGeoProcess(new DispersePointsAlgorithm());
44
    }
45

  
46
}
org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.dispersepoints/src/main/java/org/gvsig/geoprocess/algorithm/dispersepoints/DispersePointsAlgorithm.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2017 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.geoprocess.algorithm.dispersepoints;
24

  
25
import java.util.ArrayList;
26
import java.util.Iterator;
27

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

  
36
import org.gvsig.fmap.dal.DALLocator;
37
import org.gvsig.fmap.dal.DataManager;
38
import org.gvsig.fmap.dal.DataTypes;
39
import org.gvsig.fmap.dal.feature.Feature;
40
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
41
import org.gvsig.fmap.dal.feature.FeatureReference;
42
import org.gvsig.fmap.dal.feature.FeatureStore;
43
import org.gvsig.fmap.dal.feature.FeatureType;
44
import org.gvsig.fmap.geom.Geometry;
45
import org.gvsig.fmap.geom.GeometryLocator;
46
import org.gvsig.fmap.geom.GeometryManager;
47
import org.gvsig.fmap.geom.SpatialIndex;
48
import org.gvsig.fmap.geom.SpatialIndexFactory;
49
import org.gvsig.geoprocess.algorithm.base.core.GeometryOperation;
50
import org.gvsig.geoprocess.lib.sextante.AbstractSextanteGeoProcess;
51
import org.gvsig.geoprocess.lib.sextante.dataObjects.FlyrVectIVectorLayer;
52
import org.gvsig.tools.dynobject.DynObject;
53
import org.gvsig.tools.exception.BaseException;
54
import org.gvsig.tools.visitor.VisitCanceledException;
55
import org.gvsig.tools.visitor.Visitor;
56

  
57

  
58
/**
59
 * @author fdiaz
60
 *
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff