root / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / ui / cts / CSSelectionPanel.java @ 2664
History | View | Annotate | Download (6.12 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 javax.swing.JLabel; |
27 |
import javax.swing.JPanel; |
28 |
|
29 |
import org.cresques.cts.IProjection; |
30 |
import org.cresques.ui.LoadableComboBox; |
31 |
|
32 |
//import es.gva.cit.geoexplorer.ui.LoadableComboBox;
|
33 |
|
34 |
/**
|
35 |
* Panel de edici?n de Sistemas de referencia
|
36 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
37 |
*/
|
38 |
public class CSSelectionPanel extends JPanel { |
39 |
final private static long serialVersionUID = -3370601314380922368L; |
40 |
private LoadableComboBox datumComboBox = null; |
41 |
private LoadableComboBox projComboBox = null; |
42 |
private LoadableComboBox huseComboBox = null; |
43 |
private JLabel jLabel = null; |
44 |
private JLabel jLabel1 = null; |
45 |
private JLabel jLabel2 = null; |
46 |
private int wDisplay = 335; |
47 |
private int wCombo = 250; |
48 |
private int h=23, x=14; |
49 |
private String tit; |
50 |
private CSSelectionModel model;
|
51 |
|
52 |
/**
|
53 |
* Constructor de la clase.
|
54 |
*/
|
55 |
public CSSelectionPanel(String tit) { |
56 |
super();
|
57 |
if (tit == null) tit = "Sistema de referencia"; |
58 |
this.tit = tit;
|
59 |
setModel(new CSSelectionModel());
|
60 |
initialize(); |
61 |
} |
62 |
/**
|
63 |
* Inicializa el panel.
|
64 |
* @return javax.swing.JPanel
|
65 |
*/
|
66 |
private void initialize() { |
67 |
setPreferredSize(new java.awt.Dimension(280, 155)); |
68 |
setLayout(null);
|
69 |
/*javax.swing.border.Border border = javax.swing.BorderFactory.createCompoundBorder(
|
70 |
javax.swing. BorderFactory.createTitledBorder("Sistema de coordenadas"),
|
71 |
javax.swing.BorderFactory.createEmptyBorder(5,5,5,5)); */
|
72 |
setBorder(javax.swing.BorderFactory.createCompoundBorder( |
73 |
null, javax.swing.BorderFactory.createTitledBorder(
|
74 |
null, "Sistema de Referencia", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null))); |
75 |
|
76 |
jLabel = new JLabel(); |
77 |
jLabel.setBounds(15, 15, 77, 23); |
78 |
jLabel.setText("Datum :");
|
79 |
add(jLabel, null);
|
80 |
add(getDatumComboBox(), null);
|
81 |
|
82 |
jLabel1 = new JLabel(); |
83 |
jLabel1.setBounds(15, 60, 77, 23); |
84 |
jLabel1.setText("Proyecci?n :");
|
85 |
add(jLabel1, null);
|
86 |
add(getProjComboBox(), null);
|
87 |
|
88 |
jLabel2 = new JLabel(); |
89 |
jLabel2.setBounds(15, 105, 77, 23); |
90 |
jLabel2.setText("Huso :");
|
91 |
add(jLabel2, null);
|
92 |
add(getHuseComboBox(), null);
|
93 |
|
94 |
setHuseComboBoxEnabled(false);
|
95 |
} |
96 |
|
97 |
public void setModel(CSSelectionModel model) { |
98 |
this.model = model;
|
99 |
|
100 |
getHuseComboBox().loadData(model.getHuseList()); |
101 |
getDatumComboBox().loadData(model.getDatumList()); |
102 |
getProjComboBox().loadData(model.getProjectionList()); |
103 |
} |
104 |
|
105 |
private void setHuseComboBoxEnabled(boolean enabled) { |
106 |
if (jLabel2 != null) |
107 |
jLabel2.setEnabled(enabled); |
108 |
getHuseComboBox().setEnabled(enabled); |
109 |
} |
110 |
|
111 |
private void setDatumComboBoxEnabled(boolean enabled) { |
112 |
if (jLabel != null) |
113 |
jLabel.setEnabled(enabled); |
114 |
getDatumComboBox().setEnabled(enabled); |
115 |
} |
116 |
|
117 |
public void setProjection(IProjection proj) { |
118 |
model.setProjection(proj); |
119 |
if (model.getSelectedDatum() >= 0) { |
120 |
setDatumComboBoxEnabled(true);
|
121 |
getDatumComboBox().setSelectedIndex(model.getSelectedDatum()); |
122 |
} else {
|
123 |
setDatumComboBoxEnabled(false);
|
124 |
getDatumComboBox().setSelectedIndex(0);
|
125 |
} |
126 |
getProjComboBox().setSelectedIndex(model.getSelectedProj()); |
127 |
if (model.getSelectedHuse() >= 0) { |
128 |
setHuseComboBoxEnabled(true);
|
129 |
getHuseComboBox().setSelectedIndex(model.getSelectedHuse()); |
130 |
} else {
|
131 |
setHuseComboBoxEnabled(false);
|
132 |
getHuseComboBox().setSelectedIndex(0);
|
133 |
} |
134 |
} |
135 |
|
136 |
|
137 |
/**
|
138 |
* Inicializa datumComboBox
|
139 |
*
|
140 |
* @return javax.swing.JComboBox
|
141 |
*/
|
142 |
private LoadableComboBox getDatumComboBox() {
|
143 |
if (datumComboBox == null) { |
144 |
datumComboBox = new LoadableComboBox();
|
145 |
datumComboBox.setBounds(14, 35, 250, 23); |
146 |
// ((LoadableComboBox) datumComboBox).loadData(model.getDatumList());
|
147 |
datumComboBox.addItemListener(new java.awt.event.ItemListener() {
|
148 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
149 |
model.setSelectedDatum(e.getItem()); |
150 |
} |
151 |
}); |
152 |
} |
153 |
return datumComboBox;
|
154 |
} |
155 |
|
156 |
/**
|
157 |
* Inicializa projComboBox
|
158 |
*
|
159 |
* @return javax.swing.JComboBox
|
160 |
*/
|
161 |
private LoadableComboBox getProjComboBox() {
|
162 |
if (projComboBox == null) { |
163 |
projComboBox = new LoadableComboBox();
|
164 |
projComboBox.setBounds(14, 80, 250, 23); |
165 |
projComboBox.addItemListener(new java.awt.event.ItemListener() {
|
166 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
167 |
model.setSelectedProj(e.getItem()); |
168 |
if (model.getSelectedProjType() == CSSelectionModel.TRANSVERSAL)
|
169 |
setHuseComboBoxEnabled(true);
|
170 |
else
|
171 |
setHuseComboBoxEnabled(false);
|
172 |
if (model.getSelectedProjType() == CSSelectionModel.NONE)
|
173 |
setDatumComboBoxEnabled(false);
|
174 |
else
|
175 |
setDatumComboBoxEnabled(true);
|
176 |
} |
177 |
}); |
178 |
} |
179 |
return projComboBox;
|
180 |
} |
181 |
|
182 |
/**
|
183 |
* Inicializa usoComboBox
|
184 |
*
|
185 |
* @return javax.swing.JComboBox
|
186 |
*/
|
187 |
private LoadableComboBox getHuseComboBox() {
|
188 |
if (huseComboBox == null) { |
189 |
huseComboBox = new LoadableComboBox();
|
190 |
huseComboBox.setBounds(14, 125, 250, 23); |
191 |
huseComboBox.addItemListener(new java.awt.event.ItemListener() {
|
192 |
public void itemStateChanged(java.awt.event.ItemEvent e) { |
193 |
model.setSelectedHuse(e.getItem()); |
194 |
} |
195 |
}); |
196 |
} |
197 |
return huseComboBox;
|
198 |
} |
199 |
/**
|
200 |
* @return
|
201 |
*/
|
202 |
public IProjection getProjection() {
|
203 |
return model.getProjection();
|
204 |
} |
205 |
} |