svn-gvsig-desktop / branches / F2 / extensions / extJCRS / src / org / gvsig / crs / gui / panels / wizard / DefSistCoordenadas.java @ 10603
History | View | Annotate | Download (9.1 KB)
1 |
package org.gvsig.crs.gui.panels.wizard; |
---|---|
2 |
import java.awt.BorderLayout; |
3 |
import java.awt.CardLayout; |
4 |
import java.awt.Dimension; |
5 |
import java.awt.FlowLayout; |
6 |
import java.awt.GridLayout; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
9 |
|
10 |
import javax.swing.BorderFactory; |
11 |
import javax.swing.ButtonGroup; |
12 |
import javax.swing.ImageIcon; |
13 |
import javax.swing.JButton; |
14 |
import javax.swing.JComboBox; |
15 |
import javax.swing.JLabel; |
16 |
import javax.swing.JPanel; |
17 |
import javax.swing.JRadioButton; |
18 |
import javax.swing.JScrollPane; |
19 |
import javax.swing.JTable; |
20 |
import javax.swing.SwingConstants; |
21 |
import javax.swing.border.TitledBorder; |
22 |
import javax.swing.table.DefaultTableCellRenderer; |
23 |
import javax.swing.table.DefaultTableModel; |
24 |
import javax.swing.table.TableColumn; |
25 |
import javax.swing.text.TableView.TableRow; |
26 |
|
27 |
import com.iver.andami.PluginServices; |
28 |
|
29 |
|
30 |
|
31 |
/**
|
32 |
* Panel de Definici?n del Sistema de Coordenadas
|
33 |
*
|
34 |
* @author Luisa Marina Fernandez Ruiz (luisam.fernandez@uclm.es)
|
35 |
*
|
36 |
*/
|
37 |
public class DefSistCoordenadas extends JPanel implements ActionListener{ |
38 |
|
39 |
private static final long serialVersionUID = 1L; |
40 |
private JPanel top; |
41 |
private JPanel proyectadoPanel; |
42 |
private JPanel geograficoPanel; |
43 |
private JPanel cardPanel; |
44 |
private JRadioButton rbGeografico; |
45 |
private JRadioButton rbProyectado; |
46 |
private ButtonGroup coordGroup; |
47 |
|
48 |
private JLabel lblProyeccion; |
49 |
private JComboBox cbProyeccion; |
50 |
private JTable tableParametros; |
51 |
private JScrollPane scrollTable; |
52 |
|
53 |
private int theigth=140; |
54 |
private int twidth=300; |
55 |
|
56 |
final static String PROYECTADOPANEL = "Proyectado"; |
57 |
final static String GEOGRAFICOPANEL = "Geogr?fico"; |
58 |
|
59 |
|
60 |
public DefSistCoordenadas() {
|
61 |
super();
|
62 |
BorderLayout bl=new BorderLayout(); |
63 |
bl.setVgap(5);
|
64 |
bl.setHgap(5);
|
65 |
this.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); |
66 |
this.setLayout(bl);
|
67 |
this.add(getTop(),BorderLayout.NORTH); |
68 |
cardPanel=new JPanel(); |
69 |
cardPanel.setLayout(new CardLayout()); |
70 |
//agregar los elementos correspondientes en el cardPanel
|
71 |
cardPanel.add(PROYECTADOPANEL,getProyectadoPanel()); |
72 |
cardPanel.add(GEOGRAFICOPANEL,getGeograficoPanel()); |
73 |
//agregar cardPanel en el this
|
74 |
this.add(cardPanel,BorderLayout.CENTER); |
75 |
|
76 |
|
77 |
} |
78 |
/**
|
79 |
* Inicializa el radio button Geogr?fico 2D
|
80 |
* @return
|
81 |
*/
|
82 |
public JRadioButton getRbGeografico() { |
83 |
if (rbGeografico==null){ |
84 |
//TODO:Comprobar que funcionan las traducciones
|
85 |
//rbGeografico=new JRadioButton(PluginServices.getText(this,"jpSistCoor_Geografico2D"));
|
86 |
rbGeografico=new JRadioButton("Geogr?fico 2D"); |
87 |
rbGeografico.addActionListener(this);
|
88 |
} |
89 |
return rbGeografico;
|
90 |
} |
91 |
/**
|
92 |
* Inicializa el radio button Proyectado
|
93 |
* @return
|
94 |
*/
|
95 |
public JRadioButton getRbProyectado() { |
96 |
if (rbProyectado==null){ |
97 |
//TODO:Comprobar que funcionan las traducciones
|
98 |
//rbProyectado=new JRadioButton(PluginServices.getText(this,"jpSistCoor_Proyactado"));
|
99 |
rbProyectado=new JRadioButton("Proyectado"); |
100 |
rbProyectado.addActionListener(this);
|
101 |
} |
102 |
return rbProyectado;
|
103 |
} |
104 |
/**
|
105 |
* Inicializa el panel que contiene las opciones
|
106 |
* si el crs seleccionado es proyectado
|
107 |
*
|
108 |
*/
|
109 |
public JPanel getProyectadoPanel() { |
110 |
if(proyectadoPanel==null){ |
111 |
BorderLayout b=new BorderLayout(); |
112 |
b.setVgap(5);
|
113 |
b.setHgap(5);
|
114 |
proyectadoPanel=new JPanel(b); |
115 |
proyectadoPanel.setBorder(BorderFactory.createEmptyBorder(0,3,0,3)); |
116 |
//JPanel p=new JPanel(new FlowLayout(FlowLayout.CENTER,10,10));
|
117 |
JPanel p=new JPanel(new GridLayout(1,0,10,10)); |
118 |
JPanel in=new JPanel(new FlowLayout(FlowLayout.RIGHT,3,5)); |
119 |
in.add(getLblProyeccion()); |
120 |
p.add(in); |
121 |
p.add(getCbProyeccion()); |
122 |
proyectadoPanel.add(p,BorderLayout.NORTH);
|
123 |
//JPanel center=new JPanel();
|
124 |
//center.add(parametrosJtable);
|
125 |
//center.add(new JButton("agregar la tabla con los parametros"));
|
126 |
proyectadoPanel.add(getScrollTable(),BorderLayout.CENTER);
|
127 |
//CREAR TODOS LOS ELEMENTOS
|
128 |
} |
129 |
return proyectadoPanel;
|
130 |
} |
131 |
/**
|
132 |
* Inicializa el panel superior donde se define el sistema
|
133 |
* de coordenadas
|
134 |
*
|
135 |
*/
|
136 |
public JPanel getTop() { |
137 |
if(top==null){ |
138 |
top=new JPanel(); |
139 |
top.add(getRbGeografico()); |
140 |
top.add(getRbProyectado()); |
141 |
//Agrupar las opciones
|
142 |
agruparRadioButtons(); |
143 |
//TODO:Comprobar que funcionan las traducciones
|
144 |
//top.setBorder(new TitledBorder(PluginServices.getText(this,"jpSistCoor_titmarco")));
|
145 |
top.setBorder(new TitledBorder("Sistema de Coordenadas ")); |
146 |
} |
147 |
return top;
|
148 |
} |
149 |
/**
|
150 |
* Agrupa los radio button
|
151 |
*
|
152 |
*/
|
153 |
private void agruparRadioButtons() { |
154 |
if (coordGroup==null){ |
155 |
coordGroup=new ButtonGroup(); |
156 |
//Agrupar los botones de opcion
|
157 |
coordGroup.add(getRbProyectado()); |
158 |
coordGroup.add(getRbGeografico()); |
159 |
getRbProyectado().setSelected(true);
|
160 |
} |
161 |
} |
162 |
/**
|
163 |
* Inicializa el label Proyecci?n
|
164 |
* @return
|
165 |
*/
|
166 |
public JLabel getLblProyeccion() { |
167 |
if (lblProyeccion==null){ |
168 |
lblProyeccion=new JLabel(); |
169 |
//TODO: Comprobar que funcionan las traducciones
|
170 |
//lblProyeccion.setText(PluginServices.getText(this,"jpSistCoor_Proyeccion"));
|
171 |
lblProyeccion.setText("Proyecci?n");
|
172 |
} |
173 |
return lblProyeccion;
|
174 |
} |
175 |
/**
|
176 |
* Crea la tabla donde se definen los par?metros de la
|
177 |
* proyecci?n seleccionada en el combobox
|
178 |
* @return
|
179 |
*/
|
180 |
public JTable getTableParametros() { |
181 |
|
182 |
if(tableParametros==null){ |
183 |
tableParametros = new JTable(); |
184 |
DefaultTableModel model = (DefaultTableModel)tableParametros.getModel(); |
185 |
//Crea la tabla con 7 filas
|
186 |
Object[][] data = { |
187 |
{"", "", "Metros"}, |
188 |
{"", "", "Metros"}, |
189 |
{"", "", "Metros"}, |
190 |
{"", "", "Metros"}, |
191 |
{"", "", "Metros"}, |
192 |
{"", "", "Metros"}, |
193 |
{"", "", "Metros"}}; |
194 |
//TODO: Comprobar que funcionan las traducciones
|
195 |
/*String col1=PluginServices.getText(this,"jpSistCoor_Parametro");
|
196 |
String col2=PluginServices.getText(this,"jpSistCoor_Valor");
|
197 |
String col3=PluginServices.getText(this,"jpSistCoor_Unidades");
|
198 |
Object[] headers = {col1, col2, col3};*/
|
199 |
Object[] headers = {"Parametro", "Valor", "Unidades"}; |
200 |
model.setDataVector(data,headers); |
201 |
/*Agrega otra fila
|
202 |
model.addRow(new Object[]{"fila","","Metros"});*/
|
203 |
//TODO: Agregar los items "Unidades" al combo
|
204 |
//define los items del combo
|
205 |
String[] items = new String[] { "Metros", "Grados", "Kilometros", "Decimetros", "Hect?metros" }; |
206 |
TableColumn col = tableParametros.getColumnModel().getColumn(2); |
207 |
ComboBoxEditor editor = new ComboBoxEditor(items); |
208 |
col.setCellEditor(editor); |
209 |
col.setCellRenderer(new ComboBoxRenderer(items));
|
210 |
//Define el tama?o de la tabla
|
211 |
tableParametros.setPreferredScrollableViewportSize(new Dimension(twidth,theigth)); |
212 |
//la posicion de las columnas es fija
|
213 |
tableParametros.getTableHeader().setReorderingAllowed( false );
|
214 |
//Ajustar ancho y alto de las filas y columnas
|
215 |
ajustarTama?oTabla(); |
216 |
} |
217 |
|
218 |
return tableParametros;
|
219 |
} |
220 |
|
221 |
/**
|
222 |
* Crear scrollPane y agregar la tabla en ?l
|
223 |
*/
|
224 |
public JScrollPane getScrollTable() { |
225 |
if(scrollTable==null){ |
226 |
scrollTable = new JScrollPane(getTableParametros()); |
227 |
scrollTable.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
228 |
} |
229 |
return scrollTable;
|
230 |
} |
231 |
/**
|
232 |
* Contiene los nombres de las distintas proyecciones
|
233 |
* @return
|
234 |
*/
|
235 |
public JComboBox getCbProyeccion() { |
236 |
if (cbProyeccion==null){ |
237 |
cbProyeccion=new JComboBox(); |
238 |
//no se pueden modificar los items del combobox
|
239 |
cbProyeccion.setEditable(false);
|
240 |
//TODO: //Poner texto con plugin services
|
241 |
//cbProyeccion.setToolTipText(PluginServices.getText(this,"jpSistCoor_cbToolTip"));
|
242 |
cbProyeccion.setToolTipText("Selecciona una opci?n");
|
243 |
/*A?adir las opciones al combo*/
|
244 |
cbProyeccion.addItem("uno");
|
245 |
cbProyeccion.addItem("dos");
|
246 |
cbProyeccion.addItem("tres");
|
247 |
cbProyeccion.addItem("cuatro");
|
248 |
} |
249 |
return cbProyeccion;
|
250 |
} |
251 |
/*
|
252 |
* Redimensiona el tama?o de las filas y columnas de la tabla
|
253 |
*
|
254 |
*/
|
255 |
public void ajustarTama?oTabla(){ |
256 |
TableColumn column = null; |
257 |
//Fijar el alto de las filas
|
258 |
getTableParametros().setRowHeight(20);
|
259 |
//Fijar el ancho de las columnas
|
260 |
column = getTableParametros().getColumnModel().getColumn(0);
|
261 |
column.setPreferredWidth(30);
|
262 |
column = getTableParametros().getColumnModel().getColumn(1);
|
263 |
column.setPreferredWidth(90);
|
264 |
column = getTableParametros().getColumnModel().getColumn(2);
|
265 |
column.setPreferredWidth(120);
|
266 |
|
267 |
} |
268 |
|
269 |
/**
|
270 |
* Fija los eventos de los RadioButtons y dem?s controles
|
271 |
*/
|
272 |
public void actionPerformed(ActionEvent e) { |
273 |
//MOSTRAR UN PANEL U OTRO
|
274 |
CardLayout cl = (CardLayout)(cardPanel.getLayout()); |
275 |
if (e.getSource().equals(getRbProyectado())){
|
276 |
/*Si est? seleccionada la opci?n de Proyectado
|
277 |
se muestra el panel de selecci?n de la proyecci?n con sus par?metros*/
|
278 |
cl.show(cardPanel, PROYECTADOPANEL); |
279 |
}else if(e.getSource().equals(getRbGeografico())){ |
280 |
/*Se muestra el panel de Sistema de Coordenadas Geografico*/
|
281 |
cl.show(cardPanel, GEOGRAFICOPANEL); |
282 |
} |
283 |
|
284 |
} |
285 |
|
286 |
/*
|
287 |
* Crear el panel que contiene los componentes de
|
288 |
* un sistema de coordenadas geografico
|
289 |
* */
|
290 |
public JPanel getGeograficoPanel() { |
291 |
if(geograficoPanel==null){ |
292 |
BorderLayout b=new BorderLayout(); |
293 |
b.setVgap(5);
|
294 |
b.setHgap(5);
|
295 |
geograficoPanel=new JPanel(b); |
296 |
geograficoPanel.add(new JButton("Crear panel Geogr?fico 2D")); |
297 |
} |
298 |
return geograficoPanel;
|
299 |
} |
300 |
|
301 |
} |
302 |
|