root / trunk / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / impl / convexhull / gui / GeoProcessingConvexHullPanel.java @ 6489
History | View | Annotate | Download (9.42 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 6489 2006-07-21 09:13:55Z azabala $
|
47 |
* $Log$
|
48 |
* Revision 1.3 2006-07-21 09:10:34 azabala
|
49 |
* fixed bug 608: user doesnt enter any result file to the geoprocess panel
|
50 |
*
|
51 |
* Revision 1.2 2006/06/29 17:32:10 azabala
|
52 |
* result layer selection is congruent with AbstractGeoprocessPanel
|
53 |
*
|
54 |
* Revision 1.1 2006/06/20 18:20:45 azabala
|
55 |
* first version in cvs
|
56 |
*
|
57 |
* Revision 1.2 2006/05/24 23:19:10 azabala
|
58 |
* arreglado bug que hacia que falle el geoprocessing cuando el fichero resultado no acaba en shp
|
59 |
*
|
60 |
* Revision 1.1 2006/05/24 21:13:44 azabala
|
61 |
* primera version en cvs despues de refactoring orientado a crear un framework extensible de geoprocessing
|
62 |
*
|
63 |
* Revision 1.5 2006/04/11 18:02:42 azabala
|
64 |
* Intento de que el Panel salga bien en todas las resoluciones (y de dejarlos mas bonitos)
|
65 |
*
|
66 |
* Revision 1.4 2006/03/28 16:25:53 azabala
|
67 |
* *** empty log message ***
|
68 |
*
|
69 |
* Revision 1.3 2006/03/21 19:26:08 azabala
|
70 |
* *** empty log message ***
|
71 |
*
|
72 |
* Revision 1.2 2006/03/09 17:04:15 azabala
|
73 |
* *** empty log message ***
|
74 |
*
|
75 |
* Revision 1.1 2006/03/05 19:56:06 azabala
|
76 |
* *** empty log message ***
|
77 |
*
|
78 |
*
|
79 |
*/
|
80 |
package com.iver.cit.gvsig.geoprocess.impl.convexhull.gui; |
81 |
|
82 |
import java.awt.Component; |
83 |
import java.io.File; |
84 |
|
85 |
import javax.swing.DefaultComboBoxModel; |
86 |
import javax.swing.JButton; |
87 |
import javax.swing.JCheckBox; |
88 |
import javax.swing.JComboBox; |
89 |
import javax.swing.JFileChooser; |
90 |
import javax.swing.JLabel; |
91 |
import javax.swing.JTextField; |
92 |
|
93 |
import com.iver.andami.PluginServices; |
94 |
import com.iver.andami.ui.mdiManager.View; |
95 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
96 |
import com.iver.cit.gvsig.fmap.DriverException; |
97 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
98 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
99 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
100 |
import com.iver.cit.gvsig.geoprocess.core.gui.AbstractGeoprocessPanel; |
101 |
import com.iver.utiles.GenericFileFilter; |
102 |
import javax.swing.JPanel; |
103 |
|
104 |
public class GeoProcessingConvexHullPanel extends AbstractGeoprocessPanel |
105 |
implements View{ |
106 |
|
107 |
private static final long serialVersionUID = 1L; |
108 |
private JLabel jLabel = null; |
109 |
private JCheckBox selectedOnlyCheckbox = null; |
110 |
private JButton openFileButton = null; |
111 |
private ViewInfo viewInfo;
|
112 |
private JPanel resultLayerPanel = null; |
113 |
private JLabel jLabel1 = null; |
114 |
private JPanel inputLayerPanel = null; |
115 |
private JLabel jLabel2 = null; |
116 |
|
117 |
/**
|
118 |
* This constructor initializes the set of layers
|
119 |
*/
|
120 |
public GeoProcessingConvexHullPanel(FLayers layers) {
|
121 |
super();
|
122 |
this.layers = layers;
|
123 |
initialize(); |
124 |
} |
125 |
/**
|
126 |
* This method initializes this
|
127 |
*
|
128 |
* @return void
|
129 |
*/
|
130 |
private void initialize() { |
131 |
jLabel = new JLabel(); |
132 |
this.setLayout(null); |
133 |
this.setBounds(new java.awt.Rectangle(0,0,486,377)); |
134 |
jLabel.setText("Convex_Hull._Introduccion_de_datos");
|
135 |
jLabel.setBounds(10, 26, 426, 21); |
136 |
this.add(jLabel, null); |
137 |
this.add(getLayersComboBox(), null); |
138 |
this.add(getResultLayerPanel(), null); |
139 |
this.add(getInputLayerPanel(), null); |
140 |
layersComboBox.setSelectedIndex(0);
|
141 |
initSelectedItemsJCheckBox(); |
142 |
} |
143 |
|
144 |
|
145 |
private void initSelectedItemsJCheckBox() { |
146 |
String selectedLayer = (String)layersComboBox.getSelectedItem(); |
147 |
FLyrVect inputLayer = (FLyrVect)layers.getLayer(selectedLayer); |
148 |
FBitSet fBitSet = null;
|
149 |
try {
|
150 |
fBitSet = inputLayer.getRecordset().getSelection(); |
151 |
} catch (DriverException e) {
|
152 |
// TODO Auto-generated catch block
|
153 |
e.printStackTrace(); |
154 |
} |
155 |
if (fBitSet.cardinality()==0) { |
156 |
selectedOnlyCheckbox.setEnabled(false);
|
157 |
} else {
|
158 |
selectedOnlyCheckbox.setEnabled(true);
|
159 |
} |
160 |
selectedOnlyCheckbox.setSelected(false);
|
161 |
} |
162 |
|
163 |
|
164 |
private JCheckBox getSelectedOnlyCheckBox() { |
165 |
if (selectedOnlyCheckbox == null) { |
166 |
selectedOnlyCheckbox = new JCheckBox(); |
167 |
selectedOnlyCheckbox.setText(PluginServices.getText(this,"Usar_solamente_los_elementos_seleccionados")); |
168 |
selectedOnlyCheckbox.setBounds(new java.awt.Rectangle(10,72,300,24)); |
169 |
} |
170 |
return selectedOnlyCheckbox;
|
171 |
} |
172 |
/**
|
173 |
* This method initializes layersComboBox
|
174 |
*
|
175 |
* @return javax.swing.JComboBox
|
176 |
*/
|
177 |
private JComboBox getLayersComboBox() { |
178 |
if (layersComboBox == null) { |
179 |
layersComboBox = new JComboBox(); |
180 |
DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(getLayerNames()); |
181 |
layersComboBox.setModel(defaultModel); |
182 |
layersComboBox.setBounds(142, 26, 123, 23); |
183 |
layersComboBox.addItemListener(new java.awt.event.ItemListener() {
|
184 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
185 |
// Cambiar el estado del CheckBox
|
186 |
initSelectedItemsJCheckBox(); |
187 |
} |
188 |
}); |
189 |
} |
190 |
return layersComboBox;
|
191 |
} |
192 |
/**
|
193 |
* This method initializes fileNameResultTextField
|
194 |
*
|
195 |
* @return javax.swing.JTextField
|
196 |
*/
|
197 |
public JTextField getFileNameResultTextField() { |
198 |
if (fileNameResultTextField == null) { |
199 |
super.getFileNameResultTextField().
|
200 |
setBounds(new java.awt.Rectangle(135,11,169,21)); |
201 |
} |
202 |
return fileNameResultTextField;
|
203 |
} |
204 |
/**
|
205 |
* This method initializes openFileButton
|
206 |
*
|
207 |
* @return javax.swing.JButton
|
208 |
*/
|
209 |
private JButton getOpenFileButton() { |
210 |
if (openFileButton == null) { |
211 |
openFileButton = new JButton(); |
212 |
openFileButton.setText(PluginServices.getText(this,"Abrir")); |
213 |
openFileButton.setBounds(new java.awt.Rectangle(311,12,101,21)); |
214 |
openFileButton.addActionListener(new java.awt.event.ActionListener() {
|
215 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
216 |
openResultFile(); |
217 |
} |
218 |
}); |
219 |
} |
220 |
return openFileButton;
|
221 |
} |
222 |
|
223 |
public void openResultFile() { |
224 |
JFileChooser jfc = new JFileChooser(); |
225 |
jfc.addChoosableFileFilter(new GenericFileFilter("shp", |
226 |
"Ficheros SHP"));
|
227 |
if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == |
228 |
JFileChooser.APPROVE_OPTION) {
|
229 |
File file = jfc.getSelectedFile();
|
230 |
if (!(file.getPath().endsWith(".shp") || file.getPath().endsWith(".SHP"))){ |
231 |
file = new File(file.getPath()+".shp"); |
232 |
} |
233 |
}//if
|
234 |
if (jfc.getSelectedFile()!=null) { |
235 |
getFileNameResultTextField().setText( |
236 |
jfc.getSelectedFile().getAbsolutePath()); |
237 |
} |
238 |
|
239 |
} |
240 |
|
241 |
public FLyrVect getInputLayer() {
|
242 |
FLyrVect solution = null;
|
243 |
String selectedLayer = (String)layersComboBox.getSelectedItem(); |
244 |
solution = (FLyrVect)layers.getLayer(selectedLayer); |
245 |
return solution;
|
246 |
} |
247 |
|
248 |
public boolean isConvexHullOnlySelected() { |
249 |
return selectedOnlyCheckbox.isSelected();
|
250 |
} |
251 |
|
252 |
public ViewInfo getViewInfo() {
|
253 |
if (viewInfo == null) { |
254 |
viewInfo = new ViewInfo(ViewInfo.MODALDIALOG);
|
255 |
viewInfo.setTitle(PluginServices.getText(this,
|
256 |
"Convex_Hull"));
|
257 |
} |
258 |
return viewInfo;
|
259 |
} |
260 |
/**
|
261 |
* This method initializes resultLayerPanel
|
262 |
*
|
263 |
* @return javax.swing.JPanel
|
264 |
*/
|
265 |
private JPanel getResultLayerPanel() { |
266 |
if (resultLayerPanel == null) { |
267 |
jLabel1 = new JLabel(); |
268 |
jLabel1.setBounds(new java.awt.Rectangle(4,13,126,17)); |
269 |
jLabel1.setText(PluginServices.getText(this, "Cobertura_de_salida") + ":"); |
270 |
resultLayerPanel = new JPanel(); |
271 |
resultLayerPanel.setLayout(null);
|
272 |
resultLayerPanel.setBounds(new java.awt.Rectangle(11,200,426,39)); |
273 |
resultLayerPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED)); |
274 |
resultLayerPanel.add(getOpenFileButton(), null);
|
275 |
resultLayerPanel.add(getFileNameResultTextField(), null);
|
276 |
resultLayerPanel.add(jLabel1, null);
|
277 |
} |
278 |
return resultLayerPanel;
|
279 |
} |
280 |
/**
|
281 |
* This method initializes inputLayerPanel
|
282 |
*
|
283 |
* @return javax.swing.JPanel
|
284 |
*/
|
285 |
private JPanel getInputLayerPanel() { |
286 |
if (inputLayerPanel == null) { |
287 |
jLabel2 = new JLabel(); |
288 |
jLabel2.setBounds(new java.awt.Rectangle(11,26,149,23)); |
289 |
jLabel2.setText(PluginServices.getText(this, "Cobertura_de_entrada") + ":"); |
290 |
inputLayerPanel = new JPanel(); |
291 |
inputLayerPanel.setLayout(null);
|
292 |
inputLayerPanel.setBounds(new java.awt.Rectangle(10,60,428,133)); |
293 |
inputLayerPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED)); |
294 |
inputLayerPanel.add(getSelectedOnlyCheckBox(), null);
|
295 |
inputLayerPanel.add(jLabel2, null);
|
296 |
inputLayerPanel.add(getLayersComboBox(), null);
|
297 |
} |
298 |
return inputLayerPanel;
|
299 |
} |
300 |
|
301 |
} // @jve:decl-index=0:visual-constraint="15,20"
|