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 @ 40559
History | View | Annotate | Download (5.29 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 JPanel jPanelProj = null; |
54 |
private boolean okPressed = false; |
55 |
|
56 |
/**
|
57 |
*
|
58 |
*/
|
59 |
public ProjChooserPanel(IProjection proj) {
|
60 |
super(proj);
|
61 |
setCurProj(proj); |
62 |
initialize(); |
63 |
} |
64 |
|
65 |
/**
|
66 |
* This method initializes this
|
67 |
*
|
68 |
* @return void
|
69 |
*/
|
70 |
private void initialize() { |
71 |
GridLayout gl = new GridLayout(1,2); |
72 |
|
73 |
this.setLayout(gl); // new FlowLayout(FlowLayout.LEFT, 15, 0)); |
74 |
this.add(getJLblProjName());
|
75 |
|
76 |
JPanel secondHalf = new JPanel(new GridBagLayout()); |
77 |
GridBagConstraints c = new GridBagConstraints(); |
78 |
|
79 |
c.fill = GridBagConstraints.HORIZONTAL;
|
80 |
c.weightx = 1.0; //request any extra vertical space |
81 |
c.gridx = 0;
|
82 |
c.gridwidth = 1;
|
83 |
c.gridy = 0;
|
84 |
secondHalf.add(getJLblProj(), c); |
85 |
|
86 |
c.fill = GridBagConstraints.NONE;
|
87 |
c.weightx = 0.0;
|
88 |
c.gridx = 1;
|
89 |
secondHalf.add(getJBtnChangeProj(), c); |
90 |
|
91 |
this.add(secondHalf);
|
92 |
initBtnChangeProj(); |
93 |
} |
94 |
|
95 |
private void initBtnChangeProj() { |
96 |
getJBtnChangeProj().addActionListener( |
97 |
new java.awt.event.ActionListener() {
|
98 |
|
99 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
100 |
okPressed = false;
|
101 |
|
102 |
ISelectCrsPanel csSelect = |
103 |
getUIFactory().getSelectCrsPanel(curProj, true);
|
104 |
|
105 |
ToolsSwingLocator.getWindowManager().showWindow((JComponent) csSelect, Messages.getText("selecciona_sistema_de_referencia"), MODE.DIALOG); |
106 |
|
107 |
if (csSelect.isOkPressed()) {
|
108 |
curProj = csSelect.getProjection(); |
109 |
jLblProj.setText(curProj.getAbrev()); |
110 |
okPressed = true;
|
111 |
if (actionListener != null) { |
112 |
actionListener.actionPerformed(e); |
113 |
} |
114 |
} |
115 |
} |
116 |
}); |
117 |
} |
118 |
|
119 |
public JLabel getJLblProjName() { |
120 |
if (jLblProjName == null) { |
121 |
jLblProjName = new JLabel("Proyeccion actual"); |
122 |
jLblProjName.setText(Messages.getText("__proyeccion_actual")); //$NON-NLS-1$ |
123 |
} |
124 |
return jLblProjName;
|
125 |
} |
126 |
|
127 |
public JLabel getJLabel() { |
128 |
return getJLblProjName();
|
129 |
} |
130 |
|
131 |
public JLabel getJLblProj() { |
132 |
if (jLblProj == null) { |
133 |
jLblProj = new JLabel(); |
134 |
jLblProj.setAlignmentX(JLabel.CENTER_ALIGNMENT);
|
135 |
if (curProj != null) |
136 |
jLblProj.setText(curProj.getAbrev()); |
137 |
} |
138 |
return jLblProj;
|
139 |
} |
140 |
|
141 |
public void addBtnChangeProjActionListener(java.awt.event.ActionListener al) { |
142 |
jBtnChangeProj.addActionListener(al); |
143 |
} |
144 |
|
145 |
/**
|
146 |
* This method initializes jButton
|
147 |
*
|
148 |
* @return javax.swing.JButton
|
149 |
*/
|
150 |
public JButton getJBtnChangeProj() { |
151 |
if (jBtnChangeProj == null) { |
152 |
jBtnChangeProj = new JButton(); |
153 |
jBtnChangeProj.setText("..."); //$NON-NLS-1$ |
154 |
// jBtnChangeProj.setPreferredSize(new java.awt.Dimension(26, 26));
|
155 |
} |
156 |
return jBtnChangeProj;
|
157 |
} |
158 |
|
159 |
/**
|
160 |
* @return Returns the curProj.
|
161 |
*/
|
162 |
public IProjection getCurProj() {
|
163 |
return curProj;
|
164 |
} |
165 |
|
166 |
/**
|
167 |
* @param curProj
|
168 |
* The curProj to set.
|
169 |
*/
|
170 |
public void setCurProj(IProjection curProj) { |
171 |
this.curProj = curProj;
|
172 |
} |
173 |
|
174 |
/**
|
175 |
* @return Returns the okPressed.
|
176 |
*/
|
177 |
public boolean isOkPressed() { |
178 |
return okPressed;
|
179 |
} |
180 |
} // @jve:decl-index=0:visual-constraint="10,10"
|