59 |
59 |
import javax.swing.BorderFactory;
|
60 |
60 |
import javax.swing.JCheckBox;
|
61 |
61 |
import javax.swing.JLabel;
|
|
62 |
import javax.swing.JOptionPane;
|
62 |
63 |
import javax.swing.JPanel;
|
|
64 |
import javax.swing.JTextField;
|
63 |
65 |
import javax.swing.text.NumberFormatter;
|
64 |
66 |
|
65 |
67 |
import org.gvsig.andami.PluginServices;
|
66 |
68 |
import org.gvsig.andami.messages.NotificationManager;
|
67 |
69 |
import org.gvsig.andami.ui.mdiManager.IWindow;
|
68 |
70 |
import org.gvsig.andami.ui.mdiManager.WindowInfo;
|
|
71 |
import org.gvsig.app.ApplicationLocator;
|
69 |
72 |
import org.gvsig.app.project.documents.view.gui.IView;
|
70 |
73 |
import org.gvsig.fmap.dal.exception.DataException;
|
71 |
74 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
|
... | ... | |
73 |
76 |
import org.gvsig.gui.beans.AcceptCancelPanel;
|
74 |
77 |
import org.gvsig.gui.beans.incrementabletask.IncrementableTask;
|
75 |
78 |
import org.gvsig.gui.beans.progresspanel.ProgressPanel;
|
76 |
|
import org.gvsig.gui.beans.specificcaretposition.JFormattedTextFieldSCP;
|
77 |
79 |
import org.gvsig.i18n.Messages;
|
78 |
80 |
import org.gvsig.selectiontools.app.extension.tools.buffer.process.BufferSelectionProcess;
|
79 |
81 |
import org.gvsig.utils.swing.JComboBox;
|
... | ... | |
88 |
90 |
private WindowInfo viewInfo = null;
|
89 |
91 |
private final short Window_Width = 354;
|
90 |
92 |
private final short Window_Height = 315; // 35;
|
91 |
|
private JFormattedTextFieldSCP distanceTextField = null;
|
|
93 |
private JTextField distanceText = null;
|
92 |
94 |
private JComboBox distanceUnitsCombo = null;
|
93 |
95 |
private JComboBox polygonSidesCombo = null;
|
94 |
96 |
private JComboBox lineSidesCombo = null;
|
... | ... | |
188 |
190 |
"Width")));
|
189 |
191 |
widthPanel.setLayout(new FlowLayout());
|
190 |
192 |
widthPanel.add(getWidthLabel());
|
191 |
|
widthPanel.add(getWidthTextField());
|
|
193 |
widthPanel.add(getWidthText());
|
192 |
194 |
widthPanel.add(getDistanceUnitsLabel());
|
193 |
195 |
widthPanel.add(getDistanceUnitsCombo());
|
194 |
196 |
}
|
... | ... | |
208 |
210 |
return widthLabel;
|
209 |
211 |
}
|
210 |
212 |
|
211 |
|
private JFormattedTextFieldSCP getWidthTextField() {
|
212 |
|
if (distanceTextField == null) {
|
|
213 |
private JTextField getWidthText() {
|
|
214 |
if (distanceText == null) {
|
|
215 |
/*
|
213 |
216 |
DecimalFormat decimalFormat = new DecimalFormat();
|
214 |
217 |
|
215 |
218 |
decimalFormat.setDecimalSeparatorAlwaysShown(true);
|
... | ... | |
226 |
229 |
numberFormatter.setCommitsOnValidEdit(true);
|
227 |
230 |
numberFormatter.setMinimum(new Double(0));
|
228 |
231 |
numberFormatter.setFormat(decimalFormat);
|
|
232 |
*/
|
229 |
233 |
|
230 |
234 |
// numberFormatter.setFormat(new
|
231 |
235 |
// DecimalFormat("([+]|[-])?[0-9]+([.][0-9]+)?"));
|
232 |
236 |
|
233 |
|
distanceTextField = new JFormattedTextFieldSCP(numberFormatter);
|
234 |
|
distanceTextField.setPreferredSize(new Dimension(85, 22));
|
235 |
|
distanceTextField.setValue(new Double(100.00));
|
236 |
|
distanceTextField.setToolTipText(PluginServices.getText(null,
|
237 |
|
"bufferWidth_TOOLTIP_HTML_explanation"));
|
|
237 |
distanceText = new JTextField();
|
|
238 |
distanceText.setPreferredSize(new Dimension(85, 22));
|
|
239 |
distanceText.setText("100");
|
238 |
240 |
}
|
239 |
241 |
|
240 |
|
return distanceTextField;
|
|
242 |
return distanceText;
|
241 |
243 |
}
|
242 |
244 |
|
243 |
245 |
private JLabel getDistanceUnitsLabel() {
|
... | ... | |
506 |
508 |
* .ActionEvent)
|
507 |
509 |
*/
|
508 |
510 |
public void actionPerformed(ActionEvent e) {
|
509 |
|
/* 1- Closes this window */
|
510 |
|
closeThis();
|
511 |
511 |
|
512 |
|
/* 2- Validates the buffer width */
|
|
512 |
/* 1- Validates the buffer width */
|
513 |
513 |
double width;
|
514 |
514 |
|
515 |
515 |
try {
|
516 |
|
width = Double.parseDouble(getWidthTextField().getText());
|
|
516 |
width = Double.parseDouble(getWidthText().getText());
|
517 |
517 |
/*
|
518 |
518 |
.replaceAll("(\\.)?", "")
|
519 |
519 |
.replace(",", ".")); // Formats the decimal
|
... | ... | |
521 |
521 |
*
|
522 |
522 |
*/
|
523 |
523 |
} catch (Exception ex) {
|
524 |
|
NotificationManager.showMessageError(PluginServices.getText(null,
|
525 |
|
"Invalid_width"),
|
526 |
|
ex);
|
|
524 |
|
|
525 |
JOptionPane.showMessageDialog(
|
|
526 |
ApplicationLocator.getManager().getRootComponent(),
|
|
527 |
Messages.getText("_Invalid_width_value")
|
|
528 |
+ " : \"" + getWidthText().getText() + "\"",
|
|
529 |
Messages.getText("Select_by_buffer"),
|
|
530 |
JOptionPane.WARNING_MESSAGE);
|
527 |
531 |
return;
|
528 |
532 |
}
|
|
533 |
|
|
534 |
/* 2- Closes this window */
|
|
535 |
closeThis();
|
529 |
536 |
|
|
537 |
|
530 |
538 |
/* 3- Creates the process */
|
531 |
539 |
// checks layers to proccess if multilayer is not selected
|
532 |
540 |
ArrayList<FLyrVect> tmpLayersToProccess =
|
... | ... | |
558 |
566 |
|
559 |
567 |
BufferSelectionProcess iprocess =
|
560 |
568 |
new BufferSelectionProcess(PluginServices.getText(this,
|
561 |
|
"Selection_by_buffer_process"),
|
|
569 |
"Select_by_buffer"),
|
562 |
570 |
PluginServices.getText(this,
|
563 |
571 |
"Ongoing_process_please_wait"),
|
564 |
572 |
mapControl,
|
... | ... | |
577 |
585 |
new ProgressPanel(false));
|
578 |
586 |
iTask.addIncrementableListener(iprocess);
|
579 |
587 |
iprocess.setIncrementableTask(iTask);
|
580 |
|
final BufferSelectionProcess f_iprocess = iprocess;
|
581 |
|
final IncrementableTask f_iTask = iTask;
|
582 |
588 |
|
583 |
589 |
iTask.getProgressPanel()
|
584 |
590 |
.addComponentListener(new ComponentAdapter() {
|
585 |
|
|
586 |
|
/*
|
587 |
|
* (non-Javadoc)
|
588 |
|
*
|
589 |
|
* @see
|
590 |
|
* java.awt.event.ComponentAdapter#componentHidden
|
591 |
|
* (java.awt.event.ComponentEvent)
|
592 |
|
*/
|
593 |
591 |
public void componentHidden(ComponentEvent e) {
|
594 |
|
/*
|
595 |
|
* 5- If the process has failed, tries to reload
|
596 |
|
* the layers
|
597 |
|
*/
|
598 |
|
if (f_iprocess.getPercent() < 100) {
|
599 |
|
/* 5.1- Forces to reload the active layers */
|
600 |
|
mapControl.drawMap(false);
|
601 |
|
f_iTask.getProgressPanel().dispose();
|
602 |
|
|
603 |
|
for (int i = 0; i < layers.length; i++) {
|
604 |
|
try {
|
605 |
|
layers[i].reload();
|
606 |
|
} catch (Exception ex) {
|
607 |
|
try {
|
608 |
|
NotificationManager.showMessageError(PluginServices.getText(null,
|
609 |
|
"Failed_reloading_the_layer")
|
610 |
|
+ " " + layers[i].getName(),
|
611 |
|
ex);
|
612 |
|
} catch (Exception ex2) {
|
613 |
|
NotificationManager.showMessageError(PluginServices.getText(null,
|
614 |
|
"Undefined_layer"),
|
615 |
|
ex);
|
616 |
|
}
|
617 |
|
}
|
618 |
|
}
|
619 |
|
|
620 |
|
view.getTOC().setVisible(false);
|
621 |
|
view.getTOC().setVisible(true);
|
622 |
|
}
|
623 |
|
|
624 |
|
/*
|
625 |
|
* 6- Writes in the gvSIG log the results of the
|
626 |
|
* process
|
627 |
|
*/
|
628 |
|
String text =
|
629 |
|
"\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"
|
630 |
|
+ PluginServices.getText(this,
|
631 |
|
"Summary_of_the_process_of_selecting_by_buffer")
|
632 |
|
+ ":\n"
|
633 |
|
+ f_iprocess.getLog()
|
634 |
|
+ "\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n";
|
635 |
|
PluginServices.getLogger().info(text);
|
|
592 |
mapControl.getMapContext().invalidate();
|
636 |
593 |
}
|
637 |
594 |
});
|
638 |
595 |
|