svn-gvsig-desktop / tags / v2_0_0_Build_2031 / extensions / extJCRS / src / org / gvsig / crs / gui / panels / ProjChooserPanel.java @ 36066
History | View | Annotate | Download (7.36 KB)
1 |
/* gvSIG. Sistema de Informacin Geogrfica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2006 Instituto de Desarrollo Regional and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ibez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* Instituto de Desarrollo Regional (Universidad de Castilla La-Mancha)
|
34 |
* Campus Universitario s/n
|
35 |
* 02071 Alabacete
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 967 599 200
|
39 |
*/
|
40 |
package org.gvsig.crs.gui.panels; |
41 |
|
42 |
import java.awt.Dimension; |
43 |
import java.awt.FlowLayout; |
44 |
import java.awt.GridLayout; |
45 |
import java.awt.event.ActionListener; |
46 |
|
47 |
import javax.swing.JLabel; |
48 |
|
49 |
import org.cresques.cts.IProjection; |
50 |
import org.gvsig.andami.PluginServices; |
51 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
52 |
import org.gvsig.app.addlayer.AddLayerDialog; |
53 |
import org.gvsig.app.gui.panels.CRSSelectPanel; |
54 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
55 |
import org.gvsig.crs.ICrs; |
56 |
import org.gvsig.crs.gui.dialog.CSSelectionDialog; |
57 |
import org.gvsig.crs.gui.dialog.TRSelectionDialog; |
58 |
import org.gvsig.gui.beans.swing.JButton; |
59 |
|
60 |
|
61 |
/**
|
62 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
63 |
*/
|
64 |
public class ProjChooserPanel extends CRSSelectPanel { |
65 |
|
66 |
private static final long serialVersionUID = 1L; |
67 |
|
68 |
public ICrs curProj = null; //(IProjection) new CRSFactory().getCRS("EPSG:23030"); |
69 |
|
70 |
private JLabel jLblProj = null; |
71 |
private JLabel jLblProjName = null; |
72 |
private JButton jBtnChangeProj = null; |
73 |
private boolean okPressed = false; |
74 |
private String abrev; |
75 |
boolean panel = false; |
76 |
boolean targetNad = false; |
77 |
String dataSource = "EPSG"; |
78 |
|
79 |
public ProjChooserPanel(IProjection proj) {
|
80 |
super(proj);
|
81 |
IProjection pr = proj; |
82 |
IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
83 |
if (activeWindow instanceof AbstractViewPanel) { |
84 |
AbstractViewPanel activeView = (AbstractViewPanel) activeWindow; |
85 |
pr = activeView.getMapControl().getProjection(); |
86 |
} |
87 |
AddLayerDialog.setLastProjection(pr); |
88 |
setCurProj(pr); |
89 |
initialize(); |
90 |
} |
91 |
|
92 |
|
93 |
/**
|
94 |
* This method initializes this
|
95 |
*
|
96 |
* @return void
|
97 |
*/
|
98 |
private void initialize() { |
99 |
this.setLayout(new GridLayout(3,1)); |
100 |
this.setLayout(new FlowLayout(FlowLayout.LEFT, 15, 0)); |
101 |
setPreferredSize(new java.awt.Dimension(330,35)); |
102 |
this.setSize(new java.awt.Dimension(330,23)); |
103 |
this.add(getJLblProjName(), null); |
104 |
this.add(getJLblProj(), null); |
105 |
this.add(getJBtnChangeProj(), null); |
106 |
initBtnChangeProj(); |
107 |
refresh(); |
108 |
} |
109 |
|
110 |
private void initBtnChangeProj() { |
111 |
getJBtnChangeProj().addActionListener(new java.awt.event.ActionListener() {
|
112 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
113 |
CSSelectionDialog csSelect = null;
|
114 |
TRSelectionDialog trSelect = null;
|
115 |
if (!isTransPanelActive()){
|
116 |
okPressed = false;
|
117 |
csSelect = new CSSelectionDialog((ICrs) curProj);
|
118 |
csSelect.setProjection(curProj); |
119 |
csSelect.initRecents(curProj); |
120 |
//csSelect.setLayout(new GridLayout(0,1));
|
121 |
|
122 |
PluginServices.getMDIManager().addWindow(csSelect); |
123 |
// abrev = curProj.getAbrev();
|
124 |
abrev = dataSource+ ":" +String.valueOf(curProj.getCode()); |
125 |
if (csSelect.isOkPressed()) {
|
126 |
curProj = (ICrs) csSelect.getProjection(); |
127 |
dataSource = curProj.getCrsWkt().getAuthority()[0];
|
128 |
//dataSource = csSelect.getDataSource();
|
129 |
abrev = dataSource+ ":" +String.valueOf(curProj.getCode()); |
130 |
|
131 |
getJLblProj().setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//.getAbrev()); |
132 |
AddLayerDialog.setLastProjection(curProj); |
133 |
okPressed = true;
|
134 |
if (actionListener != null) { |
135 |
actionListener.actionPerformed(e); |
136 |
} |
137 |
}else{
|
138 |
getJLblProj().setText(abrev); |
139 |
} |
140 |
} |
141 |
else {
|
142 |
okPressed = false;
|
143 |
trSelect = new TRSelectionDialog(curProj);
|
144 |
|
145 |
trSelect.setProjection(curProj); |
146 |
|
147 |
trSelect.setLayout(new GridLayout(0,1)); |
148 |
|
149 |
PluginServices.getMDIManager().addWindow(trSelect); |
150 |
setTargetNad(trSelect.getTargetNad()); |
151 |
//abrev = curProj.getAbrev();
|
152 |
|
153 |
if (trSelect.getProjection() != curProj) {
|
154 |
curProj = (ICrs) trSelect.getProjection(); |
155 |
dataSource = curProj.getCrsWkt().getAuthority()[0];
|
156 |
//dataSource = trSelect.getProjPanel().getDataSource();
|
157 |
//abrev = trSelect.getProjectionName();
|
158 |
getJLblProj().setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//abrev); |
159 |
AddLayerDialog.setLastProjection(curProj); |
160 |
okPressed = true;
|
161 |
|
162 |
if (actionListener != null) { |
163 |
actionListener.actionPerformed(e); |
164 |
} |
165 |
}else{
|
166 |
refresh(); |
167 |
} |
168 |
} |
169 |
|
170 |
} |
171 |
}); |
172 |
} |
173 |
|
174 |
|
175 |
|
176 |
public JLabel getJLblProjName() { |
177 |
if (jLblProjName == null) { |
178 |
jLblProjName = new JLabel("Proyeccion actual"); |
179 |
jLblProjName.setText(PluginServices.getText(this,"proyeccion_actual")); //$NON-NLS-1$ |
180 |
} |
181 |
return jLblProjName;
|
182 |
} |
183 |
|
184 |
public JLabel getJLabel() { |
185 |
return getJLblProjName();
|
186 |
} |
187 |
|
188 |
public JLabel getJLblProj() { |
189 |
if (jLblProj == null) { |
190 |
jLblProj = new JLabel(); |
191 |
} |
192 |
return jLblProj;
|
193 |
} |
194 |
|
195 |
/**
|
196 |
* This method initializes jButton
|
197 |
*
|
198 |
* @return javax.swing.JButton
|
199 |
*/
|
200 |
public JButton getJBtnChangeProj() { |
201 |
if (jBtnChangeProj == null) { |
202 |
jBtnChangeProj = new JButton(); |
203 |
jBtnChangeProj.setText("..."); //$NON-NLS-1$ |
204 |
jBtnChangeProj.setPreferredSize(new Dimension(50, 23)); |
205 |
} |
206 |
return jBtnChangeProj;
|
207 |
} |
208 |
|
209 |
public void setTargetNad(boolean tarNad){ |
210 |
targetNad = tarNad; |
211 |
} |
212 |
|
213 |
public boolean getTargetNad(){ |
214 |
return targetNad;
|
215 |
} |
216 |
|
217 |
/**
|
218 |
* @return Returns the curProj.
|
219 |
*/
|
220 |
public IProjection getCurProj() {
|
221 |
return curProj;
|
222 |
} |
223 |
|
224 |
/**
|
225 |
* @param curProj The curProj to set.
|
226 |
*/
|
227 |
public void setCurProj(IProjection curProj) { |
228 |
this.curProj = (ICrs) curProj;
|
229 |
refresh(); |
230 |
} |
231 |
|
232 |
private void refresh() { |
233 |
if (curProj != null){ |
234 |
dataSource = curProj.getCrsWkt().getAuthority()[0];
|
235 |
String text = dataSource + ":" + String.valueOf(curProj.getCode()); |
236 |
getJLblProj().setText(text.trim()); |
237 |
}else{
|
238 |
getJLblProj().setText("");
|
239 |
} |
240 |
} |
241 |
|
242 |
/**
|
243 |
* @return Returns the okPressed.
|
244 |
*/
|
245 |
public boolean isOkPressed() { |
246 |
return okPressed;
|
247 |
} |
248 |
|
249 |
/**
|
250 |
* @param actionListener The actionListener to set.
|
251 |
*/
|
252 |
public void addActionListener(ActionListener actionListener) { |
253 |
this.actionListener = actionListener;
|
254 |
} |
255 |
} // @jve:decl-index=0:visual-constraint="10,10"
|