svn-gvsig-desktop / branches / Mobile_Compatible_Hito_1 / libProjectionCresques / src / org / gvsig / projection / cresques / ui / cts / CSSelectionPanel.java @ 21932
History | View | Annotate | Download (8.61 KB)
1 |
/*
|
---|---|
2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
3 |
*
|
4 |
* Copyright (C) 2004-5.
|
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 2
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* cresques@gmail.com
|
23 |
*/
|
24 |
package org.gvsig.projection.cresques.ui.cts; |
25 |
|
26 |
import javax.swing.JLabel; |
27 |
import javax.swing.JPanel; |
28 |
|
29 |
import org.gvsig.projection.cresques.Messages; |
30 |
import org.gvsig.projection.cresques.ui.LoadableComboBox; |
31 |
import org.gvsig.projection.cts.IProjection; |
32 |
|
33 |
|
34 |
//import es.gva.cit.geoexplorer.ui.LoadableComboBox;
|
35 |
|
36 |
/**
|
37 |
* Panel de edici?n de Sistemas de referencia
|
38 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
39 |
*/
|
40 |
public class CSSelectionPanel extends JPanel { |
41 |
final private static long serialVersionUID = -3370601314380922368L; |
42 |
private LoadableComboBox datumComboBox = null; |
43 |
private LoadableComboBox projComboBox = null; |
44 |
private LoadableComboBox huseComboBox = null; |
45 |
private JLabel jLabel = null; |
46 |
private JLabel jLabel1 = null; |
47 |
private JLabel jLabel2 = null; |
48 |
private String tit; |
49 |
private CSSelectionModel model;
|
50 |
|
51 |
/**
|
52 |
* Constructor de la clase.
|
53 |
*/
|
54 |
public CSSelectionPanel(String tit) { |
55 |
super();
|
56 |
|
57 |
if (tit == null) { |
58 |
//tit = "Sistema de referencia";
|
59 |
//TODO: add com.iver.andami.PluginServices to this project
|
60 |
//change all the labels from fix text got from the internationalitation
|
61 |
tit = Messages.getText("reference_system");
|
62 |
if (tit == null) tit="Reference System"; |
63 |
} |
64 |
|
65 |
this.tit = tit;
|
66 |
setModel(new CSSelectionModel());
|
67 |
initialize(); |
68 |
} |
69 |
|
70 |
/**
|
71 |
* Inicializa el panel.
|
72 |
* @return javax.swing.JPanel
|
73 |
*/
|
74 |
private void initialize() { |
75 |
setPreferredSize(new java.awt.Dimension(295, 170)); |
76 |
setLayout(null);
|
77 |
|
78 |
/*javax.swing.border.Border border = javax.swing.BorderFactory.createCompoundBorder(
|
79 |
javax.swing. BorderFactory.createTitledBorder("Sistema de coordenadas"),
|
80 |
javax.swing.BorderFactory.createEmptyBorder(5,5,5,5)); */
|
81 |
setBorder(javax.swing.BorderFactory.createCompoundBorder(null,
|
82 |
javax.swing.BorderFactory.createTitledBorder(null,
|
83 |
Messages.getText("reference_system"),
|
84 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
85 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, |
86 |
null,
|
87 |
null)));
|
88 |
|
89 |
jLabel = new JLabel(); |
90 |
jLabel.setBounds(15, 15, 77, 23); |
91 |
jLabel.setText(Messages.getText("datum") + ":"); |
92 |
add(jLabel, null);
|
93 |
add(getDatumComboBox(), null);
|
94 |
|
95 |
jLabel1 = new JLabel(); |
96 |
jLabel1.setBounds(15, 60, 77, 23); |
97 |
jLabel1.setText(Messages.getText("projection") + ":"); |
98 |
add(jLabel1, null);
|
99 |
add(getProjComboBox(), null);
|
100 |
|
101 |
jLabel2 = new JLabel(); |
102 |
jLabel2.setBounds(15, 105, 77, 23); |
103 |
jLabel2.setText(Messages.getText("zone") + ":"); |
104 |
add(jLabel2, null);
|
105 |
add(getHuseComboBox(), null);
|
106 |
|
107 |
setHuseComboBoxEnabled(false);
|
108 |
} |
109 |
|
110 |
public void setModel(CSSelectionModel model) { |
111 |
this.model = model;
|
112 |
|
113 |
getHuseComboBox().loadData(model.getZoneList()); |
114 |
getDatumComboBox().loadData(model.getDatumList()); |
115 |
getProjComboBox().loadData(model.getProjectionList()); |
116 |
} |
117 |
|
118 |
private void setHuseComboBoxEnabled(boolean enabled) { |
119 |
if (jLabel2 != null) { |
120 |
jLabel2.setEnabled(enabled); |
121 |
} |
122 |
|
123 |
getHuseComboBox().setEnabled(enabled); |
124 |
} |
125 |
|
126 |
private void setDatumComboBoxEnabled(boolean enabled) { |
127 |
if (jLabel != null) { |
128 |
jLabel.setEnabled(enabled); |
129 |
} |
130 |
|
131 |
getDatumComboBox().setEnabled(enabled); |
132 |
} |
133 |
|
134 |
public void setProjection(IProjection proj) { |
135 |
model.setProjection(proj); |
136 |
|
137 |
setDatumComboBoxEnabled(true);
|
138 |
getDatumComboBox().setSelectedIndex(model.getSelectedDatum()); |
139 |
|
140 |
getProjComboBox().removeAllItems(); |
141 |
getProjComboBox().loadData(model.getProjectionList()); |
142 |
|
143 |
model.setProjection(proj); |
144 |
getProjComboBox().setSelectedIndex(model.getSelectedProj()); |
145 |
model.setProjection(proj); |
146 |
|
147 |
if (model.getSelectedZone() >= 0) { |
148 |
setHuseComboBoxEnabled(true);
|
149 |
getHuseComboBox().removeAllItems(); |
150 |
getHuseComboBox().loadData(model.getZoneList()); |
151 |
|
152 |
model.setProjection(proj); |
153 |
getHuseComboBox().setSelectedIndex(model.getSelectedZone()); |
154 |
} else {
|
155 |
setHuseComboBoxEnabled(false);
|
156 |
getHuseComboBox().setSelectedIndex(0);
|
157 |
} |
158 |
} |
159 |
|
160 |
/**
|
161 |
* Inicializa datumComboBox
|
162 |
*
|
163 |
* @return javax.swing.JComboBox
|
164 |
*/
|
165 |
private LoadableComboBox getDatumComboBox() {
|
166 |
if (datumComboBox == null) { |
167 |
datumComboBox = new LoadableComboBox();
|
168 |
datumComboBox.setBounds(14, 35, 250, 23); |
169 |
|
170 |
// ((LoadableComboBox) datumComboBox).loadData(model.getDatumList());
|
171 |
datumComboBox.addItemListener(new java.awt.event.ItemListener() {
|
172 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
173 |
model.setSelectedDatum(e.getItem()); |
174 |
getProjComboBox().removeAllItems(); |
175 |
getProjComboBox().loadData(model.getProjectionList()); |
176 |
} |
177 |
}); |
178 |
} |
179 |
|
180 |
return datumComboBox;
|
181 |
} |
182 |
|
183 |
/**
|
184 |
* Inicializa projComboBox
|
185 |
*
|
186 |
* @return javax.swing.JComboBox
|
187 |
*/
|
188 |
private LoadableComboBox getProjComboBox() {
|
189 |
if (projComboBox == null) { |
190 |
projComboBox = new LoadableComboBox();
|
191 |
projComboBox.setBounds(14, 80, 250, 23); |
192 |
projComboBox.addItemListener(new java.awt.event.ItemListener() {
|
193 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
194 |
model.setSelectedProj(e.getItem()); |
195 |
|
196 |
if (model.getSelectedProjType() == CSSelectionModel.TRANSVERSAL) {
|
197 |
setHuseComboBoxEnabled(true);
|
198 |
getHuseComboBox().removeAllItems(); |
199 |
getHuseComboBox().loadData(model.getZoneList()); |
200 |
|
201 |
} else {
|
202 |
setHuseComboBoxEnabled(false);
|
203 |
} |
204 |
|
205 |
// if (model.getSelectedProjType() == CSSelectionModel.NONE) {
|
206 |
// setDatumComboBoxEnabled(false);
|
207 |
// } else {
|
208 |
// setDatumComboBoxEnabled(true);
|
209 |
// }
|
210 |
} |
211 |
}); |
212 |
} |
213 |
|
214 |
return projComboBox;
|
215 |
} |
216 |
|
217 |
/**
|
218 |
* Inicializa usoComboBox
|
219 |
*
|
220 |
* @return javax.swing.JComboBox
|
221 |
*/
|
222 |
private LoadableComboBox getHuseComboBox() {
|
223 |
if (huseComboBox == null) { |
224 |
huseComboBox = new LoadableComboBox();
|
225 |
huseComboBox.setBounds(14, 125, 250, 23); |
226 |
huseComboBox.addItemListener(new java.awt.event.ItemListener() {
|
227 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
228 |
model.setSelectedZone(e.getItem()); |
229 |
} |
230 |
}); |
231 |
} |
232 |
|
233 |
return huseComboBox;
|
234 |
} |
235 |
|
236 |
/**
|
237 |
* @return
|
238 |
*/
|
239 |
public IProjection getProjection() {
|
240 |
return model.getProjection();
|
241 |
} |
242 |
} |