root / trunk / libraries / libCq_CMS_praster / src / org / cresques / ui / cts / CSSelectionPanel.java @ 8026
History | View | Annotate | Download (7.65 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 org.cresques.cts.IProjection; |
27 |
|
28 |
import org.cresques.ui.LoadableComboBox; |
29 |
|
30 |
import javax.swing.JLabel; |
31 |
import javax.swing.JPanel; |
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 int wDisplay = 335; |
49 |
private int wCombo = 250; |
50 |
private int h = 23; |
51 |
private int x = 14; |
52 |
private String tit; |
53 |
private CSSelectionModel model;
|
54 |
|
55 |
/**
|
56 |
* Constructor de la clase.
|
57 |
*/
|
58 |
public CSSelectionPanel(String tit) { |
59 |
super();
|
60 |
|
61 |
if (tit == null) { |
62 |
tit = "Sistema de referencia";
|
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 |
"Sistema de Referencia",
|
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("Datum :");
|
92 |
add(jLabel, null);
|
93 |
add(getDatumComboBox(), null);
|
94 |
|
95 |
jLabel1 = new JLabel(); |
96 |
jLabel1.setBounds(15, 60, 77, 23); |
97 |
jLabel1.setText("Proyecci?n :");
|
98 |
add(jLabel1, null);
|
99 |
add(getProjComboBox(), null);
|
100 |
|
101 |
jLabel2 = new JLabel(); |
102 |
jLabel2.setBounds(15, 105, 77, 23); |
103 |
jLabel2.setText("Huso :");
|
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.getHuseList()); |
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 |
if (model.getSelectedDatum() >= 0) { |
138 |
setDatumComboBoxEnabled(true);
|
139 |
getDatumComboBox().setSelectedIndex(model.getSelectedDatum()); |
140 |
} else {
|
141 |
setDatumComboBoxEnabled(false);
|
142 |
getDatumComboBox().setSelectedIndex(0);
|
143 |
} |
144 |
|
145 |
getProjComboBox().setSelectedIndex(model.getSelectedProj()); |
146 |
|
147 |
if (model.getSelectedHuse() >= 0) { |
148 |
setHuseComboBoxEnabled(true);
|
149 |
getHuseComboBox().setSelectedIndex(model.getSelectedHuse()); |
150 |
} else {
|
151 |
setHuseComboBoxEnabled(false);
|
152 |
getHuseComboBox().setSelectedIndex(0);
|
153 |
} |
154 |
} |
155 |
|
156 |
/**
|
157 |
* Inicializa datumComboBox
|
158 |
*
|
159 |
* @return javax.swing.JComboBox
|
160 |
*/
|
161 |
private LoadableComboBox getDatumComboBox() {
|
162 |
if (datumComboBox == null) { |
163 |
datumComboBox = new LoadableComboBox();
|
164 |
datumComboBox.setBounds(14, 35, 250, 23); |
165 |
|
166 |
// ((LoadableComboBox) datumComboBox).loadData(model.getDatumList());
|
167 |
datumComboBox.addItemListener(new java.awt.event.ItemListener() {
|
168 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
169 |
model.setSelectedDatum(e.getItem()); |
170 |
} |
171 |
}); |
172 |
} |
173 |
|
174 |
return datumComboBox;
|
175 |
} |
176 |
|
177 |
/**
|
178 |
* Inicializa projComboBox
|
179 |
*
|
180 |
* @return javax.swing.JComboBox
|
181 |
*/
|
182 |
private LoadableComboBox getProjComboBox() {
|
183 |
if (projComboBox == null) { |
184 |
projComboBox = new LoadableComboBox();
|
185 |
projComboBox.setBounds(14, 80, 250, 23); |
186 |
projComboBox.addItemListener(new java.awt.event.ItemListener() {
|
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 |
} else {
|
193 |
setHuseComboBoxEnabled(false);
|
194 |
} |
195 |
|
196 |
if (model.getSelectedProjType() == CSSelectionModel.NONE) {
|
197 |
setDatumComboBoxEnabled(false);
|
198 |
} else {
|
199 |
setDatumComboBoxEnabled(true);
|
200 |
} |
201 |
} |
202 |
}); |
203 |
} |
204 |
|
205 |
return projComboBox;
|
206 |
} |
207 |
|
208 |
/**
|
209 |
* Inicializa usoComboBox
|
210 |
*
|
211 |
* @return javax.swing.JComboBox
|
212 |
*/
|
213 |
private LoadableComboBox getHuseComboBox() {
|
214 |
if (huseComboBox == null) { |
215 |
huseComboBox = new LoadableComboBox();
|
216 |
huseComboBox.setBounds(14, 125, 250, 23); |
217 |
huseComboBox.addItemListener(new java.awt.event.ItemListener() {
|
218 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
219 |
model.setSelectedHuse(e.getItem()); |
220 |
} |
221 |
}); |
222 |
} |
223 |
|
224 |
return huseComboBox;
|
225 |
} |
226 |
|
227 |
/**
|
228 |
* @return
|
229 |
*/
|
230 |
public IProjection getProjection() {
|
231 |
return model.getProjection();
|
232 |
} |
233 |
} |