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