root / trunk / libraries / libJCRS / src / org / gvsig / crs / gui / panels / ProjChooserPanel.java @ 7701
History | View | Annotate | Download (5.53 KB)
1 |
/*
|
---|---|
2 |
* Created on 30-ene-2005
|
3 |
*/
|
4 |
package org.gvsig.crs.gui.panels; |
5 |
|
6 |
import java.awt.FlowLayout; |
7 |
import java.awt.GridLayout; |
8 |
import java.awt.event.ActionListener; |
9 |
|
10 |
import org.gvsig.gui.beans.swing.JButton; |
11 |
import javax.swing.JLabel; |
12 |
|
13 |
import org.cresques.cts.IProjection; |
14 |
import org.gvsig.crs.EpsgConnection; |
15 |
import org.gvsig.crs.ICrs; |
16 |
import org.gvsig.crs.gui.dialog.CSSelectionDialog; |
17 |
import org.gvsig.crs.gui.dialog.TRSelectionDialog; |
18 |
|
19 |
import com.iver.andami.PluginServices; |
20 |
import com.iver.andami.ui.mdiManager.IWindow; |
21 |
import com.iver.cit.gvsig.gui.FOpenDialog; |
22 |
import com.iver.cit.gvsig.gui.View; |
23 |
import com.iver.cit.gvsig.gui.panels.CRSSelectPanel; |
24 |
|
25 |
/**
|
26 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
27 |
*/
|
28 |
public class ProjChooserPanel extends CRSSelectPanel { |
29 |
|
30 |
private static final long serialVersionUID = 1L; |
31 |
|
32 |
private static IProjection curProj = null; //(IProjection) new CRSFactory().getCRS("EPSG:23030"); |
33 |
private JLabel jLblProj = null; |
34 |
private JLabel jLblProjName = null; |
35 |
private JButton jBtnChangeProj = null; |
36 |
private static boolean okPressed = false; |
37 |
private String abrev; |
38 |
boolean panel = false; |
39 |
|
40 |
public EpsgConnection connect = null; |
41 |
|
42 |
private ActionListener actionListener = null; |
43 |
|
44 |
public ProjChooserPanel(IProjection proj, Boolean pan) { |
45 |
super(proj);
|
46 |
setCurProj(proj); |
47 |
panel = pan.booleanValue(); |
48 |
initialize(); |
49 |
} |
50 |
|
51 |
/* public ProjChooserPanel(){
|
52 |
connect = new EpsgConnection();
|
53 |
connect.setConnection();
|
54 |
}*/
|
55 |
|
56 |
/**
|
57 |
* This method initializes this
|
58 |
*
|
59 |
* @return void
|
60 |
*/
|
61 |
private void initialize() { |
62 |
this.setLayout(new FlowLayout(FlowLayout.LEFT, 15, 0)); |
63 |
setPreferredSize(new java.awt.Dimension(330,35)); |
64 |
this.setSize(new java.awt.Dimension(330,23)); |
65 |
this.add(getJLblProjName(), null); |
66 |
this.add(getJLblProj(), null); |
67 |
this.add(getJBtnChangeProj(), null); |
68 |
//cambiar cuando la parte de JLuis se ensamble
|
69 |
if(!((ICrs)curProj).getAbrev().equals("EPSG:23030")) |
70 |
jLblProj.setText(((ICrs)curProj).getCrsWkt().getName()); |
71 |
else
|
72 |
jLblProj.setText("EPSG:23030");
|
73 |
initBtnChangeProj(); |
74 |
} |
75 |
|
76 |
private void initBtnChangeProj() { |
77 |
getJBtnChangeProj().addActionListener(new java.awt.event.ActionListener() {
|
78 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
79 |
CSSelectionDialog csSelect = null;
|
80 |
TRSelectionDialog trSelect = null;
|
81 |
if (!panel){
|
82 |
okPressed = false;
|
83 |
csSelect = new CSSelectionDialog();
|
84 |
csSelect.setProjection(curProj); |
85 |
|
86 |
csSelect.setLayout(new GridLayout(0,1)); |
87 |
|
88 |
PluginServices.getMDIManager().addWindow(csSelect); |
89 |
abrev = curProj.getAbrev(); |
90 |
/*else
|
91 |
abrev = activeView.getMapControl().getProjection().getAbrev();*/
|
92 |
|
93 |
if (csSelect.isOkPressed()) {
|
94 |
curProj = csSelect.getProjection(); |
95 |
// if(activeView.getMapControl() == null)
|
96 |
abrev = csSelect.getProjectionAbrev(); |
97 |
/*else
|
98 |
abrev = activeView.getMapControl().getProjection().getAbrev();*/
|
99 |
jLblProj.setText(curProj.getAbrev()); |
100 |
FOpenDialog.setLastProjection(curProj); |
101 |
okPressed = true;
|
102 |
if (actionListener != null) { |
103 |
actionListener.actionPerformed(e); |
104 |
} |
105 |
}else
|
106 |
|
107 |
jLblProj.setText(abrev); |
108 |
|
109 |
} |
110 |
else {
|
111 |
okPressed = false;
|
112 |
trSelect = new TRSelectionDialog();
|
113 |
trSelect.setProjection(curProj); |
114 |
|
115 |
trSelect.setLayout(new GridLayout(0,1)); |
116 |
|
117 |
PluginServices.getMDIManager().addWindow(trSelect); |
118 |
abrev = curProj.getAbrev(); |
119 |
|
120 |
if (trSelect.getProjection() != curProj) {
|
121 |
curProj = trSelect.getProjection(); |
122 |
abrev = trSelect.getProjectionName(); |
123 |
jLblProj.setText(abrev); |
124 |
FOpenDialog.setLastProjection(curProj); |
125 |
okPressed = true;
|
126 |
if (actionListener != null) { |
127 |
actionListener.actionPerformed(e); |
128 |
} |
129 |
}else
|
130 |
jLblProj.setText(abrev); |
131 |
|
132 |
} |
133 |
|
134 |
/* IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow();
|
135 |
View activeView = (com.iver.cit.gvsig.gui.View) activeWindow;
|
136 |
if(activeView.getMapControl() == null)*/
|
137 |
|
138 |
} |
139 |
}); |
140 |
} |
141 |
|
142 |
public JLabel getJLblProjName() { |
143 |
if (jLblProjName == null) { |
144 |
jLblProjName = new JLabel("Proyeccion actual"); |
145 |
jLblProjName.setText(PluginServices.getText(this,"__proyeccion_actual")); //$NON-NLS-1$ |
146 |
} |
147 |
return jLblProjName;
|
148 |
} |
149 |
|
150 |
public JLabel getJLblProj() { |
151 |
if (jLblProj == null) { |
152 |
jLblProj = new JLabel(); |
153 |
jLblProj.setText(curProj.getAbrev()); |
154 |
} |
155 |
return jLblProj;
|
156 |
} |
157 |
public void addBtnChangeProjActionListener(java.awt.event.ActionListener al) { |
158 |
jBtnChangeProj.addActionListener(al); |
159 |
} |
160 |
|
161 |
/**
|
162 |
* This method initializes jButton
|
163 |
*
|
164 |
* @return javax.swing.JButton
|
165 |
*/
|
166 |
public JButton getJBtnChangeProj() { |
167 |
if (jBtnChangeProj == null) { |
168 |
jBtnChangeProj = new JButton(); |
169 |
jBtnChangeProj.setText("..."); //$NON-NLS-1$ |
170 |
} |
171 |
return jBtnChangeProj;
|
172 |
} |
173 |
/**
|
174 |
* @return Returns the curProj.
|
175 |
*/
|
176 |
public IProjection getCurProj() {
|
177 |
return curProj;
|
178 |
} |
179 |
/**
|
180 |
* @param curProj The curProj to set.
|
181 |
*/
|
182 |
public void setCurProj(IProjection curProj) { |
183 |
this.curProj = curProj;
|
184 |
} |
185 |
/**
|
186 |
* @return Returns the okPressed.
|
187 |
*/
|
188 |
public boolean isOkPressed() { |
189 |
return okPressed;
|
190 |
} |
191 |
/**
|
192 |
* @param actionListener The actionListener to set.
|
193 |
*/
|
194 |
public void addActionListener(ActionListener actionListener) { |
195 |
this.actionListener = actionListener;
|
196 |
} |
197 |
} // @jve:decl-index=0:visual-constraint="10,10"
|