svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.selectiontools.app / org.gvsig.selectiontools.app.mainplugin / src / main / java / org / gvsig / selectiontools / app / extension / tools / buffer / gui / BufferConfigurationPanel.java @ 42095
History | View | Annotate | Download (24 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.selectiontools.app.extension.tools.buffer.gui; |
25 |
|
26 |
/* gvSIG. Geographic Information System of the Valencian Government
|
27 |
*
|
28 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
29 |
* of the Valencian Government (CIT)
|
30 |
*
|
31 |
* This program is free software; you can redistribute it and/or
|
32 |
* modify it under the terms of the GNU General Public License
|
33 |
* as published by the Free Software Foundation; either version 2
|
34 |
* of the License, or (at your option) any later version.
|
35 |
*
|
36 |
* This program is distributed in the hope that it will be useful,
|
37 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
38 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
39 |
* GNU General Public License for more details.
|
40 |
*
|
41 |
* You should have received a copy of the GNU General Public License
|
42 |
* along with this program; if not, write to the Free Software
|
43 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
44 |
* MA 02110-1301, USA.
|
45 |
*
|
46 |
*/
|
47 |
|
48 |
import java.awt.Dimension; |
49 |
import java.awt.FlowLayout; |
50 |
import java.awt.event.ActionEvent; |
51 |
import java.awt.event.ActionListener; |
52 |
import java.awt.event.ComponentAdapter; |
53 |
import java.awt.event.ComponentEvent; |
54 |
import java.util.ArrayList; |
55 |
import java.util.Arrays; |
56 |
import java.util.Iterator; |
57 |
import java.util.List; |
58 |
|
59 |
import javax.swing.BorderFactory; |
60 |
import javax.swing.JCheckBox; |
61 |
import javax.swing.JLabel; |
62 |
import javax.swing.JOptionPane; |
63 |
import javax.swing.JPanel; |
64 |
import javax.swing.JTextField; |
65 |
|
66 |
import org.gvsig.andami.PluginServices; |
67 |
import org.gvsig.andami.messages.NotificationManager; |
68 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
69 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
70 |
import org.gvsig.app.ApplicationLocator; |
71 |
import org.gvsig.app.project.documents.view.gui.IView; |
72 |
import org.gvsig.fmap.dal.exception.DataException; |
73 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
74 |
import org.gvsig.fmap.mapcontrol.MapControl; |
75 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
76 |
import org.gvsig.gui.beans.incrementabletask.IncrementableTask; |
77 |
import org.gvsig.gui.beans.progresspanel.ProgressPanel; |
78 |
import org.gvsig.i18n.Messages; |
79 |
import org.gvsig.selectiontools.app.extension.tools.buffer.process.BufferSelectionProcess; |
80 |
import org.gvsig.utils.swing.JComboBox; |
81 |
|
82 |
/**
|
83 |
*
|
84 |
*
|
85 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
86 |
*/
|
87 |
public class BufferConfigurationPanel extends JPanel implements IWindow { |
88 |
|
89 |
private WindowInfo viewInfo = null; |
90 |
private final short Window_Width = 354; |
91 |
private final short Window_Height = 315; // 35; |
92 |
private JTextField distanceText = null; |
93 |
private JComboBox distanceUnitsCombo = null; |
94 |
private JComboBox polygonSidesCombo = null; |
95 |
private JComboBox lineSidesCombo = null; |
96 |
private JComboBox pointSidesCombo = null; |
97 |
private JComboBox multiPointSidesCombo = null; |
98 |
private JLabel distanceUnitsLabel = null; |
99 |
private JLabel polygonSideLabel = null; |
100 |
private JLabel lineSideLabel = null; |
101 |
private JLabel pointSideLabel = null; |
102 |
private JLabel multiPointSideLabel = null; |
103 |
private JPanel polygonSidePanel = null; |
104 |
private JPanel lineSidePanel = null; |
105 |
private JPanel pointSidePanel = null; |
106 |
private JPanel multiPointSidePanel = null; |
107 |
private JLabel widthLabel = null; |
108 |
private JPanel widthPanel = null; |
109 |
// private JPanel distanceUnits = null;
|
110 |
private JPanel sidePanel = null; |
111 |
private JPanel optionsPanel = null; |
112 |
private AdaptedAcceptCancelPanel acceptCancelPanel = null; |
113 |
private List<FLyrVect> layers; |
114 |
private MapControl mapControl;
|
115 |
private IView view;
|
116 |
private JCheckBox multiLayerSelectionCBox; |
117 |
private SideInfo outside, inside, out_in_side;
|
118 |
|
119 |
/**
|
120 |
* Creates a new form where user can define the option of the buffer.
|
121 |
*/
|
122 |
public BufferConfigurationPanel(List<FLyrVect> layers, IView view) { |
123 |
super();
|
124 |
|
125 |
this.layers = layers;
|
126 |
this.view = view;
|
127 |
this.mapControl = view.getMapControl();
|
128 |
|
129 |
initialize(); |
130 |
} |
131 |
|
132 |
public BufferConfigurationPanel(FLyrVect[] array, IView view) { |
133 |
this(Arrays.asList(array),view); |
134 |
} |
135 |
|
136 |
/**
|
137 |
* Initializes this component.
|
138 |
*/
|
139 |
private void initialize() { |
140 |
outside = |
141 |
new SideInfo(BufferSelectionProcess.BUFFER_OUTSIDE_POLY,
|
142 |
PluginServices.getText(null, "Outside")); |
143 |
inside = |
144 |
new SideInfo(BufferSelectionProcess.BUFFER_INSIDE_POLY,
|
145 |
PluginServices.getText(null, "Inside")); |
146 |
out_in_side = |
147 |
new SideInfo(BufferSelectionProcess.BUFFER_INSIDE_OUTSIDE_POLY,
|
148 |
PluginServices.getText(null, "Both")); |
149 |
|
150 |
setLayout(new FlowLayout()); |
151 |
add(getWidthPanel()); |
152 |
add(getSidePanel()); |
153 |
add(getOptionsPanel()); |
154 |
add(getAdaptedAcceptCancelPanel()); |
155 |
} |
156 |
|
157 |
private JPanel getOptionsPanel() { |
158 |
if (optionsPanel == null) { |
159 |
optionsPanel = new JPanel(); |
160 |
optionsPanel.setLayout(new FlowLayout()); |
161 |
optionsPanel.setPreferredSize(new Dimension(344, 80)); // 106)); |
162 |
optionsPanel.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(optionsPanel,
|
163 |
"Options")));
|
164 |
optionsPanel.add(getMultiLayerSelectionCBox()); |
165 |
} |
166 |
|
167 |
return optionsPanel;
|
168 |
} |
169 |
|
170 |
private JCheckBox getMultiLayerSelectionCBox() { |
171 |
if (multiLayerSelectionCBox == null) { |
172 |
multiLayerSelectionCBox = new JCheckBox(); |
173 |
multiLayerSelectionCBox.setPreferredSize(new Dimension(330, 22)); |
174 |
multiLayerSelectionCBox.setText(PluginServices.getText(multiLayerSelectionCBox, |
175 |
"MultiLayer_selection"));
|
176 |
multiLayerSelectionCBox.setSelected(true);
|
177 |
multiLayerSelectionCBox.setToolTipText(PluginServices.getText(null,
|
178 |
"multiLayerSelection_checkbox_TOOLTIP_HTML_explanation"));
|
179 |
} |
180 |
|
181 |
return multiLayerSelectionCBox;
|
182 |
} |
183 |
|
184 |
private JPanel getWidthPanel() { |
185 |
if (widthPanel == null) { |
186 |
widthPanel = new JPanel(); |
187 |
widthPanel.setPreferredSize(new Dimension(344, 55)); |
188 |
widthPanel.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(widthPanel,
|
189 |
"width")));
|
190 |
widthPanel.setLayout(new FlowLayout()); |
191 |
widthPanel.add(getWidthLabel()); |
192 |
widthPanel.add(getWidthText()); |
193 |
widthPanel.add(getDistanceUnitsLabel()); |
194 |
widthPanel.add(getDistanceUnitsCombo()); |
195 |
} |
196 |
|
197 |
return widthPanel;
|
198 |
} |
199 |
|
200 |
private JLabel getWidthLabel() { |
201 |
if (widthLabel == null) { |
202 |
widthLabel = new JLabel(); |
203 |
widthLabel.setPreferredSize(new Dimension(68, 22)); |
204 |
widthLabel.setText(PluginServices.getText(widthLabel, "Width"));
|
205 |
widthLabel.setToolTipText(PluginServices.getText(null,
|
206 |
"bufferWidth_TOOLTIP_HTML_explanation"));
|
207 |
} |
208 |
|
209 |
return widthLabel;
|
210 |
} |
211 |
|
212 |
private JTextField getWidthText() { |
213 |
if (distanceText == null) { |
214 |
/*
|
215 |
DecimalFormat decimalFormat = new DecimalFormat();
|
216 |
|
217 |
decimalFormat.setDecimalSeparatorAlwaysShown(true);
|
218 |
decimalFormat.setMaximumIntegerDigits(12);
|
219 |
decimalFormat.setMinimumIntegerDigits(1);
|
220 |
decimalFormat.setMinimumFractionDigits(2);
|
221 |
decimalFormat.setMaximumFractionDigits(4);
|
222 |
|
223 |
decimalFormat.getDecimalFormatSymbols().setDecimalSeparator('.');
|
224 |
|
225 |
NumberFormatter numberFormatter = new NumberFormatter();
|
226 |
numberFormatter.setAllowsInvalid(false);
|
227 |
numberFormatter.setOverwriteMode(false);
|
228 |
numberFormatter.setCommitsOnValidEdit(true);
|
229 |
numberFormatter.setMinimum(new Double(0));
|
230 |
numberFormatter.setFormat(decimalFormat);
|
231 |
*/
|
232 |
|
233 |
// numberFormatter.setFormat(new
|
234 |
// DecimalFormat("([+]|[-])?[0-9]+([.][0-9]+)?"));
|
235 |
|
236 |
distanceText = new JTextField(); |
237 |
distanceText.setPreferredSize(new Dimension(85, 22)); |
238 |
distanceText.setText("100");
|
239 |
} |
240 |
|
241 |
return distanceText;
|
242 |
} |
243 |
|
244 |
private JLabel getDistanceUnitsLabel() { |
245 |
if (distanceUnitsLabel == null) { |
246 |
distanceUnitsLabel = |
247 |
new JLabel(PluginServices.getText(distanceUnitsLabel, "Units") + ":"); |
248 |
distanceUnitsLabel.setAlignmentX(JLabel.RIGHT_ALIGNMENT);
|
249 |
distanceUnitsLabel.setPreferredSize(new Dimension(68, 22)); |
250 |
distanceUnitsLabel.setToolTipText(PluginServices.getText(null,
|
251 |
"distanceUnitsLabel_TOOLTIP_HTML_explanation"));
|
252 |
} |
253 |
|
254 |
return distanceUnitsLabel;
|
255 |
} |
256 |
|
257 |
private JComboBox getDistanceUnitsCombo() { |
258 |
if (distanceUnitsCombo == null) { |
259 |
distanceUnitsCombo = new JComboBox(); |
260 |
distanceUnitsCombo.setPreferredSize(new Dimension(85, 22)); |
261 |
distanceUnitsCombo.addItem("km");
|
262 |
distanceUnitsCombo.addItem("m");
|
263 |
distanceUnitsCombo.addItem("cm");
|
264 |
distanceUnitsCombo.addItem("mm");
|
265 |
distanceUnitsCombo.addItem("mi");
|
266 |
distanceUnitsCombo.addItem("Ya");
|
267 |
distanceUnitsCombo.addItem("ft");
|
268 |
distanceUnitsCombo.addItem("in");
|
269 |
// distanceUnitsCombo.addItem("?");
|
270 |
distanceUnitsCombo.setSelectedIndex(1); // By default in meters |
271 |
distanceUnitsCombo.setToolTipText(PluginServices.getText(null,
|
272 |
"distanceUnitsLabel_TOOLTIP_HTML_explanation"));
|
273 |
} |
274 |
|
275 |
return distanceUnitsCombo;
|
276 |
} |
277 |
|
278 |
private JPanel getSidePanel() { |
279 |
if (sidePanel == null) { |
280 |
sidePanel = new JPanel(); |
281 |
sidePanel.setLayout(new FlowLayout()); |
282 |
sidePanel.setPreferredSize(new Dimension(344, 166)); |
283 |
sidePanel.setBorder(BorderFactory.createTitledBorder(PluginServices.getText(sidePanel,
|
284 |
"Side")));
|
285 |
sidePanel.setToolTipText(PluginServices.getText(null,
|
286 |
"sideLabel_TOOLTIP_HTML_explanation"));
|
287 |
sidePanel.add(getPolygonSidePanel()); |
288 |
sidePanel.add(getLineSidePanel()); |
289 |
sidePanel.add(getPointSidePanel()); |
290 |
sidePanel.add(getMultiPointSidePanel()); |
291 |
} |
292 |
|
293 |
return sidePanel;
|
294 |
} |
295 |
|
296 |
private JPanel getPolygonSidePanel() { |
297 |
if (polygonSidePanel == null) { |
298 |
polygonSidePanel = new JPanel(); |
299 |
polygonSidePanel.setPreferredSize(new Dimension(336, 28)); |
300 |
polygonSidePanel.add(getPolygonSideLabel()); |
301 |
polygonSidePanel.add(getPolygonSidesCombo()); |
302 |
} |
303 |
|
304 |
return polygonSidePanel;
|
305 |
} |
306 |
|
307 |
private JLabel getPolygonSideLabel() { |
308 |
if (polygonSideLabel == null) { |
309 |
polygonSideLabel = |
310 |
new JLabel(PluginServices.getText(polygonSideLabel, "Polygon") + ":"); |
311 |
polygonSideLabel.setPreferredSize(new Dimension(90, 22)); |
312 |
polygonSideLabel.setToolTipText(PluginServices.getText(null,
|
313 |
"polygonSideLabel_TOOLTIP_HTML_explanation"));
|
314 |
} |
315 |
|
316 |
return polygonSideLabel;
|
317 |
} |
318 |
|
319 |
private JComboBox getPolygonSidesCombo() { |
320 |
if (polygonSidesCombo == null) { |
321 |
polygonSidesCombo = new JComboBox(); |
322 |
polygonSidesCombo.setPreferredSize(new Dimension(230, 22)); |
323 |
polygonSidesCombo.addItem(outside); |
324 |
polygonSidesCombo.addItem(inside); |
325 |
// polygonSidesCombo.addItem(out_in_side); // Disabled because fails
|
326 |
// quite often
|
327 |
polygonSidesCombo.setToolTipText(PluginServices.getText(null,
|
328 |
"polygonSideLabel_TOOLTIP_HTML_explanation"));
|
329 |
} |
330 |
|
331 |
return polygonSidesCombo;
|
332 |
} |
333 |
|
334 |
private JPanel getLineSidePanel() { |
335 |
if (lineSidePanel == null) { |
336 |
lineSidePanel = new JPanel(); |
337 |
lineSidePanel.setPreferredSize(new Dimension(336, 28)); |
338 |
lineSidePanel.add(getLineSideLabel()); |
339 |
lineSidePanel.add(getLineSidesCombo()); |
340 |
} |
341 |
|
342 |
return lineSidePanel;
|
343 |
} |
344 |
|
345 |
private JLabel getLineSideLabel() { |
346 |
if (lineSideLabel == null) { |
347 |
lineSideLabel = |
348 |
new JLabel(PluginServices.getText(lineSideLabel, "Line") + ":"); |
349 |
lineSideLabel.setPreferredSize(new Dimension(90, 22)); |
350 |
lineSideLabel.setToolTipText(PluginServices.getText(null,
|
351 |
"lineSideLabel_TOOLTIP_HTML_explanation"));
|
352 |
} |
353 |
|
354 |
return lineSideLabel;
|
355 |
} |
356 |
|
357 |
private JComboBox getLineSidesCombo() { |
358 |
if (lineSidesCombo == null) { |
359 |
lineSidesCombo = new JComboBox(); |
360 |
lineSidesCombo.setPreferredSize(new Dimension(230, 22)); |
361 |
lineSidesCombo.addItem(outside); |
362 |
lineSidesCombo.setToolTipText(PluginServices.getText(null,
|
363 |
"lineSideLabel_TOOLTIP_HTML_explanation"));
|
364 |
} |
365 |
|
366 |
return lineSidesCombo;
|
367 |
} |
368 |
|
369 |
private JPanel getPointSidePanel() { |
370 |
if (pointSidePanel == null) { |
371 |
pointSidePanel = new JPanel(); |
372 |
pointSidePanel.setPreferredSize(new Dimension(336, 28)); |
373 |
pointSidePanel.add(getPointSideLabel()); |
374 |
pointSidePanel.add(getPointSidesCombo()); |
375 |
} |
376 |
|
377 |
return pointSidePanel;
|
378 |
} |
379 |
|
380 |
private JLabel getPointSideLabel() { |
381 |
if (pointSideLabel == null) { |
382 |
pointSideLabel = |
383 |
new JLabel(PluginServices.getText(pointSideLabel, "Point") + ":"); |
384 |
pointSideLabel.setPreferredSize(new Dimension(90, 22)); |
385 |
pointSideLabel.setToolTipText(PluginServices.getText(null,
|
386 |
"pointSideLabel_TOOLTIP_HTML_explanation"));
|
387 |
} |
388 |
|
389 |
return pointSideLabel;
|
390 |
} |
391 |
|
392 |
private JComboBox getPointSidesCombo() { |
393 |
if (pointSidesCombo == null) { |
394 |
pointSidesCombo = new JComboBox(); |
395 |
pointSidesCombo.setPreferredSize(new Dimension(230, 22)); |
396 |
pointSidesCombo.addItem(outside); |
397 |
pointSidesCombo.setToolTipText(PluginServices.getText(null,
|
398 |
"pointSideLabel_TOOLTIP_HTML_explanation"));
|
399 |
} |
400 |
|
401 |
return pointSidesCombo;
|
402 |
} |
403 |
|
404 |
private JPanel getMultiPointSidePanel() { |
405 |
if (multiPointSidePanel == null) { |
406 |
multiPointSidePanel = new JPanel(); |
407 |
multiPointSidePanel.setPreferredSize(new Dimension(336, 28)); |
408 |
multiPointSidePanel.add(getMultiPointSideLabel()); |
409 |
multiPointSidePanel.add(getMultiPointSidesCombo()); |
410 |
} |
411 |
|
412 |
return multiPointSidePanel;
|
413 |
} |
414 |
|
415 |
private JLabel getMultiPointSideLabel() { |
416 |
if (multiPointSideLabel == null) { |
417 |
multiPointSideLabel = |
418 |
new JLabel(PluginServices.getText(multiPointSideLabel, |
419 |
"MultiPoint") + ":"); |
420 |
multiPointSideLabel.setPreferredSize(new Dimension(90, 22)); |
421 |
multiPointSideLabel.setToolTipText(PluginServices.getText(null,
|
422 |
"multiPointSideLabel_TOOLTIP_HTML_explanation"));
|
423 |
} |
424 |
|
425 |
return multiPointSideLabel;
|
426 |
} |
427 |
|
428 |
private JComboBox getMultiPointSidesCombo() { |
429 |
if (multiPointSidesCombo == null) { |
430 |
multiPointSidesCombo = new JComboBox(); |
431 |
multiPointSidesCombo.setPreferredSize(new Dimension(230, 22)); |
432 |
multiPointSidesCombo.addItem(outside); |
433 |
multiPointSidesCombo.setToolTipText(PluginServices.getText(null,
|
434 |
"multiPointSideLabel_TOOLTIP_HTML_explanation"));
|
435 |
} |
436 |
|
437 |
return multiPointSidesCombo;
|
438 |
} |
439 |
|
440 |
/**
|
441 |
* <p>
|
442 |
* This method initializes acceptCancelPanel.
|
443 |
* </p>
|
444 |
*
|
445 |
* @return an adapted {@link AcceptCancelPanel AcceptCancelPanel}
|
446 |
*/
|
447 |
private AdaptedAcceptCancelPanel getAdaptedAcceptCancelPanel() {
|
448 |
if (acceptCancelPanel == null) { |
449 |
acceptCancelPanel = new AdaptedAcceptCancelPanel();
|
450 |
} |
451 |
|
452 |
return acceptCancelPanel;
|
453 |
} |
454 |
|
455 |
/*
|
456 |
* (non-Javadoc)
|
457 |
*
|
458 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
|
459 |
*/
|
460 |
public WindowInfo getWindowInfo() {
|
461 |
if (viewInfo == null) { |
462 |
viewInfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
463 |
viewInfo.setTitle( |
464 |
Messages.getText("Select_by_buffer"));
|
465 |
viewInfo.setWidth(Window_Width); |
466 |
viewInfo.setHeight(Window_Height); |
467 |
} |
468 |
|
469 |
return viewInfo;
|
470 |
} |
471 |
|
472 |
/**
|
473 |
* <p>
|
474 |
* Adapts {@link AcceptCancelPanel AcceptCancelPanel} to be used as a
|
475 |
* component of the <code>BufferConfigurationPanel</code> panel.
|
476 |
* </p>
|
477 |
*
|
478 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
479 |
*/
|
480 |
private class AdaptedAcceptCancelPanel extends AcceptCancelPanel { |
481 |
|
482 |
public AdaptedAcceptCancelPanel() {
|
483 |
super();
|
484 |
|
485 |
addOkButtonActionListener(getOKAction()); |
486 |
addCancelButtonActionListener(getCancelAction()); |
487 |
setPreferredSize(new Dimension(350, 30)); |
488 |
} |
489 |
|
490 |
/**
|
491 |
* <p>
|
492 |
* Create the action that will be executed when user pressed the
|
493 |
* <i>ok</i> button.
|
494 |
* </p>
|
495 |
*
|
496 |
* @return action that will be executed when user pressed the
|
497 |
* <i>cancel</i>
|
498 |
* button
|
499 |
*/
|
500 |
private ActionListener getOKAction() { |
501 |
// OK button action
|
502 |
return new ActionListener() { |
503 |
|
504 |
/*
|
505 |
* @see
|
506 |
* java.awt.event.ActionListener#actionPerformed(java.awt.event
|
507 |
* .ActionEvent)
|
508 |
*/
|
509 |
public void actionPerformed(ActionEvent e) { |
510 |
|
511 |
/* 1- Validates the buffer width */
|
512 |
double width;
|
513 |
|
514 |
try {
|
515 |
width = Double.parseDouble(getWidthText().getText());
|
516 |
/*
|
517 |
.replaceAll("(\\.)?", "")
|
518 |
.replace(",", ".")); // Formats the decimal
|
519 |
// number to be parsed
|
520 |
*
|
521 |
*/
|
522 |
} catch (Exception ex) { |
523 |
|
524 |
JOptionPane.showMessageDialog(
|
525 |
ApplicationLocator.getManager().getRootComponent(), |
526 |
Messages.getText("_Invalid_width_value")
|
527 |
+ " : \"" + getWidthText().getText() + "\"", |
528 |
Messages.getText("Select_by_buffer"),
|
529 |
JOptionPane.WARNING_MESSAGE);
|
530 |
return;
|
531 |
} |
532 |
|
533 |
/* 2- Closes this window */
|
534 |
closeThis(); |
535 |
|
536 |
|
537 |
/* 3- Creates the process */
|
538 |
// checks layers to proccess if multilayer is not selected
|
539 |
List<FLyrVect> tmpLayersToProccess = new ArrayList<FLyrVect>(); |
540 |
tmpLayersToProccess.addAll(layers); |
541 |
if (!multiLayerSelectionCBox.isSelected()) {
|
542 |
Iterator<FLyrVect> iter =
|
543 |
tmpLayersToProccess.iterator(); |
544 |
FLyrVect curLayer; |
545 |
while (iter.hasNext()) {
|
546 |
curLayer = (FLyrVect) iter.next(); |
547 |
try {
|
548 |
if (curLayer.getFeatureStore()
|
549 |
.getFeatureSelection() |
550 |
.isEmpty()) { |
551 |
iter.remove(); |
552 |
} |
553 |
} catch (DataException e1) {
|
554 |
NotificationManager.showMessageError(PluginServices.getText(null,
|
555 |
"Failed_selecting_layer"),
|
556 |
e1); |
557 |
return;
|
558 |
|
559 |
} |
560 |
} |
561 |
} |
562 |
FLyrVect[] layersToProcess =
|
563 |
(FLyrVect[]) tmpLayersToProccess.toArray(new FLyrVect[tmpLayersToProccess.size()]); |
564 |
|
565 |
BufferSelectionProcess iprocess = |
566 |
new BufferSelectionProcess(PluginServices.getText(this, |
567 |
"Select_by_buffer"),
|
568 |
PluginServices.getText(this,
|
569 |
"Ongoing_process_please_wait"),
|
570 |
mapControl, |
571 |
((SideInfo) getPolygonSidesCombo().getSelectedItem()).getSide(), |
572 |
((SideInfo) getLineSidesCombo().getSelectedItem()).getSide(), |
573 |
((SideInfo) getPointSidesCombo().getSelectedItem()).getSide(), |
574 |
((SideInfo) getMultiPointSidesCombo().getSelectedItem()).getSide(), |
575 |
width, |
576 |
(short) getDistanceUnitsCombo().getSelectedIndex(),
|
577 |
layersToProcess, |
578 |
getMultiLayerSelectionCBox().isSelected());// getAddBufferLayersCBox().isSelected(),
|
579 |
// getAddInfluenceAreaLayersCBox().isSelected(),
|
580 |
// getMultiLayerSelectionCBox().isSelected());
|
581 |
IncrementableTask iTask = |
582 |
new IncrementableTask(iprocess,
|
583 |
new ProgressPanel(false)); |
584 |
iTask.addIncrementableListener(iprocess); |
585 |
iprocess.setIncrementableTask(iTask); |
586 |
|
587 |
iTask.getProgressPanel() |
588 |
.addComponentListener(new ComponentAdapter() { |
589 |
public void componentHidden(ComponentEvent e) { |
590 |
mapControl.getMapContext().invalidate(); |
591 |
} |
592 |
}); |
593 |
|
594 |
/* 4- Starts the process */
|
595 |
iprocess.start(); |
596 |
iTask.start(); |
597 |
} |
598 |
}; |
599 |
} |
600 |
|
601 |
/**
|
602 |
* <p>
|
603 |
* Create the action that will be executed when user pressed the
|
604 |
* <i>cancel</i> button.
|
605 |
* </p>
|
606 |
*
|
607 |
* @return action that will be executed when user pressed the
|
608 |
* <i>cancel</i>
|
609 |
* button
|
610 |
*/
|
611 |
private ActionListener getCancelAction() { |
612 |
// Cancel button action
|
613 |
return new ActionListener() { |
614 |
|
615 |
/*
|
616 |
* @see
|
617 |
* java.awt.event.ActionListener#actionPerformed(java.awt.event
|
618 |
* .ActionEvent)
|
619 |
*/
|
620 |
public void actionPerformed(ActionEvent e) { |
621 |
closeThis(); |
622 |
} |
623 |
}; |
624 |
} |
625 |
} |
626 |
|
627 |
/**
|
628 |
* <p>
|
629 |
* Closes this window.
|
630 |
* </p>
|
631 |
*/
|
632 |
private void closeThis() { |
633 |
PluginServices.getMDIManager().closeWindow(this);
|
634 |
} |
635 |
|
636 |
/**
|
637 |
*
|
638 |
*
|
639 |
*
|
640 |
* @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
|
641 |
*/
|
642 |
private class SideInfo { |
643 |
|
644 |
private byte side; |
645 |
private String name; |
646 |
|
647 |
public SideInfo(byte side, String name) { |
648 |
this.side = side;
|
649 |
this.name = name;
|
650 |
} |
651 |
|
652 |
public String toString() { |
653 |
return name;
|
654 |
} |
655 |
|
656 |
public String getName() { |
657 |
return name;
|
658 |
} |
659 |
|
660 |
public byte getSide() { |
661 |
return side;
|
662 |
} |
663 |
} |
664 |
|
665 |
public Object getWindowProfile() { |
666 |
return WindowInfo.DIALOG_PROFILE;
|
667 |
} |
668 |
} |