svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.projection / org.gvsig.projection.cresques / org.gvsig.projection.cresques.ui / src / main / java / org / gvsig / app / gui / panels / ProjChooserPanel.java @ 42543
History | View | Annotate | Download (5.42 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
/*
|
25 |
* Created on 30-ene-2005
|
26 |
*/
|
27 |
package org.gvsig.app.gui.panels; |
28 |
|
29 |
import java.awt.GridBagConstraints; |
30 |
import java.awt.GridBagLayout; |
31 |
import java.awt.GridLayout; |
32 |
|
33 |
import javax.swing.JButton; |
34 |
import javax.swing.JComponent; |
35 |
import javax.swing.JLabel; |
36 |
import javax.swing.JPanel; |
37 |
|
38 |
import org.cresques.Messages; |
39 |
import org.cresques.cts.IProjection; |
40 |
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel; |
41 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
42 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager.MODE; |
43 |
|
44 |
/**
|
45 |
* @author Luis W. Sevilla (sevilla_lui@gva.es)
|
46 |
*/
|
47 |
public class ProjChooserPanel extends CRSSelectPanel { |
48 |
|
49 |
private IProjection curProj = null; |
50 |
private JLabel jLblProj = null; |
51 |
private JLabel jLblProjName = null; |
52 |
private JButton jBtnChangeProj = null; |
53 |
private final JPanel jPanelProj = null; |
54 |
private boolean okPressed = false; |
55 |
|
56 |
/**
|
57 |
*
|
58 |
* @param proj
|
59 |
*/
|
60 |
public ProjChooserPanel(IProjection proj) {
|
61 |
super(proj);
|
62 |
setCurProj(proj); |
63 |
initialize(); |
64 |
} |
65 |
|
66 |
/**
|
67 |
* This method initializes this
|
68 |
*
|
69 |
* @return void
|
70 |
*/
|
71 |
private void initialize() { |
72 |
GridLayout gl = new GridLayout(1,2); |
73 |
|
74 |
this.setLayout(gl); // new FlowLayout(FlowLayout.LEFT, 15, 0)); |
75 |
this.add(getJLblProjName());
|
76 |
|
77 |
JPanel secondHalf = new JPanel(new GridBagLayout()); |
78 |
GridBagConstraints c = new GridBagConstraints(); |
79 |
|
80 |
c.fill = GridBagConstraints.HORIZONTAL;
|
81 |
c.weightx = 1.0; //request any extra vertical space |
82 |
c.gridx = 0;
|
83 |
c.gridwidth = 1;
|
84 |
c.gridy = 0;
|
85 |
secondHalf.add(getJLblProj(), c); |
86 |
|
87 |
c.fill = GridBagConstraints.NONE;
|
88 |
c.weightx = 0.0;
|
89 |
c.gridx = 1;
|
90 |
secondHalf.add(getJBtnChangeProj(), c); |
91 |
|
92 |
this.add(secondHalf);
|
93 |
initBtnChangeProj(); |
94 |
} |
95 |
|
96 |
private void initBtnChangeProj() { |
97 |
getJBtnChangeProj().addActionListener( |
98 |
new java.awt.event.ActionListener() {
|
99 |
|
100 |
@Override
|
101 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
102 |
okPressed = false;
|
103 |
|
104 |
ISelectCrsPanel csSelect = |
105 |
getUIFactory().getSelectCrsPanel(curProj, true);
|
106 |
|
107 |
ToolsSwingLocator.getWindowManager().showWindow((JComponent) csSelect, Messages.getText("selecciona_sistema_de_referencia"), MODE.DIALOG); |
108 |
|
109 |
if (csSelect.isOkPressed()) {
|
110 |
curProj = csSelect.getProjection(); |
111 |
jLblProj.setText(curProj.getAbrev()); |
112 |
okPressed = true;
|
113 |
if (actionListener != null) { |
114 |
actionListener.actionPerformed(e); |
115 |
} |
116 |
} |
117 |
} |
118 |
}); |
119 |
} |
120 |
|
121 |
public JLabel getJLblProjName() { |
122 |
if (jLblProjName == null) { |
123 |
jLblProjName = new JLabel("Proyeccion actual"); |
124 |
jLblProjName.setText(Messages.getText("__proyeccion_actual")); //$NON-NLS-1$ |
125 |
} |
126 |
return jLblProjName;
|
127 |
} |
128 |
|
129 |
@Override
|
130 |
public JLabel getJLabel() { |
131 |
return getJLblProjName();
|
132 |
} |
133 |
|
134 |
public JLabel getJLblProj() { |
135 |
if (jLblProj == null) { |
136 |
jLblProj = new JLabel(); |
137 |
jLblProj.setAlignmentX(JLabel.CENTER_ALIGNMENT);
|
138 |
if (curProj != null) |
139 |
jLblProj.setText(curProj.getAbrev()); |
140 |
} |
141 |
return jLblProj;
|
142 |
} |
143 |
|
144 |
public void addBtnChangeProjActionListener(java.awt.event.ActionListener al) { |
145 |
jBtnChangeProj.addActionListener(al); |
146 |
} |
147 |
|
148 |
/**
|
149 |
* This method initializes jButton
|
150 |
*
|
151 |
* @return javax.swing.JButton
|
152 |
*/
|
153 |
@Override
|
154 |
public JButton getJBtnChangeProj() { |
155 |
if (jBtnChangeProj == null) { |
156 |
jBtnChangeProj = new JButton(); |
157 |
jBtnChangeProj.setText("..."); //$NON-NLS-1$ |
158 |
// jBtnChangeProj.setPreferredSize(new java.awt.Dimension(26, 26));
|
159 |
} |
160 |
return jBtnChangeProj;
|
161 |
} |
162 |
|
163 |
/**
|
164 |
* @return Returns the curProj.
|
165 |
*/
|
166 |
@Override
|
167 |
public IProjection getCurProj() {
|
168 |
return curProj;
|
169 |
} |
170 |
|
171 |
/**
|
172 |
* @param curProj
|
173 |
* The curProj to set.
|
174 |
*/
|
175 |
@Override
|
176 |
public void setCurProj(IProjection curProj) { |
177 |
this.curProj = curProj;
|
178 |
} |
179 |
|
180 |
/**
|
181 |
* @return Returns the okPressed.
|
182 |
*/
|
183 |
@Override
|
184 |
public boolean isOkPressed() { |
185 |
return okPressed;
|
186 |
} |
187 |
} // @jve:decl-index=0:visual-constraint="10,10"
|