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