root / trunk / extensions / extGeoProcessing / src / com / iver / gvsig / geoprocessing / gui / GeoProcessingPanel.java @ 2688
History | View | Annotate | Download (38.6 KB)
1 |
/*
|
---|---|
2 |
* Created on 01-jul-2005
|
3 |
*
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
5 |
*
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
21 |
*
|
22 |
* For more information, contact:
|
23 |
*
|
24 |
* Generalitat Valenciana
|
25 |
* Conselleria d'Infraestructures i Transport
|
26 |
* Av. Blasco Ib??ez, 50
|
27 |
* 46010 VALENCIA
|
28 |
* SPAIN
|
29 |
*
|
30 |
* +34 963862235
|
31 |
* gvsig@gva.es
|
32 |
* www.gvsig.gva.es
|
33 |
*
|
34 |
* or
|
35 |
*
|
36 |
* IVER T.I. S.A
|
37 |
* Salamanca 50
|
38 |
* 46005 Valencia
|
39 |
* Spain
|
40 |
*
|
41 |
* +34 963163400
|
42 |
* dac@iver.es
|
43 |
*/
|
44 |
package com.iver.gvsig.geoprocessing.gui; |
45 |
|
46 |
import javax.swing.JCheckBox; |
47 |
import javax.swing.JComboBox; |
48 |
import javax.swing.JDialog; |
49 |
import javax.swing.JList; |
50 |
import javax.swing.JPanel; |
51 |
import javax.swing.JRadioButton; |
52 |
import javax.swing.JTextField; |
53 |
import javax.swing.JScrollPane; |
54 |
|
55 |
import com.hardcode.gdbms.engine.data.DataSource; |
56 |
import com.hardcode.gdbms.engine.instruction.IncompatibleTypesException; |
57 |
import com.hardcode.gdbms.engine.values.BooleanValue; |
58 |
import com.hardcode.gdbms.engine.values.Value; |
59 |
import com.iver.andami.PluginServices; |
60 |
import com.iver.andami.ui.mdiManager.View; |
61 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
62 |
import com.iver.cit.gvsig.fmap.DriverException; |
63 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
64 |
import com.iver.cit.gvsig.fmap.core.FShape; |
65 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
66 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
67 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
68 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
69 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
70 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
71 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
72 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
73 |
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter; |
74 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
75 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.Selectable; |
76 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.SingleLayer; |
77 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.VectorialData; |
78 |
import com.iver.cit.gvsig.fmap.operations.strategies.SelectedShapeVisitor; |
79 |
import com.iver.cit.gvsig.fmap.operations.strategies.SelectedZoomVisitor; |
80 |
import com.iver.cit.gvsig.fmap.operations.strategies.VisitException; |
81 |
import com.iver.gvsig.geoprocessing.gui.operationpanels.GeoProcessingBufferPanel; |
82 |
import com.iver.gvsig.geoprocessing.gui.operationpanels.GeoProcessingClipPanel; |
83 |
import com.iver.gvsig.geoprocessing.gui.operationpanels.GeoProcessingDissolvePanel; |
84 |
import com.iver.gvsig.geoprocessing.gui.operationpanels.GeoProcessingIntersectPanel; |
85 |
import com.iver.gvsig.geoprocessing.gui.operationpanels.GeoProcessingMergePanel; |
86 |
import com.iver.gvsig.geoprocessing.gui.operationpanels.GeoProcessingSpatialjoinPanel; |
87 |
import com.iver.gvsig.geoprocessing.gui.operationpanels.GeoProcessingUnionPanel; |
88 |
import com.iver.gvsig.geoprocessing.operations.GeoProcessingPersistenceOperations; |
89 |
import com.iver.gvsig.geoprocessing.operations.GeoProcessingTopologyOperations; |
90 |
import com.iver.gvsig.geoprocessing.operations.strategies.SelectedShapeToJTSVisitor; |
91 |
import com.vividsolutions.jts.geom.Geometry; |
92 |
|
93 |
import java.awt.Component; |
94 |
import java.awt.GridLayout; |
95 |
import java.awt.GridBagLayout; |
96 |
import java.awt.GridBagConstraints; |
97 |
import java.awt.FlowLayout; |
98 |
import java.awt.CardLayout; |
99 |
import javax.swing.BoxLayout; |
100 |
import java.awt.BorderLayout; |
101 |
import java.util.Vector; |
102 |
|
103 |
import javax.swing.JButton; |
104 |
|
105 |
public class GeoProcessingPanel extends JPanel implements View { |
106 |
|
107 |
/**
|
108 |
*
|
109 |
*/
|
110 |
private static final long serialVersionUID = 1L; |
111 |
private GeoProcessingOperationSelectorPanel geoProcessingOperationSelectorPanel = null; |
112 |
private GeoProcessingBufferPanel geoProcessingBufferPanel = null; |
113 |
private GeoProcessingClipPanel geoProcessingClipPanel = null; |
114 |
private GeoProcessingDissolvePanel geoProcessingDissolvePanel = null; |
115 |
private GeoProcessingMergePanel geoProcessingMergePanel = null; |
116 |
private GeoProcessingIntersectPanel geoProcessingIntersectPanel = null; |
117 |
private GeoProcessingUnionPanel geoProcessingUnionPanel = null; |
118 |
private GeoProcessingSpatialjoinPanel geoProcessingSpatialjoinPanel = null; |
119 |
private JPanel buttonsPanel = null; |
120 |
|
121 |
private JButton jButton = null; |
122 |
private JButton jButton1 = null; |
123 |
private JButton jButton2 = null; |
124 |
private ViewInfo viewInfo = null; |
125 |
private FLayers layers = null; |
126 |
/**
|
127 |
* This constructor initializes the set of layers
|
128 |
*/
|
129 |
public GeoProcessingPanel(FLayers layers) {
|
130 |
super();
|
131 |
this.layers = layers;
|
132 |
initialize(); |
133 |
} |
134 |
|
135 |
/**
|
136 |
* This method initializes this
|
137 |
*
|
138 |
* @return void
|
139 |
*/
|
140 |
private void initialize() { |
141 |
this.setLayout(new BorderLayout()); |
142 |
this.setSize(416, 271); |
143 |
this.add(getButtonsPanel(), java.awt.BorderLayout.SOUTH);
|
144 |
this.add(getGeoProcessingOperationSelectorPanel(), java.awt.BorderLayout.NORTH);
|
145 |
this.add(getGeoProcessingBufferPanel(), java.awt.BorderLayout.NORTH);
|
146 |
this.add(getGeoProcessingClipPanel(), java.awt.BorderLayout.NORTH);
|
147 |
this.add(getGeoProcessingDissolvePanel(), java.awt.BorderLayout.NORTH);
|
148 |
this.add(getGeoProcessingMergePanel(), java.awt.BorderLayout.NORTH);
|
149 |
this.add(getGeoProcessingIntersectPanel(), java.awt.BorderLayout.NORTH);
|
150 |
this.add(getGeoProcessingUnionPanel(), java.awt.BorderLayout.NORTH);
|
151 |
this.add(getGeoProcessingSpatialjoinPanel(), java.awt.BorderLayout.NORTH);
|
152 |
geoProcessingOperationSelectorPanel.setVisible(true);
|
153 |
geoProcessingBufferPanel.setVisible(false);
|
154 |
geoProcessingClipPanel.setVisible(false);
|
155 |
geoProcessingDissolvePanel.setVisible(false);
|
156 |
geoProcessingMergePanel.setVisible(false);
|
157 |
geoProcessingIntersectPanel.setVisible(false);
|
158 |
geoProcessingUnionPanel.setVisible(false);
|
159 |
geoProcessingSpatialjoinPanel.setVisible(false);
|
160 |
jButton1.setEnabled(false);
|
161 |
} |
162 |
|
163 |
public ViewInfo getViewInfo() {
|
164 |
// TODO Auto-generated method stub
|
165 |
if (viewInfo == null) { |
166 |
viewInfo=new ViewInfo(ViewInfo.MODALDIALOG);
|
167 |
viewInfo.setTitle(PluginServices.getText(this,"Herramientas_de_analisis")); |
168 |
} |
169 |
return viewInfo;
|
170 |
} |
171 |
|
172 |
/**
|
173 |
* This method initializes geoProcessingOperationSelectorPanel
|
174 |
*
|
175 |
* @return javax.swing.JPanel
|
176 |
*/
|
177 |
private JPanel getGeoProcessingOperationSelectorPanel() { |
178 |
if (geoProcessingOperationSelectorPanel == null) { |
179 |
geoProcessingOperationSelectorPanel = new GeoProcessingOperationSelectorPanel();
|
180 |
geoProcessingOperationSelectorPanel.setName("geoProcessingOperationSelectorPanel");
|
181 |
} |
182 |
return geoProcessingOperationSelectorPanel;
|
183 |
} |
184 |
|
185 |
/**
|
186 |
* This method initializes geoProcessingBufferPanel
|
187 |
*
|
188 |
* @return javax.swing.JPanel
|
189 |
*/
|
190 |
private JPanel getGeoProcessingBufferPanel() { |
191 |
if (geoProcessingBufferPanel == null) { |
192 |
geoProcessingBufferPanel = new GeoProcessingBufferPanel(layers);
|
193 |
geoProcessingBufferPanel.setName("geoProcessingBufferPanel");
|
194 |
} |
195 |
return geoProcessingBufferPanel;
|
196 |
} |
197 |
|
198 |
/**
|
199 |
* This method initializes geoProcessingClipPanel
|
200 |
*
|
201 |
* @return javax.swing.JPanel
|
202 |
*/
|
203 |
private JPanel getGeoProcessingClipPanel() { |
204 |
if (geoProcessingClipPanel == null) { |
205 |
geoProcessingClipPanel = new GeoProcessingClipPanel(layers);
|
206 |
geoProcessingClipPanel.setName("geoProcessingClipPanel");
|
207 |
// Si no le meto esta l?nea, no se visualiza el men?. Ver que puede
|
208 |
// estar pasando ...
|
209 |
geoProcessingClipPanel.setPreferredSize(new java.awt.Dimension(300,300)); |
210 |
} |
211 |
return geoProcessingClipPanel;
|
212 |
} |
213 |
|
214 |
/**
|
215 |
* This method initializes geoProcessingDissolvePanel
|
216 |
*
|
217 |
* @return javax.swing.JPanel
|
218 |
*/
|
219 |
private JPanel getGeoProcessingDissolvePanel() { |
220 |
if (geoProcessingDissolvePanel == null) { |
221 |
geoProcessingDissolvePanel = new GeoProcessingDissolvePanel(layers);
|
222 |
geoProcessingDissolvePanel.setName("geoProcessingDissolvePanel");
|
223 |
} |
224 |
return geoProcessingDissolvePanel;
|
225 |
} |
226 |
|
227 |
/**
|
228 |
* This method initializes geoProcessingMergePanel
|
229 |
*
|
230 |
* @return javax.swing.JPanel
|
231 |
*/
|
232 |
private JPanel getGeoProcessingMergePanel() { |
233 |
if (geoProcessingMergePanel == null) { |
234 |
geoProcessingMergePanel = new GeoProcessingMergePanel(layers);
|
235 |
geoProcessingMergePanel.setName("geoProcessingMergePanel");
|
236 |
} |
237 |
return geoProcessingMergePanel;
|
238 |
} |
239 |
|
240 |
/**
|
241 |
* This method initializes geoProcessingIntersectPanel
|
242 |
*
|
243 |
* @return javax.swing.JPanel
|
244 |
*/
|
245 |
private JPanel getGeoProcessingIntersectPanel() { |
246 |
if (geoProcessingIntersectPanel == null) { |
247 |
geoProcessingIntersectPanel = new GeoProcessingIntersectPanel(layers);
|
248 |
geoProcessingIntersectPanel.setName("geoProcessingIntersectPanel");
|
249 |
} |
250 |
return geoProcessingIntersectPanel;
|
251 |
} |
252 |
|
253 |
/**
|
254 |
* This method initializes geoProcessingUnionPanel
|
255 |
*
|
256 |
* @return javax.swing.JPanel
|
257 |
*/
|
258 |
private JPanel getGeoProcessingUnionPanel() { |
259 |
if (geoProcessingUnionPanel == null) { |
260 |
geoProcessingUnionPanel = new GeoProcessingUnionPanel(layers);
|
261 |
geoProcessingUnionPanel.setName("geoProcessingUnionPanel");
|
262 |
} |
263 |
return geoProcessingUnionPanel;
|
264 |
} |
265 |
|
266 |
/**
|
267 |
* This method initializes geoProcessingSpatialjoinPanel
|
268 |
*
|
269 |
* @return javax.swing.JPanel
|
270 |
*/
|
271 |
private JPanel getGeoProcessingSpatialjoinPanel() { |
272 |
if (geoProcessingSpatialjoinPanel == null) { |
273 |
geoProcessingSpatialjoinPanel = new GeoProcessingSpatialjoinPanel(layers);
|
274 |
geoProcessingSpatialjoinPanel.setName("geoProcessingSpatialjoinPanel");
|
275 |
// Si no le meto esta l?nea, no se visualiza el men?. Ver que puede
|
276 |
// estar pasando ...
|
277 |
geoProcessingSpatialjoinPanel.setPreferredSize(new java.awt.Dimension(300,300)); |
278 |
} |
279 |
return geoProcessingSpatialjoinPanel;
|
280 |
} |
281 |
|
282 |
/**
|
283 |
* This method initializes buttonsPanel
|
284 |
*
|
285 |
* @return javax.swing.JPanel
|
286 |
*/
|
287 |
private JPanel getButtonsPanel() { |
288 |
if (buttonsPanel == null) { |
289 |
buttonsPanel = new JPanel(); |
290 |
buttonsPanel.setName("buttonsPanel");
|
291 |
buttonsPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED)); |
292 |
buttonsPanel.add(getJButton(), null);
|
293 |
buttonsPanel.add(getJButton1(), null);
|
294 |
buttonsPanel.add(getJButton2(), null);
|
295 |
} |
296 |
return buttonsPanel;
|
297 |
} |
298 |
|
299 |
/**
|
300 |
* This method initializes jButton
|
301 |
*
|
302 |
* @return javax.swing.JButton
|
303 |
*/
|
304 |
private JButton getJButton() { |
305 |
if (jButton == null) { |
306 |
jButton = new JButton(); |
307 |
jButton.setText(PluginServices.getText(this,"Cerrar")); |
308 |
jButton.addActionListener(new java.awt.event.ActionListener() {
|
309 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
310 |
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed() |
311 |
closeMethod(); |
312 |
} |
313 |
}); |
314 |
} |
315 |
return jButton;
|
316 |
} |
317 |
/**
|
318 |
* This method initializes jButton1
|
319 |
*
|
320 |
* @return javax.swing.JButton
|
321 |
*/
|
322 |
private JButton getJButton1() { |
323 |
if (jButton1 == null) { |
324 |
jButton1 = new JButton(); |
325 |
jButton1.setText(PluginServices.getText(this,"Anterior")); |
326 |
jButton1.addActionListener(new java.awt.event.ActionListener() {
|
327 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
328 |
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed() |
329 |
getGeoProcessingOperationSelectorPanel().setVisible(true);
|
330 |
getGeoProcessingBufferPanel().setVisible(false);
|
331 |
getGeoProcessingClipPanel().setVisible(false);
|
332 |
getGeoProcessingDissolvePanel().setVisible(false);
|
333 |
getGeoProcessingMergePanel().setVisible(false);
|
334 |
getGeoProcessingIntersectPanel().setVisible(false);
|
335 |
getGeoProcessingUnionPanel().setVisible(false);
|
336 |
getGeoProcessingSpatialjoinPanel().setVisible(false);
|
337 |
jButton1.setEnabled(false);
|
338 |
jButton2.setText(PluginServices.getText(this,"Siguiente")); |
339 |
} |
340 |
}); |
341 |
} |
342 |
return jButton1;
|
343 |
} |
344 |
/**
|
345 |
* This method initializes jButton2
|
346 |
*
|
347 |
* @return javax.swing.JButton
|
348 |
*/
|
349 |
private JButton getJButton2() { |
350 |
if (jButton2 == null) { |
351 |
jButton2 = new JButton(); |
352 |
jButton2.setText(PluginServices.getText(this,"Siguiente")); |
353 |
jButton2.addActionListener(new java.awt.event.ActionListener() {
|
354 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
355 |
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed() |
356 |
if (jButton2.getText().equals(PluginServices.getText(this,"Siguiente"))) { |
357 |
if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(1)).isSelected()) { |
358 |
getGeoProcessingOperationSelectorPanel().setVisible(false);
|
359 |
getGeoProcessingBufferPanel().setVisible(true);
|
360 |
getGeoProcessingClipPanel().setVisible(false);
|
361 |
getGeoProcessingDissolvePanel().setVisible(false);
|
362 |
getGeoProcessingMergePanel().setVisible(false);
|
363 |
getGeoProcessingIntersectPanel().setVisible(false);
|
364 |
getGeoProcessingUnionPanel().setVisible(false);
|
365 |
getGeoProcessingSpatialjoinPanel().setVisible(false);
|
366 |
} else if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(2)).isSelected()) { |
367 |
getGeoProcessingOperationSelectorPanel().setVisible(false);
|
368 |
getGeoProcessingBufferPanel().setVisible(false);
|
369 |
getGeoProcessingClipPanel().setVisible(true);
|
370 |
getGeoProcessingDissolvePanel().setVisible(false);
|
371 |
getGeoProcessingMergePanel().setVisible(false);
|
372 |
getGeoProcessingIntersectPanel().setVisible(false);
|
373 |
getGeoProcessingUnionPanel().setVisible(false);
|
374 |
getGeoProcessingSpatialjoinPanel().setVisible(false);
|
375 |
} else if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(3)).isSelected()) { |
376 |
getGeoProcessingOperationSelectorPanel().setVisible(false);
|
377 |
getGeoProcessingBufferPanel().setVisible(false);
|
378 |
getGeoProcessingClipPanel().setVisible(false);
|
379 |
getGeoProcessingDissolvePanel().setVisible(true);
|
380 |
getGeoProcessingMergePanel().setVisible(false);
|
381 |
getGeoProcessingIntersectPanel().setVisible(false);
|
382 |
getGeoProcessingUnionPanel().setVisible(false);
|
383 |
getGeoProcessingSpatialjoinPanel().setVisible(false);
|
384 |
} else if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(4)).isSelected()) { |
385 |
getGeoProcessingOperationSelectorPanel().setVisible(false);
|
386 |
getGeoProcessingBufferPanel().setVisible(false);
|
387 |
getGeoProcessingClipPanel().setVisible(false);
|
388 |
getGeoProcessingDissolvePanel().setVisible(false);
|
389 |
getGeoProcessingMergePanel().setVisible(true);
|
390 |
getGeoProcessingIntersectPanel().setVisible(false);
|
391 |
getGeoProcessingUnionPanel().setVisible(false);
|
392 |
getGeoProcessingSpatialjoinPanel().setVisible(false);
|
393 |
} else if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(5)).isSelected()) { |
394 |
getGeoProcessingOperationSelectorPanel().setVisible(false);
|
395 |
getGeoProcessingBufferPanel().setVisible(false);
|
396 |
getGeoProcessingClipPanel().setVisible(false);
|
397 |
getGeoProcessingDissolvePanel().setVisible(false);
|
398 |
getGeoProcessingMergePanel().setVisible(false);
|
399 |
getGeoProcessingIntersectPanel().setVisible(true);
|
400 |
getGeoProcessingUnionPanel().setVisible(false);
|
401 |
getGeoProcessingSpatialjoinPanel().setVisible(false);
|
402 |
} else if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(6)).isSelected()) { |
403 |
getGeoProcessingOperationSelectorPanel().setVisible(false);
|
404 |
getGeoProcessingBufferPanel().setVisible(false);
|
405 |
getGeoProcessingClipPanel().setVisible(false);
|
406 |
getGeoProcessingDissolvePanel().setVisible(false);
|
407 |
getGeoProcessingMergePanel().setVisible(false);
|
408 |
getGeoProcessingIntersectPanel().setVisible(false);
|
409 |
getGeoProcessingUnionPanel().setVisible(true);
|
410 |
getGeoProcessingSpatialjoinPanel().setVisible(false);
|
411 |
} else if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(7)).isSelected()) { |
412 |
getGeoProcessingOperationSelectorPanel().setVisible(false);
|
413 |
getGeoProcessingBufferPanel().setVisible(false);
|
414 |
getGeoProcessingClipPanel().setVisible(false);
|
415 |
getGeoProcessingDissolvePanel().setVisible(false);
|
416 |
getGeoProcessingMergePanel().setVisible(false);
|
417 |
getGeoProcessingIntersectPanel().setVisible(false);
|
418 |
getGeoProcessingUnionPanel().setVisible(false);
|
419 |
getGeoProcessingSpatialjoinPanel().setVisible(true);
|
420 |
} else {
|
421 |
// Si no hay ninguna operaci?n de geoprocesamiento seleccionada no se cambia el di?logo de opciones.
|
422 |
getGeoProcessingOperationSelectorPanel().setVisible(true);
|
423 |
getGeoProcessingBufferPanel().setVisible(false);
|
424 |
getGeoProcessingClipPanel().setVisible(false);
|
425 |
getGeoProcessingDissolvePanel().setVisible(false);
|
426 |
getGeoProcessingMergePanel().setVisible(false);
|
427 |
getGeoProcessingIntersectPanel().setVisible(false);
|
428 |
getGeoProcessingUnionPanel().setVisible(false);
|
429 |
getGeoProcessingSpatialjoinPanel().setVisible(false);
|
430 |
} |
431 |
jButton1.setEnabled(true);
|
432 |
jButton2.setText(PluginServices.getText(this,"Terminar")); |
433 |
} else if (jButton2.getText().equals(PluginServices.getText(this,"Terminar"))) { |
434 |
if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(1)).isSelected()) { |
435 |
bufferMethod(); |
436 |
} else if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(2)).isSelected()) { |
437 |
clipMethod(); |
438 |
} else if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(3)).isSelected()) { |
439 |
dissolveMethod(); |
440 |
} else if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(4)).isSelected()) { |
441 |
mergeMethod(); |
442 |
} else if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(5)).isSelected()) { |
443 |
intersectMethod(); |
444 |
} else if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(6)).isSelected()) { |
445 |
unionMethod(); |
446 |
} else if (((JRadioButton)geoProcessingOperationSelectorPanel.getComponent(7)).isSelected()) { |
447 |
spatialjoinMethod(); |
448 |
} else {
|
449 |
//
|
450 |
} |
451 |
closeMethod(); |
452 |
} |
453 |
} |
454 |
}); |
455 |
} |
456 |
return jButton2;
|
457 |
} |
458 |
private Geometry[] getJtsGeometries(FLayer bufferingLayer, boolean selected) { |
459 |
FBitSet fBitSet = ((Selectable)bufferingLayer).getSelection(); |
460 |
// Extraigo todos los elementos de la capa o solo los seleccionados
|
461 |
//if (!((JCheckBox)component).isSelected()) {
|
462 |
if (!selected) {
|
463 |
VectorialAdapter va = (VectorialAdapter)((SingleLayer)bufferingLayer).getSource(); |
464 |
fBitSet = new FBitSet();
|
465 |
try {
|
466 |
for (int i=0;i<va.getShapeCount();i++) { |
467 |
fBitSet.set(i); |
468 |
} |
469 |
} catch (DriverIOException e) {
|
470 |
// TODO Auto-generated catch block
|
471 |
e.printStackTrace(); |
472 |
} |
473 |
((Selectable)bufferingLayer).setSelection(fBitSet); |
474 |
} |
475 |
SelectedShapeToJTSVisitor visitor = new SelectedShapeToJTSVisitor();
|
476 |
try {
|
477 |
((VectorialData)bufferingLayer).process(visitor); |
478 |
} catch (DriverException e1) {
|
479 |
// TODO Auto-generated catch block
|
480 |
e1.printStackTrace(); |
481 |
} catch (VisitException e1) {
|
482 |
// TODO Auto-generated catch block
|
483 |
e1.printStackTrace(); |
484 |
} |
485 |
// Si no hab?an elementos seleccionados, cambio la selecci?n temporal
|
486 |
// completa actual por la original selecci?n nula
|
487 |
if (!selected) ((Selectable)bufferingLayer).clearSelection();
|
488 |
// Almaceno en un vector los elementos para el buffer
|
489 |
return visitor.getJtsGeometries();
|
490 |
} |
491 |
private IGeometry[] getFmapGeometries(Geometry[] jtsGeometries) { |
492 |
FShape[] shapes = new FShape[jtsGeometries.length]; |
493 |
IGeometry[] geoms = new IGeometry[jtsGeometries.length]; |
494 |
for (int i=0;i<jtsGeometries.length;i++) { |
495 |
shapes[i] = FConverter.jts_to_java2d(jtsGeometries[i]); |
496 |
geoms[i] = ShapeFactory.createGeometry(shapes[i]); |
497 |
} |
498 |
return geoms;
|
499 |
} |
500 |
private void bufferMethod() { |
501 |
String bufferingLayerName = (String)((JComboBox)geoProcessingBufferPanel.getComponent(2)).getSelectedItem(); |
502 |
FLayer bufferingLayer = layers.getLayer(bufferingLayerName); |
503 |
boolean selected = false; |
504 |
if (((JCheckBox)geoProcessingBufferPanel.getComponent(3)).isSelected()) selected = true; |
505 |
Geometry[] geometries = getJtsGeometries(bufferingLayer, selected);
|
506 |
IGeometry[] shapes = null; |
507 |
// Realizo el buffer llamando al metodo makeBuffer de GeoProcessingTopologyOperations
|
508 |
if (((JRadioButton)geoProcessingBufferPanel.getComponent(4)).isSelected()) { |
509 |
double bufferDistance = Double.parseDouble(((JTextField)geoProcessingBufferPanel.getComponent(7)).getText()); |
510 |
if (((JCheckBox)geoProcessingBufferPanel.getComponent(13)).isSelected()) { |
511 |
Geometry jtsBuffer = GeoProcessingTopologyOperations.makeDissolveBuffer(geometries, bufferDistance, getQuadrantSegments()); |
512 |
// Realizo las operaciones relacionadas con tablas que el buffer requiere llamando a los m?todos convenientes de GeoProcessingTableOperations
|
513 |
// (A lo mejor este paso no es necesario) Convierto las tablas modificadas y las nuevas entidades JTS al modelo de gvSIG
|
514 |
System.out.println("jtsBuffer = " + jtsBuffer); |
515 |
FPolygon2D shapeBuffer = (FPolygon2D)FConverter.jts_to_java2d(jtsBuffer); |
516 |
System.out.println("shapeBuffer = " + shapeBuffer); |
517 |
shapes = new IGeometry[]{ShapeFactory.createGeometry(shapeBuffer)}; |
518 |
// Guardo la tabla mediante gdbms. Guardo tambi?n las entidades JTS mediante gvSIG o usando solo gdbms (probablemente bastar? con usar gdbms)
|
519 |
} else {
|
520 |
double[] bufferDistances = new double[geometries.length]; |
521 |
for (int i=0;i<bufferDistances.length;i++) { |
522 |
bufferDistances[i] = bufferDistance; |
523 |
} |
524 |
Geometry[] jtsBuffers = GeoProcessingTopologyOperations.makeBuffers(geometries, bufferDistances, getQuadrantSegments());
|
525 |
// Realizo las operaciones relacionadas con tablas que el buffer requiere llamando a los m?todos convenientes de GeoProcessingTableOperations
|
526 |
// (A lo mejor este paso no es necesario) Convierto las tablas modificadas y las nuevas entidades JTS al modelo de gvSIG
|
527 |
shapes = getFmapGeometries(jtsBuffers); |
528 |
// Guardo la tabla mediante gdbms. Guardo tambi?n las entidades JTS mediante gvSIG o usando solo gdbms (probablemente bastar? con usar gdbms)
|
529 |
} |
530 |
} else if (((JRadioButton)geoProcessingBufferPanel.getComponent(5)).isSelected()) { |
531 |
double[] bufferDistances = getBufferDistancesFromTable(bufferingLayer); |
532 |
if (((JCheckBox)geoProcessingBufferPanel.getComponent(13)).isSelected()) { |
533 |
// Aqu? hay problemas ... Con distintas distancias y haciendo dissolve ...
|
534 |
Geometry jtsBuffer = GeoProcessingTopologyOperations.makeDissolveBuffer(geometries, bufferDistances, getQuadrantSegments()); |
535 |
// Realizo las operaciones relacionadas con tablas que el buffer requiere llamando a los m?todos convenientes de GeoProcessingTableOperations
|
536 |
// (A lo mejor este paso no es necesario) Convierto las tablas modificadas y las nuevas entidades JTS al modelo de gvSIG
|
537 |
System.out.println("jtsBuffer = " + jtsBuffer); |
538 |
FPolygon2D shapeBuffer = (FPolygon2D)FConverter.jts_to_java2d(jtsBuffer); |
539 |
System.out.println("shapeBuffer = " + shapeBuffer); |
540 |
shapes = new IGeometry[]{ShapeFactory.createGeometry(shapeBuffer)}; |
541 |
// Guardo la tabla mediante gdbms. Guardo tambi?n las entidades JTS mediante gvSIG o usando solo gdbms (probablemente bastar? con usar gdbms)
|
542 |
} else {
|
543 |
Geometry[] jtsBuffers = GeoProcessingTopologyOperations.makeBuffers(geometries, bufferDistances, getQuadrantSegments());
|
544 |
// Realizo las operaciones relacionadas con tablas que el buffer requiere llamando a los m?todos convenientes de GeoProcessingTableOperations
|
545 |
// (A lo mejor este paso no es necesario) Convierto las tablas modificadas y las nuevas entidades JTS al modelo de gvSIG
|
546 |
shapes = getFmapGeometries(jtsBuffers); |
547 |
// Guardo la tabla mediante gdbms. Guardo tambi?n las entidades JTS mediante gvSIG o usando solo gdbms (probablemente bastar? con usar gdbms)
|
548 |
} |
549 |
} |
550 |
GeoProcessingPersistenceOperations.saveResultsToShapeFile(shapes, geoProcessingBufferPanel.getOutputFile()); |
551 |
if (!((JCheckBox)geoProcessingBufferPanel.getComponent(3)).isSelected()) ((Selectable)bufferingLayer).clearSelection(); |
552 |
} |
553 |
private void clipMethod() { |
554 |
String layerToClipName = (String)((JComboBox)geoProcessingClipPanel.getComponent(0)).getSelectedItem(); |
555 |
FLayer layerToClip = layers.getLayer(layerToClipName); |
556 |
boolean selected = false; |
557 |
if (((JCheckBox)geoProcessingClipPanel.getComponent(1)).isSelected()) selected = true; |
558 |
Geometry[] geometriesToClip = getJtsGeometries(layerToClip, selected);
|
559 |
String clippingLayerName = (String)((JComboBox)geoProcessingClipPanel.getComponent(3)).getSelectedItem(); |
560 |
FLayer clippingLayer = layers.getLayer(clippingLayerName); |
561 |
if (((JCheckBox)geoProcessingClipPanel.getComponent(5)).isSelected()) selected = true; |
562 |
Geometry[] clippingGeometries = getJtsGeometries(clippingLayer, selected);
|
563 |
Geometry[] clippedGeometries = GeoProcessingTopologyOperations.makeClip(geometriesToClip, clippingGeometries);
|
564 |
IGeometry[] shapes = getFmapGeometries(clippedGeometries);
|
565 |
// Guardo la tabla mediante gdbms. Guardo tambi?n las entidades JTS mediante gvSIG o usando solo gdbms (probablemente bastar? con usar gdbms)
|
566 |
GeoProcessingPersistenceOperations.saveResultsToShapeFile(shapes, geoProcessingClipPanel.getOutputFile()); |
567 |
} |
568 |
private void mergeMethod() { |
569 |
Object[] layerNamesToMerge = geoProcessingMergePanel.getLayerSelectedNames(); |
570 |
FLayer[] layersToMerge = new FLayer[layerNamesToMerge.length]; |
571 |
boolean selected = false; |
572 |
Vector allGeometriesToMerge = new Vector(); |
573 |
for (int i=0;i<layerNamesToMerge.length;i++) { |
574 |
layersToMerge[i] = layers.getLayer((String)layerNamesToMerge[i]);
|
575 |
if (!((Selectable)layersToMerge[i]).getSelection().isEmpty()) selected = true; |
576 |
Geometry[] geometriesToMerge = getJtsGeometries(layersToMerge[i], selected);
|
577 |
for (int j=0;j<geometriesToMerge.length;j++) { |
578 |
allGeometriesToMerge.add(geometriesToMerge[j]); |
579 |
} |
580 |
} |
581 |
//Geometry[] clippedGeometries = GeoProcessingTopologyOperations.makeClip(geometriesToClip, clippingGeometries);
|
582 |
Geometry[] mergedGeometries = new Geometry[allGeometriesToMerge.size()]; |
583 |
for (int i=0;i<allGeometriesToMerge.size();i++) { |
584 |
mergedGeometries[i] = (Geometry)allGeometriesToMerge.get(i); |
585 |
} |
586 |
IGeometry[] shapes = getFmapGeometries(mergedGeometries);
|
587 |
GeoProcessingPersistenceOperations.saveResultsToShapeFile(shapes, geoProcessingMergePanel.getOutputFile()); |
588 |
} |
589 |
private void dissolveMethod() { |
590 |
String layerToDissolveName = (String)((JComboBox)geoProcessingDissolvePanel.getComponent(2)).getSelectedItem(); |
591 |
FLayer layerToDissolve = layers.getLayer(layerToDissolveName); |
592 |
boolean selected = false; |
593 |
if (((JCheckBox)geoProcessingDissolvePanel.getComponent(3)).isSelected()) selected = true; |
594 |
Geometry[] geometriesToDissolve = getJtsGeometries(layerToDissolve, selected);
|
595 |
String dissolveAttributeName = (String)((JComboBox)geoProcessingDissolvePanel.getComponent(5)).getSelectedItem(); |
596 |
//
|
597 |
Vector resultGeometries = new Vector(); |
598 |
AlphanumericData lyr = (AlphanumericData)layerToDissolve; |
599 |
DataSource ds;
|
600 |
try {
|
601 |
ds = lyr.getRecordset(); |
602 |
int fieldId = ds.getFieldIndexByName(dissolveAttributeName);
|
603 |
Value[] fieldValues = new Value[(int)ds.getRowCount()]; |
604 |
//int j = 0;
|
605 |
for (int i=0;i<ds.getRowCount();i++) { |
606 |
fieldValues[i] = ds.getFieldValue(i, fieldId); |
607 |
} |
608 |
for (int i=0;i<fieldValues.length;i++) { |
609 |
Value valuei = fieldValues[i]; |
610 |
Geometry geometryi = geometriesToDissolve[i]; |
611 |
//Geometry jtsGeometryi = geometryi.toJTSGeometry();
|
612 |
for (int j=0;j<ds.getRowCount();j++) { |
613 |
if (j!=i) {
|
614 |
Value valuej = ds.getFieldValue(j, fieldId); |
615 |
if (((BooleanValue)(valuej.equals(valuei))).getValue()) {
|
616 |
Geometry geometryj = geometriesToDissolve[j]; |
617 |
//Geometry jtsGeometryj = geometryj.toJTSGeometry();
|
618 |
//if (jtsGeometryj.intersection(jtsGeometryi) instanceof LineString ||
|
619 |
// jtsGeometryj.intersection(jtsGeometryi) instanceof LinearRing) {
|
620 |
geometryi = geometryj.union(geometryi); |
621 |
//FPolygon2D union = (FPolygon2D)FConverter.jts_to_java2d(jtsUnion);
|
622 |
//resultGeometries.add(ShapeFactory.createGeometry(union));
|
623 |
//}
|
624 |
} |
625 |
} |
626 |
} |
627 |
resultGeometries.add(geometryi); |
628 |
} |
629 |
} catch (DriverException e) {
|
630 |
// TODO Auto-generated catch block
|
631 |
e.printStackTrace(); |
632 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
633 |
// TODO Auto-generated catch block
|
634 |
e.printStackTrace(); |
635 |
} catch (IncompatibleTypesException e) {
|
636 |
// TODO Auto-generated catch block
|
637 |
e.printStackTrace(); |
638 |
} |
639 |
Geometry[] result = new Geometry[resultGeometries.size()]; |
640 |
for (int i=0;i<resultGeometries.size();i++) { |
641 |
result[i] = (Geometry)resultGeometries.get(i); |
642 |
} |
643 |
//
|
644 |
//Geometry[] dissolvedGeometries = GeoProcessingTopologyOperations.makeDissolve(geometriesToDissolve);
|
645 |
IGeometry[] shapes = getFmapGeometries(result);
|
646 |
// Guardo la tabla mediante gdbms. Guardo tambi?n las entidades JTS mediante gvSIG o usando solo gdbms (probablemente bastar? con usar gdbms)
|
647 |
GeoProcessingPersistenceOperations.saveResultsToShapeFile(shapes, geoProcessingDissolvePanel.getOutputFile()); |
648 |
} |
649 |
private void intersectMethod() { |
650 |
String layerToIntersectName = (String)((JComboBox)geoProcessingIntersectPanel.getComponent(0)).getSelectedItem(); |
651 |
FLayer layerToIntersect = layers.getLayer(layerToIntersectName); |
652 |
boolean selected = false; |
653 |
if (((JCheckBox)geoProcessingIntersectPanel.getComponent(1)).isSelected()) selected = true; |
654 |
Geometry[] geometriesToIntersect = getJtsGeometries(layerToIntersect, selected);
|
655 |
String intersectingLayerName = (String)((JComboBox)geoProcessingIntersectPanel.getComponent(3)).getSelectedItem(); |
656 |
FLayer intersectingLayer = layers.getLayer(intersectingLayerName); |
657 |
if (((JCheckBox)geoProcessingIntersectPanel.getComponent(5)).isSelected()) selected = true; |
658 |
Geometry[] intersectingGeometries = getJtsGeometries(intersectingLayer, selected);
|
659 |
Geometry[] intersectedGeometries = GeoProcessingTopologyOperations.makeIntersect(geometriesToIntersect, intersectingGeometries);
|
660 |
IGeometry[] shapes = getFmapGeometries(intersectedGeometries);
|
661 |
// Guardo la tabla mediante gdbms. Guardo tambi?n las entidades JTS mediante gvSIG o usando solo gdbms (probablemente bastar? con usar gdbms)
|
662 |
GeoProcessingPersistenceOperations.saveResultsToShapeFile(shapes, geoProcessingIntersectPanel.getOutputFile()); |
663 |
} |
664 |
private void unionMethod() { |
665 |
String layerToUnionName = (String)((JComboBox)geoProcessingUnionPanel.getComponent(0)).getSelectedItem(); |
666 |
FLayer layerToUnion = layers.getLayer(layerToUnionName); |
667 |
boolean selected = false; |
668 |
if (((JCheckBox)geoProcessingUnionPanel.getComponent(1)).isSelected()) selected = true; |
669 |
Geometry[] geometriesToUnion = getJtsGeometries(layerToUnion, selected);
|
670 |
String uningLayerName = (String)((JComboBox)geoProcessingUnionPanel.getComponent(3)).getSelectedItem(); |
671 |
FLayer uningLayer = layers.getLayer(uningLayerName); |
672 |
if (((JCheckBox)geoProcessingUnionPanel.getComponent(5)).isSelected()) selected = true; |
673 |
Geometry[] uningGeometries = getJtsGeometries(uningLayer, selected);
|
674 |
Geometry[] unedGeometries = GeoProcessingTopologyOperations.makeUnion(geometriesToUnion, uningGeometries);
|
675 |
IGeometry[] shapes = getFmapGeometries(unedGeometries);
|
676 |
// Guardo la tabla mediante gdbms. Guardo tambi?n las entidades JTS mediante gvSIG o usando solo gdbms (probablemente bastar? con usar gdbms)
|
677 |
GeoProcessingPersistenceOperations.saveResultsToShapeFile(shapes, geoProcessingUnionPanel.getOutputFile()); |
678 |
} |
679 |
private void spatialjoinMethod() { |
680 |
String layerToSJoinName = (String)((JComboBox)geoProcessingSpatialjoinPanel.getComponent(0)).getSelectedItem(); |
681 |
FLayer layerToSJoin = layers.getLayer(layerToSJoinName); |
682 |
boolean selected = false; |
683 |
if (((JCheckBox)geoProcessingSpatialjoinPanel.getComponent(1)).isSelected()) selected = true; |
684 |
Geometry[] geometriesToSJoin = getJtsGeometries(layerToSJoin, selected);
|
685 |
Geometry[] sJoinGeometries = geometriesToSJoin;
|
686 |
IGeometry[] shapes = getFmapGeometries(sJoinGeometries);
|
687 |
// Guardo la tabla mediante gdbms. Guardo tambi?n las entidades JTS mediante gvSIG o usando solo gdbms (probablemente bastar? con usar gdbms)
|
688 |
GeoProcessingPersistenceOperations.saveResultsToShapeFile(shapes, geoProcessingSpatialjoinPanel.getOutputFile()); |
689 |
} |
690 |
public double[] getBufferDistancesFromTable(FLayer bufferingLayer) { |
691 |
AlphanumericData lyr = (AlphanumericData)bufferingLayer; |
692 |
DataSource ds;
|
693 |
double[] bufferDistances = null; |
694 |
try {
|
695 |
ds = lyr.getRecordset(); |
696 |
int fieldId = ds.getFieldIndexByName(getSelectedField());
|
697 |
Value[] fieldValues = new Value[(int)ds.getRowCount()]; |
698 |
SelectableDataSource selectableDataSource = (SelectableDataSource)ds; |
699 |
FBitSet fBitSet = selectableDataSource.getSelection(); |
700 |
Value[] valuesSelected = new Value[fBitSet.cardinality()]; |
701 |
int j = 0; |
702 |
for (int i=0;i<ds.getRowCount();i++) { |
703 |
boolean isSelected = fBitSet.get(i);
|
704 |
fieldValues[i] = ds.getFieldValue(i, fieldId); |
705 |
if (isSelected) {
|
706 |
valuesSelected[j] = fieldValues[i]; |
707 |
j++; |
708 |
} |
709 |
} |
710 |
bufferDistances = new double[fBitSet.cardinality()]; |
711 |
for (int i=0;i<fBitSet.cardinality();i++) { |
712 |
bufferDistances[i] = new Double(valuesSelected[i].toString()).doubleValue(); |
713 |
} |
714 |
} catch (DriverException e) {
|
715 |
// TODO Auto-generated catch block
|
716 |
e.printStackTrace(); |
717 |
} catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
718 |
// TODO Auto-generated catch block
|
719 |
e.printStackTrace(); |
720 |
} |
721 |
return bufferDistances;
|
722 |
} |
723 |
private String getSelectedField() { |
724 |
return ((String)((JComboBox)geoProcessingBufferPanel.getComponent(6)).getSelectedItem()); |
725 |
} |
726 |
private int getQuadrantSegments() { |
727 |
return (Integer.valueOf((String)((JComboBox)geoProcessingBufferPanel.getComponent(11)).getSelectedItem())).intValue(); |
728 |
} |
729 |
private void closeMethod() { |
730 |
if (PluginServices.getMainFrame() == null) |
731 |
((JDialog) (getParent().getParent().getParent().getParent())).dispose();
|
732 |
else
|
733 |
PluginServices.getMDIManager().closeView(GeoProcessingPanel.this); |
734 |
} |
735 |
} // @jve:decl-index=0:visual-constraint="10,10"
|