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