svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / gui / preferencespage / ViewPageView.java @ 43983
History | View | Annotate | Download (12.7 KB)
1 |
package org.gvsig.app.gui.preferencespage; |
---|---|
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.Color; |
8 |
import java.awt.ComponentOrientation; |
9 |
import java.awt.Container; |
10 |
import java.awt.Dimension; |
11 |
import javax.swing.Box; |
12 |
import javax.swing.ImageIcon; |
13 |
import javax.swing.JButton; |
14 |
import javax.swing.JCheckBox; |
15 |
import javax.swing.JComboBox; |
16 |
import javax.swing.JFrame; |
17 |
import javax.swing.JLabel; |
18 |
import javax.swing.JPanel; |
19 |
import javax.swing.JSlider; |
20 |
import javax.swing.JSpinner; |
21 |
import javax.swing.JTextField; |
22 |
import javax.swing.border.BevelBorder; |
23 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
24 |
|
25 |
|
26 |
public abstract class ViewPageView extends AbstractPreferencePage |
27 |
{ |
28 |
JLabel lblDefaultProjection = new JLabel(); |
29 |
JButton btnChangeProjection = new JButton(); |
30 |
JTextField txtDefaultProjection = new JTextField(); |
31 |
JLabel lblZoomInFactor = new JLabel(); |
32 |
JCheckBox chkInvisibleNewLayers = new JCheckBox(); |
33 |
JCheckBox chkKeepScaleOnResizing = new JCheckBox(); |
34 |
JCheckBox chkOpenWithANewMaximizedView = new JCheckBox(); |
35 |
JLabel lblZoomOutFactor = new JLabel(); |
36 |
JLabel lblDefaultViewBackColor = new JLabel(); |
37 |
JLabel lblDefaultSelectionColor = new JLabel(); |
38 |
JLabel lblMapUnits = new JLabel(); |
39 |
JLabel lblDistanceUnits = new JLabel(); |
40 |
JLabel lblDistanceArea = new JLabel(); |
41 |
JComboBox jCmbMapUnits = new JComboBox(); |
42 |
JComboBox jCmbDistanceUnits = new JComboBox(); |
43 |
JComboBox jCmbDistanceArea = new JComboBox(); |
44 |
JButton btnDefaultViewBackColor = new JButton(); |
45 |
JTextField txtDefaultViewBackColor = new JTextField(); |
46 |
JTextField txtDefaultSelectionColor = new JTextField(); |
47 |
JSlider sldDefaultSelectionColor = new JSlider(); |
48 |
JButton btnDefaultSelectionColor = new JButton(); |
49 |
JLabel lblAlpha = new JLabel(); |
50 |
JSpinner txtZoomInFactor = new JSpinner(); |
51 |
JSpinner txtZoomOutFactor = new JSpinner(); |
52 |
JLabel lblToC = new JLabel(); |
53 |
JCheckBox chkHideLegendOfNonVisibleLayers = new JCheckBox(); |
54 |
|
55 |
/**
|
56 |
* Default constructor
|
57 |
*/
|
58 |
public ViewPageView()
|
59 |
{ |
60 |
initializePanel(); |
61 |
} |
62 |
|
63 |
/**
|
64 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
65 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
66 |
* @param cols an array of column indices in the first row where fill components should be added.
|
67 |
* @param rows an array of row indices in the first column where fill components should be added.
|
68 |
*/
|
69 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
70 |
{ |
71 |
Dimension filler = new Dimension(10,10); |
72 |
|
73 |
boolean filled_cell_11 = false; |
74 |
CellConstraints cc = new CellConstraints();
|
75 |
if ( cols.length > 0 && rows.length > 0 ) |
76 |
{ |
77 |
if ( cols[0] == 1 && rows[0] == 1 ) |
78 |
{ |
79 |
/** add a rigid area */
|
80 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
81 |
filled_cell_11 = true;
|
82 |
} |
83 |
} |
84 |
|
85 |
for( int index = 0; index < cols.length; index++ ) |
86 |
{ |
87 |
if ( cols[index] == 1 && filled_cell_11 ) |
88 |
{ |
89 |
continue;
|
90 |
} |
91 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
92 |
} |
93 |
|
94 |
for( int index = 0; index < rows.length; index++ ) |
95 |
{ |
96 |
if ( rows[index] == 1 && filled_cell_11 ) |
97 |
{ |
98 |
continue;
|
99 |
} |
100 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
101 |
} |
102 |
|
103 |
} |
104 |
|
105 |
/**
|
106 |
* Helper method to load an image file from the CLASSPATH
|
107 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
108 |
* @return an ImageIcon instance with the specified image file
|
109 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
110 |
*/
|
111 |
public ImageIcon loadImage( String imageName ) |
112 |
{ |
113 |
try
|
114 |
{ |
115 |
ClassLoader classloader = getClass().getClassLoader();
|
116 |
java.net.URL url = classloader.getResource( imageName ); |
117 |
if ( url != null ) |
118 |
{ |
119 |
ImageIcon icon = new ImageIcon( url ); |
120 |
return icon;
|
121 |
} |
122 |
} |
123 |
catch( Exception e ) |
124 |
{ |
125 |
e.printStackTrace(); |
126 |
} |
127 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
128 |
} |
129 |
|
130 |
/**
|
131 |
* Method for recalculating the component orientation for
|
132 |
* right-to-left Locales.
|
133 |
* @param orientation the component orientation to be applied
|
134 |
*/
|
135 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
136 |
{ |
137 |
// Not yet implemented...
|
138 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
139 |
super.applyComponentOrientation(orientation);
|
140 |
} |
141 |
|
142 |
public JPanel createPanel() |
143 |
{ |
144 |
JPanel jpanel1 = new JPanel(); |
145 |
FormLayout formlayout1 = new FormLayout("FILL:8DLU:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0)"); |
146 |
CellConstraints cc = new CellConstraints();
|
147 |
jpanel1.setLayout(formlayout1); |
148 |
|
149 |
lblDefaultProjection.setName("lblDefaultProjection");
|
150 |
lblDefaultProjection.setText("Default proyection");
|
151 |
jpanel1.add(lblDefaultProjection,cc.xy(2,2)); |
152 |
|
153 |
jpanel1.add(createPanel1(),cc.xy(4,2)); |
154 |
lblZoomInFactor.setName("lblZoomInFactor");
|
155 |
lblZoomInFactor.setText("Zoom in factor");
|
156 |
jpanel1.add(lblZoomInFactor,cc.xy(2,6)); |
157 |
|
158 |
jpanel1.add(createPanel2(),cc.xy(4,4)); |
159 |
lblZoomOutFactor.setName("lblZoomOutFactor");
|
160 |
lblZoomOutFactor.setText("Zoom out factor");
|
161 |
jpanel1.add(lblZoomOutFactor,cc.xy(2,8)); |
162 |
|
163 |
lblDefaultViewBackColor.setName("lblDefaultViewBackColor");
|
164 |
lblDefaultViewBackColor.setText("Default view back color");
|
165 |
jpanel1.add(lblDefaultViewBackColor,cc.xy(2,10)); |
166 |
|
167 |
lblDefaultSelectionColor.setName("lblDefaultSelectionColor");
|
168 |
lblDefaultSelectionColor.setText("Default selection color");
|
169 |
jpanel1.add(lblDefaultSelectionColor,new CellConstraints(2,12,1,1,CellConstraints.DEFAULT,CellConstraints.CENTER)); |
170 |
|
171 |
lblMapUnits.setName("lblMapUnits");
|
172 |
lblMapUnits.setText("Map units");
|
173 |
jpanel1.add(lblMapUnits,cc.xy(2,14)); |
174 |
|
175 |
lblDistanceUnits.setName("lblDistanceUnits");
|
176 |
lblDistanceUnits.setText("Measuring units");
|
177 |
jpanel1.add(lblDistanceUnits,cc.xy(2,16)); |
178 |
|
179 |
lblDistanceArea.setName("lblDistanceArea");
|
180 |
lblDistanceArea.setText("Area units");
|
181 |
jpanel1.add(lblDistanceArea,cc.xy(2,18)); |
182 |
|
183 |
jCmbMapUnits.setName("jCmbMapUnits");
|
184 |
jpanel1.add(jCmbMapUnits,cc.xy(4,14)); |
185 |
|
186 |
jCmbDistanceUnits.setName("jCmbDistanceUnits");
|
187 |
jpanel1.add(jCmbDistanceUnits,cc.xy(4,16)); |
188 |
|
189 |
jCmbDistanceArea.setName("jCmbDistanceArea");
|
190 |
jpanel1.add(jCmbDistanceArea,cc.xy(4,18)); |
191 |
|
192 |
jpanel1.add(createPanel3(),cc.xy(4,10)); |
193 |
jpanel1.add(createPanel4(),cc.xy(4,12)); |
194 |
txtZoomInFactor.setName("txtZoomInFactor");
|
195 |
jpanel1.add(txtZoomInFactor,cc.xy(4,6)); |
196 |
|
197 |
txtZoomOutFactor.setName("txtZoomOutFactor");
|
198 |
jpanel1.add(txtZoomOutFactor,cc.xy(4,8)); |
199 |
|
200 |
lblToC.setName("lblToC");
|
201 |
lblToC.setText("ToC");
|
202 |
jpanel1.add(lblToC,new CellConstraints(2,20,1,1,CellConstraints.DEFAULT,CellConstraints.TOP)); |
203 |
|
204 |
jpanel1.add(createPanel5(),cc.xy(4,20)); |
205 |
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 }); |
206 |
return jpanel1;
|
207 |
} |
208 |
|
209 |
public JPanel createPanel1() |
210 |
{ |
211 |
JPanel jpanel1 = new JPanel(); |
212 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
213 |
CellConstraints cc = new CellConstraints();
|
214 |
jpanel1.setLayout(formlayout1); |
215 |
|
216 |
btnChangeProjection.setActionCommand("Change");
|
217 |
btnChangeProjection.setName("btnChangeProjection");
|
218 |
btnChangeProjection.setText("Change");
|
219 |
jpanel1.add(btnChangeProjection,cc.xy(3,1)); |
220 |
|
221 |
txtDefaultProjection.setBackground(new Color(236,233,216)); |
222 |
txtDefaultProjection.setEditable(false);
|
223 |
txtDefaultProjection.setName("txtDefaultProjection");
|
224 |
jpanel1.add(txtDefaultProjection,cc.xy(1,1)); |
225 |
|
226 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
227 |
return jpanel1;
|
228 |
} |
229 |
|
230 |
public JPanel createPanel2() |
231 |
{ |
232 |
JPanel jpanel1 = new JPanel(); |
233 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE"); |
234 |
CellConstraints cc = new CellConstraints();
|
235 |
jpanel1.setLayout(formlayout1); |
236 |
|
237 |
chkInvisibleNewLayers.setActionCommand("Add new layers in invisible mode");
|
238 |
chkInvisibleNewLayers.setName("chkInvisibleNewLayers");
|
239 |
chkInvisibleNewLayers.setText("Add new layers in invisible mode");
|
240 |
jpanel1.add(chkInvisibleNewLayers,cc.xy(1,3)); |
241 |
|
242 |
chkKeepScaleOnResizing.setActionCommand("Keep scale on resizing");
|
243 |
chkKeepScaleOnResizing.setName("chkKeepScaleOnResizing");
|
244 |
chkKeepScaleOnResizing.setText("Keep scale on resizing");
|
245 |
jpanel1.add(chkKeepScaleOnResizing,cc.xy(1,5)); |
246 |
|
247 |
chkOpenWithANewMaximizedView.setActionCommand("Open with a new maximized view ");
|
248 |
chkOpenWithANewMaximizedView.setName("chkOpenWithANewMaximizedView");
|
249 |
chkOpenWithANewMaximizedView.setText("Open with a new maximized view ");
|
250 |
jpanel1.add(chkOpenWithANewMaximizedView,cc.xy(1,1)); |
251 |
|
252 |
addFillComponents(jpanel1,new int[0],new int[]{ 2,4 }); |
253 |
return jpanel1;
|
254 |
} |
255 |
|
256 |
public JPanel createPanel3() |
257 |
{ |
258 |
JPanel jpanel1 = new JPanel(); |
259 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
260 |
CellConstraints cc = new CellConstraints();
|
261 |
jpanel1.setLayout(formlayout1); |
262 |
|
263 |
btnDefaultViewBackColor.setActionCommand("...");
|
264 |
btnDefaultViewBackColor.setName("btnDefaultViewBackColor");
|
265 |
btnDefaultViewBackColor.setText("...");
|
266 |
jpanel1.add(btnDefaultViewBackColor,cc.xy(3,1)); |
267 |
|
268 |
txtDefaultViewBackColor.setEnabled(false);
|
269 |
txtDefaultViewBackColor.setName("txtDefaultViewBackColor");
|
270 |
jpanel1.add(txtDefaultViewBackColor,cc.xy(1,1)); |
271 |
|
272 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
273 |
return jpanel1;
|
274 |
} |
275 |
|
276 |
public JPanel createPanel4() |
277 |
{ |
278 |
JPanel jpanel1 = new JPanel(); |
279 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,LEFT:50DLU:NONE","CENTER:DEFAULT:NONE"); |
280 |
CellConstraints cc = new CellConstraints();
|
281 |
jpanel1.setLayout(formlayout1); |
282 |
|
283 |
txtDefaultSelectionColor.setBackground(new Color(255,255,0)); |
284 |
txtDefaultSelectionColor.setEnabled(false);
|
285 |
txtDefaultSelectionColor.setName("txtDefaultSelectionColor");
|
286 |
jpanel1.add(txtDefaultSelectionColor,cc.xy(1,1)); |
287 |
|
288 |
sldDefaultSelectionColor.setMajorTickSpacing(10);
|
289 |
sldDefaultSelectionColor.setMaximum(255);
|
290 |
sldDefaultSelectionColor.setName("sldDefaultSelectionColor");
|
291 |
sldDefaultSelectionColor.setToolTipText("Alpha");
|
292 |
sldDefaultSelectionColor.setValue(255);
|
293 |
jpanel1.add(sldDefaultSelectionColor,cc.xy(7,1)); |
294 |
|
295 |
btnDefaultSelectionColor.setActionCommand("...");
|
296 |
btnDefaultSelectionColor.setName("btnDefaultSelectionColor");
|
297 |
btnDefaultSelectionColor.setText("...");
|
298 |
jpanel1.add(btnDefaultSelectionColor,cc.xy(3,1)); |
299 |
|
300 |
lblAlpha.setName("lblAlpha");
|
301 |
lblAlpha.setText("Alpha");
|
302 |
jpanel1.add(lblAlpha,cc.xy(5,1)); |
303 |
|
304 |
addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[0]); |
305 |
return jpanel1;
|
306 |
} |
307 |
|
308 |
public JPanel createPanel5() |
309 |
{ |
310 |
JPanel jpanel1 = new JPanel(); |
311 |
FormLayout formlayout1 = new FormLayout("FILL:12DLU:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
312 |
CellConstraints cc = new CellConstraints();
|
313 |
jpanel1.setLayout(formlayout1); |
314 |
|
315 |
chkHideLegendOfNonVisibleLayers.setActionCommand("Hide legend of non visible layers");
|
316 |
chkHideLegendOfNonVisibleLayers.setName("chkHideLegendOfNonVisibleLayers");
|
317 |
chkHideLegendOfNonVisibleLayers.setText("Hide legend of non visible layers");
|
318 |
jpanel1.add(chkHideLegendOfNonVisibleLayers,cc.xywh(1,1,2,1)); |
319 |
|
320 |
JLabel jlabel1 = new JLabel(); |
321 |
jpanel1.add(jlabel1,cc.xy(1,2)); |
322 |
|
323 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
324 |
return jpanel1;
|
325 |
} |
326 |
|
327 |
/**
|
328 |
* Initializer
|
329 |
*/
|
330 |
protected void initializePanel() |
331 |
{ |
332 |
setLayout(new BorderLayout()); |
333 |
add(createPanel(), BorderLayout.CENTER);
|
334 |
} |
335 |
|
336 |
|
337 |
} |