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 / JLrsEditRouteCalibrationParamsView.java @ 851

History | View | Annotate | Download (7.53 KB)

1
package org.gvsig.lrs.swing.impl;
2

    
3
import com.jeta.open.i18n.I18NUtils;
4
import com.jgoodies.forms.layout.CellConstraints;
5
import com.jgoodies.forms.layout.FormLayout;
6
import java.awt.BorderLayout;
7
import java.awt.ComponentOrientation;
8
import java.awt.Container;
9
import java.awt.Dimension;
10
import javax.swing.Box;
11
import javax.swing.ImageIcon;
12
import javax.swing.JButton;
13
import javax.swing.JComboBox;
14
import javax.swing.JFrame;
15
import javax.swing.JLabel;
16
import javax.swing.JPanel;
17
import javax.swing.JScrollPane;
18
import javax.swing.JTable;
19
import javax.swing.JTextField;
20

    
21

    
22
public class JLrsEditRouteCalibrationParamsView extends JPanel
23
{
24
   JLabel lblIdRouteField = new JLabel();
25
   JLabel lblMinimum = new JLabel();
26
   JLabel lblMaximum = new JLabel();
27
   JTable tblLayerInfo = new JTable();
28
   JButton btnInvert = new JButton();
29
   JButton btnApply = new JButton();
30
   JButton btnAccept = new JButton();
31
   JButton btnCancel = new JButton();
32
   JComboBox cmbRoute = new JComboBox();
33
   JTextField txtMaximum = new JTextField();
34
   JTextField txtMinimum = new JTextField();
35
   JComboBox cmbStretch = new JComboBox();
36

    
37
   /**
38
    * Default constructor
39
    */
40
   public JLrsEditRouteCalibrationParamsView()
41
   {
42
      initializePanel();
43
   }
44

    
45
   /**
46
    * Adds fill components to empty cells in the first row and first column of the grid.
47
    * This ensures that the grid spacing will be the same as shown in the designer.
48
    * @param cols an array of column indices in the first row where fill components should be added.
49
    * @param rows an array of row indices in the first column where fill components should be added.
50
    */
51
   void addFillComponents( Container panel, int[] cols, int[] rows )
52
   {
53
      Dimension filler = new Dimension(10,10);
54

    
55
      boolean filled_cell_11 = false;
56
      CellConstraints cc = new CellConstraints();
57
      if ( cols.length > 0 && rows.length > 0 )
58
      {
59
         if ( cols[0] == 1 && rows[0] == 1 )
60
         {
61
            /** add a rigid area  */
62
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
63
            filled_cell_11 = true;
64
         }
65
      }
66

    
67
      for( int index = 0; index < cols.length; index++ )
68
      {
69
         if ( cols[index] == 1 && filled_cell_11 )
70
         {
71
            continue;
72
         }
73
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
74
      }
75

    
76
      for( int index = 0; index < rows.length; index++ )
77
      {
78
         if ( rows[index] == 1 && filled_cell_11 )
79
         {
80
            continue;
81
         }
82
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
83
      }
84

    
85
   }
86

    
87
   /**
88
    * Helper method to load an image file from the CLASSPATH
89
    * @param imageName the package and name of the file to load relative to the CLASSPATH
90
    * @return an ImageIcon instance with the specified image file
91
    * @throws IllegalArgumentException if the image resource cannot be loaded.
92
    */
93
   public ImageIcon loadImage( String imageName )
94
   {
95
      try
96
      {
97
         ClassLoader classloader = getClass().getClassLoader();
98
         java.net.URL url = classloader.getResource( imageName );
99
         if ( url != null )
100
         {
101
            ImageIcon icon = new ImageIcon( url );
102
            return icon;
103
         }
104
      }
105
      catch( Exception e )
106
      {
107
         e.printStackTrace();
108
      }
109
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
110
   }
111

    
112
   /**
113
    * Method for recalculating the component orientation for 
114
    * right-to-left Locales.
115
    * @param orientation the component orientation to be applied
116
    */
117
   public void applyComponentOrientation( ComponentOrientation orientation )
118
   {
119
      // Not yet implemented...
120
      // I18NUtils.applyComponentOrientation(this, orientation);
121
      super.applyComponentOrientation(orientation);
122
   }
123

    
124
   public JPanel createPanel()
125
   {
126
      JPanel jpanel1 = new JPanel();
127
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:MAX(12DLU;DEFAULT):NONE,FILL:4DLU:NONE,FILL:120PX:NONE,FILL:4DLU:NONE,FILL:120PX:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:MAX(73PX;DEFAULT):GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:MAX(74PX;DEFAULT):GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:MAX(12DLU;DEFAULT):GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
128
      CellConstraints cc = new CellConstraints();
129
      jpanel1.setLayout(formlayout1);
130

    
131
      lblIdRouteField.setName("lblIdRouteField");
132
      lblIdRouteField.setText("id_route_field");
133
      jpanel1.add(lblIdRouteField,cc.xy(2,4));
134

    
135
      lblMinimum.setName("lblMinimum");
136
      lblMinimum.setText("minimum");
137
      jpanel1.add(lblMinimum,cc.xy(8,4));
138

    
139
      lblMaximum.setName("lblMaximum");
140
      lblMaximum.setText("maximum");
141
      jpanel1.add(lblMaximum,cc.xy(12,4));
142

    
143
      tblLayerInfo.setName("tblLayerInfo");
144
      JScrollPane jscrollpane1 = new JScrollPane();
145
      jscrollpane1.setViewportView(tblLayerInfo);
146
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
147
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
148
      jpanel1.add(jscrollpane1,new CellConstraints(2,2,13,1,CellConstraints.DEFAULT,CellConstraints.FILL));
149

    
150
      jpanel1.add(createPanel1(),new CellConstraints(2,6,13,1,CellConstraints.RIGHT,CellConstraints.DEFAULT));
151
      jpanel1.add(createPanel2(),new CellConstraints(2,8,13,1,CellConstraints.RIGHT,CellConstraints.DEFAULT));
152
      cmbRoute.setName("cmbRoute");
153
      jpanel1.add(cmbRoute,cc.xy(4,4));
154

    
155
      txtMaximum.setName("txtMaximum");
156
      jpanel1.add(txtMaximum,cc.xy(14,4));
157

    
158
      txtMinimum.setName("txtMinimum");
159
      jpanel1.add(txtMinimum,cc.xy(10,4));
160

    
161
      cmbStretch.setName("cmbStretch");
162
      jpanel1.add(cmbStretch,cc.xy(6,4));
163

    
164
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 },new int[]{ 1,2,3,4,5,6,7,8,9 });
165
      return jpanel1;
