root / trunk / libraries / libJCRS / src / org / gvsig / crs / ui / TransformationNadgridsPanel.java @ 7020
History | View | Annotate | Download (6.83 KB)
1 |
package org.gvsig.crs.ui; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
import java.awt.Dimension; |
5 |
import java.awt.FlowLayout; |
6 |
import java.awt.GridLayout; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.io.File; |
9 |
|
10 |
import javax.swing.BorderFactory; |
11 |
import javax.swing.JButton; |
12 |
import javax.swing.JFileChooser; |
13 |
import javax.swing.JLabel; |
14 |
import javax.swing.JPanel; |
15 |
import javax.swing.JScrollPane; |
16 |
import javax.swing.JTextArea; |
17 |
import javax.swing.JTextField; |
18 |
|
19 |
import org.cresques.cts.IProjection; |
20 |
import org.cresques.ui.DefaultDialogPanel; |
21 |
import org.gvsig.crs.CrsFactory; |
22 |
import org.gvsig.crs.ICrs; |
23 |
|
24 |
import com.iver.andami.PluginServices; |
25 |
import com.iver.andami.ui.mdiManager.IWindow; |
26 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
27 |
import com.iver.cit.gvsig.gui.panels.ProjChooserPanelTransformation; |
28 |
|
29 |
public class TransformationNadgridsPanel extends DefaultDialogPanel implements IWindow { |
30 |
|
31 |
private static final long serialVersionUID = 1L; |
32 |
|
33 |
private IProjection firstProj;
|
34 |
private String nad = "+nadgrids=sped2et.gsb"; |
35 |
|
36 |
private JPanel buttonPane; |
37 |
private JButton accept; |
38 |
private JButton cancel; |
39 |
|
40 |
ProjChooserPanelTransformation pcpt; |
41 |
|
42 |
private String cadWKT = ""; |
43 |
private int codeEpsg; |
44 |
|
45 |
private JPanel jPaneOpen; |
46 |
private JLabel open_gsb; |
47 |
private JTextField jTextOpen; |
48 |
private JFileChooser openChooser; |
49 |
private JButton jButtonOpen; |
50 |
File f = new File("C:/Archivos de programa/FWTools1.0.0a7/proj_lib"); |
51 |
|
52 |
private JPanel panel; |
53 |
private JLabel wkt; |
54 |
private JTextArea info; |
55 |
private JScrollPane areaScrollPane; |
56 |
|
57 |
public TransformationNadgridsPanel(String cad, int code) { |
58 |
super(false); |
59 |
pcpt = new ProjChooserPanelTransformation();
|
60 |
cadWKT = cad; |
61 |
codeEpsg = code; |
62 |
/*this.setPreferredSize(new Dimension(680, 650));
|
63 |
this.setLayout(new GridLayout(2,2));
|
64 |
this.setLayout(new FlowLayout(FlowLayout.LEFT,5,10));*/
|
65 |
init(); |
66 |
} |
67 |
|
68 |
private void init() { |
69 |
this.add(getJPanel(), null); |
70 |
this.add(getOpenPanel(), null); |
71 |
this.add(getButtonPane(), null); |
72 |
} |
73 |
|
74 |
private JPanel getJPanel(){ |
75 |
if (panel == null) { |
76 |
panel = new JPanel(); |
77 |
panel.setLayout(new GridLayout(1,2)); |
78 |
panel.setLayout(new FlowLayout(FlowLayout.LEADING,5,10)); |
79 |
panel.setPreferredSize(new Dimension(525, 110)); |
80 |
panel.add(getLabel()); |
81 |
panel.add(getScrollPanelArea()); |
82 |
} |
83 |
return panel;
|
84 |
} |
85 |
|
86 |
private JScrollPane getScrollPanelArea() { |
87 |
if(areaScrollPane == null) { |
88 |
areaScrollPane = new JScrollPane(getInfo()); |
89 |
areaScrollPane.setVerticalScrollBarPolicy( |
90 |
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
91 |
areaScrollPane.setPreferredSize(new Dimension(420, 100)); |
92 |
areaScrollPane.setBorder( |
93 |
BorderFactory.createCompoundBorder(
|
94 |
BorderFactory.createCompoundBorder(
|
95 |
BorderFactory.createTitledBorder("Wkt"), |
96 |
BorderFactory.createEmptyBorder(2,2,2,2)), |
97 |
areaScrollPane.getBorder())); |
98 |
} |
99 |
return areaScrollPane;
|
100 |
} |
101 |
|
102 |
private Component getLabel() { |
103 |
if (wkt == null){ |
104 |
wkt = new JLabel(); |
105 |
wkt.setPreferredSize(new Dimension(90, 80)); |
106 |
wkt.setText("Cadena WKT: ");
|
107 |
} |
108 |
return wkt;
|
109 |
} |
110 |
|
111 |
private Component getInfo() { |
112 |
if (info == null){ |
113 |
info = new JTextArea(); |
114 |
info.setLineWrap(true);
|
115 |
info.setWrapStyleWord(true);
|
116 |
info.setPreferredSize(new Dimension(400, 100)); |
117 |
info.setEditable(false);
|
118 |
info.setText(cadWKT); |
119 |
} |
120 |
return info;
|
121 |
} |
122 |
|
123 |
private JPanel getButtonPane() { |
124 |
if(buttonPane == null) { |
125 |
buttonPane = new JPanel(); |
126 |
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
127 |
buttonPane.setPreferredSize(new Dimension(525,50)); |
128 |
buttonPane.add(getButtonAccept(),null);
|
129 |
buttonPane.add(getButtonCancel(),null);
|
130 |
} |
131 |
return buttonPane;
|
132 |
} |
133 |
|
134 |
private JButton getButtonCancel() { |
135 |
if(cancel == null) { |
136 |
cancel = new JButton(); |
137 |
cancel.setText("Cancelar");
|
138 |
cancel.setPreferredSize(new Dimension(100,25)); |
139 |
cancel.setMnemonic('C');
|
140 |
cancel.setToolTipText("Cancel");
|
141 |
cancel.addActionListener(new java.awt.event.ActionListener() {
|
142 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
143 |
cancelButton_actionPerformed(e); |
144 |
} |
145 |
}); |
146 |
} |
147 |
return cancel;
|
148 |
} |
149 |
|
150 |
public void cancelButton_actionPerformed(ActionEvent e) { |
151 |
PluginServices.getMDIManager().closeWindow(this);
|
152 |
} |
153 |
|
154 |
private JButton getButtonAccept() { |
155 |
if(accept == null) { |
156 |
accept = new JButton(); |
157 |
accept.setText("Aceptar");
|
158 |
accept.setPreferredSize(new Dimension(100,25)); |
159 |
accept.setMnemonic('A');
|
160 |
accept.setToolTipText("Accept");
|
161 |
accept.addActionListener(new java.awt.event.ActionListener() {
|
162 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
163 |
acceptButton_actionPerformed(e); |
164 |
} |
165 |
}); |
166 |
} |
167 |
return accept;
|
168 |
} |
169 |
|
170 |
public void acceptButton_actionPerformed(ActionEvent e) { |
171 |
PluginServices.getMDIManager().closeWindow(this);
|
172 |
} |
173 |
|
174 |
private JPanel getOpenPanel() { |
175 |
if(jPaneOpen == null) { |
176 |
jPaneOpen = new JPanel(); |
177 |
jPaneOpen.setPreferredSize(new Dimension(525,50)); |
178 |
jPaneOpen.setLayout(new GridLayout(2,2)); |
179 |
jPaneOpen.setLayout(new FlowLayout(FlowLayout.LEFT,5,5)); |
180 |
jPaneOpen.add(getOpenGsb(), null);
|
181 |
jPaneOpen.add(getOpenTextField(), null);
|
182 |
jPaneOpen.add(getButtonOpen(), null);
|
183 |
// jPaneOpen.add(getOpen(), null);
|
184 |
|
185 |
} |
186 |
return jPaneOpen;
|
187 |
} |
188 |
|
189 |
private JLabel getOpenGsb() { |
190 |
if(open_gsb == null) { |
191 |
open_gsb = new JLabel(); |
192 |
open_gsb.setPreferredSize(new Dimension(80,20)); |
193 |
open_gsb.setText("Open .gsb:");
|
194 |
} |
195 |
return open_gsb;
|
196 |
} |
197 |
|
198 |
private JTextField getOpenTextField() { |
199 |
if(jTextOpen == null) { |
200 |
jTextOpen = new JTextField(); |
201 |
jTextOpen.setPreferredSize(new Dimension(200,20)); |
202 |
jTextOpen.setText("");
|
203 |
} |
204 |
return jTextOpen;
|
205 |
} |
206 |
|
207 |
private JFileChooser getOpen(){ |
208 |
if(openChooser == null){ |
209 |
openChooser = new JFileChooser(); |
210 |
openChooser.setEnabled(false);
|
211 |
} |
212 |
return openChooser;
|
213 |
} |
214 |
|
215 |
private JButton getButtonOpen() { |
216 |
if(jButtonOpen == null) { |
217 |
jButtonOpen = new JButton(); |
218 |
jButtonOpen.setText("");
|
219 |
jButtonOpen.setPreferredSize(new Dimension(20,20)); |
220 |
jButtonOpen.addActionListener(new java.awt.event.ActionListener() {
|
221 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
222 |
Open_actionPerformed(e); |
223 |
} |
224 |
}); |
225 |
} |
226 |
return jButtonOpen;
|
227 |
} |
228 |
|
229 |
private void Open_actionPerformed(ActionEvent e){ |
230 |
jPaneOpen.add(getOpen(), null);
|
231 |
openChooser.setCurrentDirectory(f); |
232 |
int returnVal = openChooser.showOpenDialog(TransformationNadgridsPanel.this);
|
233 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
234 |
File file = openChooser.getSelectedFile();
|
235 |
jTextOpen.setText(file.getAbsolutePath()); |
236 |
} |
237 |
} |
238 |
|
239 |
public ICrs getProjection() {
|
240 |
try {
|
241 |
ICrs crs = new CrsFactory().getCRS(codeEpsg,
|
242 |
cadWKT,nad); |
243 |
return crs;
|
244 |
} catch (org.gvsig.crs.CrsException e) {
|
245 |
e.printStackTrace(); |
246 |
} |
247 |
return null; |
248 |
} |
249 |
|
250 |
public void setProjection(IProjection proj) { |
251 |
firstProj = proj; |
252 |
} |
253 |
|
254 |
public WindowInfo getWindowInfo() {
|
255 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG);
|
256 |
m_viewinfo.setTitle(PluginServices.getText(this,"Nadgrids")); |
257 |
return m_viewinfo;
|
258 |
} |
259 |
} |