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

History | View | Annotate | Download (8.67 KB)

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

    
20

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

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

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

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

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

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

    
90
   }
91

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

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

    
129
   public JPanel createPanel()
130
   {
131
      JPanel jpanel1 = new JPanel();
132
      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,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
133
      CellConstraints cc = new CellConstraints();
134
      jpanel1.setLayout(formlayout1);
135

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

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

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

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

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

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

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

    
165
      rdbConditions.setActionCommand("dont_show_layer_when");
166
      rdbConditions.setName("rdbConditions");
167
      rdbConditions.setRolloverEnabled(true);
168
      rdbConditions.setText("dont_show_layer_when_scale");
169
      buttongroup1.add(rdbConditions);
170
      jpanel1.add(rdbConditions,cc.xywh(2,13,6,1));
171

    
172
      lbl_1_25000_description.setName("lbl_1_25000_description");
173
      lbl_1_25000_description.setText("1_25000_description");
174
      jpanel1.add(lbl_1_25000_description,cc.xywh(3,5,5,1));
175

    
176
      lblDescription.setName("lblDescription");
177
      lblDescription.setText("visibility_scale_selector_dialog_description");
178
      jpanel1.add(lblDescription,cc.xywh(2,2,6,1));
179

    
180
      chkRememberAnswer.setActionCommand("remember_this_answer");
181
      chkRememberAnswer.setName("chkRememberAnswer");
182
      chkRememberAnswer.setRolloverEnabled(true);
183
      chkRememberAnswer.setText("_Remember_this_answer_for_future_times_when_this_layer_is_loaded");
184
      jpanel1.add(chkRememberAnswer,new CellConstraints(2,19,6,1,CellConstraints.DEFAULT,CellConstraints.TOP));
185

    
186
      rdb1_1000.setActionCommand("1:1000");
187
      rdb1_1000.setName("rdb1_1000");
188
      rdb1_1000.setRolloverEnabled(true);
189
      rdb1_1000.setText("1:1000");
190
      buttongroup1.add(rdb1_1000);
191
      jpanel1.add(rdb1_1000,cc.xywh(2,10,6,1));
192

    
193
      lbl_1_1000_description.setName("lbl_1_1000_description");
194
      lbl_1_1000_description.setText("1_1000_description");
195
      jpanel1.add(lbl_1_1000_description,cc.xywh(3,11,5,1));
196

    
197
      rdb1_5000.setActionCommand("1:5000");
198
      rdb1_5000.setName("rdb1_5000");
199
      rdb1_5000.setRolloverEnabled(true);
200
      rdb1_5000.setText("1:5000");
201
      buttongroup1.add(rdb1_5000);
202
      jpanel1.add(rdb1_5000,cc.xywh(2,7,6,1));
203

    
204
      lbl_1_5000_description.setName("lbl_1_5000_description");
205
      lbl_1_5000_description.setText("1_5000_description");
206
      jpanel1.add(lbl_1_5000_description,cc.xywh(3,8,5,1));
207

    
208
      rdbDontAssignScale.setActionCommand("1:1000");
209
      rdbDontAssignScale.setName("rdbDontAssignScale");
210
      rdbDontAssignScale.setRolloverEnabled(true);
211
      rdbDontAssignScale.setText("_Do_not_assign_a_display_scale");
212
      buttongroup1.add(rdbDontAssignScale);
213
      jpanel1.add(rdbDontAssignScale,cc.xywh(2,17,6,1));
214

    
215
      chkDoNotAskScale.setActionCommand("remember_this_answer");
216
      chkDoNotAskScale.setName("chkDoNotAskScale");
217
      chkDoNotAskScale.setRolloverEnabled(true);
218
      chkDoNotAskScale.setText("_Do_not_ask_the_scale_again");
219
      jpanel1.add(chkDoNotAskScale,cc.xywh(2,20,6,1));
220

    
221
      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 });
222
      return jpanel1;
223
   }
224

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

    
234

    
235
}