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