root / branches / v2_0_0_prep / extensions / extJCRS / src / org / gvsig / crs / gui / panels / ProjChooserPanel.java @ 31496
History | View | Annotate | Download (7.6 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 |
private ActionListener actionListener = null; |
80 |
|
81 |
public ProjChooserPanel(IProjection proj) {
|
82 |
super(proj);
|
83 |
IProjection pr = proj; |
84 |
IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
85 |
if (activeWindow instanceof AbstractViewPanel) { |
86 |
AbstractViewPanel activeView = (AbstractViewPanel) activeWindow; |
87 |
pr = activeView.getMapControl().getProjection(); |
88 |
} |
89 |
AddLayerDialog.setLastProjection(pr); |
90 |
setCurProj(pr); |
91 |
initialize(); |
92 |
} |
93 |
|
94 |
|
95 |
/**
|
96 |
* This method initializes this
|
97 |
*
|
98 |
* @return void
|
99 |
*/
|
100 |
private void initialize() { |
101 |
this.setLayout(new GridLayout(3,1)); |
102 |
this.setLayout(new FlowLayout(FlowLayout.LEFT, 15, 0)); |
103 |
setPreferredSize(new java.awt.Dimension(330,35)); |
104 |
this.setSize(new java.awt.Dimension(330,23)); |
105 |
this.add(getJLblProjName(), null); |
106 |
this.add(getJLblProj(), null); |
107 |
this.add(getJBtnChangeProj(), null); |
108 |
|
109 |
|
110 |
//cambiar cuando la parte de JLuis se ensamble
|
111 |
if(!((ICrs)curProj).getAbrev().equals("EPSG:23030")){ |
112 |
dataSource = curProj.getCrsWkt().getAuthority()[0];
|
113 |
jLblProj.setText(dataSource+":" +String.valueOf(curProj.getCode())); |
114 |
//jLblProj.setText(((ICrs)curProj).getCrsWkt().getName());
|
115 |
} |
116 |
else
|
117 |
jLblProj.setText("EPSG:23030");
|
118 |
initBtnChangeProj(); |
119 |
} |
120 |
|
121 |
private void initBtnChangeProj() { |
122 |
getJBtnChangeProj().addActionListener(new java.awt.event.ActionListener() {
|
123 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
124 |
CSSelectionDialog csSelect = null;
|
125 |
TRSelectionDialog trSelect = null;
|
126 |
if (!isTransPanelActive()){
|
127 |
okPressed = false;
|
128 |
csSelect = new CSSelectionDialog((ICrs) curProj);
|
129 |
csSelect.setProjection(curProj); |
130 |
csSelect.initRecents(curProj); |
131 |
//csSelect.setLayout(new GridLayout(0,1));
|
132 |
|
133 |
PluginServices.getMDIManager().addWindow(csSelect); |
134 |
abrev = dataSource+ ":" +String.valueOf(curProj.getCode()); |
135 |
if (csSelect.isOkPressed()) {
|
136 |
curProj = (ICrs) csSelect.getProjection(); |
137 |
dataSource = curProj.getCrsWkt().getAuthority()[0];
|
138 |
//dataSource = csSelect.getDataSource();
|
139 |
abrev = dataSource+ ":" +String.valueOf(curProj.getCode()); |
140 |
|
141 |
jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//.getAbrev()); |
142 |
AddLayerDialog.setLastProjection(curProj); |
143 |
okPressed = true;
|
144 |
if (actionListener != null) { |
145 |
actionListener.actionPerformed(e); |
146 |
} |
147 |
}else
|
148 |
jLblProj.setText(abrev); |
149 |
} |
150 |
else {
|
151 |
okPressed = false;
|
152 |
trSelect = new TRSelectionDialog(curProj);
|
153 |
|
154 |
trSelect.setProjection(curProj); |
155 |
|
156 |
trSelect.setLayout(new GridLayout(0,1)); |
157 |
|
158 |
PluginServices.getMDIManager().addWindow(trSelect); |
159 |
setTargetNad(trSelect.getTargetNad()); |
160 |
//abrev = curProj.getAbrev();
|
161 |
|
162 |
if (trSelect.getProjection() != curProj) {
|
163 |
curProj = (ICrs) trSelect.getProjection(); |
164 |
dataSource = curProj.getCrsWkt().getAuthority()[0];
|
165 |
//dataSource = trSelect.getProjPanel().getDataSource();
|
166 |
//abrev = trSelect.getProjectionName();
|
167 |
jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//abrev); |
168 |
AddLayerDialog.setLastProjection(curProj); |
169 |
okPressed = true;
|
170 |
|
171 |
if (actionListener != null) { |
172 |
actionListener.actionPerformed(e); |
173 |
} |
174 |
}else
|
175 |
jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//abrev); |
176 |
|
177 |
} |
178 |
|
179 |
} |
180 |
}); |
181 |
} |
182 |
|
183 |
public JLabel getJLblProjName() { |
184 |
if (jLblProjName == null) { |
185 |
jLblProjName = new JLabel("Proyeccion actual"); |
186 |
jLblProjName.setText(PluginServices.getText(this,"proyeccion_actual")); //$NON-NLS-1$ |
187 |
} |
188 |
return jLblProjName;
|
189 |
} |
190 |
|
191 |
public JLabel getJLabel() { |
192 |
return getJLblProjName();
|
193 |
} |
194 |
|
195 |
public JLabel getJLblProj() { |
196 |
if (jLblProj == null) { |
197 |
jLblProj = new JLabel(); |
198 |
jLblProj.setText(curProj.getAbrev()); |
199 |
} |
200 |
return jLblProj;
|
201 |
} |
202 |
public void addBtnChangeProjActionListener(java.awt.event.ActionListener al) { |
203 |
jBtnChangeProj.addActionListener(al); |
204 |
} |
205 |
|
206 |
/**
|
207 |
* This method initializes jButton
|
208 |
*
|
209 |
* @return javax.swing.JButton
|
210 |
*/
|
211 |
public JButton getJBtnChangeProj() { |
212 |
if (jBtnChangeProj == null) { |
213 |
jBtnChangeProj = new JButton(); |
214 |
jBtnChangeProj.setText("..."); //$NON-NLS-1$ |
215 |
jBtnChangeProj.setPreferredSize(new Dimension(50, 23)); |
216 |
} |
217 |
return jBtnChangeProj;
|
218 |
} |
219 |
|
220 |
public void setTargetNad(boolean tarNad){ |
221 |
targetNad = tarNad; |
222 |
} |
223 |
|
224 |
public boolean getTargetNad(){ |
225 |
return targetNad;
|
226 |
} |
227 |
|
228 |
/**
|
229 |
* @return Returns the curProj.
|
230 |
*/
|
231 |
public IProjection getCurProj() {
|
232 |
return curProj;
|
233 |
} |
234 |
/**
|
235 |
* @param curProj The curProj to set.
|
236 |
*/
|
237 |
public void setCurProj(IProjection curProj) { |
238 |
this.curProj = (ICrs) curProj;
|
239 |
} |
240 |
/**
|
241 |
* @return Returns the okPressed.
|
242 |
*/
|
243 |
public boolean isOkPressed() { |
244 |
return okPressed;
|
245 |
} |
246 |
/**
|
247 |
* @param actionListener The actionListener to set.
|
248 |
*/
|
249 |
public void addActionListener(ActionListener actionListener) { |
250 |
this.actionListener = actionListener;
|
251 |
} |
252 |
} // @jve:decl-index=0:visual-constraint="10,10"
|