Statistics
| Revision:

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 @ 9

History | View | Annotate | Download (11.3 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 JLrsCalibrateRouteParamsView extends JPanel
22
{
23
   JLabel lblInputLayer = new JLabel();
24
   JComboBox cmbInputLayer = new JComboBox();
25
   JLabel lblIdRouteField = new JLabel();
26
   JComboBox cmbIdRouteField = new JComboBox();
27
   JLabel lblFromMeasureField = new JLabel();
28
   JComboBox cmbFromMeasureField = new JComboBox();
29
   JLabel lblOutputFile = new JLabel();
30
   JComboBox cmbCalibratePointLayer = new JComboBox();
31
   JLabel lblCalibratePointLayer = new JLabel();
32
   JComboBox cmbCalibrationPointIdRouteField = new JComboBox();
33
   JLabel lblCalibrationPointIdRouteField = new JLabel();
34
   JComboBox cmbMeasureCalcMethod = new JComboBox();
35
   JLabel lblMeasureCalcMethod = new JLabel();
36
   JCheckBox chkInterpolateBetweenCalibrationPoints = new JCheckBox();
37
   JCheckBox chkExtrapolateBeforeCalibrationPoints = new JCheckBox();
38
   JCheckBox chkExtrapolateAfterCalibrationPoints = new JCheckBox();
39
   JCheckBox chkIgnoreSpatialGaps = new JCheckBox();
40
   JCheckBox chkIncludeAll = new JCheckBox();
41
   JLabel lblSearchRadius = new JLabel();
42
   JTextField txtOutputFile = new JTextField();
43
   JButton btnBrowser = new JButton();
44
   JLabel lblMeasureUnits = new JLabel();
45
   JComboBox cmbMeasureUnits = new JComboBox();
46
   JFormattedTextField txtSearchRadius = new JFormattedTextField();
47
   JButton btnAccept = new JButton();
48
   JButton btnCancel = new JButton();
49

    
50
   /**
51
    * Default constructor
52
    */
53
   public JLrsCalibrateRouteParamsView()
54
   {
55
      initializePanel();
56
   }
57

    
58
   /**
59
    * Adds fill components to empty cells in the first row and first column of the grid.
60
    * This ensures that the grid spacing will be the same as shown in the designer.
61
    * @param cols an array of column indices in the first row where fill components should be added.
62
    * @param rows an array of row indices in the first column where fill components should be added.
63
    */
64
   void addFillComponents( Container panel, int[] cols, int[] rows )
65
   {
66
      Dimension filler = new Dimension(10,10);
67

    
68
      boolean filled_cell_11 = false;
69
      CellConstraints cc = new CellConstraints();
70
      if ( cols.length > 0 && rows.length > 0 )
71
      {
72
         if ( cols[0] == 1 && rows[0] == 1 )
73
         {
74
            /** add a rigid area  */
75
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
76
            filled_cell_11 = true;
77
         }
78
      }
79

    
80
      for( int index = 0; index < cols.length; index++ )
81
      {
82
         if ( cols[index] == 1 && filled_cell_11 )
83
         {
84
            continue;
85
         }
86
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
87
      }
88

    
89
      for( int index = 0; index < rows.length; index++ )
90
      {
91
         if ( rows[index] == 1 && filled_cell_11 )
92
         {
93
            continue;
94
         }
95
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
96
      }
97

    
98
   }
99

    
100
   /**
101
    * Helper method to load an image file from the CLASSPATH
102
    * @param imageName the package and name of the file to load relative to the CLASSPATH
103
    * @return an ImageIcon instance with the specified image file
104
    * @throws IllegalArgumentException if the image resource cannot be loaded.
105
    */
106
   public ImageIcon loadImage( String imageName )
107
   {
108
      try
109
      {
110
         ClassLoader classloader = getClass().getClassLoader();
111
         java.net.URL url = classloader.getResource( imageName );
112
         if ( url != null )
113
         {
114
            ImageIcon icon = new ImageIcon( url );
115
            return icon;
116
         }
117
      }
118
      catch( Exception e )
119
      {
120
         e.printStackTrace();
121
      }
122
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
123
   }
124

    
125
   /**
126
    * Method for recalculating the component orientation for
127
    * right-to-left Locales.
128
    * @param orientation the component orientation to be applied
129
    */
130
   public void applyComponentOrientation( ComponentOrientation orientation )
131
   {
132
      // Not yet implemented...
133
      // I18NUtils.applyComponentOrientation(this, orientation);
134
      super.applyComponentOrientation(orientation);
135
   }
136

    
137
   public JPanel createPanel()
138
   {
139
      JPanel jpanel1 = new JPanel();
140
      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");
141
      CellConstraints cc = new CellConstraints();
142
      jpanel1.setLayout(formlayout1);
143

    
144
      lblInputLayer.setName("lblInputLayer");
145
      lblInputLayer.setText("source");
146
      jpanel1.add(lblInputLayer,cc.xy(2,2));
147

    
148
      cmbInputLayer.setName("cmbInputLayer");
149
      jpanel1.add(cmbInputLayer,cc.xywh(4,2,2,1));
150

    
151
      lblIdRouteField.setName("lblIdRouteField");
152
      lblIdRouteField.setText("id_route_field");
153
      jpanel1.add(lblIdRouteField,cc.xy(2,3));
154

    
155
      cmbIdRouteField.setName("cmbIdRouteField");
156
      jpanel1.add(cmbIdRouteField,cc.xywh(4,3,2,1));
157

    
158
      lblFromMeasureField.setName("lblFromMeasureField");
159
      lblFromMeasureField.setText("from_measure_field");
160
      jpanel1.add(lblFromMeasureField,cc.xy(2,6));
161

    
162
      cmbFromMeasureField.setName("cmbFromMeasureField");
163
      jpanel1.add(cmbFromMeasureField,cc.xywh(4,6,2,1));
164

    
165
      lblOutputFile.setName("lblOutputFile");
166
      lblOutputFile.setText("output_file");
167
      jpanel1.add(lblOutputFile,cc.xy(2,7));
168

    
169
      cmbCalibratePointLayer.setName("cmbCalibratePointLayer");
170
      jpanel1.add(cmbCalibratePointLayer,cc.xywh(4,4,2,1));
171

    
172
      lblCalibratePointLayer.setName("lblCalibratePointLayer");
173
      lblCalibratePointLayer.setText("calibrate_point_layer");
174
      jpanel1.add(lblCalibratePointLayer,cc.xy(2,4));
175

    
176
      cmbCalibrationPointIdRouteField.setName("cmbCalibrationPointIdRouteField");
177
      jpanel1.add(cmbCalibrationPointIdRouteField,cc.xywh(4,5,2,1));
178

    
179
      lblCalibrationPointIdRouteField.setName("lblCalibrationPointIdRouteField");
180
      lblCalibrationPointIdRouteField.setText("id_calibration_point_route_field");
181
      jpanel1.add(lblCalibrationPointIdRouteField,cc.xy(2,5));
182

    
183
      cmbMeasureCalcMethod.setName("cmbMeasureCalcMethod");
184
      jpanel1.add(cmbMeasureCalcMethod,cc.xywh(4,8,2,1));
185

    
186
      lblMeasureCalcMethod.setName("lblMeasureCalcMethod");
187
      lblMeasureCalcMethod.setText("measure_calc_method");
188
      jpanel1.add(lblMeasureCalcMethod,cc.xy(2,8));
189

    
190
      chkInterpolateBetweenCalibrationPoints.setActionCommand("JCBIgnoreSpatialGaps");
191
      chkInterpolateBetweenCalibrationPoints.setName("chkInterpolateBetweenCalibrationPoints");
192
      chkInterpolateBetweenCalibrationPoints.setText("interpolate_between_calibration_points");
193
      jpanel1.add(chkInterpolateBetweenCalibrationPoints,cc.xywh(2,10,4,1));
194

    
195
      chkExtrapolateBeforeCalibrationPoints.setActionCommand("JCBIgnoreSpatialGaps");
196
      chkExtrapolateBeforeCalibrationPoints.setName("chkExtrapolateBeforeCalibrationPoints");
197
      chkExtrapolateBeforeCalibrationPoints.setText("extrapolate_before_calibration_points");
198
      jpanel1.add(chkExtrapolateBeforeCalibrationPoints,cc.xywh(2,11,4,1));
199

    
200
      chkExtrapolateAfterCalibrationPoints.setActionCommand("JCBIgnoreSpatialGaps");
201
      chkExtrapolateAfterCalibrationPoints.setName("chkExtrapolateAfterCalibrationPoints");
202
      chkExtrapolateAfterCalibrationPoints.setText("extrapolate_after_calibration_points");
203
      jpanel1.add(chkExtrapolateAfterCalibrationPoints,cc.xywh(2,12,4,1));
204

    
205
      chkIgnoreSpatialGaps.setActionCommand("JCBIgnoreSpatialGaps");
206
      chkIgnoreSpatialGaps.setName("chkIgnoreSpatialGaps");
207
      chkIgnoreSpatialGaps.setText("ignore_spatial_gaps");
208
      jpanel1.add(chkIgnoreSpatialGaps,cc.xywh(2,13,4,1));
209

    
210
      chkIncludeAll.setActionCommand("JCBIgnoreSpatialGaps");
211
      chkIncludeAll.setName("chkIncludeAll");
212
      chkIncludeAll.setText("include_all");
213
      jpanel1.add(chkIncludeAll,cc.xywh(2,14,4,1));
214

    
215
      lblSearchRadius.setName("lblSearchRadius");
216
      lblSearchRadius.setText("search_radius");
217
      jpanel1.add(lblSearchRadius,cc.xy(2,9));
218

    
219
      jpanel1.add(createPanel1(),cc.xywh(4,7,2,1));
220
      jpanel1.add(createPanel2(),cc.xywh(4,9,2,1));
221
      jpanel1.add(createPanel3(),new CellConstraints(2,16,4,1,CellConstraints.RIGHT,CellConstraints.DEFAULT));
222
      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 });
223
      return jpanel1;
224
   }
