svn-gvsig-desktop / branches / v10 / libraries / libJCRS / src / org / gvsig / crs / gui / panels / ProjChooserPanel.java @ 14864
History | View | Annotate | Download (7.59 KB)
1 | 8911 | jlgomez | /* 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 | 7570 | jlgomez | */
|
40 | package org.gvsig.crs.gui.panels; |
||
41 | |||
42 | 8122 | jlgomez | import java.awt.Dimension; |
43 | 7570 | jlgomez | 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 | 7581 | dguerrero | import org.gvsig.crs.gui.dialog.CSSelectionDialog; |
52 | 7701 | jlgomez | import org.gvsig.crs.gui.dialog.TRSelectionDialog; |
53 | 8863 | dguerrero | import org.gvsig.gui.beans.swing.JButton; |
54 | 7570 | jlgomez | |
55 | import com.iver.andami.PluginServices; |
||
56 | 7576 | jlgomez | import com.iver.andami.ui.mdiManager.IWindow; |
57 | 7581 | dguerrero | import com.iver.cit.gvsig.gui.panels.CRSSelectPanel; |
58 | 8863 | dguerrero | import com.iver.cit.gvsig.project.documents.gui.FOpenDialog; |
59 | 14864 | gsdiego | import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
60 | 7570 | jlgomez | |
61 | /**
|
||
62 | * @author Luis W. Sevilla (sevilla_lui@gva.es)
|
||
63 | */
|
||
64 | 7581 | dguerrero | public class ProjChooserPanel extends CRSSelectPanel { |
65 | 7570 | jlgomez | |
66 | private static final long serialVersionUID = 1L; |
||
67 | |||
68 | 8003 | jlgomez | public ICrs curProj = null; //(IProjection) new CRSFactory().getCRS("EPSG:23030"); |
69 | 8000 | jlgomez | |
70 | 7570 | jlgomez | private JLabel jLblProj = null; |
71 | private JLabel jLblProjName = null; |
||
72 | private JButton jBtnChangeProj = null; |
||
73 | 8003 | jlgomez | private boolean okPressed = false; |
74 | 7570 | jlgomez | private String abrev; |
75 | 7701 | jlgomez | boolean panel = false; |
76 | 7823 | jlgomez | boolean targetNad = false; |
77 | 8114 | jlgomez | String dataSource = "EPSG"; |
78 | 7570 | jlgomez | |
79 | private ActionListener actionListener = null; |
||
80 | |||
81 | 7705 | dguerrero | public ProjChooserPanel(IProjection proj) {
|
82 | 8105 | jlgomez | super(proj);
|
83 | 8347 | jlgomez | IProjection pr = proj; |
84 | 8105 | jlgomez | IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
85 | 14864 | gsdiego | if (activeWindow instanceof BaseView) { |
86 | BaseView activeView = (com.iver.cit.gvsig.project.documents.view.gui.BaseView) activeWindow; |
||
87 | 8347 | jlgomez | pr = activeView.getMapControl().getProjection(); |
88 | 8105 | jlgomez | } |
89 | 8347 | jlgomez | FOpenDialog.setLastProjection(pr); |
90 | 8105 | jlgomez | setCurProj(pr); |
91 | initialize(); |
||
92 | 7570 | jlgomez | } |
93 | |||
94 | |||
95 | /**
|
||
96 | * This method initializes this
|
||
97 | *
|
||
98 | * @return void
|
||
99 | */
|
||
100 | private void initialize() { |
||
101 | 8122 | jlgomez | this.setLayout(new GridLayout(3,1)); |
102 | 7570 | jlgomez | 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 | 8105 | jlgomez | |
109 | 8114 | jlgomez | |
110 | 7570 | jlgomez | //cambiar cuando la parte de JLuis se ensamble
|
111 | 8114 | jlgomez | if(!((ICrs)curProj).getAbrev().equals("EPSG:23030")){ |
112 | dataSource = curProj.getCrsWkt().getAuthority()[0];
|
||
113 | 7888 | jlgomez | jLblProj.setText(dataSource+":" +String.valueOf(curProj.getCode())); |
114 | //jLblProj.setText(((ICrs)curProj).getCrsWkt().getName());
|
||
115 | 8114 | jlgomez | } |
116 | 7570 | jlgomez | else
|
117 | 8347 | jlgomez | jLblProj.setText("EPSG:23030");
|
118 | 7570 | jlgomez | 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 | 7701 | jlgomez | CSSelectionDialog csSelect = null;
|
125 | TRSelectionDialog trSelect = null;
|
||
126 | 7705 | dguerrero | if (!isTransPanelActive()){
|
127 | 7701 | jlgomez | okPressed = false;
|
128 | 7735 | jlgomez | csSelect = new CSSelectionDialog();
|
129 | 7701 | jlgomez | csSelect.setProjection(curProj); |
130 | |||
131 | 8426 | dguerrero | //csSelect.setLayout(new GridLayout(0,1));
|
132 | 8073 | jlgomez | |
133 | 7701 | jlgomez | PluginServices.getMDIManager().addWindow(csSelect); |
134 | 7888 | jlgomez | abrev = dataSource+ ":" +String.valueOf(curProj.getCode()); |
135 | 7701 | jlgomez | if (csSelect.isOkPressed()) {
|
136 | 7888 | jlgomez | curProj = (ICrs) csSelect.getProjection(); |
137 | 8073 | jlgomez | dataSource = curProj.getCrsWkt().getAuthority()[0];
|
138 | //dataSource = csSelect.getDataSource();
|
||
139 | 7888 | jlgomez | abrev = dataSource+ ":" +String.valueOf(curProj.getCode()); |
140 | 7735 | jlgomez | |
141 | 7888 | jlgomez | jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//.getAbrev()); |
142 | 7701 | jlgomez | FOpenDialog.setLastProjection(curProj); |
143 | okPressed = true;
|
||
144 | if (actionListener != null) { |
||
145 | actionListener.actionPerformed(e); |
||
146 | } |
||
147 | 7735 | jlgomez | }else
|
148 | jLblProj.setText(abrev); |
||
149 | 7701 | jlgomez | } |
150 | else {
|
||
151 | 8000 | jlgomez | okPressed = false;
|
152 | 8003 | jlgomez | trSelect = new TRSelectionDialog(curProj);
|
153 | 7823 | jlgomez | |
154 | 7701 | jlgomez | trSelect.setProjection(curProj); |
155 | |||
156 | trSelect.setLayout(new GridLayout(0,1)); |
||
157 | |||
158 | PluginServices.getMDIManager().addWindow(trSelect); |
||
159 | 7823 | jlgomez | setTargetNad(trSelect.getTargetNad()); |
160 | 7888 | jlgomez | //abrev = curProj.getAbrev();
|
161 | 8000 | jlgomez | |
162 | 7701 | jlgomez | if (trSelect.getProjection() != curProj) {
|
163 | 7888 | jlgomez | curProj = (ICrs) trSelect.getProjection(); |
164 | 8073 | jlgomez | dataSource = curProj.getCrsWkt().getAuthority()[0];
|
165 | //dataSource = trSelect.getProjPanel().getDataSource();
|
||
166 | 7888 | jlgomez | //abrev = trSelect.getProjectionName();
|
167 | jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//abrev); |
||
168 | 8000 | jlgomez | FOpenDialog.setLastProjection(curProj); |
169 | 7701 | jlgomez | okPressed = true;
|
170 | 8000 | jlgomez | |
171 | 7701 | jlgomez | if (actionListener != null) { |
172 | actionListener.actionPerformed(e); |
||
173 | } |
||
174 | }else
|
||
175 | 7888 | jlgomez | jLblProj.setText(dataSource+ ":" +String.valueOf(curProj.getCode()));//abrev); |
176 | 7701 | jlgomez | |
177 | } |
||
178 | 7823 | jlgomez | |
179 | 7570 | jlgomez | } |
180 | }); |
||
181 | } |
||
182 | |||
183 | public JLabel getJLblProjName() { |
||
184 | if (jLblProjName == null) { |
||
185 | jLblProjName = new JLabel("Proyeccion actual"); |
||
186 | 8304 | jlgomez | jLblProjName.setText(PluginServices.getText(this,"proyeccion_actual")); //$NON-NLS-1$ |
187 | 7570 | jlgomez | } |
188 | return jLblProjName;
|
||
189 | } |
||
190 | 8902 | luisw | |
191 | public JLabel getJLabel() { |
||
192 | return getJLblProjName();
|
||
193 | } |
||
194 | 7570 | jlgomez | |
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 | 8122 | jlgomez | jBtnChangeProj = new JButton(); |
214 | 7570 | jlgomez | jBtnChangeProj.setText("..."); //$NON-NLS-1$ |
215 | 8127 | jlgomez | jBtnChangeProj.setPreferredSize(new Dimension(50, 23)); |
216 | 7570 | jlgomez | } |
217 | return jBtnChangeProj;
|
||
218 | } |
||
219 | 7823 | jlgomez | |
220 | public void setTargetNad(boolean tarNad){ |
||
221 | targetNad = tarNad; |
||
222 | } |
||
223 | |||
224 | public boolean getTargetNad(){ |
||
225 | return targetNad;
|
||
226 | } |
||
227 | |||
228 | 7570 | jlgomez | /**
|
229 | * @return Returns the curProj.
|
||
230 | */
|
||
231 | 7581 | dguerrero | public IProjection getCurProj() {
|
232 | 7570 | jlgomez | return curProj;
|
233 | } |
||
234 | /**
|
||
235 | * @param curProj The curProj to set.
|
||
236 | */
|
||
237 | public void setCurProj(IProjection curProj) { |
||
238 | 7888 | jlgomez | this.curProj = (ICrs) curProj;
|
239 | 7570 | jlgomez | } |
240 | /**
|
||
241 | * @return Returns the okPressed.
|
||
242 | */
|
||
243 | 7581 | dguerrero | public boolean isOkPressed() { |
244 | 7570 | jlgomez | 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" |