root / trunk / libraries / libTopology / src / com / vividsolutions / jcs / plugin / conflate / roads / AutoAdjustConflationOptionsPanel.java @ 22873
History | View | Annotate | Download (9.71 KB)
1 |
package com.vividsolutions.jcs.plugin.conflate.roads; |
---|---|
2 |
|
3 |
import javax.swing.*; |
4 |
|
5 |
import com.vividsolutions.jcs.conflate.roads.ConflationSession; |
6 |
import com.vividsolutions.jcs.jump.FUTURE_ValidatingTextField; |
7 |
import com.vividsolutions.jump.util.StringUtil; |
8 |
import com.vividsolutions.jump.workbench.WorkbenchContext; |
9 |
import com.vividsolutions.jump.workbench.ui.GUIUtil; |
10 |
import com.vividsolutions.jump.workbench.ui.OptionsPanel; |
11 |
import com.vividsolutions.jump.workbench.ui.ValidatingTextField; |
12 |
import java.awt.*; |
13 |
|
14 |
public class AutoAdjustConflationOptionsPanel extends JPanel implements |
15 |
OptionsPanel { |
16 |
private GridBagLayout gridBagLayout1 = new GridBagLayout(); |
17 |
|
18 |
private JLabel adjustmentPrecedenceRuleLabel = new JLabel(); |
19 |
|
20 |
private JLabel performAdjustmentsLabel = new JLabel(); |
21 |
|
22 |
private DefaultComboBoxModel datasetComboBoxModel = new DefaultComboBoxModel(); |
23 |
|
24 |
private JComboBox datasetComboBox = PrecedenceOptionsPanel |
25 |
.createDatasetComboBox(datasetComboBoxModel); |
26 |
|
27 |
private JLabel tolerancesLabel = new JLabel(); |
28 |
|
29 |
private JLabel maxSegmentAngleDeltaLabel = new JLabel(); |
30 |
|
31 |
private JLabel maxAdjustmentSizeLabel = new JLabel(); |
32 |
|
33 |
private JLabel minIncidenceAngleLabel = new JLabel(); |
34 |
|
35 |
private JTextField maximumSegmentAngleDeltaTextField = new ValidatingTextField( |
36 |
"", 5, SwingConstants.RIGHT, |
37 |
new ValidatingTextField.BoundedDoubleValidator(0, true, 180, true), |
38 |
new ValidatingTextField.BlankCleaner("" |
39 |
+ new AutoAdjustOptions().getMaximumSegmentAngleDelta()));
|
40 |
|
41 |
private JTextField maximumAdjustmentSizeTextField = new ValidatingTextField( |
42 |
"", 5, SwingConstants.RIGHT, |
43 |
new ValidatingTextField.BoundedDoubleValidator(0, true, |
44 |
Double.POSITIVE_INFINITY, true), |
45 |
new ValidatingTextField.BlankCleaner("" |
46 |
+ new AutoAdjustOptions().getMaximumAdjustmentSize()));
|
47 |
|
48 |
private JTextField minimumIncidenceAngleTextField = new ValidatingTextField( |
49 |
"", 5, SwingConstants.RIGHT, |
50 |
new ValidatingTextField.BoundedDoubleValidator(0, true, 180, true), |
51 |
new ValidatingTextField.BlankCleaner("" |
52 |
+ new AutoAdjustOptions().getMinimumIncidenceAngle()));
|
53 |
|
54 |
private WorkbenchContext context;
|
55 |
|
56 |
private JPanel fillerPanel1 = new JPanel(); |
57 |
|
58 |
private GridBagLayout gridBagLayout2 = new GridBagLayout(); |
59 |
|
60 |
private JPanel fillerPanel2 = new JPanel(); |
61 |
|
62 |
private GridBagLayout gridBagLayout3 = new GridBagLayout(); |
63 |
|
64 |
private JLabel adjustmentMethodLabel = new JLabel(); |
65 |
|
66 |
private JRadioButton warpEntireSegmentRadioButton = new JRadioButton(); |
67 |
|
68 |
private JRadioButton warpPartialSegmentRadioButton = new JRadioButton(); |
69 |
|
70 |
private ValidatingTextField segmentAdjustmentLengthTextField = new ValidatingTextField( |
71 |
"", 5, SwingConstants.RIGHT, |
72 |
new ValidatingTextField.BoundedDoubleValidator(0, false, |
73 |
Integer.MAX_VALUE, false), |
74 |
new FUTURE_ValidatingTextField.NumberCleaner(
|
75 |
AutoAdjustOptions.DEFAULT_SEGMENT_ADJUSTMENT_LENGTH + ""));
|
76 |
|
77 |
private JCheckBox shiftSegmentsCheckBox = new JCheckBox(); |
78 |
|
79 |
private JLabel jLabel1 = new JLabel(); |
80 |
|
81 |
public AutoAdjustConflationOptionsPanel(WorkbenchContext context) {
|
82 |
this.context = context;
|
83 |
new ButtonGroup() { |
84 |
{ |
85 |
add(warpPartialSegmentRadioButton); |
86 |
add(warpEntireSegmentRadioButton); |
87 |
} |
88 |
}; |
89 |
try {
|
90 |
jbInit(); |
91 |
} catch (Exception ex) { |
92 |
ex.printStackTrace(); |
93 |
} |
94 |
} |
95 |
|
96 |
void jbInit() throws Exception { |
97 |
adjustmentPrecedenceRuleLabel |
98 |
.setFont(new java.awt.Font("Dialog", 1, 12)); |
99 |
adjustmentPrecedenceRuleLabel.setText("Precedence Rule");
|
100 |
this.setLayout(gridBagLayout1);
|
101 |
this.setFont(new java.awt.Font("Dialog", 1, 12)); |
102 |
performAdjustmentsLabel |
103 |
.setText("Perform adjustments on segments from: ");
|
104 |
tolerancesLabel.setFont(new java.awt.Font("Dialog", 1, 12)); |
105 |
tolerancesLabel.setText("Tolerances");
|
106 |
maxSegmentAngleDeltaLabel |
107 |
.setText("Maximum Segment Angle Delta (degrees): ");
|
108 |
maxAdjustmentSizeLabel.setText("Maximum Adjustment Size: ");
|
109 |
minIncidenceAngleLabel.setText("Minimum Incidence Angle (degrees): ");
|
110 |
fillerPanel1.setPreferredSize(new Dimension(12, 12)); |
111 |
fillerPanel1.setLayout(gridBagLayout2); |
112 |
fillerPanel2.setLayout(gridBagLayout3); |
113 |
adjustmentMethodLabel.setFont(new java.awt.Font("Dialog", 1, 12)); |
114 |
adjustmentMethodLabel.setText("Adjustment Method");
|
115 |
warpEntireSegmentRadioButton.setText("Warp entire segment");
|
116 |
warpPartialSegmentRadioButton.setText("Warp partial segment");
|
117 |
shiftSegmentsCheckBox.setText("Shift short segments with one connected end");
|
118 |
jLabel1.setText("Segment Adjustment Length: ");
|
119 |
this.add(adjustmentPrecedenceRuleLabel, new GridBagConstraints(1, 1, 1, |
120 |
1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, |
121 |
new Insets(0, 0, 0, 0), 0, 0)); |
122 |
this.add(performAdjustmentsLabel, new GridBagConstraints(1, 2, 1, 1, |
123 |
0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, |
124 |
new Insets(0, 30, 0, 0), 0, 0)); |
125 |
this.add(datasetComboBox, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, |
126 |
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, |
127 |
0, 0, 0), 0, 0)); |
128 |
this.add(tolerancesLabel, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, |
129 |
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets( |
130 |
20, 0, 0, 0), 0, 0)); |
131 |
this.add(maxAdjustmentSizeLabel, new GridBagConstraints(1, 4, 1, 1, |
132 |
0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, |
133 |
new Insets(0, 30, 0, 0), 0, 0)); |
134 |
this.add(maxSegmentAngleDeltaLabel, new GridBagConstraints(1, 5, 1, 1, |
135 |
0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, |
136 |
new Insets(0, 30, 0, 0), 0, 0)); |
137 |
this.add(minIncidenceAngleLabel, new GridBagConstraints(1, 6, 1, 1, |
138 |
0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, |
139 |
new Insets(0, 30, 0, 0), 0, 0)); |
140 |
this.add(maximumAdjustmentSizeTextField, new GridBagConstraints(2, 4, |
141 |
1, 1, 0.0, 0.0, GridBagConstraints.WEST, |
142 |
GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); |
143 |
this.add(maximumSegmentAngleDeltaTextField, new GridBagConstraints(2, |
144 |
5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, |
145 |
GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); |
146 |
this.add(minimumIncidenceAngleTextField, new GridBagConstraints(2, 6, |
147 |
1, 1, 0.0, 0.0, GridBagConstraints.WEST, |
148 |
GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); |
149 |
this.add(fillerPanel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, |
150 |
GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets( |
151 |
0, 0, 0, 0), 0, 0)); |
152 |
this.add(fillerPanel2, new GridBagConstraints(3, 12, 1, 1, 1.0, 1.0, |
153 |
GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets( |
154 |
0, 0, 0, 0), 0, 0)); |
155 |
this.add(adjustmentMethodLabel, new GridBagConstraints(1, 8, 2, 1, 0.0, |
156 |
0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, |
157 |
new Insets(20, 0, 0, 0), 0, 0)); |
158 |
this.add(warpPartialSegmentRadioButton, new GridBagConstraints(1, 10, |
159 |
2, 1, 0.0, 0.0, GridBagConstraints.WEST, |
160 |
GridBagConstraints.NONE, new Insets(0, 30, 0, 0), 0, 0)); |
161 |
this.add(warpEntireSegmentRadioButton, new GridBagConstraints(1, 9, 2, |
162 |
1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, |
163 |
new Insets(0, 30, 0, 0), 0, 0)); |
164 |
this.add(shiftSegmentsCheckBox, new GridBagConstraints(1, 11, 2, 1, |
165 |
0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, |
166 |
new Insets(10, 30, 0, 0), 0, 0)); |
167 |
this.add(jLabel1, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0, |
168 |
GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, |
169 |
30, 0, 0), 0, 0)); |
170 |
this.add(segmentAdjustmentLengthTextField, new GridBagConstraints(2, 7, |
171 |
1, 1, 0.0, 0.0, GridBagConstraints.WEST, |
172 |
GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); |
173 |
} |
174 |
|
175 |
public String validateInput() { |
176 |
return null; |
177 |
} |
178 |
|
179 |
private AdjustmentConstraintsOptionsPanel adjustmentConstraintsOptionsPanel() {
|
180 |
return (AdjustmentConstraintsOptionsPanel) GUIUtil
|
181 |
.getDescendantOfClass(AdjustmentConstraintsOptionsPanel.class, |
182 |
SwingUtilities.windowForComponent(this)); |
183 |
} |
184 |
|
185 |
public void okPressed() { |
186 |
options().setMaximumAdjustmentSize( |
187 |
Double.parseDouble(maximumAdjustmentSizeTextField.getText()));
|
188 |
options() |
189 |
.setMaximumSegmentAngleDelta( |
190 |
Double.parseDouble(maximumSegmentAngleDeltaTextField
|
191 |
.getText())); |
192 |
options().setMinimumIncidenceAngle( |
193 |
Double.parseDouble(minimumIncidenceAngleTextField.getText()));
|
194 |
options().setDatasetName( |
195 |
session().getSourceNetwork(datasetComboBox.getSelectedIndex()) |
196 |
.getName()); |
197 |
options().setSegmentAdjustmentLength( |
198 |
segmentAdjustmentLengthTextField.getDouble()); |
199 |
options().setShiftingSegmentsWithOneConnectedEnd( |
200 |
shiftSegmentsCheckBox.isSelected()); |
201 |
options() |
202 |
.setMethodClass( |
203 |
warpEntireSegmentRadioButton.isSelected() ? WarpAdjustmentMethod.class |
204 |
: WarpLocallyAdjustmentMethod.ModelBasedWarpZone.class); |
205 |
} |
206 |
|
207 |
private AutoAdjustOptions options() {
|
208 |
return AutoAdjustOptions.get(session());
|
209 |
} |
210 |
|
211 |
private ConflationSession session() {
|
212 |
return ToolboxModel.instance(context).getSession();
|
213 |
} |
214 |
|
215 |
public void init() { |
216 |
maximumAdjustmentSizeTextField.setText(""
|
217 |
+ options().getMaximumAdjustmentSize()); |
218 |
maximumSegmentAngleDeltaTextField.setText(""
|
219 |
+ options().getMaximumSegmentAngleDelta()); |
220 |
minimumIncidenceAngleTextField.setText(""
|
221 |
+ options().getMinimumIncidenceAngle()); |
222 |
datasetComboBoxModel.removeAllElements(); |
223 |
datasetComboBoxModel.addElement(ToolboxModel.instance(context) |
224 |
.getSourceLayer(0));
|
225 |
datasetComboBoxModel.addElement(ToolboxModel.instance(context) |
226 |
.getSourceLayer(1));
|
227 |
datasetComboBox.setSelectedIndex(session().getSourceNetwork( |
228 |
options().getDatasetName()).getID()); |
229 |
segmentAdjustmentLengthTextField.setText(options() |
230 |
.getSegmentAdjustmentLength() |
231 |
+ "");
|
232 |
warpEntireSegmentRadioButton |
233 |
.setSelected(options().getMethodClass() == WarpAdjustmentMethod.class); |
234 |
warpPartialSegmentRadioButton |
235 |
.setSelected(options().getMethodClass() == WarpLocallyAdjustmentMethod.ModelBasedWarpZone.class); |
236 |
shiftSegmentsCheckBox.setSelected(options() |
237 |
.isShiftingSegmentsWithOneConnectedEnd()); |
238 |
} |
239 |
} |