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