225

    
226
   public JPanel createPanel1()
227
   {
228
      JPanel jpanel1 = new JPanel();
229
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:36PX:NONE","CENTER:DEFAULT:NONE");
230
      CellConstraints cc = new CellConstraints();
231
      jpanel1.setLayout(formlayout1);
232

    
233
      txtOutputFile.setName("txtOutputFile");
234
      txtOutputFile.setHorizontalAlignment(JTextField.LEFT);
235
      jpanel1.add(txtOutputFile,cc.xy(1,1));
236

    
237
      btnBrowser.setActionCommand("JButton");
238
      btnBrowser.setName("btnBrowser");
239
      btnBrowser.setOpaque(false);
240
      btnBrowser.setRolloverEnabled(true);
241
      btnBrowser.setText("...");
242
      jpanel1.add(btnBrowser,cc.xy(2,1));
243

    
244
      addFillComponents(jpanel1,new int[0],new int[0]);
245
      return jpanel1;
246
   }
247

    
248
   public JPanel createPanel2()
249
   {
250
      JPanel jpanel1 = new JPanel();
251
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
252
      CellConstraints cc = new CellConstraints();
253
      jpanel1.setLayout(formlayout1);
254

    
255
      lblMeasureUnits.setName("lblMeasureUnits");
256
      lblMeasureUnits.setText("measure_units");
257
      jpanel1.add(lblMeasureUnits,cc.xy(2,1));
258

    
259
      cmbMeasureUnits.setName("cmbMeasureUnits");
260
      jpanel1.add(cmbMeasureUnits,cc.xy(4,1));
261

    
262
      txtSearchRadius.setName("txtSearchRadius");
263
      jpanel1.add(txtSearchRadius,cc.xy(1,1));
264

    
265
      addFillComponents(jpanel1,new int[]{ 3 },new int[0]);
266
      return jpanel1;
267
   }
268

    
269
   public JPanel createPanel3()
270
   {
271
      JPanel jpanel1 = new JPanel();
272
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
273
      CellConstraints cc = new CellConstraints();
274
      jpanel1.setLayout(formlayout1);
275

    
276
      btnAccept.setActionCommand("_Accept");
277
      btnAccept.setName("btnAccept");
278
      btnAccept.setText("_Accept");
279
      jpanel1.add(btnAccept,cc.xy(1,1));
280

    
281
      btnCancel.setActionCommand("_Cancel");
282
      btnCancel.setName("btnCancel");
283
      btnCancel.setText("_Cancel");
284
      jpanel1.add(btnCancel,cc.xy(3,1));
285

    
286
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
287
      return jpanel1;
288
   }
289

    
290
   /**
291
    * Initializer
292
    */
293
   protected void initializePanel()
294
   {
295
      setLayout(new BorderLayout());
296
      add(createPanel(), BorderLayout.CENTER);
297
   }
298

    
299

    
300
}