Revision 7823 trunk/libraries/libJCRS/src/org/gvsig/crs/gui/panels/TransformationNadgridsPanel.java
TransformationNadgridsPanel.java | ||
---|---|---|
13 | 13 |
import javax.swing.JFileChooser; |
14 | 14 |
import javax.swing.JLabel; |
15 | 15 |
import javax.swing.JPanel; |
16 |
import javax.swing.JRadioButton; |
|
16 | 17 |
import javax.swing.JScrollPane; |
17 | 18 |
import javax.swing.JTextArea; |
18 | 19 |
import javax.swing.JTextField; |
19 | 20 |
|
20 | 21 |
import org.cresques.cts.IProjection; |
21 | 22 |
import org.cresques.ui.DefaultDialogPanel; |
23 |
import org.gvsig.crs.CrsException; |
|
22 | 24 |
import org.gvsig.crs.CrsFactory; |
23 | 25 |
import org.gvsig.crs.ICrs; |
24 | 26 |
|
... | ... | |
30 | 32 |
|
31 | 33 |
private static final long serialVersionUID = 1L; |
32 | 34 |
|
35 |
private JPanel groupRadioButton = null; |
|
36 |
private JLabel chooserLabel = null; |
|
37 |
private JRadioButton sourceRadioButton = null; |
|
38 |
private JRadioButton targetRadioButton = null; |
|
39 |
|
|
33 | 40 |
private IProjection firstProj; |
34 |
private String nad = "+nadgrids=sped2et.gsb";
|
|
41 |
private String nad = null;
|
|
35 | 42 |
|
36 | 43 |
private String cadWKT = ""; |
37 | 44 |
private int codeEpsg; |
... | ... | |
47 | 54 |
private JLabel wkt; |
48 | 55 |
private JTextArea info; |
49 | 56 |
private JScrollPane areaScrollPane; |
57 |
boolean targetNad = false; |
|
50 | 58 |
|
51 |
public TransformationNadgridsPanel() { |
|
59 |
public TransformationNadgridsPanel() { |
|
60 |
nad = "+nadgrids=sped2et.gsb"; |
|
52 | 61 |
} |
53 | 62 |
|
54 | 63 |
public JPanel getJPanel(){ |
55 | 64 |
if (panel == null) { |
56 | 65 |
panel = new JPanel(); |
57 |
panel.setLayout(new GridLayout(1,2));
|
|
66 |
panel.setLayout(new GridLayout(1,4));
|
|
58 | 67 |
panel.setLayout(new FlowLayout(FlowLayout.LEADING,5,10)); |
59 | 68 |
panel.setPreferredSize(new Dimension(525, 110)); |
60 | 69 |
panel.setBorder( |
... | ... | |
66 | 75 |
panel.add(getLabel()); |
67 | 76 |
panel.add(getScrollPanelArea()); |
68 | 77 |
panel.add(getOpenPanel()); |
78 |
panel.add(getJLabel()); |
|
79 |
panel.add(getGroupRadioButton()); |
|
69 | 80 |
} |
70 | 81 |
return panel; |
71 | 82 |
} |
72 | 83 |
|
84 |
private JPanel getGroupRadioButton() { |
|
85 |
if (groupRadioButton == null) { |
|
86 |
groupRadioButton = new JPanel(); |
|
87 |
groupRadioButton.setLayout(new GridLayout(1,0)); |
|
88 |
groupRadioButton.setPreferredSize(new Dimension(400,30)); |
|
89 |
groupRadioButton.add(getNadgridsSource()); |
|
90 |
groupRadioButton.add(getNadgridsTarget()); |
|
91 |
} |
|
92 |
return groupRadioButton; |
|
93 |
} |
|
94 |
|
|
95 |
private JRadioButton getNadgridsSource() { |
|
96 |
if (sourceRadioButton == null) { |
|
97 |
sourceRadioButton = new JRadioButton(); |
|
98 |
sourceRadioButton.setText(PluginServices.getText(this,"Aplicar a fuente"));//setText("By Code EPSG"); |
|
99 |
sourceRadioButton.setSelected(true); |
|
100 |
sourceRadioButton.addActionListener(new java.awt.event.ActionListener() { |
|
101 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
102 |
sourceRadioButton_actionPerformed(e); |
|
103 |
} |
|
104 |
}); |
|
105 |
} |
|
106 |
return sourceRadioButton; |
|
107 |
} |
|
108 |
|
|
109 |
private void sourceRadioButton_actionPerformed(ActionEvent e) { |
|
110 |
sourceRadioButton.setSelected(true); |
|
111 |
targetRadioButton.setSelected(false); |
|
112 |
} |
|
113 |
|
|
114 |
private JRadioButton getNadgridsTarget() { |
|
115 |
if (targetRadioButton == null) { |
|
116 |
targetRadioButton = new JRadioButton(); |
|
117 |
targetRadioButton.setText(PluginServices.getText(this,"Aplicar a destino"));//setText("By Code EPSG"); |
|
118 |
targetRadioButton.setSelected(false); |
|
119 |
targetRadioButton.addActionListener(new java.awt.event.ActionListener() { |
|
120 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
121 |
targetRadioButton_actionPerformed(e); |
|
122 |
} |
|
123 |
}); |
|
124 |
} |
|
125 |
return targetRadioButton; |
|
126 |
} |
|
127 |
|
|
128 |
private void targetRadioButton_actionPerformed(ActionEvent e) { |
|
129 |
targetRadioButton.setSelected(true); |
|
130 |
sourceRadioButton.setSelected(false); |
|
131 |
} |
|
132 |
|
|
133 |
private JLabel getJLabel(){ |
|
134 |
chooserLabel = new JLabel(); |
|
135 |
chooserLabel.setPreferredSize(new Dimension(400, 20)); |
|
136 |
chooserLabel.setText(PluginServices.getText(this, "Seleccione donde quiere aplicar Nadgrids: ")); |
|
137 |
return chooserLabel; |
|
138 |
} |
|
139 |
|
|
73 | 140 |
private JScrollPane getScrollPanelArea() { |
74 | 141 |
if(areaScrollPane == null) { |
75 | 142 |
areaScrollPane = new JScrollPane(getInfo()); |
... | ... | |
172 | 239 |
} |
173 | 240 |
|
174 | 241 |
public ICrs getProjection() { |
175 |
try { |
|
176 |
ICrs crs = new CrsFactory().getCRS(getCode(), |
|
177 |
getWKT(),nad); |
|
178 |
return crs; |
|
179 |
} catch (org.gvsig.crs.CrsException e) { |
|
180 |
e.printStackTrace(); |
|
242 |
ICrs crs; |
|
243 |
if (sourceRadioButton.isSelected()){ |
|
244 |
try { |
|
245 |
setNad(false); |
|
246 |
crs = new CrsFactory().getCRS(getCode(), |
|
247 |
getWKT(),nad); |
|
248 |
return crs; |
|
249 |
} catch (org.gvsig.crs.CrsException e) { |
|
250 |
e.printStackTrace(); |
|
251 |
} |
|
252 |
return null; |
|
181 | 253 |
} |
182 |
return null; |
|
254 |
else { |
|
255 |
setNad(true); |
|
256 |
try { |
|
257 |
crs = new CrsFactory().getCRS(getCode(), |
|
258 |
getWKT()); |
|
259 |
return crs; |
|
260 |
} catch (CrsException e) { |
|
261 |
e.printStackTrace(); |
|
262 |
} |
|
263 |
return null; |
|
264 |
} |
|
183 | 265 |
} |
184 | 266 |
|
185 | 267 |
public void setProjection(IProjection proj) { |
186 | 268 |
firstProj = proj; |
187 | 269 |
} |
188 | 270 |
|
271 |
public void setNad(boolean nadg){ |
|
272 |
targetNad = nadg; |
|
273 |
} |
|
274 |
|
|
275 |
public boolean getNad(){ |
|
276 |
return targetNad; |
|
277 |
} |
|
278 |
|
|
189 | 279 |
public void setCode(int cod){ |
190 | 280 |
codeEpsg = cod; |
191 | 281 |
} |
Also available in: Unified diff