Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.geodb.app / org.gvsig.geodb.app.mainplugin / src / main / java / org / gvsig / geodb / vectorialdb / visibility / VisibilityScaleSelectorView.java @ 45160

History | View | Annotate | Download (8.47 KB)

1
package org.gvsig.geodb.vectorialdb.visibility;
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.ButtonGroup;
11
import javax.swing.ImageIcon;
12
import javax.swing.JButton;
13
import javax.swing.JCheckBox;
14
import javax.swing.JFormattedTextField;
15
import javax.swing.JLabel;
16
import javax.swing.JPanel;
17
import javax.swing.JRadioButton;
18

    
19

    
20
public class VisibilityScaleSelectorView extends JPanel
21
{
22
   JFormattedTextField txtScaleBelowDenominator = new JFormattedTextField();
23
   JLabel lblMinimumScale = new JLabel();
24
   JLabel lblMaximumScale = new JLabel();
25
   JFormattedTextField txtScaleAboveDenominator = new JFormattedTextField();
26
   JLabel lblBelow = new JLabel();
27
   JLabel lblAbove = new JLabel();
28
   JRadioButton rdb1_25000 = new JRadioButton();
29
   ButtonGroup buttongroup1 = new ButtonGroup();
30
   JRadioButton rdbConditions = new JRadioButton();
31
   JLabel lbl_1_25000_description = new JLabel();
32
   JLabel lblDescription = new JLabel();
33
   JCheckBox chkRememberAnswer = new JCheckBox();
34
   JButton btnAccept = new JButton();
35
   JButton btnCancel = new JButton();
36
   JRadioButton rdb1_1000 = new JRadioButton();
37
   JLabel lbl_1_1000_description = new JLabel();
38
   JRadioButton rdb1_5000 = new JRadioButton();
39
   JLabel lbl_1_5000_description = new JLabel();
40

    
41
   /**
42
    * Default constructor
43
    */
44
   public VisibilityScaleSelectorView()
45
   {
46
      initializePanel();
47
   }
48

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

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

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

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

    
89
   }
90

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

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

    
128
   public JPanel createPanel()
129
   {
130
      JPanel jpanel1 = new JPanel();
131
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:MAX(100PX;DEFAULT):NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
132
      CellConstraints cc = new CellConstraints();
133
      jpanel1.setLayout(formlayout1);
134

    
135
      txtScaleBelowDenominator.setName("txtScaleBelowDenominator");
136
      jpanel1.add(txtScaleBelowDenominator,cc.xy(5,14));
137

    
138
      lblMinimumScale.setName("lblMinimumScale");
139
      lblMinimumScale.setText("minimum_scale");
140
      jpanel1.add(lblMinimumScale,cc.xy(7,15));
141

    
142
      lblMaximumScale.setName("lblMaximumScale");
143
      lblMaximumScale.setText("maximum_scale");
144
      jpanel1.add(lblMaximumScale,cc.xy(7,14));
145

    
146
      txtScaleAboveDenominator.setName("txtScaleAboveDenominator");
147
      jpanel1.add(txtScaleAboveDenominator,cc.xy(5,15));
148

    
149
      lblBelow.setName("lblBelow");
150
      lblBelow.setText("is_below_1_colon");
151
      jpanel1.add(lblBelow,cc.xy(3,14));
152

    
153
      lblAbove.setName("lblAbove");
154
      lblAbove.setText("is_above_1_colon");
155
      jpanel1.add(lblAbove,cc.xy(3,15));
156

    
157
      rdb1_25000.setActionCommand("1:25000");
158
      rdb1_25000.setName("rdb1_25000");
159
      rdb1_25000.setText("1:25000");
160
      buttongroup1.add(rdb1_25000);
161
      jpanel1.add(rdb1_25000,cc.xywh(2,4,6,1));
162

    
163
      rdbConditions.setActionCommand("dont_show_layer_when");
164
      rdbConditions.setName("rdbConditions");
165
      rdbConditions.setText("dont_show_layer_when_scale");
166
      buttongroup1.add(rdbConditions);
167
      jpanel1.add(rdbConditions,cc.xywh(2,13,6,1));
168

    
169
      lbl_1_25000_description.setName("lbl_1_25000_description");
170
      lbl_1_25000_description.setText("1_25000_description");
171
      jpanel1.add(lbl_1_25000_description,cc.xywh(3,5,5,1));
172

    
173
      lblDescription.setName("lblDescription");
174
      lblDescription.setText("visibility_scale_selector_dialog_description");
175
      jpanel1.add(lblDescription,cc.xywh(2,2,6,1));
176

    
177
      chkRememberAnswer.setActionCommand("remember_this_answer");
178
      chkRememberAnswer.setName("chkRememberAnswer");
179
      chkRememberAnswer.setText("remember_this_answer");
180
      jpanel1.add(chkRememberAnswer,cc.xywh(2,17,6,1));
181

    
182
      jpanel1.add(createPanel1(),cc.xywh(2,20,6,1));
183
      rdb1_1000.setActionCommand("1:1000");
184
      rdb1_1000.setName("rdb1_1000");
185
      rdb1_1000.setText("1:1000");
186
      buttongroup1.add(rdb1_1000);
187
      jpanel1.add(rdb1_1000,cc.xywh(2,10,6,1));
188

    
189
      lbl_1_1000_description.setName("lbl_1_1000_description");
190
      lbl_1_1000_description.setText("1_1000_description");
191
      jpanel1.add(lbl_1_1000_description,cc.xywh(3,11,5,1));
192

    
193
      rdb1_5000.setActionCommand("1:5000");
194
      rdb1_5000.setName("rdb1_5000");
195
      rdb1_5000.setText("1:5000");
196
      buttongroup1.add(rdb1_5000);
197
      jpanel1.add(rdb1_5000,cc.xywh(2,7,6,1));
198

    
199
      lbl_1_5000_description.setName("lbl_1_5000_description");
200
      lbl_1_5000_description.setText("1_5000_description");
201
      jpanel1.add(lbl_1_5000_description,cc.xywh(3,8,5,1));
202

    
203
      addFillComponents(jpanel1,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,15,16,17,18,19,20,21 });
204
      return jpanel1;
205
   }
206

    
207
   public JPanel createPanel1()
208
   {
209
      JPanel jpanel1 = new JPanel();
210
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE");
211
      CellConstraints cc = new CellConstraints();
212
      jpanel1.setLayout(formlayout1);
213

    
214
      btnAccept.setActionCommand("ok");
215
      btnAccept.setName("btnAccept");
216
      btnAccept.setText("ok");
217
      jpanel1.add(btnAccept,cc.xy(2,1));
218

    
219
      btnCancel.setActionCommand("cancel");
220
      btnCancel.setName("btnCancel");
221
      btnCancel.setText("cancel");
222
      jpanel1.add(btnCancel,cc.xy(4,1));
223

    
224
      addFillComponents(jpanel1,new int[]{ 1,3,5 },new int[]{ 1 });
225
      return jpanel1;
226
   }
227

    
228
   /**
229
    * Initializer
230
    */
231
   protected void initializePanel()
232
   {
233
      setLayout(new BorderLayout());
234
      add(createPanel(), BorderLayout.CENTER);
235
   }
236

    
237

    
238
}