svn-gvsig-desktop / trunk / extensions / extGeoProcessing / src / com / iver / gvsig / geoprocessing / gui / operationpanels / GeoProcessingConvexHullPanel.java @ 4340
History | View | Annotate | Download (7.29 KB)
1 |
/*
|
---|---|
2 |
* Created on 03-mar-2006
|
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 |
/* CVS MESSAGES:
|
45 |
*
|
46 |
* $Id: GeoProcessingConvexHullPanel.java 4340 2006-03-09 17:04:27Z azabala $
|
47 |
* $Log$
|
48 |
* Revision 1.2 2006-03-09 17:04:15 azabala
|
49 |
* *** empty log message ***
|
50 |
*
|
51 |
* Revision 1.1 2006/03/05 19:56:06 azabala
|
52 |
* *** empty log message ***
|
53 |
*
|
54 |
*
|
55 |
*/
|
56 |
package com.iver.gvsig.geoprocessing.gui.operationpanels; |
57 |
|
58 |
import java.awt.Component; |
59 |
import java.io.File; |
60 |
|
61 |
import javax.swing.ButtonGroup; |
62 |
import javax.swing.DefaultComboBoxModel; |
63 |
import javax.swing.JButton; |
64 |
import javax.swing.JCheckBox; |
65 |
import javax.swing.JComboBox; |
66 |
import javax.swing.JFileChooser; |
67 |
import javax.swing.JLabel; |
68 |
import javax.swing.JPanel; |
69 |
import javax.swing.JRadioButton; |
70 |
import javax.swing.JTextField; |
71 |
|
72 |
import com.hardcode.gdbms.engine.data.DataSource; |
73 |
import com.iver.andami.PluginServices; |
74 |
import com.iver.cit.gvsig.fmap.DriverException; |
75 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
76 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
77 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
78 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
79 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
80 |
import com.iver.gvsig.geoprocessing.model.GeoprocessException; |
81 |
import com.iver.gvsig.geoprocessing.schemabuilder.XTypes; |
82 |
import com.iver.utiles.GenericFileFilter; |
83 |
|
84 |
public class GeoProcessingConvexHullPanel extends GeoProcessingOperationPanel { |
85 |
|
86 |
private static final long serialVersionUID = 1L; |
87 |
private JLabel jLabel = null; |
88 |
private JCheckBox selectedOnlyCheckbox = null; |
89 |
private JComboBox layersComboBox = null; |
90 |
private JTextField fileNameResultTextField = null; |
91 |
private JButton openFileButton = null; |
92 |
private JLabel jLabel3 = null; |
93 |
private JLabel jLabel1 = null; |
94 |
|
95 |
/**
|
96 |
* This constructor initializes the set of layers
|
97 |
*/
|
98 |
public GeoProcessingConvexHullPanel(FLayers layers) {
|
99 |
super();
|
100 |
this.layers = layers;
|
101 |
initialize(); |
102 |
} |
103 |
/**
|
104 |
* This method initializes this
|
105 |
*
|
106 |
* @return void
|
107 |
*/
|
108 |
private void initialize() { |
109 |
jLabel1 = new JLabel(); |
110 |
jLabel3 = new JLabel(); |
111 |
jLabel = new JLabel(); |
112 |
this.setLayout(null); |
113 |
this.setSize(406, 153); |
114 |
jLabel.setText("Convex_Hull._Introduccion_de_datos:");
|
115 |
jLabel.setBounds(4, 10, 239, 21); |
116 |
jLabel3.setText(PluginServices.getText(this,"Cobertura_de_entrada") + ":"); |
117 |
jLabel3.setBounds(4, 41, 126, 21); |
118 |
jLabel1.setText(PluginServices.getText(this,"Cobertura_de_salida") + ":"); |
119 |
jLabel1.setBounds(4, 109, 118, 21); |
120 |
this.add(jLabel, null); |
121 |
this.add(jLabel3, null); |
122 |
this.add(getLayersComboBox(), null); |
123 |
this.add(getSelectedOnlyCheckBox(), null); |
124 |
this.add(jLabel1, null); |
125 |
this.add(getFileNameResultTextField(), null); |
126 |
this.add(getOpenFileButton(), null); |
127 |
layersComboBox.setSelectedIndex(0);
|
128 |
initSelectedItemsJCheckBox(); |
129 |
} |
130 |
|
131 |
|
132 |
private void initSelectedItemsJCheckBox() { |
133 |
String selectedLayer = (String)layersComboBox.getSelectedItem(); |
134 |
FLyrVect inputLayer = (FLyrVect)layers.getLayer(selectedLayer); |
135 |
FBitSet fBitSet = inputLayer.getRecordset().getSelection(); |
136 |
if (fBitSet.cardinality()==0) { |
137 |
selectedOnlyCheckbox.setEnabled(false);
|
138 |
} else {
|
139 |
selectedOnlyCheckbox.setEnabled(true);
|
140 |
} |
141 |
selectedOnlyCheckbox.setSelected(false);
|
142 |
} |
143 |
|
144 |
|
145 |
private JCheckBox getSelectedOnlyCheckBox() { |
146 |
if (selectedOnlyCheckbox == null) { |
147 |
selectedOnlyCheckbox = new JCheckBox(); |
148 |
selectedOnlyCheckbox.setText(PluginServices.getText(this,"Usar_solamente_los_elementos_seleccionados")); |
149 |
selectedOnlyCheckbox.setBounds(5, 73, 271, 21); |
150 |
} |
151 |
return selectedOnlyCheckbox;
|
152 |
} |
153 |
/**
|
154 |
* This method initializes layersComboBox
|
155 |
*
|
156 |
* @return javax.swing.JComboBox
|
157 |
*/
|
158 |
private JComboBox getLayersComboBox() { |
159 |
if (layersComboBox == null) { |
160 |
layersComboBox = new JComboBox(); |
161 |
DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(getLayerNames()); |
162 |
layersComboBox.setModel(defaultModel); |
163 |
layersComboBox.setBounds(142, 41, 260, 21); |
164 |
layersComboBox.addItemListener(new java.awt.event.ItemListener() {
|
165 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
166 |
// Cambiar el estado del CheckBox
|
167 |
initSelectedItemsJCheckBox(); |
168 |
} |
169 |
}); |
170 |
} |
171 |
return layersComboBox;
|
172 |
} |
173 |
/**
|
174 |
* This method initializes fileNameResultTextField
|
175 |
*
|
176 |
* @return javax.swing.JTextField
|
177 |
*/
|
178 |
private JTextField getFileNameResultTextField() { |
179 |
if (fileNameResultTextField == null) { |
180 |
fileNameResultTextField = new JTextField(); |
181 |
fileNameResultTextField.setBounds(130, 107, 208, 21); |
182 |
} |
183 |
return fileNameResultTextField;
|
184 |
} |
185 |
/**
|
186 |
* This method initializes openFileButton
|
187 |
*
|
188 |
* @return javax.swing.JButton
|
189 |
*/
|
190 |
private JButton getOpenFileButton() { |
191 |
if (openFileButton == null) { |
192 |
openFileButton = new JButton(); |
193 |
openFileButton.setText(PluginServices.getText(this,"Abrir")); |
194 |
openFileButton.addActionListener(new java.awt.event.ActionListener() {
|
195 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
196 |
openResultFile(); |
197 |
} |
198 |
}); |
199 |
openFileButton.setBounds(344, 107, 59, 21); |
200 |
} |
201 |
return openFileButton;
|
202 |
} |
203 |
|
204 |
public File getOutputFile() { |
205 |
return new File(getFileNameResultTextField().getText()); |
206 |
} |
207 |
|
208 |
|
209 |
public void openResultFile() { |
210 |
JFileChooser jfc = new JFileChooser(); |
211 |
jfc.addChoosableFileFilter(new GenericFileFilter("shp", |
212 |
"Ficheros SHP"));
|
213 |
if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == |
214 |
JFileChooser.APPROVE_OPTION) {
|
215 |
File file = jfc.getSelectedFile();
|
216 |
if (!(file.getPath().endsWith(".shp") || file.getPath().endsWith(".SHP"))){ |
217 |
file = new File(file.getPath()+".shp"); |
218 |
} |
219 |
}//if
|
220 |
if (jfc.getSelectedFile()!=null) { |
221 |
getFileNameResultTextField().setText( |
222 |
jfc.getSelectedFile().getAbsolutePath()); |
223 |
} |
224 |
|
225 |
} |
226 |
|
227 |
public FLyrVect getInputLayer() {
|
228 |
FLyrVect solution = null;
|
229 |
String selectedLayer = (String)layersComboBox.getSelectedItem(); |
230 |
solution = (FLyrVect)layers.getLayer(selectedLayer); |
231 |
return solution;
|
232 |
} |
233 |
|
234 |
public boolean isConvexHullOnlySelected() { |
235 |
return selectedOnlyCheckbox.isSelected();
|
236 |
} |
237 |
|
238 |
} // @jve:decl-index=0:visual-constraint="10,10"
|