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 / JLrsCreateRouteParamsView.java @ 6

History | View | Annotate | Download (9.08 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
   JTextField txtOutputFile = new JTextField();
30
   JLabel lblMeasureSource = new JLabel();
31
   JComboBox cmbMeasureSource = new JComboBox();
32
   JLabel lblFromMeasureField = new JLabel();
33
   JLabel lblToMeasureField = new JLabel();
34
   JComboBox cmbFromMeasureField = new JComboBox();
35
   JComboBox cmbToMeasureField = new JComboBox();
36
   JLabel lblCoordinatesPriority = new JLabel();
37
   JComboBox cmbCoordinatePriority = new JComboBox();
38
   JFormattedTextField txtMeasureFactor = new JFormattedTextField();
39
   JLabel lblMeasureFactor = new JLabel();
40
   JLabel lblMeasureOffset = new JLabel();
41
   JFormattedTextField txtMeasureOffset = new JFormattedTextField();
42
   JCheckBox chkIgnoreSpatialGaps = new JCheckBox();
43
   JButton btnBrowser = new JButton();
44
   JButton btnCancel = new JButton();
45
   JButton btnAccept = 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:8DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,RIGHT:MAX(8DLU;DEFAULT):NONE,FILL:DEFAULT:NONE,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
      formlayout1.setColumnGroups(new int[][]{ {6,5} });
139
      CellConstraints cc = new CellConstraints();
140
      JLrsCreateRouteParametersPanel.setLayout(formlayout1);
141

    
142
      lblInputLayer.setName("lblInputLayer");
143
      lblInputLayer.setText("source");
144
      JLrsCreateRouteParametersPanel.add(lblInputLayer,cc.xy(2,2));
145

    
146
      cmbInputLayer.setName("cmbInputLayer");
147
      JLrsCreateRouteParametersPanel.add(cmbInputLayer,cc.xywh(4,2,4,1));
148

    
149
      cmbIdRouteField.setName("cmbIdRouteField");
150
      JLrsCreateRouteParametersPanel.add(cmbIdRouteField,cc.xywh(4,3,4,1));
151

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

    
156
      lblOutputFile.setName("lblOutputFile");
157
      lblOutputFile.setText("output_file");
158
      JLrsCreateRouteParametersPanel.add(lblOutputFile,cc.xy(2,4));
159

    
160
      txtOutputFile.setName("txtOutputFile");
161
      txtOutputFile.setHorizontalAlignment(JTextField.TRAILING);
162
      JLrsCreateRouteParametersPanel.add(txtOutputFile,cc.xywh(4,4,3,1));
163

    
164
      lblMeasureSource.setName("lblMeasureSource");
165
      lblMeasureSource.setText("measure_source");
166
      JLrsCreateRouteParametersPanel.add(lblMeasureSource,cc.xy(2,5));
167

    
168
      cmbMeasureSource.setName("cmbMeasureSource");
169
      JLrsCreateRouteParametersPanel.add(cmbMeasureSource,cc.xywh(4,5,4,1));
170

    
171
      lblFromMeasureField.setName("lblFromMeasureField");
172
      lblFromMeasureField.setText("from_measure_field");
173
      JLrsCreateRouteParametersPanel.add(lblFromMeasureField,cc.xy(2,6));
174

    
175
      lblToMeasureField.setName("lblToMeasureField");
176
      lblToMeasureField.setText("to_measure_field");
177
      JLrsCreateRouteParametersPanel.add(lblToMeasureField,cc.xy(2,7));
178

    
179
      cmbFromMeasureField.setName("cmbFromMeasureField");
180
      JLrsCreateRouteParametersPanel.add(cmbFromMeasureField,cc.xywh(4,6,4,1));
181

    
182
      cmbToMeasureField.setName("cmbToMeasureField");
183
      JLrsCreateRouteParametersPanel.add(cmbToMeasureField,cc.xywh(4,7,4,1));
184

    
185
      lblCoordinatesPriority.setName("lblCoordinatesPriority");
186
      lblCoordinatesPriority.setText("coordinates_priority");
187
      JLrsCreateRouteParametersPanel.add(lblCoordinatesPriority,cc.xy(2,8));
188

    
189
      cmbCoordinatePriority.setName("cmbCoordinatePriority");
190
      JLrsCreateRouteParametersPanel.add(cmbCoordinatePriority,cc.xywh(4,8,4,1));
191

    
192
      txtMeasureFactor.setName("txtMeasureFactor");
193
      JLrsCreateRouteParametersPanel.add(txtMeasureFactor,cc.xywh(4,9,4,1));
194

    
195
      lblMeasureFactor.setName("lblMeasureFactor");
196
      lblMeasureFactor.setText("measure_factor");
197
      JLrsCreateRouteParametersPanel.add(lblMeasureFactor,cc.xy(2,9));
198

    
199
      lblMeasureOffset.setName("lblMeasureOffset");
200
      lblMeasureOffset.setText("measure_offset");
201
      JLrsCreateRouteParametersPanel.add(lblMeasureOffset,cc.xy(2,10));
202

    
203
      txtMeasureOffset.setName("txtMeasureOffset");
204
      JLrsCreateRouteParametersPanel.add(txtMeasureOffset,cc.xywh(4,10,4,1));
205

    
206
      chkIgnoreSpatialGaps.setActionCommand("JCBIgnoreSpatialGaps");
207
      chkIgnoreSpatialGaps.setName("chkIgnoreSpatialGaps");
208
      chkIgnoreSpatialGaps.setText("ignore_spatial_gaps");
209
      JLrsCreateRouteParametersPanel.add(chkIgnoreSpatialGaps,cc.xywh(2,11,6,1));
210

    
211
      btnBrowser.setActionCommand("JButton");
212
      btnBrowser.setName("btnBrowser");
213
      btnBrowser.setOpaque(false);
214
      btnBrowser.setRolloverEnabled(true);
215
      btnBrowser.setText("...");
216
      JLrsCreateRouteParametersPanel.add(btnBrowser,cc.xy(7,4));
217

    
218
      btnCancel.setActionCommand("_Cancel");
219
      btnCancel.setName("btnCancel");
220
      btnCancel.setText("_Cancel");
221
      JLrsCreateRouteParametersPanel.add(btnCancel,cc.xy(6,13));
222

    
223
      btnAccept.setActionCommand("_Accept");
224
      btnAccept.setName("btnAccept");
225
      btnAccept.setText("_Accept");
226
      JLrsCreateRouteParametersPanel.add(btnAccept,cc.xy(5,13));
227

    
228
      addFillComponents(JLrsCreateRouteParametersPanel,new int[]{ 1,2,3,4,5,6,7,8 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14 });
229
      return JLrsCreateRouteParametersPanel;
230
   }
231

    
232
   /**
233
    * Initializer
234
    */
235
   protected void initializePanel()
236
   {
237
      setLayout(new BorderLayout());
238
      add(createJLrsCreateRouteParametersPanel(), BorderLayout.CENTER);
239
   }
240

    
241

    
242
}