gvsig-lrs / org.gvsig.lrs / trunk / org.gvsig.lrs / org.gvsig.lrs.swing / org.gvsig.lrs.swing.impl / src / main / java / org / gvsig / lrs / swing / impl / JLrsCalibrateRouteParamsView.java @ 50
History | View | Annotate | Download (10.9 KB)
1 |
package org.gvsig.lrs.swing.impl; |
---|---|
2 |
|
3 |
import com.jgoodies.forms.layout.CellConstraints; |
4 |
import com.jgoodies.forms.layout.FormLayout; |
5 |
import java.awt.BorderLayout; |
6 |
import java.awt.ComponentOrientation; |
7 |
import java.awt.Container; |
8 |
import java.awt.Dimension; |
9 |
import javax.swing.Box; |
10 |
import javax.swing.ImageIcon; |
11 |
import javax.swing.JButton; |
12 |
import javax.swing.JCheckBox; |
13 |
import javax.swing.JComboBox; |
14 |
import javax.swing.JFrame; |
15 |
import javax.swing.JLabel; |
16 |
import javax.swing.JPanel; |
17 |
import javax.swing.JTextField; |
18 |
|
19 |
|
20 |
public class JLrsCalibrateRouteParamsView extends JPanel |
21 |
{ |
22 |
JLabel lblInputLayer = new JLabel(); |
23 |
JComboBox cmbInputLayer = new JComboBox(); |
24 |
JLabel lblIdRouteField = new JLabel(); |
25 |
JComboBox cmbIdRouteField = new JComboBox(); |
26 |
JLabel lblMeasureField = new JLabel(); |
27 |
JComboBox cmbMeasureField = new JComboBox(); |
28 |
JLabel lblOutputFile = new JLabel(); |
29 |
JComboBox cmbCalibratePointLayer = new JComboBox(); |
30 |
JLabel lblCalibratePointLayer = new JLabel(); |
31 |
JComboBox cmbCalibrationPointIdRouteField = new JComboBox(); |
32 |
JLabel lblCalibrationPointIdRouteField = new JLabel(); |
33 |
JComboBox cmbMeasureCalcMethod = new JComboBox(); |
34 |
JLabel lblMeasureCalcMethod = new JLabel(); |
35 |
JCheckBox chkInterpolateBetweenCalibrationPoints = new JCheckBox(); |
36 |
JCheckBox chkExtrapolateBeforeCalibrationPoints = new JCheckBox(); |
37 |
JCheckBox chkExtrapolateAfterCalibrationPoints = new JCheckBox(); |
38 |
JCheckBox chkIgnoreSpatialGaps = new JCheckBox(); |
39 |
JCheckBox chkIncludeAll = new JCheckBox(); |
40 |
JLabel lblSearchRadius = new JLabel(); |
41 |
JTextField txtOutputFile = new JTextField(); |
42 |
JButton btnBrowser = new JButton(); |
43 |
JComboBox cmbMeasureUnits = new JComboBox(); |
44 |
JTextField txtSearchRadius = new JTextField(); |
45 |
JButton btnAccept = new JButton(); |
46 |
JButton btnCancel = new JButton(); |
47 |
|
48 |
/**
|
49 |
* Default constructor
|
50 |
*/
|
51 |
public JLrsCalibrateRouteParamsView()
|
52 |
{ |
53 |
initializePanel(); |
54 |
} |
55 |
|
56 |
/**
|
57 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
58 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
59 |
* @param cols an array of column indices in the first row where fill components should be added.
|
60 |
* @param rows an array of row indices in the first column where fill components should be added.
|
61 |
*/
|
62 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
63 |
{ |
64 |
Dimension filler = new Dimension(10,10); |
65 |
|
66 |
boolean filled_cell_11 = false; |
67 |
CellConstraints cc = new CellConstraints();
|
68 |
if ( cols.length > 0 && rows.length > 0 ) |
69 |
{ |
70 |
if ( cols[0] == 1 && rows[0] == 1 ) |
71 |
{ |
72 |
/** add a rigid area */
|
73 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
74 |
filled_cell_11 = true;
|
75 |
} |
76 |
} |
77 |
|
78 |
for( int index = 0; index < cols.length; index++ ) |
79 |
{ |
80 |
if ( cols[index] == 1 && filled_cell_11 ) |
81 |
{ |
82 |
continue;
|
83 |
} |
84 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
85 |
} |
86 |
|
87 |
for( int index = 0; index < rows.length; index++ ) |
88 |
{ |
89 |
if ( rows[index] == 1 && filled_cell_11 ) |
90 |
{ |
91 |
continue;
|
92 |
} |
93 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
94 |
} |
95 |
|
96 |
} |
97 |
|
98 |
/**
|
99 |
* Helper method to load an image file from the CLASSPATH
|
100 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
101 |
* @return an ImageIcon instance with the specified image file
|
102 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
103 |
*/
|
104 |
public ImageIcon loadImage( String imageName ) |
105 |
{ |
106 |
try
|
107 |
{ |
108 |
ClassLoader classloader = getClass().getClassLoader();
|
109 |
java.net.URL url = classloader.getResource( imageName ); |
110 |
if ( url != null ) |
111 |
{ |
112 |
ImageIcon icon = new ImageIcon( url ); |
113 |
return icon;
|
114 |
} |
115 |
} |
116 |
catch( Exception e ) |
117 |
{ |
118 |
e.printStackTrace(); |
119 |
} |
120 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
121 |
} |
122 |
|
123 |
/**
|
124 |
* Method for recalculating the component orientation for
|
125 |
* right-to-left Locales.
|
126 |
* @param orientation the component orientation to be applied
|
127 |
*/
|
128 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
129 |
{ |
130 |
// Not yet implemented...
|
131 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
132 |
super.applyComponentOrientation(orientation);
|
133 |
} |
134 |
|
135 |
public JPanel createPanel() |
136 |
{ |
137 |
JPanel jpanel1 = new JPanel(); |
138 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:GROW(1.0),BOTTOM:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
139 |
CellConstraints cc = new CellConstraints();
|
140 |
jpanel1.setLayout(formlayout1); |
141 |
|
142 |
lblInputLayer.setName("lblInputLayer");
|
143 |
lblInputLayer.setText("source");
|
144 |
jpanel1.add(lblInputLayer,cc.xy(2,2)); |
145 |
|
146 |
cmbInputLayer.setName("cmbInputLayer");
|
147 |
jpanel1.add(cmbInputLayer,cc.xywh(4,2,2,1)); |
148 |
|
149 |
lblIdRouteField.setName("lblIdRouteField");
|
150 |
lblIdRouteField.setText("id_route_field");
|
151 |
jpanel1.add(lblIdRouteField,cc.xy(2,3)); |
152 |
|
153 |
cmbIdRouteField.setName("cmbIdRouteField");
|
154 |
jpanel1.add(cmbIdRouteField,cc.xywh(4,3,2,1)); |
155 |
|
156 |
lblMeasureField.setName("lblMeasureField");
|
157 |
lblMeasureField.setText("measures_field");
|
158 |
jpanel1.add(lblMeasureField,cc.xy(2,6)); |
159 |
|
160 |
cmbMeasureField.setName("cmbMeasureField");
|
161 |
jpanel1.add(cmbMeasureField,cc.xywh(4,6,2,1)); |
162 |
|
163 |
lblOutputFile.setName("lblOutputFile");
|
164 |
lblOutputFile.setText("output_file");
|
165 |
jpanel1.add(lblOutputFile,cc.xy(2,7)); |
166 |
|
167 |
cmbCalibratePointLayer.setName("cmbCalibratePointLayer");
|
168 |
jpanel1.add(cmbCalibratePointLayer,cc.xywh(4,4,2,1)); |
169 |
|
170 |
lblCalibratePointLayer.setName("lblCalibratePointLayer");
|
171 |
lblCalibratePointLayer.setText("calibrate_point_layer");
|
172 |
jpanel1.add(lblCalibratePointLayer,cc.xy(2,4)); |
173 |
|
174 |
cmbCalibrationPointIdRouteField.setName("cmbCalibrationPointIdRouteField");
|
175 |
jpanel1.add(cmbCalibrationPointIdRouteField,cc.xywh(4,5,2,1)); |
176 |
|
177 |
lblCalibrationPointIdRouteField.setName("lblCalibrationPointIdRouteField");
|
178 |
lblCalibrationPointIdRouteField.setText("id_calibration_point_route_field");
|
179 |
jpanel1.add(lblCalibrationPointIdRouteField,cc.xy(2,5)); |
180 |
|
181 |
cmbMeasureCalcMethod.setName("cmbMeasureCalcMethod");
|
182 |
jpanel1.add(cmbMeasureCalcMethod,cc.xywh(4,8,2,1)); |
183 |
|
184 |
lblMeasureCalcMethod.setName("lblMeasureCalcMethod");
|
185 |
lblMeasureCalcMethod.setText("measure_calc_method");
|
186 |
jpanel1.add(lblMeasureCalcMethod,cc.xy(2,8)); |
187 |
|
188 |
chkInterpolateBetweenCalibrationPoints.setActionCommand("JCBIgnoreSpatialGaps");
|
189 |
chkInterpolateBetweenCalibrationPoints.setName("chkInterpolateBetweenCalibrationPoints");
|
190 |
chkInterpolateBetweenCalibrationPoints.setText("interpolate_between_calibration_points");
|
191 |
jpanel1.add(chkInterpolateBetweenCalibrationPoints,cc.xywh(2,10,4,1)); |
192 |
|
193 |
chkExtrapolateBeforeCalibrationPoints.setActionCommand("JCBIgnoreSpatialGaps");
|
194 |
chkExtrapolateBeforeCalibrationPoints.setName("chkExtrapolateBeforeCalibrationPoints");
|
195 |
chkExtrapolateBeforeCalibrationPoints.setText("extrapolate_before_calibration_points");
|
196 |
jpanel1.add(chkExtrapolateBeforeCalibrationPoints,cc.xywh(2,11,4,1)); |
197 |
|
198 |
chkExtrapolateAfterCalibrationPoints.setActionCommand("JCBIgnoreSpatialGaps");
|
199 |
chkExtrapolateAfterCalibrationPoints.setName("chkExtrapolateAfterCalibrationPoints");
|
200 |
chkExtrapolateAfterCalibrationPoints.setText("extrapolate_after_calibration_points");
|
201 |
jpanel1.add(chkExtrapolateAfterCalibrationPoints,cc.xywh(2,12,4,1)); |
202 |
|
203 |
chkIgnoreSpatialGaps.setActionCommand("JCBIgnoreSpatialGaps");
|
204 |
chkIgnoreSpatialGaps.setName("chkIgnoreSpatialGaps");
|
205 |
chkIgnoreSpatialGaps.setText("ignore_spatial_gaps");
|
206 |
jpanel1.add(chkIgnoreSpatialGaps,cc.xywh(2,13,4,1)); |
207 |
|
208 |
chkIncludeAll.setActionCommand("JCBIgnoreSpatialGaps");
|
209 |
chkIncludeAll.setName("chkIncludeAll");
|
210 |
chkIncludeAll.setText("include_all");
|
211 |
jpanel1.add(chkIncludeAll,cc.xywh(2,14,4,1)); |
212 |
|
213 |
lblSearchRadius.setName("lblSearchRadius");
|
214 |
lblSearchRadius.setText("search_radius");
|
215 |
jpanel1.add(lblSearchRadius,cc.xy(2,9)); |
216 |
|
217 |
jpanel1.add(createPanel1(),cc.xywh(4,7,2,1)); |
218 |
jpanel1.add(createPanel2(),cc.xywh(4,9,2,1)); |
219 |
jpanel1.add(createPanel3(),new CellConstraints(2,16,4,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
220 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 }); |
221 |
return jpanel1;
|
222 |
} |
223 |
|
224 |
public JPanel createPanel1() |
225 |
{ |
226 |
JPanel jpanel1 = new JPanel(); |
227 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:36PX:NONE","CENTER:DEFAULT:NONE"); |
228 |
CellConstraints cc = new CellConstraints();
|
229 |
jpanel1.setLayout(formlayout1); |
230 |
|
231 |
txtOutputFile.setName("txtOutputFile");
|
232 |
txtOutputFile.setHorizontalAlignment(JTextField.LEFT);
|
233 |
jpanel1.add(txtOutputFile,cc.xy(1,1)); |
234 |
|
235 |
btnBrowser.setActionCommand("JButton");
|
236 |
btnBrowser.setName("btnBrowser");
|
237 |
btnBrowser.setOpaque(false);
|
238 |
btnBrowser.setRolloverEnabled(true);
|
239 |
btnBrowser.setText("...");
|
240 |
jpanel1.add(btnBrowser,cc.xy(2,1)); |
241 |
|
242 |
addFillComponents(jpanel1,new int[0],new int[0]); |
243 |
return jpanel1;
|
244 |
} |
245 |
|
246 |
public JPanel createPanel2() |
247 |
{ |
248 |
JPanel jpanel1 = new JPanel(); |
249 |
FormLayout formlayout1 = new FormLayout("FILL:20DLU:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
250 |
CellConstraints cc = new CellConstraints();
|
251 |
jpanel1.setLayout(formlayout1); |
252 |
|
253 |
cmbMeasureUnits.setName("cmbMeasureUnits");
|
254 |
jpanel1.add(cmbMeasureUnits,cc.xy(2,1)); |
255 |
|
256 |
txtSearchRadius.setName("txtSearchRadius");
|
257 |
jpanel1.add(txtSearchRadius,cc.xy(1,1)); |
258 |
|
259 |
addFillComponents(jpanel1,new int[0],new int[0]); |
260 |
return jpanel1;
|
261 |
} |
262 |
|
263 |
public JPanel createPanel3() |
264 |
{ |
265 |
JPanel jpanel1 = new JPanel(); |
266 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
267 |
CellConstraints cc = new CellConstraints();
|
268 |
jpanel1.setLayout(formlayout1); |
269 |
|
270 |
btnAccept.setActionCommand("_Accept");
|
271 |
btnAccept.setName("btnAccept");
|
272 |
btnAccept.setText("_Accept");
|
273 |
jpanel1.add(btnAccept,cc.xy(1,1)); |
274 |
|
275 |
btnCancel.setActionCommand("_Cancel");
|
276 |
btnCancel.setName("btnCancel");
|
277 |
btnCancel.setText("_Cancel");
|
278 |
jpanel1.add(btnCancel,cc.xy(3,1)); |
279 |
|
280 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
281 |
return jpanel1;
|
282 |
} |
283 |
|
284 |
/**
|
285 |
* Initializer
|
286 |
*/
|
287 |
protected void initializePanel() |
288 |
{ |
289 |
setLayout(new BorderLayout()); |
290 |
add(createPanel(), BorderLayout.CENTER);
|
291 |
} |
292 |
|
293 |
|
294 |
} |