166
   }
167

    
168
   public JPanel createPanel1()
169
   {
170
      JPanel jpanel1 = new JPanel();
171
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
172
      CellConstraints cc = new CellConstraints();
173
      jpanel1.setLayout(formlayout1);
174

    
175
      btnInvert.setActionCommand("_Invert");
176
      btnInvert.setName("btnInvert");
177
      btnInvert.setText("_Invert");
178
      jpanel1.add(btnInvert,new CellConstraints(1,1,1,1,CellConstraints.CENTER,CellConstraints.DEFAULT));
179

    
180
      btnApply.setActionCommand("_Apply");
181
      btnApply.setName("btnApply");
182
      btnApply.setText("_Apply");
183
      jpanel1.add(btnApply,cc.xy(3,1));
184

    
185
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
186
      return jpanel1;
187
   }
188

    
189
   public JPanel createPanel2()
190
   {
191
      JPanel jpanel1 = new JPanel();
192
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
193
      CellConstraints cc = new CellConstraints();
194
      jpanel1.setLayout(formlayout1);
195

    
196
      btnAccept.setActionCommand("_Accept");
197
      btnAccept.setName("btnAccept");
198
      btnAccept.setText("_Accept");
199
      jpanel1.add(btnAccept,new CellConstraints(1,1,1,1,CellConstraints.CENTER,CellConstraints.DEFAULT));
200

    
201
      btnCancel.setActionCommand("_Cancel");
202
      btnCancel.setName("btnCancel");
203
      btnCancel.setText("_Cancel");
204
      jpanel1.add(btnCancel,cc.xy(3,1));
205

    
206
      addFillComponents(jpanel1,new int[]{ 2 },new int[0]);
207
      return jpanel1;
208
   }
209

    
210
   /**
211
    * Initializer
212
    */
213
   protected void initializePanel()
214
   {
215
      setLayout(new BorderLayout());
216
      add(createPanel(), BorderLayout.CENTER);
217
   }
218

    
219

    
220
}