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