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 @ 45425
History | View | Annotate | Download (7.64 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 |
|
40 |
/**
|
41 |
* Default constructor
|
42 |
*/
|
43 |
public VisibilityScaleSelectorView()
|
44 |
{ |
45 |
initializePanel(); |
46 |
} |
47 |
|
48 |
/**
|
49 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
50 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
51 |
* @param cols an array of column indices in the first row where fill components should be added.
|
52 |
* @param rows an array of row indices in the first column where fill components should be added.
|
53 |
*/
|
54 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
55 |
{ |
56 |
Dimension filler = new Dimension(10,10); |
57 |
|
58 |
boolean filled_cell_11 = false; |
59 |
CellConstraints cc = new CellConstraints();
|
60 |
if ( cols.length > 0 && rows.length > 0 ) |
61 |
{ |
62 |
if ( cols[0] == 1 && rows[0] == 1 ) |
63 |
{ |
64 |
/** add a rigid area */
|
65 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
66 |
filled_cell_11 = true;
|
67 |
} |
68 |
} |
69 |
|
70 |
for( int index = 0; index < cols.length; index++ ) |
71 |
{ |
72 |
if ( cols[index] == 1 && filled_cell_11 ) |
73 |
{ |
74 |
continue;
|
75 |
} |
76 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
77 |
} |
78 |
|
79 |
for( int index = 0; index < rows.length; index++ ) |
80 |
{ |
81 |
if ( rows[index] == 1 && filled_cell_11 ) |
82 |
{ |
83 |
continue;
|
84 |
} |
85 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
86 |
} |
87 |
|
88 |
} |
89 |
|
90 |
/**
|
91 |
* Helper method to load an image file from the CLASSPATH
|
92 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
93 |
* @return an ImageIcon instance with the specified image file
|
94 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
95 |
*/
|
96 |
public ImageIcon loadImage( String imageName ) |
97 |
{ |
98 |
try
|
99 |
{ |
100 |
ClassLoader classloader = getClass().getClassLoader();
|
101 |
java.net.URL url = classloader.getResource( imageName ); |
102 |
if ( url != null ) |
103 |
{ |
104 |
ImageIcon icon = new ImageIcon( url ); |
105 |
return icon;
|
106 |
} |
107 |
} |
108 |
catch( Exception e ) |
109 |
{ |
110 |
e.printStackTrace(); |
111 |
} |
112 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
113 |
} |
114 |
|
115 |
/**
|
116 |
* Method for recalculating the component orientation for
|
117 |
* right-to-left Locales.
|
118 |
* @param orientation the component orientation to be applied
|
119 |
*/
|
120 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
121 |
{ |
122 |
// Not yet implemented...
|
123 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
124 |
super.applyComponentOrientation(orientation);
|
125 |
} |
126 |
|
127 |
public JPanel createPanel() |
128 |
{ |
129 |
JPanel jpanel1 = new JPanel(); |
130 |
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"); |
131 |
CellConstraints cc = new CellConstraints();
|
132 |
jpanel1.setLayout(formlayout1); |
133 |
|
134 |
txtScaleBelowDenominator.setName("txtScaleBelowDenominator");
|
135 |
jpanel1.add(txtScaleBelowDenominator,cc.xy(5,14)); |
136 |
|
137 |
lblMinimumScale.setName("lblMinimumScale");
|
138 |
lblMinimumScale.setText("minimum_scale");
|
139 |
jpanel1.add(lblMinimumScale,cc.xy(7,15)); |
140 |
|
141 |
lblMaximumScale.setName("lblMaximumScale");
|
142 |
lblMaximumScale.setText("maximum_scale");
|
143 |
jpanel1.add(lblMaximumScale,cc.xy(7,14)); |
144 |
|
145 |
txtScaleAboveDenominator.setName("txtScaleAboveDenominator");
|
146 |
jpanel1.add(txtScaleAboveDenominator,cc.xy(5,15)); |
147 |
|
148 |
lblBelow.setName("lblBelow");
|
149 |
lblBelow.setText("is_below_1_colon");
|
150 |
jpanel1.add(lblBelow,cc.xy(3,14)); |
151 |
|
152 |
lblAbove.setName("lblAbove");
|
153 |
lblAbove.setText("is_above_1_colon");
|
154 |
jpanel1.add(lblAbove,cc.xy(3,15)); |
155 |
|
156 |
rdb1_25000.setActionCommand("1:25000");
|
157 |
rdb1_25000.setName("rdb1_25000");
|
158 |
rdb1_25000.setText("1:25000");
|
159 |
buttongroup1.add(rdb1_25000); |
160 |
jpanel1.add(rdb1_25000,cc.xywh(2,4,6,1)); |
161 |
|
162 |
rdbConditions.setActionCommand("dont_show_layer_when");
|
163 |
rdbConditions.setName("rdbConditions");
|
164 |
rdbConditions.setText("dont_show_layer_when_scale");
|
165 |
buttongroup1.add(rdbConditions); |
166 |
jpanel1.add(rdbConditions,cc.xywh(2,13,6,1)); |
167 |
|
168 |
lbl_1_25000_description.setName("lbl_1_25000_description");
|
169 |
lbl_1_25000_description.setText("1_25000_description");
|
170 |
jpanel1.add(lbl_1_25000_description,cc.xywh(3,5,5,1)); |
171 |
|
172 |
lblDescription.setName("lblDescription");
|
173 |
lblDescription.setText("visibility_scale_selector_dialog_description");
|
174 |
jpanel1.add(lblDescription,cc.xywh(2,2,6,1)); |
175 |
|
176 |
chkRememberAnswer.setActionCommand("remember_this_answer");
|
177 |
chkRememberAnswer.setName("chkRememberAnswer");
|
178 |
chkRememberAnswer.setText("remember_this_answer");
|
179 |
jpanel1.add(chkRememberAnswer,new CellConstraints(2,17,6,1,CellConstraints.DEFAULT,CellConstraints.TOP)); |
180 |
|
181 |
rdb1_1000.setActionCommand("1:1000");
|
182 |
rdb1_1000.setName("rdb1_1000");
|
183 |
rdb1_1000.setText("1:1000");
|
184 |
buttongroup1.add(rdb1_1000); |
185 |
jpanel1.add(rdb1_1000,cc.xywh(2,10,6,1)); |
186 |
|
187 |
lbl_1_1000_description.setName("lbl_1_1000_description");
|
188 |
lbl_1_1000_description.setText("1_1000_description");
|
189 |
jpanel1.add(lbl_1_1000_description,cc.xywh(3,11,5,1)); |
190 |
|
191 |
rdb1_5000.setActionCommand("1:5000");
|
192 |
rdb1_5000.setName("rdb1_5000");
|
193 |
rdb1_5000.setText("1:5000");
|
194 |
buttongroup1.add(rdb1_5000); |
195 |
jpanel1.add(rdb1_5000,cc.xywh(2,7,6,1)); |
196 |
|
197 |
lbl_1_5000_description.setName("lbl_1_5000_description");
|
198 |
lbl_1_5000_description.setText("1_5000_description");
|
199 |
jpanel1.add(lbl_1_5000_description,cc.xywh(3,8,5,1)); |
200 |
|
201 |
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 }); |
202 |
return jpanel1;
|
203 |
} |
204 |
|
205 |
/**
|
206 |
* Initializer
|
207 |
*/
|
208 |
protected void initializePanel() |
209 |
{ |
210 |
setLayout(new BorderLayout()); |
211 |
add(createPanel(), BorderLayout.CENTER);
|
212 |
} |
213 |
|
214 |
|
215 |
} |