root / trunk / extensions / extGeoprocessingExtensions / src / com / iver / cit / gvsig / geoprocess / impl / xyshift / gui / GeoprocessingXYShiftPanel.java @ 13881
History | View | Annotate | Download (9.2 KB)
1 |
/*
|
---|---|
2 |
* Created on 28-jun-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: GeoprocessingXYShiftPanel.java 13881 2007-09-19 16:22:04Z jaume $
|
47 |
* $Log$
|
48 |
* Revision 1.6 2007-09-19 16:09:14 jaume
|
49 |
* removed unnecessary imports
|
50 |
*
|
51 |
* Revision 1.5 2007/03/06 16:48:14 caballero
|
52 |
* Exceptions
|
53 |
*
|
54 |
* Revision 1.4 2006/08/11 17:17:55 azabala
|
55 |
* *** empty log message ***
|
56 |
*
|
57 |
* Revision 1.3 2006/07/03 20:29:08 azabala
|
58 |
* *** empty log message ***
|
59 |
*
|
60 |
* Revision 1.2 2006/06/29 17:58:31 azabala
|
61 |
* *** empty log message ***
|
62 |
*
|
63 |
* Revision 1.1 2006/06/28 18:17:21 azabala
|
64 |
* first version in cvs
|
65 |
*
|
66 |
*
|
67 |
*/
|
68 |
package com.iver.cit.gvsig.geoprocess.impl.xyshift.gui; |
69 |
|
70 |
import java.awt.Rectangle; |
71 |
import java.awt.event.ItemEvent; |
72 |
|
73 |
import javax.swing.BorderFactory; |
74 |
import javax.swing.DefaultComboBoxModel; |
75 |
import javax.swing.JButton; |
76 |
import javax.swing.JCheckBox; |
77 |
import javax.swing.JComboBox; |
78 |
import javax.swing.JLabel; |
79 |
import javax.swing.JPanel; |
80 |
import javax.swing.JTextField; |
81 |
import javax.swing.border.EtchedBorder; |
82 |
|
83 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
84 |
import com.iver.andami.PluginServices; |
85 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
86 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
87 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
88 |
import com.iver.cit.gvsig.geoprocess.core.fmap.GeoprocessException; |
89 |
import com.iver.cit.gvsig.geoprocess.core.gui.AbstractGeoprocessPanel; |
90 |
|
91 |
public class GeoprocessingXYShiftPanel |
92 |
extends AbstractGeoprocessPanel {
|
93 |
|
94 |
private static final long serialVersionUID = 1L; |
95 |
private JLabel jLabel = null; |
96 |
private JLabel jLabel1 = null; |
97 |
private JCheckBox selectedOnlyCheckBox = null; |
98 |
private JPanel resultSelectionPanel = null; |
99 |
private JButton openResultButton = null; |
100 |
private JLabel jLabel2 = null; |
101 |
private JLabel xoffsetLabel = null; |
102 |
private JTextField xoffsetTextField = null; |
103 |
private JLabel jLabel3 = null; |
104 |
private JTextField yoffsetTextField = null; |
105 |
private JLabel offsetLabel = null; |
106 |
|
107 |
/**
|
108 |
* This method initializes
|
109 |
*
|
110 |
*/
|
111 |
public GeoprocessingXYShiftPanel(FLayers layers) {
|
112 |
super();
|
113 |
this.layers = layers;
|
114 |
initialize(); |
115 |
} |
116 |
|
117 |
public double getXOffset() throws GeoprocessException{ |
118 |
try {
|
119 |
String strDist = xoffsetTextField.getText();
|
120 |
return Double.parseDouble(strDist); |
121 |
} catch (NumberFormatException ex) { |
122 |
throw new GeoprocessException( |
123 |
"Offset en x introducido no numerico");
|
124 |
} |
125 |
} |
126 |
|
127 |
public double getYOffset() throws GeoprocessException{ |
128 |
try {
|
129 |
String strDist = yoffsetTextField.getText();
|
130 |
return Double.parseDouble(strDist); |
131 |
} catch (NumberFormatException ex) { |
132 |
throw new GeoprocessException( |
133 |
"Distancia de buffer introducida no numerica");
|
134 |
} |
135 |
} |
136 |
|
137 |
/**
|
138 |
* Tells if apply geoprocess only to selected features of the input
|
139 |
* layer or to all features
|
140 |
* @return
|
141 |
*/
|
142 |
public boolean isOnlySelected(){ |
143 |
return selectedOnlyCheckBox.isSelected();
|
144 |
} |
145 |
|
146 |
/**
|
147 |
* This method initializes this
|
148 |
*
|
149 |
*/
|
150 |
private void initialize() { |
151 |
offsetLabel = new JLabel(); |
152 |
offsetLabel.setBounds(new java.awt.Rectangle(29,147,211,23)); |
153 |
offsetLabel.setText(PluginServices.getText(this,"Introducir_valores_desplazamiento")); |
154 |
jLabel3 = new JLabel(); |
155 |
jLabel3.setBounds(new java.awt.Rectangle(27,215,152,27)); |
156 |
jLabel3.setText(PluginServices.getText(this,"yOffset")+":"); |
157 |
xoffsetLabel = new JLabel(); |
158 |
xoffsetLabel.setBounds(new java.awt.Rectangle(26,182,154,26)); |
159 |
xoffsetLabel.setText(PluginServices.getText(this,"xOffset")+":"); |
160 |
jLabel1 = new JLabel(); |
161 |
jLabel1.setBounds(new java.awt.Rectangle(27,60,384,23)); |
162 |
jLabel1.setText(PluginServices.getText(this, "Cobertura_de_entrada") + ":"); |
163 |
jLabel = new JLabel(); |
164 |
jLabel.setBounds(new java.awt.Rectangle(27,17,384,27)); |
165 |
jLabel.setText(PluginServices.getText(this, "XYShift._Introduccion_de_datos") + ":"); |
166 |
this.setLayout(null); |
167 |
this.setBounds(new java.awt.Rectangle(0,0,500,400)); |
168 |
this.add(jLabel, null); |
169 |
this.add(jLabel1, null); |
170 |
this.add(getSelectedOnlyCheckBox(), null); |
171 |
this.add(getResultPanel(), null); |
172 |
this.add(xoffsetLabel, null); |
173 |
this.add(getXoffsetTextField(), null); |
174 |
this.add(jLabel3, null); |
175 |
this.add(getYoffsetjTextField1(), null); |
176 |
this.add(offsetLabel, null); |
177 |
this.add(getLayersComboBox(), null); |
178 |
} |
179 |
|
180 |
/**
|
181 |
* This method initializes selectedOnlyCheckBox
|
182 |
*
|
183 |
* @return javax.swing.JCheckBox
|
184 |
*/
|
185 |
private JCheckBox getSelectedOnlyCheckBox() { |
186 |
if (selectedOnlyCheckBox == null) { |
187 |
selectedOnlyCheckBox = new JCheckBox(); |
188 |
selectedOnlyCheckBox.setBounds(new java.awt.Rectangle(27,94,383,23)); |
189 |
selectedOnlyCheckBox.setText(PluginServices.getText(this, "Usar_solamente_los_elementos_seleccionados")); |
190 |
} |
191 |
return selectedOnlyCheckBox;
|
192 |
} |
193 |
|
194 |
private JComboBox getLayersComboBox() { |
195 |
if (layersComboBox == null) { |
196 |
layersComboBox = new JComboBox(); |
197 |
DefaultComboBoxModel defaultModel = new DefaultComboBoxModel( |
198 |
getLayerNames()); |
199 |
layersComboBox.setModel(defaultModel); |
200 |
layersComboBox.setBounds(142, 63, 260, 21); |
201 |
layersComboBox.addItemListener(new java.awt.event.ItemListener() {
|
202 |
public void itemStateChanged(ItemEvent e) { |
203 |
if (e.getStateChange() == ItemEvent.SELECTED) { |
204 |
// Cambiar el estado del CheckBox
|
205 |
initSelectedItemsJCheckBox(); |
206 |
} |
207 |
}//itemStateChange
|
208 |
}); |
209 |
} |
210 |
return layersComboBox;
|
211 |
} |
212 |
|
213 |
private void initSelectedItemsJCheckBox() { |
214 |
String selectedLayer = (String) layersComboBox.getSelectedItem(); |
215 |
FLyrVect inputLayer = (FLyrVect) layers.getLayer(selectedLayer); |
216 |
FBitSet fBitSet = null;
|
217 |
try {
|
218 |
fBitSet = inputLayer.getRecordset().getSelection(); |
219 |
} catch (ReadDriverException e) {
|
220 |
// TODO Auto-generated catch block
|
221 |
e.printStackTrace(); |
222 |
} |
223 |
if (fBitSet.cardinality() == 0) { |
224 |
selectedOnlyCheckBox.setEnabled(false);
|
225 |
} else {
|
226 |
selectedOnlyCheckBox.setEnabled(true);
|
227 |
} |
228 |
selectedOnlyCheckBox.setSelected(false);
|
229 |
} |
230 |
|
231 |
/**
|
232 |
* This method initializes resultSelectionPanel
|
233 |
*
|
234 |
* @return javax.swing.JPanel
|
235 |
*/
|
236 |
private JPanel getResultPanel() { |
237 |
if (resultSelectionPanel == null) { |
238 |
jLabel2 = new JLabel(); |
239 |
jLabel2.setBounds(new Rectangle(4, 13, 126, 17)); |
240 |
jLabel2.setText(PluginServices.getText(this, "Cobertura_de_salida") + ":"); |
241 |
resultSelectionPanel = new JPanel(); |
242 |
resultSelectionPanel.setLayout(null);
|
243 |
resultSelectionPanel.setBounds(new java.awt.Rectangle(26,259,443,46)); |
244 |
resultSelectionPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); |
245 |
resultSelectionPanel.add(getOpenResultButton(), null);
|
246 |
resultSelectionPanel.add(getFileNameResultTextField(), null);
|
247 |
resultSelectionPanel.add(jLabel2, null);
|
248 |
} |
249 |
return resultSelectionPanel;
|
250 |
} |
251 |
|
252 |
/**
|
253 |
* This method initializes openResultButton
|
254 |
*
|
255 |
* @return javax.swing.JButton
|
256 |
*/
|
257 |
private JButton getOpenResultButton() { |
258 |
if (openResultButton == null) { |
259 |
openResultButton = new JButton(); |
260 |
openResultButton.setBounds(new Rectangle(311, 12, 101, 21)); |
261 |
openResultButton.setText(PluginServices.getText(this, "Abrir")); |
262 |
openResultButton.addActionListener(new java.awt.event.ActionListener() {
|
263 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
264 |
openResultFile(); |
265 |
} |
266 |
}); |
267 |
} |
268 |
return openResultButton;
|
269 |
} |
270 |
|
271 |
/**
|
272 |
* This method initializes jTextField
|
273 |
*
|
274 |
* @return javax.swing.JTextField
|
275 |
*/
|
276 |
public JTextField getFileNameResultTextField() { |
277 |
if (fileNameResultTextField == null) { |
278 |
super.getFileNameResultTextField().
|
279 |
setBounds(new Rectangle(135, 11, |
280 |
169, 21)); |
281 |
} |
282 |
return fileNameResultTextField;
|
283 |
} |
284 |
|
285 |
/**
|
286 |
* This method initializes xoffsetTextField
|
287 |
*
|
288 |
* @return javax.swing.JTextField
|
289 |
*/
|
290 |
private JTextField getXoffsetTextField() { |
291 |
if (xoffsetTextField == null) { |
292 |
xoffsetTextField = new JTextField(); |
293 |
xoffsetTextField.setBounds(new java.awt.Rectangle(193,182,216,25)); |
294 |
} |
295 |
return xoffsetTextField;
|
296 |
} |
297 |
|
298 |
/**
|
299 |
* This method initializes yoffsetjTextField1
|
300 |
*
|
301 |
* @return javax.swing.JTextField
|
302 |
*/
|
303 |
private JTextField getYoffsetjTextField1() { |
304 |
if (yoffsetTextField == null) { |
305 |
yoffsetTextField = new JTextField(); |
306 |
yoffsetTextField.setBounds(new java.awt.Rectangle(193,216,216,25)); |
307 |
} |
308 |
return yoffsetTextField;
|
309 |
} |
310 |
|
311 |
} // @jve:decl-index=0:visual-constraint="13,15"
|
312 |
|