root / trunk / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / buffer / gui / GeoProcessingBufferPanel.java @ 5412
History | View | Annotate | Download (20.7 KB)
1 | 5412 | azabala | /*
|
---|---|---|---|
2 | * Created on 04-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.cit.gvsig.geoprocess.buffer.gui; |
||
45 | |||
46 | import java.awt.Color; |
||
47 | import java.awt.Component; |
||
48 | import java.awt.event.ItemEvent; |
||
49 | import java.io.File; |
||
50 | |||
51 | import javax.swing.ButtonGroup; |
||
52 | import javax.swing.DefaultComboBoxModel; |
||
53 | import javax.swing.JButton; |
||
54 | import javax.swing.JCheckBox; |
||
55 | import javax.swing.JComboBox; |
||
56 | import javax.swing.JFileChooser; |
||
57 | import javax.swing.JFormattedTextField; |
||
58 | import javax.swing.JLabel; |
||
59 | import javax.swing.JRadioButton; |
||
60 | import javax.swing.JSpinner; |
||
61 | import javax.swing.JTextField; |
||
62 | import javax.swing.SpinnerListModel; |
||
63 | |||
64 | import com.hardcode.gdbms.engine.data.DataSource; |
||
65 | import com.iver.andami.PluginServices; |
||
66 | import com.iver.andami.ui.mdiManager.View; |
||
67 | import com.iver.andami.ui.mdiManager.ViewInfo; |
||
68 | import com.iver.cit.gvsig.fmap.DriverException; |
||
69 | import com.iver.cit.gvsig.fmap.layers.FBitSet; |
||
70 | import com.iver.cit.gvsig.fmap.layers.FLayers; |
||
71 | import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
||
72 | import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
||
73 | import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
||
74 | import com.iver.cit.gvsig.geoprocess.core.fmap.GeoprocessException; |
||
75 | import com.iver.cit.gvsig.geoprocess.core.fmap.XTypes; |
||
76 | import com.iver.cit.gvsig.geoprocess.core.gui.AbstractGeoprocessPanel; |
||
77 | import com.iver.utiles.GenericFileFilter; |
||
78 | import javax.swing.JPanel; |
||
79 | |||
80 | /**
|
||
81 | * Component that represents a Step of the GeoProcessingPanel Wizard. It allows
|
||
82 | * user to make selections to do buffers geoprocesses.
|
||
83 | *
|
||
84 | * @author jmorell, azabala
|
||
85 | *
|
||
86 | * TODO copiar del ClipPanel el que se muestre el numero de elementos
|
||
87 | * seleccionados en la capa
|
||
88 | */
|
||
89 | public class GeoProcessingBufferPanel extends AbstractGeoprocessPanel implements |
||
90 | BufferPanelIF, View {
|
||
91 | /*
|
||
92 | * Constants to indicate how to create buffers on polygonal geometries
|
||
93 | */
|
||
94 | public final String BUFFER_INSIDE = PluginServices.getText(this, "Dentro"); |
||
95 | |||
96 | public final String BUFFER_INSIDE_OUTSIDE = PluginServices.getText(this, |
||
97 | "Dentro_y_fuera");
|
||
98 | |||
99 | public final String BUFFER_OUTSIDE = PluginServices.getText(this, "Fuera"); |
||
100 | |||
101 | private static final long serialVersionUID = 1L; |
||
102 | |||
103 | private JLabel jLabel = null; |
||
104 | |||
105 | private JCheckBox selectedOnlyCheckbox = null; |
||
106 | |||
107 | private JTextField fileNameResultTextField = null; |
||
108 | |||
109 | private JButton openFileButton = null; |
||
110 | |||
111 | private JRadioButton distanceBufferRadioButton = null; |
||
112 | |||
113 | private JTextField bufferDistanceTextField = null; |
||
114 | |||
115 | private JRadioButton attributeBufferRadioButton = null; |
||
116 | |||
117 | private JComboBox layerFieldsComboBox = null; |
||
118 | |||
119 | private ButtonGroup buttonGroup = null; |
||
120 | |||
121 | private JLabel jLabel3 = null; |
||
122 | |||
123 | private JCheckBox dissolveEntitiesJCheckBox = null; |
||
124 | |||
125 | private ViewInfo viewInfo;
|
||
126 | |||
127 | private JPanel methodSelectionPanel = null; |
||
128 | |||
129 | private JPanel resultSelectionPanel = null; |
||
130 | |||
131 | private JLabel jLabel1 = null; |
||
132 | |||
133 | private JCheckBox endCapCheckBox = null; |
||
134 | |||
135 | private JPanel extendedOptionsPanel = null; |
||
136 | |||
137 | private JPanel typePolygonBufferPanel = null; |
||
138 | |||
139 | private JLabel typeBufferLabel = null; |
||
140 | |||
141 | private JComboBox typeBufferComboBox = null; |
||
142 | |||
143 | private JPanel numBuffersPanel = null; |
||
144 | |||
145 | private JLabel radialBufferLabel = null; |
||
146 | |||
147 | private JSpinner radialBufferSpinner = null; |
||
148 | |||
149 | /**
|
||
150 | * This constructor initializes the set of layers
|
||
151 | */
|
||
152 | public GeoProcessingBufferPanel(FLayers layers) {
|
||
153 | super();
|
||
154 | this.layers = layers;
|
||
155 | initialize(); |
||
156 | } |
||
157 | |||
158 | /**
|
||
159 | * This method initializes this
|
||
160 | *
|
||
161 | * @return void
|
||
162 | */
|
||
163 | private void initialize() { |
||
164 | jLabel3 = new JLabel(); |
||
165 | jLabel = new JLabel(); |
||
166 | this.setLayout(null); |
||
167 | this.setBounds(new java.awt.Rectangle(0, 0, 486, 377)); |
||
168 | jLabel.setText(PluginServices.getText(this,
|
||
169 | "Areas_de_influencia._Introduccion_de_datos")
|
||
170 | + ":");
|
||
171 | jLabel.setBounds(5, 20, 343, 21); |
||
172 | jLabel3.setText(PluginServices.getText(this, "Cobertura_de_entrada") |
||
173 | + ":");
|
||
174 | jLabel3.setBounds(6, 63, 190, 21); |
||
175 | this.add(jLabel, null); |
||
176 | this.add(jLabel3, null); |
||
177 | this.add(getLayersComboBox(), null); |
||
178 | this.add(getSelectedOnlyCheckBox(), null); |
||
179 | this.add(getMethodSelectionPanel(), null); |
||
180 | this.add(getResultSelectionPanel(), null); |
||
181 | this.add(getExtendedOptionsPanel(), null); |
||
182 | confButtonGroup(); |
||
183 | layersComboBox.setSelectedIndex(0);
|
||
184 | initSelectedItemsJCheckBox(); |
||
185 | distanceBufferRadioButton.setSelected(true);
|
||
186 | layerFieldsComboBox.setEnabled(false);
|
||
187 | verifyTypeBufferComboEnabled(); |
||
188 | } |
||
189 | |||
190 | private String[] getFieldNames() { |
||
191 | AlphanumericData lyr = (AlphanumericData) (layers |
||
192 | .getLayer((String) layersComboBox.getSelectedItem()));
|
||
193 | DataSource ds;
|
||
194 | String[] fieldNames = null; |
||
195 | try {
|
||
196 | ds = lyr.getRecordset(); |
||
197 | fieldNames = new String[ds.getFieldCount()]; |
||
198 | for (int i = 0; i < ds.getFieldCount(); i++) { |
||
199 | fieldNames[i] = ds.getFieldName(i); |
||
200 | } |
||
201 | } catch (DriverException e) {
|
||
202 | // TODO Auto-generated catch block
|
||
203 | e.printStackTrace(); |
||
204 | } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
||
205 | // TODO Auto-generated catch block
|
||
206 | e.printStackTrace(); |
||
207 | } |
||
208 | return fieldNames;
|
||
209 | } |
||
210 | |||
211 | private void initSelectedItemsJCheckBox() { |
||
212 | String selectedLayer = (String) layersComboBox.getSelectedItem(); |
||
213 | FLyrVect inputLayer = (FLyrVect) layers.getLayer(selectedLayer); |
||
214 | FBitSet fBitSet = null;
|
||
215 | try {
|
||
216 | fBitSet = inputLayer.getRecordset().getSelection(); |
||
217 | } catch (DriverException e) {
|
||
218 | // TODO Auto-generated catch block
|
||
219 | e.printStackTrace(); |
||
220 | } |
||
221 | if (fBitSet.cardinality() == 0) { |
||
222 | selectedOnlyCheckbox.setEnabled(false);
|
||
223 | } else {
|
||
224 | selectedOnlyCheckbox.setEnabled(true);
|
||
225 | } |
||
226 | selectedOnlyCheckbox.setSelected(false);
|
||
227 | } |
||
228 | |||
229 | private JCheckBox getSelectedOnlyCheckBox() { |
||
230 | if (selectedOnlyCheckbox == null) { |
||
231 | selectedOnlyCheckbox = new JCheckBox(); |
||
232 | selectedOnlyCheckbox.setText(PluginServices.getText(this,
|
||
233 | "Usar_solamente_los_elementos_seleccionados"));
|
||
234 | selectedOnlyCheckbox.setBounds(8, 102, 339, 21); |
||
235 | } |
||
236 | return selectedOnlyCheckbox;
|
||
237 | } |
||
238 | |||
239 | /**
|
||
240 | * This method initializes layersComboBox
|
||
241 | *
|
||
242 | * @return javax.swing.JComboBox
|
||
243 | */
|
||
244 | private JComboBox getLayersComboBox() { |
||
245 | if (layersComboBox == null) { |
||
246 | layersComboBox = new JComboBox(); |
||
247 | DefaultComboBoxModel defaultModel = new DefaultComboBoxModel( |
||
248 | getLayerNames()); |
||
249 | layersComboBox.setModel(defaultModel); |
||
250 | layersComboBox.setBounds(142, 63, 260, 21); |
||
251 | layersComboBox.addItemListener(new java.awt.event.ItemListener() {
|
||
252 | public void itemStateChanged(ItemEvent e) { |
||
253 | if (e.getStateChange() == ItemEvent.SELECTED) { |
||
254 | // Cambiar el estado del CheckBox
|
||
255 | initSelectedItemsJCheckBox(); |
||
256 | |||
257 | // Cambiar el estado del layerFieldsComboBox
|
||
258 | DefaultComboBoxModel defaultModel = new DefaultComboBoxModel( |
||
259 | getFieldNames()); |
||
260 | layerFieldsComboBox.setModel(defaultModel); |
||
261 | verifyTypeBufferComboEnabled(); |
||
262 | } |
||
263 | } |
||
264 | }); |
||
265 | } |
||
266 | return layersComboBox;
|
||
267 | } |
||
268 | |||
269 | |||
270 | private void verifyTypeBufferComboEnabled(){ |
||
271 | String layerName = (String) layersComboBox.getSelectedItem(); |
||
272 | FLyrVect layer = (FLyrVect) layers.getLayer(layerName); |
||
273 | boolean enable = false; |
||
274 | try {
|
||
275 | enable = layer.getShapeType() == XTypes.POLYGON; |
||
276 | } catch (DriverException e1) {
|
||
277 | e1.printStackTrace(); |
||
278 | } |
||
279 | enableTypePolygonBufferPanel(enable); |
||
280 | } |
||
281 | |||
282 | |||
283 | /**
|
||
284 | * This method initializes fileNameResultTextField
|
||
285 | *
|
||
286 | * @return javax.swing.JTextField
|
||
287 | */
|
||
288 | private JTextField getFileNameResultTextField() { |
||
289 | if (fileNameResultTextField == null) { |
||
290 | fileNameResultTextField = new JTextField(); |
||
291 | fileNameResultTextField.setBounds(new java.awt.Rectangle(132, 11, |
||
292 | 199, 21)); |
||
293 | } |
||
294 | return fileNameResultTextField;
|
||
295 | } |
||
296 | |||
297 | /**
|
||
298 | * This method initializes openFileButton
|
||
299 | *
|
||
300 | * @return javax.swing.JButton
|
||
301 | */
|
||
302 | private JButton getOpenFileButton() { |
||
303 | if (openFileButton == null) { |
||
304 | openFileButton = new JButton(); |
||
305 | openFileButton.setText(PluginServices.getText(this, "Abrir")); |
||
306 | openFileButton.setBounds(new java.awt.Rectangle(335, 11, 129, 21)); |
||
307 | openFileButton |
||
308 | .addActionListener(new java.awt.event.ActionListener() {
|
||
309 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
310 | openResultFile(); |
||
311 | } |
||
312 | }); |
||
313 | } |
||
314 | return openFileButton;
|
||
315 | } |
||
316 | |||
317 | private void confButtonGroup() { |
||
318 | if (buttonGroup == null) { |
||
319 | buttonGroup = new ButtonGroup(); |
||
320 | buttonGroup.add(getDistanceBufferRadioButton()); |
||
321 | buttonGroup.add(getAttributeBufferRadioButton()); |
||
322 | } |
||
323 | } |
||
324 | |||
325 | /**
|
||
326 | * This method initializes distanceBufferRadioButton
|
||
327 | *
|
||
328 | * @return javax.swing.JRadioButton
|
||
329 | */
|
||
330 | private JRadioButton getDistanceBufferRadioButton() { |
||
331 | if (distanceBufferRadioButton == null) { |
||
332 | distanceBufferRadioButton = new JRadioButton(); |
||
333 | distanceBufferRadioButton.setText(PluginServices.getText(this,
|
||
334 | "Area_de_influencia_definida_por_una_distancia")
|
||
335 | + ":");
|
||
336 | distanceBufferRadioButton.setBounds(new java.awt.Rectangle(2, 10, |
||
337 | 303, 24)); |
||
338 | distanceBufferRadioButton |
||
339 | .addActionListener(new java.awt.event.ActionListener() {
|
||
340 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
341 | constantDistanceSelected(); |
||
342 | } |
||
343 | }); |
||
344 | } |
||
345 | return distanceBufferRadioButton;
|
||
346 | } |
||
347 | |||
348 | /**
|
||
349 | * This method initializes bufferDistanceTextField
|
||
350 | *
|
||
351 | * @return javax.swing.JTextField
|
||
352 | */
|
||
353 | private JTextField getBufferDistanceTextField() { |
||
354 | if (bufferDistanceTextField == null) { |
||
355 | bufferDistanceTextField = new JTextField(); |
||
356 | bufferDistanceTextField.setBounds(new java.awt.Rectangle(308, 11, |
||
357 | 134, 21)); |
||
358 | } |
||
359 | return bufferDistanceTextField;
|
||
360 | } |
||
361 | |||
362 | /**
|
||
363 | * This method initializes attributeBufferRadioButton
|
||
364 | *
|
||
365 | * @return javax.swing.JRadioButton
|
||
366 | */
|
||
367 | private JRadioButton getAttributeBufferRadioButton() { |
||
368 | if (attributeBufferRadioButton == null) { |
||
369 | attributeBufferRadioButton = new JRadioButton(); |
||
370 | attributeBufferRadioButton.setText(PluginServices.getText(this,
|
||
371 | "Area_de_influencia_definida_por_un_campo")
|
||
372 | + ":");
|
||
373 | attributeBufferRadioButton.setBounds(new java.awt.Rectangle(2, 41, |
||
374 | 287, 21)); |
||
375 | attributeBufferRadioButton |
||
376 | .addActionListener(new java.awt.event.ActionListener() {
|
||
377 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
378 | attributeDistanceSelected(); |
||
379 | } |
||
380 | }); |
||
381 | } |
||
382 | return attributeBufferRadioButton;
|
||
383 | } |
||
384 | |||
385 | /**
|
||
386 | * This method initializes layerFieldsComboBox
|
||
387 | *
|
||
388 | * @return javax.swing.JComboBox
|
||
389 | */
|
||
390 | private JComboBox getLayerFieldsComboBox() { |
||
391 | if (layerFieldsComboBox == null) { |
||
392 | layerFieldsComboBox = new JComboBox(); |
||
393 | layerFieldsComboBox.setBounds(new java.awt.Rectangle(308, 41, 138, |
||
394 | 21));
|
||
395 | DefaultComboBoxModel defaultModel = new DefaultComboBoxModel( |
||
396 | getFieldNames()); |
||
397 | layerFieldsComboBox.setModel(defaultModel); |
||
398 | } |
||
399 | return layerFieldsComboBox;
|
||
400 | } |
||
401 | |||
402 | public File getOutputFile() { |
||
403 | return new File(getFileNameResultTextField().getText()); |
||
404 | } |
||
405 | |||
406 | private JCheckBox getDissolveEntitiesJCheckBox() { |
||
407 | if (dissolveEntitiesJCheckBox == null) { |
||
408 | dissolveEntitiesJCheckBox = new JCheckBox(); |
||
409 | dissolveEntitiesJCheckBox.setText(PluginServices.getText(this,
|
||
410 | "Disolver_entidades"));
|
||
411 | dissolveEntitiesJCheckBox.setBounds(new java.awt.Rectangle(9, 70, |
||
412 | 190, 21)); |
||
413 | } |
||
414 | return dissolveEntitiesJCheckBox;
|
||
415 | } |
||
416 | |||
417 | public void openResultFile() { |
||
418 | JFileChooser jfc = new JFileChooser(); |
||
419 | jfc |
||
420 | .addChoosableFileFilter(new GenericFileFilter("shp", |
||
421 | "Ficheros SHP"));
|
||
422 | if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
||
423 | File file = jfc.getSelectedFile();
|
||
424 | if (!(file.getPath().endsWith(".shp") || file.getPath().endsWith( |
||
425 | ".SHP"))) {
|
||
426 | file = new File(file.getPath() + ".shp"); |
||
427 | } |
||
428 | }// if
|
||
429 | if (jfc.getSelectedFile() != null) { |
||
430 | getFileNameResultTextField().setText( |
||
431 | jfc.getSelectedFile().getAbsolutePath()); |
||
432 | } |
||
433 | |||
434 | } |
||
435 | |||
436 | public void constantDistanceSelected() { |
||
437 | getBufferDistanceTextField().setEnabled(true);
|
||
438 | getLayerFieldsComboBox().setEnabled(false);
|
||
439 | |||
440 | } |
||
441 | |||
442 | public void attributeDistanceSelected() { |
||
443 | getBufferDistanceTextField().setEnabled(false);
|
||
444 | getLayerFieldsComboBox().setEnabled(true);
|
||
445 | |||
446 | } |
||
447 | |||
448 | public boolean isConstantDistanceSelected() { |
||
449 | return distanceBufferRadioButton.isSelected();
|
||
450 | } |
||
451 | |||
452 | public boolean isAttributeDistanceSelected() { |
||
453 | return attributeBufferRadioButton.isSelected();
|
||
454 | } |
||
455 | |||
456 | public double getConstantDistance() throws GeoprocessException { |
||
457 | try {
|
||
458 | String strDist = bufferDistanceTextField.getText();
|
||
459 | return Double.parseDouble(strDist); |
||
460 | } catch (NumberFormatException ex) { |
||
461 | throw new GeoprocessException( |
||
462 | "Distancia de buffer introducida no numerica");
|
||
463 | } |
||
464 | } |
||
465 | |||
466 | public String getAttributeDistanceField() throws GeoprocessException { |
||
467 | String attributeField = (String) layerFieldsComboBox.getSelectedItem(); |
||
468 | FLyrVect selectedLayer = getInputLayer(); |
||
469 | try {
|
||
470 | SelectableDataSource selectable = selectedLayer.getRecordset(); |
||
471 | |||
472 | int fieldIndex = selectable.getFieldIndexByName(attributeField);
|
||
473 | int fieldType = selectable.getFieldType(fieldIndex);
|
||
474 | |||
475 | if (!XTypes.isNumeric(fieldType))
|
||
476 | throw new GeoprocessException( |
||
477 | "Atributo no numerico para distancia de buffer");
|
||
478 | |||
479 | } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
|
||
480 | throw new GeoprocessException( |
||
481 | "Problemas accediendo al campo que define la distancia de buffer");
|
||
482 | } catch (DriverException e) {
|
||
483 | throw new GeoprocessException( |
||
484 | "Problemas accediendo al campo que define la distancia de buffer");
|
||
485 | } |
||
486 | return attributeField;
|
||
487 | } |
||
488 | |||
489 | public boolean isBufferOnlySelected() { |
||
490 | return selectedOnlyCheckbox.isSelected();
|
||
491 | } |
||
492 | |||
493 | public boolean isDissolveBuffersSelected() { |
||
494 | return dissolveEntitiesJCheckBox.isSelected();
|
||
495 | } |
||
496 | |||
497 | public ViewInfo getViewInfo() {
|
||
498 | if (viewInfo == null) { |
||
499 | viewInfo = new ViewInfo(ViewInfo.MODALDIALOG);
|
||
500 | viewInfo.setTitle(PluginServices |
||
501 | .getText(this, "Area_de_influencia")); |
||
502 | } |
||
503 | return viewInfo;
|
||
504 | } |
||
505 | |||
506 | /**
|
||
507 | * This method initializes methodSelectionPanel
|
||
508 | *
|
||
509 | * @return javax.swing.JPanel
|
||
510 | */
|
||
511 | private JPanel getMethodSelectionPanel() { |
||
512 | if (methodSelectionPanel == null) { |
||
513 | methodSelectionPanel = new JPanel(); |
||
514 | methodSelectionPanel.setLayout(null);
|
||
515 | methodSelectionPanel.setBounds(new java.awt.Rectangle(2, 127, 467, |
||
516 | 94));
|
||
517 | methodSelectionPanel |
||
518 | .setBorder(javax.swing.BorderFactory |
||
519 | .createEtchedBorder(javax.swing.border.EtchedBorder.RAISED)); |
||
520 | methodSelectionPanel.add(getDistanceBufferRadioButton(), null);
|
||
521 | methodSelectionPanel.add(getBufferDistanceTextField(), null);
|
||
522 | methodSelectionPanel.add(getAttributeBufferRadioButton(), null);
|
||
523 | methodSelectionPanel.add(getLayerFieldsComboBox(), null);
|
||
524 | methodSelectionPanel.add(getDissolveEntitiesJCheckBox(), null);
|
||
525 | methodSelectionPanel.add(getEndCapCheckBox(), null);
|
||
526 | } |
||
527 | return methodSelectionPanel;
|
||
528 | } |
||
529 | |||
530 | /**
|
||
531 | * This method initializes resultSelectionPanel
|
||
532 | *
|
||
533 | * @return javax.swing.JPanel
|
||
534 | */
|
||
535 | private JPanel getResultSelectionPanel() { |
||
536 | if (resultSelectionPanel == null) { |
||
537 | jLabel1 = new JLabel(); |
||
538 | jLabel1.setBounds(new java.awt.Rectangle(5, 9, 132, 24)); |
||
539 | jLabel1.setText(PluginServices.getText(this, "Cobertura_de_salida") |
||
540 | + ":");
|
||
541 | resultSelectionPanel = new JPanel(); |
||
542 | resultSelectionPanel.setLayout(null);
|
||
543 | resultSelectionPanel.setBounds(new java.awt.Rectangle(0, 291, 468, |
||
544 | 41));
|
||
545 | resultSelectionPanel |
||
546 | .setBorder(javax.swing.BorderFactory |
||
547 | .createEtchedBorder(javax.swing.border.EtchedBorder.RAISED)); |
||
548 | resultSelectionPanel.add(getFileNameResultTextField(), null);
|
||
549 | resultSelectionPanel.add(getOpenFileButton(), null);
|
||
550 | resultSelectionPanel.add(jLabel1, null);
|
||
551 | } |
||
552 | return resultSelectionPanel;
|
||
553 | } |
||
554 | |||
555 | public boolean isSquareCap() { |
||
556 | return getEndCapCheckBox().isSelected();
|
||
557 | } |
||
558 | |||
559 | /**
|
||
560 | * This method initializes endCapCheckBox
|
||
561 | *
|
||
562 | * @return javax.swing.JCheckBox
|
||
563 | */
|
||
564 | private JCheckBox getEndCapCheckBox() { |
||
565 | if (endCapCheckBox == null) { |
||
566 | endCapCheckBox = new JCheckBox(); |
||
567 | endCapCheckBox.setBounds(new java.awt.Rectangle(209, 69, 235, 21)); |
||
568 | endCapCheckBox.setText(PluginServices.getText(this,
|
||
569 | "No_usar_buffer_redondeado"));
|
||
570 | } |
||
571 | return endCapCheckBox;
|
||
572 | } |
||
573 | |||
574 | /**
|
||
575 | * This method initializes extendedOptionsPanel
|
||
576 | *
|
||
577 | * @return javax.swing.JPanel
|
||
578 | */
|
||
579 | private JPanel getExtendedOptionsPanel() { |
||
580 | if (extendedOptionsPanel == null) { |
||
581 | extendedOptionsPanel = new JPanel(); |
||
582 | extendedOptionsPanel.setLayout(null);
|
||
583 | extendedOptionsPanel.setBounds(new java.awt.Rectangle(2, 226, 465, |
||
584 | 62));
|
||
585 | extendedOptionsPanel |
||
586 | .setBorder(javax.swing.BorderFactory |
||
587 | .createEtchedBorder(javax.swing.border.EtchedBorder.RAISED)); |
||
588 | extendedOptionsPanel.add(getTypePolygonBufferPanel(), null);
|
||
589 | extendedOptionsPanel.add(getNumBuffersPanel(), null);
|
||
590 | } |
||
591 | return extendedOptionsPanel;
|
||
592 | } |
||
593 | |||
594 | /**
|
||
595 | * This method initializes typePolygonBufferPanel
|
||
596 | *
|
||
597 | * @return javax.swing.JPanel
|
||
598 | */
|
||
599 | private JPanel getTypePolygonBufferPanel() { |
||
600 | if (typePolygonBufferPanel == null) { |
||
601 | typeBufferLabel = new JLabel(); |
||
602 | typeBufferLabel.setBounds(new java.awt.Rectangle(10, 3, 143, 18)); |
||
603 | typeBufferLabel.setText(PluginServices |
||
604 | .getText(this, "Crear_Buffer")); |
||
605 | typePolygonBufferPanel = new JPanel(); |
||
606 | typePolygonBufferPanel.setLayout(null);
|
||
607 | typePolygonBufferPanel.setBounds(new java.awt.Rectangle(8, 6, 449, |
||
608 | 24));
|
||
609 | typePolygonBufferPanel.add(typeBufferLabel, null);
|
||
610 | typePolygonBufferPanel.add(getTypeBufferComboBox(), null);
|
||
611 | } |
||
612 | return typePolygonBufferPanel;
|
||
613 | } |
||
614 | |||
615 | /**
|
||
616 | * This method initializes typeBufferComboBox
|
||
617 | *
|
||
618 | * @return javax.swing.JComboBox
|
||
619 | */
|
||
620 | private JComboBox getTypeBufferComboBox() { |
||
621 | if (typeBufferComboBox == null) { |
||
622 | typeBufferComboBox = new JComboBox(); |
||
623 | typeBufferComboBox |
||
624 | .setBounds(new java.awt.Rectangle(167, 4, 270, 18)); |
||
625 | typeBufferComboBox.addItem(BUFFER_INSIDE); |
||
626 | typeBufferComboBox.addItem(BUFFER_OUTSIDE); |
||
627 | typeBufferComboBox.addItem(BUFFER_INSIDE_OUTSIDE); |
||
628 | typeBufferComboBox.setSelectedItem(BUFFER_OUTSIDE); |
||
629 | } |
||
630 | return typeBufferComboBox;
|
||
631 | } |
||
632 | |||
633 | /**
|
||
634 | * Returns the type of polygon byffer (inside, outside, inside and outside)
|
||
635 | * selected by user
|
||
636 | *
|
||
637 | * @return
|
||
638 | */
|
||
639 | public String getTypePolygonBuffer() { |
||
640 | return (String) getTypeBufferComboBox().getSelectedItem(); |
||
641 | } |
||
642 | |||
643 | /**
|
||
644 | * Allow to enable/disable typePolygonBufferPanel (and all its components).
|
||
645 | * The reason is that this customizations are only possible with polygon
|
||
646 | * layers.
|
||
647 | *
|
||
648 | * @param enable
|
||
649 | */
|
||
650 | public void enableTypePolygonBufferPanel(boolean enable) { |
||
651 | getTypePolygonBufferPanel().setEnabled(enable); |
||
652 | getTypeBufferComboBox().setEnabled(enable); |
||
653 | } |
||
654 | |||
655 | /**
|
||
656 | * This method initializes numBuffersPanel
|
||
657 | *
|
||
658 | * @return javax.swing.JPanel
|
||
659 | */
|
||
660 | private JPanel getNumBuffersPanel() { |
||
661 | if (numBuffersPanel == null) { |
||
662 | radialBufferLabel = new JLabel(); |
||
663 | radialBufferLabel.setBounds(new java.awt.Rectangle(5, 3, 269, 19)); |
||
664 | radialBufferLabel.setText(PluginServices.getText(this,
|
||
665 | "Numero_anillos_concentricos"));
|
||
666 | numBuffersPanel = new JPanel(); |
||
667 | numBuffersPanel.setLayout(null);
|
||
668 | numBuffersPanel.setBounds(new java.awt.Rectangle(10, 35, 448, 24)); |
||
669 | numBuffersPanel.add(radialBufferLabel, null);
|
||
670 | numBuffersPanel.add(getRadialBufferSpinner(), null);
|
||
671 | } |
||
672 | return numBuffersPanel;
|
||
673 | } |
||
674 | |||
675 | /**
|
||
676 | * This method initializes radialBufferTextField
|
||
677 | *
|
||
678 | * @return javax.swing.JTextField
|
||
679 | */
|
||
680 | private JSpinner getRadialBufferSpinner() { |
||
681 | if (radialBufferSpinner == null) { |
||
682 | Integer one = new Integer(1); |
||
683 | Integer two = new Integer(2); |
||
684 | Integer three = new Integer(3); |
||
685 | SpinnerListModel listModel = new SpinnerListModel(new Integer[] { |
||
686 | one, two, three }); |
||
687 | radialBufferSpinner = new JSpinner(listModel); |
||
688 | radialBufferSpinner.setBounds(new java.awt.Rectangle(298, 3, 137, |
||
689 | 19));
|
||
690 | |||
691 | // Disable keyboard edits in the spinner
|
||
692 | JFormattedTextField tf = ((JSpinner.DefaultEditor) radialBufferSpinner |
||
693 | .getEditor()).getTextField(); |
||
694 | tf.setEditable(false);
|
||
695 | tf.setBackground(Color.white);
|
||
696 | } |
||
697 | return radialBufferSpinner;
|
||
698 | } |
||
699 | |||
700 | /**
|
||
701 | * Returns the number of radial buffers selected by user (by now, only a
|
||
702 | * maximum of three radial buffers allowed)
|
||
703 | *
|
||
704 | * @return
|
||
705 | */
|
||
706 | public int getNumberOfRadialBuffers() { |
||
707 | return ((Integer) radialBufferSpinner.getValue()).intValue(); |
||
708 | } |
||
709 | } // @jve:decl-index=0:visual-constraint="25,13" |