root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / reproject / ui / ProjectionChooserPanel.java @ 20856
History | View | Annotate | Download (6.88 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.rastertools.reproject.ui; |
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 |
import org.gvsig.raster.util.RasterToolsUtil; |
55 |
|
56 |
import com.iver.cit.gvsig.addlayer.AddLayerDialog; |
57 |
import com.iver.cit.gvsig.gui.panels.CRSSelectPanel; |
58 |
|
59 |
/**
|
60 |
* Selecci?n de proyecci?n para la reproyecci?n raster
|
61 |
* 13/05/2008
|
62 |
* @author Nacho Brodin nachobrodin@gmail.com
|
63 |
*/
|
64 |
public class ProjectionChooserPanel extends CRSSelectPanel { |
65 |
|
66 |
private static final long serialVersionUID = 1L; |
67 |
public ICrs curProj = null; |
68 |
private JLabel jLblProj = null; |
69 |
private JLabel jLblProjName = null; |
70 |
private JButton jBtnChangeProj = null; |
71 |
private boolean okPressed = false; |
72 |
private String abrev; |
73 |
boolean panel = false; |
74 |
boolean targetNad = false; |
75 |
String dataSource = "EPSG"; |
76 |
private ActionListener actionListener = null; |
77 |
|
78 |
/**
|
79 |
* Constructor.
|
80 |
* @param proj
|
81 |
*/
|
82 |
public ProjectionChooserPanel(IProjection proj) {
|
83 |
super(proj);
|
84 |
setCurProj(proj); |
85 |
initialize(); |
86 |
} |
87 |
|
88 |
|
89 |
/**
|
90 |
* This method initializes this
|
91 |
*
|
92 |
* @return void
|
93 |
*/
|
94 |
private void initialize() { |
95 |
this.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0)); |
96 |
this.add(getJLblProjName(), null); |
97 |
this.add(getJLblProj(), null); |
98 |
this.add(getJBtnChangeProj(), null); |
99 |
|
100 |
if(!((ICrs)curProj).getAbrev().equals("EPSG:23030")){ |
101 |
dataSource = curProj.getCrsWkt().getAuthority()[0];
|
102 |
jLblProj.setText(dataSource+":" +String.valueOf(curProj.getCode())); |
103 |
|
104 |
} |
105 |
else
|
106 |
jLblProj.setText("EPSG:23030");
|
107 |
initBtnChangeProj(); |
108 |
} |
109 |
|
110 |
/**
|
111 |
* Inicializa el bot?n que lanza el dialogo para selecci?n de
|
112 |
* proyecci?n.
|
113 |
*/
|
114 |
private void initBtnChangeProj() { |
115 |
getJBtnChangeProj().addActionListener(new java.awt.event.ActionListener() {
|
116 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
117 |
CSSelectionDialog csSelect = null;
|
118 |
TRSelectionDialog trSelect = null;
|
119 |
if (!isTransPanelActive()){
|
120 |
okPressed = false;
|
121 |
csSelect = new CSSelectionDialog((ICrs) curProj);
|
122 |
csSelect.setProjection(curProj); |
123 |
csSelect.initRecents(curProj); |
124 |
|
125 |
RasterToolsUtil.addWindow(csSelect); |
126 |
abrev = dataSource+ ":" +String.valueOf(curProj.getCode()); |
127 |
if (csSelect.isOkPressed()) {
|
128 |
curProj = (ICrs) csSelect.getProjection(); |
129 |
dataSource = curProj.getCrsWkt().getAuthority()[0];
|
130 |
abrev = dataSource+ ":" +String.valueOf(curProj.getCode()); |
131 |
|
132 |
jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode())); |
133 |
AddLayerDialog.setLastProjection(curProj); |
134 |
okPressed = true;
|
135 |
if (actionListener != null) { |
136 |
actionListener.actionPerformed(e); |
137 |
} |
138 |
}else
|
139 |
jLblProj.setText(abrev); |
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 |
RasterToolsUtil.addWindow(trSelect); |
150 |
setTargetNad(trSelect.getTargetNad()); |
151 |
|
152 |
if (trSelect.getProjection() != curProj) {
|
153 |
curProj = (ICrs) trSelect.getProjection(); |
154 |
dataSource = curProj.getCrsWkt().getAuthority()[0];
|
155 |
jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//abrev); |
156 |
AddLayerDialog.setLastProjection(curProj); |
157 |
okPressed = true;
|
158 |
|
159 |
if (actionListener != null) { |
160 |
actionListener.actionPerformed(e); |
161 |
} |
162 |
}else
|
163 |
jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode())); |
164 |
|
165 |
} |
166 |
|
167 |
} |
168 |
}); |
169 |
} |
170 |
|
171 |
/**
|
172 |
* Obtiene la etiqueta
|
173 |
* @return
|
174 |
*/
|
175 |
public JLabel getJLblProjName() { |
176 |
if (jLblProjName == null) { |
177 |
jLblProjName = new JLabel("proj"); |
178 |
} |
179 |
return jLblProjName;
|
180 |
} |
181 |
|
182 |
public JLabel getJLabel() { |
183 |
return getJLblProjName();
|
184 |
} |
185 |
|
186 |
public JLabel getJLblProj() { |
187 |
if (jLblProj == null) { |
188 |
jLblProj = new JLabel(); |
189 |
jLblProj.setText(curProj.getAbrev()); |
190 |
} |
191 |
return jLblProj;
|
192 |
} |
193 |
public void addBtnChangeProjActionListener(java.awt.event.ActionListener al) { |
194 |
jBtnChangeProj.addActionListener(al); |
195 |
} |
196 |
|
197 |
/**
|
198 |
* This method initializes jButton
|
199 |
*
|
200 |
* @return javax.swing.JButton
|
201 |
*/
|
202 |
public JButton getJBtnChangeProj() { |
203 |
if (jBtnChangeProj == null) { |
204 |
jBtnChangeProj = new JButton(); |
205 |
jBtnChangeProj.setText("...");
|
206 |
jBtnChangeProj.setPreferredSize(new Dimension(50, 23)); |
207 |
} |
208 |
return jBtnChangeProj;
|
209 |
} |
210 |
|
211 |
public void setTargetNad(boolean tarNad){ |
212 |
targetNad = tarNad; |
213 |
} |
214 |
|
215 |
public boolean getTargetNad(){ |
216 |
return targetNad;
|
217 |
} |
218 |
|
219 |
/**
|
220 |
* @return Returns the curProj.
|
221 |
*/
|
222 |
public IProjection getCurProj() {
|
223 |
return curProj;
|
224 |
} |
225 |
/**
|
226 |
* @param curProj The curProj to set.
|
227 |
*/
|
228 |
public void setCurProj(IProjection curProj) { |
229 |
this.curProj = (ICrs) curProj;
|
230 |
} |
231 |
/**
|
232 |
* @return Returns the okPressed.
|
233 |
*/
|
234 |
public boolean isOkPressed() { |
235 |
return okPressed;
|
236 |
} |
237 |
/**
|
238 |
* @param actionListener The actionListener to set.
|
239 |
*/
|
240 |
public void addActionListener(ActionListener actionListener) { |
241 |
this.actionListener = actionListener;
|
242 |
} |
243 |
} |