svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.impl / src / main / java / org / gvsig / exportto / swing / impl / panel / ExportTargetProjectionPanelLayout.java @ 42676
History | View | Annotate | Download (6.92 KB)
1 |
package org.gvsig.exportto.swing.impl.panel; |
---|---|
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.JFrame; |
13 |
import javax.swing.JLabel; |
14 |
import javax.swing.JPanel; |
15 |
import javax.swing.JRadioButton; |
16 |
|
17 |
|
18 |
public class ExportTargetProjectionPanelLayout extends JPanel |
19 |
{ |
20 |
JLabel lblSelectTargetProjection = new JLabel(); |
21 |
JRadioButton rdbtnOriginalProjection = new JRadioButton(); |
22 |
ButtonGroup btngrpSelection = new ButtonGroup(); |
23 |
JLabel lblRdbtnOriginalProjection = new JLabel(); |
24 |
JLabel lblOriginalProjection = new JLabel(); |
25 |
JRadioButton rdbtnViewProjection = new JRadioButton(); |
26 |
JLabel lblRdbtnViewProjection = new JLabel(); |
27 |
JLabel lblViewProjection = new JLabel(); |
28 |
JRadioButton rdbtnUserProjection = new JRadioButton(); |
29 |
JLabel lblRdbtnUserProjection = new JLabel(); |
30 |
JPanel jPanelProj = new JPanel(); |
31 |
|
32 |
/**
|
33 |
* Default constructor
|
34 |
*/
|
35 |
public ExportTargetProjectionPanelLayout()
|
36 |
{ |
37 |
initializePanel(); |
38 |
} |
39 |
|
40 |
/**
|
41 |
* Adds fill components to empty cells in the first row and first column of the grid.
|
42 |
* This ensures that the grid spacing will be the same as shown in the designer.
|
43 |
* @param cols an array of column indices in the first row where fill components should be added.
|
44 |
* @param rows an array of row indices in the first column where fill components should be added.
|
45 |
*/
|
46 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
47 |
{ |
48 |
Dimension filler = new Dimension(10,10); |
49 |
|
50 |
boolean filled_cell_11 = false; |
51 |
CellConstraints cc = new CellConstraints();
|
52 |
if ( cols.length > 0 && rows.length > 0 ) |
53 |
{ |
54 |
if ( cols[0] == 1 && rows[0] == 1 ) |
55 |
{ |
56 |
/** add a rigid area */
|
57 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
58 |
filled_cell_11 = true;
|
59 |
} |
60 |
} |
61 |
|
62 |
for( int index = 0; index < cols.length; index++ ) |
63 |
{ |
64 |
if ( cols[index] == 1 && filled_cell_11 ) |
65 |
{ |
66 |
continue;
|
67 |
} |
68 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
69 |
} |
70 |
|
71 |
for( int index = 0; index < rows.length; index++ ) |
72 |
{ |
73 |
if ( rows[index] == 1 && filled_cell_11 ) |
74 |
{ |
75 |
continue;
|
76 |
} |
77 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
78 |
} |
79 |
|
80 |
} |
81 |
|
82 |
/**
|
83 |
* Helper method to load an image file from the CLASSPATH
|
84 |
* @param imageName the package and name of the file to load relative to the CLASSPATH
|
85 |
* @return an ImageIcon instance with the specified image file
|
86 |
* @throws IllegalArgumentException if the image resource cannot be loaded.
|
87 |
*/
|
88 |
public ImageIcon loadImage( String imageName ) |
89 |
{ |
90 |
try
|
91 |
{ |
92 |
ClassLoader classloader = getClass().getClassLoader();
|
93 |
java.net.URL url = classloader.getResource( imageName ); |
94 |
if ( url != null ) |
95 |
{ |
96 |
ImageIcon icon = new ImageIcon( url ); |
97 |
return icon;
|
98 |
} |
99 |
} |
100 |
catch( Exception e ) |
101 |
{ |
102 |
e.printStackTrace(); |
103 |
} |
104 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
105 |
} |
106 |
|
107 |
/**
|
108 |
* Method for recalculating the component orientation for
|
109 |
* right-to-left Locales.
|
110 |
* @param orientation the component orientation to be applied
|
111 |
*/
|
112 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
113 |
{ |
114 |
// Not yet implemented...
|
115 |
// I18NUtils.applyComponentOrientation(this, orientation);
|
116 |
super.applyComponentOrientation(orientation);
|
117 |
} |
118 |
|
119 |
public JPanel createPanel() |
120 |
{ |
121 |
JPanel jpanel1 = new JPanel(); |
122 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL: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,FILL:DEFAULT:NONE,CENTER:2DLU:NONE"); |
123 |
CellConstraints cc = new CellConstraints();
|
124 |
jpanel1.setLayout(formlayout1); |
125 |
|
126 |
lblSelectTargetProjection.setName("lblSelectTargetProjection");
|
127 |
lblSelectTargetProjection.setText("select_target_projection");
|
128 |
lblSelectTargetProjection.setToolTipText("select_target_projection");
|
129 |
jpanel1.add(lblSelectTargetProjection,cc.xywh(2,2,4,1)); |
130 |
|
131 |
rdbtnOriginalProjection.setActionCommand("original_projection ");
|
132 |
rdbtnOriginalProjection.setName("rdbtnOriginalProjection");
|
133 |
rdbtnOriginalProjection.setToolTipText("projection_from_source_layer_before_view_reprojection");
|
134 |
btngrpSelection.add(rdbtnOriginalProjection); |
135 |
jpanel1.add(rdbtnOriginalProjection,cc.xy(3,4)); |
136 |
|
137 |
lblRdbtnOriginalProjection.setName("lblRdbtnOriginalProjection");
|
138 |
lblRdbtnOriginalProjection.setText("original_projection");
|
139 |
lblRdbtnOriginalProjection.setToolTipText("projection_from_source_layer_before_view_reprojection");
|
140 |
jpanel1.add(lblRdbtnOriginalProjection,cc.xy(5,4)); |
141 |
|
142 |
lblOriginalProjection.setName("lblOriginalProjection");
|
143 |
jpanel1.add(lblOriginalProjection,cc.xy(5,5)); |
144 |
|
145 |
rdbtnViewProjection.setActionCommand("original_projection ");
|
146 |
rdbtnViewProjection.setName("rdbtnViewProjection");
|
147 |
rdbtnViewProjection.setToolTipText("projection_used_in_view");
|
148 |
btngrpSelection.add(rdbtnViewProjection); |
149 |
jpanel1.add(rdbtnViewProjection,cc.xy(3,7)); |
150 |
|
151 |
lblRdbtnViewProjection.setName("lblRdbtnViewProjection");
|
152 |
lblRdbtnViewProjection.setText("view_projection");
|
153 |
lblRdbtnViewProjection.setToolTipText("projection_used_in_view");
|
154 |
jpanel1.add(lblRdbtnViewProjection,cc.xy(5,7)); |
155 |
|
156 |
lblViewProjection.setName("lblViewProjection");
|
157 |
jpanel1.add(lblViewProjection,cc.xy(5,8)); |
158 |
|
159 |
rdbtnUserProjection.setActionCommand("original_projection ");
|
160 |
rdbtnUserProjection.setName("rdbtnUserProjection");
|
161 |
rdbtnUserProjection.setToolTipText("projection_selected_by_user");
|
162 |
btngrpSelection.add(rdbtnUserProjection); |
163 |
jpanel1.add(rdbtnUserProjection,cc.xy(3,10)); |
164 |
|
165 |
lblRdbtnUserProjection.setName("lblRdbtnUserProjection");
|
166 |
lblRdbtnUserProjection.setText("user_selected_projection");
|
167 |
lblRdbtnUserProjection.setToolTipText("projection_selected_by_user");
|
168 |
jpanel1.add(lblRdbtnUserProjection,cc.xy(5,10)); |
169 |
|
170 |
jPanelProj.setName("jPanelProj");
|
171 |
jPanelProj.setToolTipText("projection_selector");
|
172 |
jpanel1.add(jPanelProj,new CellConstraints(5,11,1,1,CellConstraints.LEFT,CellConstraints.DEFAULT)); |
173 |
|
174 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12 }); |
175 |
return jpanel1;
|
176 |
} |
177 |
|
178 |
/**
|
179 |
* Initializer
|
180 |
*/
|
181 |
protected void initializePanel() |
182 |
{ |
183 |
setLayout(new BorderLayout()); |
184 |
add(createPanel(), BorderLayout.CENTER);
|
185 |
} |
186 |
|
187 |
|
188 |
} |