root / branches / F2 / extensions / extJCRS / src / org / gvsig / crs / gui / panels / ProjChooserPanel.java @ 10786
History | View | Annotate | Download (7.59 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica 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 Ib??ez, 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.crs.ICrs; |
51 |
import org.gvsig.crs.gui.dialog.CSSelectionDialog; |
52 |
import org.gvsig.crs.gui.dialog.TRSelectionDialog; |
53 |
import org.gvsig.gui.beans.swing.JButton; |
54 |
|
55 |
import com.iver.andami.PluginServices; |
56 |
import com.iver.andami.ui.mdiManager.IWindow; |
57 |
import com.iver.cit.gvsig.gui.panels.CRSSelectPanel; |
58 |
import com.iver.cit.gvsig.project.documents.gui.FOpenDialog; |
59 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
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 View) { |
86 |
View activeView = (com.iver.cit.gvsig.project.documents.view.gui.View) activeWindow;
|
87 |
pr = activeView.getMapControl().getProjection(); |
88 |
} |
89 |
FOpenDialog.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();
|
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 |
FOpenDialog.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 |
trSelect.setLayout(new GridLayout(0,1)); |
156 |
|
157 |
PluginServices.getMDIManager().addWindow(trSelect); |
158 |
setTargetNad(trSelect.getTargetNad()); |
159 |
//abrev = curProj.getAbrev();
|
160 |
|
161 |
if (trSelect.getProjection() != curProj) {
|
162 |
curProj = (ICrs) trSelect.getProjection(); |
163 |
dataSource = curProj.getCrsWkt().getAuthority()[0];
|
164 |
//dataSource = trSelect.getProjPanel().getDataSource();
|
165 |
//abrev = trSelect.getProjectionName();
|
166 |
jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//abrev); |
167 |
FOpenDialog.setLastProjection(curProj); |
168 |
okPressed = true;
|
169 |
|
170 |
if (actionListener != null) { |
171 |
actionListener.actionPerformed(e); |
172 |
} |
173 |
}else
|
174 |
jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//abrev); |
175 |
|
176 |
} |
177 |
|
178 |
} |
179 |
}); |
180 |
} |
181 |
|
182 |
public JLabel getJLblProjName() { |
183 |
if (jLblProjName == null) { |
184 |
jLblProjName = new JLabel("Proyeccion actual"); |
185 |
jLblProjName.setText(PluginServices.getText(this,"proyeccion_actual")); //$NON-NLS-1$ |
186 |
} |
187 |
return jLblProjName;
|
188 |
} |
189 |
|
190 |
public JLabel getJLabel() { |
191 |
return getJLblProjName();
|
192 |
} |
193 |
|
194 |
public JLabel getJLblProj() { |
195 |
if (jLblProj == null) { |
196 |
jLblProj = new JLabel(); |
197 |
jLblProj.setText(curProj.getAbrev()); |
198 |
} |
199 |
return jLblProj;
|
200 |
} |
201 |
public void addBtnChangeProjActionListener(java.awt.event.ActionListener al) { |
202 |
jBtnChangeProj.addActionListener(al); |
203 |
} |
204 |
|
205 |
/**
|
206 |
* This method initializes jButton
|
207 |
*
|
208 |
* @return javax.swing.JButton
|
209 |
*/
|
210 |
public JButton getJBtnChangeProj() { |
211 |
if (jBtnChangeProj == null) { |
212 |
jBtnChangeProj = new JButton(); |
213 |
jBtnChangeProj.setText("..."); //$NON-NLS-1$ |
214 |
jBtnChangeProj.setPreferredSize(new Dimension(50, 23)); |
215 |
} |
216 |
return jBtnChangeProj;
|
217 |
} |
218 |
|
219 |
public void setTargetNad(boolean tarNad){ |
220 |
targetNad = tarNad; |
221 |
} |
222 |
|
223 |
public boolean getTargetNad(){ |
224 |
return targetNad;
|
225 |
} |
226 |
|
227 |
/**
|
228 |
* @return Returns the curProj.
|
229 |
*/
|
230 |
public IProjection getCurProj() {
|
231 |
return curProj;
|
232 |
} |
233 |
/**
|
234 |
* @param curProj The curProj to set.
|
235 |
*/
|
236 |
public void setCurProj(IProjection curProj) { |
237 |
this.curProj = (ICrs) curProj;
|
238 |
} |
239 |
/**
|
240 |
* @return Returns the okPressed.
|
241 |
*/
|
242 |
public boolean isOkPressed() { |
243 |
return okPressed;
|
244 |
} |
245 |
/**
|
246 |
* @param actionListener The actionListener to set.
|
247 |
*/
|
248 |
public void addActionListener(ActionListener actionListener) { |
249 |
this.actionListener = actionListener;
|
250 |
} |
251 |
} // @jve:decl-index=0:visual-constraint="10,10"
|