Revision 7416
trunk/libraries/libJCRS/src-test/org/gvsig/crs/gui/testCRSSelectionPanel.java | ||
---|---|---|
1 |
package org.gvsig.crs.gui; |
|
2 |
import java.awt.BorderLayout; |
|
3 |
import java.awt.CardLayout; |
|
4 |
import java.awt.Color; |
|
5 |
import java.awt.Container; |
|
6 |
import java.awt.Dimension; |
|
7 |
import java.awt.FlowLayout; |
|
8 |
import java.awt.GridLayout; |
|
9 |
import java.awt.event.ActionEvent; |
|
10 |
import java.awt.event.ItemEvent; |
|
11 |
import java.awt.event.ItemListener; |
|
12 |
import java.awt.event.KeyEvent; |
|
13 |
import java.awt.event.KeyListener; |
|
14 |
import java.awt.event.WindowAdapter; |
|
15 |
import java.awt.event.WindowEvent; |
|
16 |
import java.sql.ResultSet; |
|
17 |
import java.sql.SQLException; |
|
18 |
|
|
19 |
import javax.swing.BorderFactory; |
|
20 |
import javax.swing.JButton; |
|
21 |
import javax.swing.JComboBox; |
|
22 |
import javax.swing.JFrame; |
|
23 |
import javax.swing.JLabel; |
|
24 |
import javax.swing.JOptionPane; |
|
25 |
import javax.swing.JPanel; |
|
26 |
import javax.swing.JRadioButton; |
|
27 |
import javax.swing.JScrollPane; |
|
28 |
import javax.swing.JTable; |
|
29 |
import javax.swing.JTextField; |
|
30 |
import javax.swing.ListSelectionModel; |
|
31 |
import javax.swing.table.DefaultTableModel; |
|
32 |
import javax.swing.table.TableColumn; |
|
33 |
|
|
34 |
import org.cresques.cts.IProjection; |
|
35 |
import org.gvsig.crs.CrsException; |
|
36 |
import org.gvsig.crs.CrsFactory; |
|
37 |
import org.gvsig.crs.ICrs; |
|
38 |
import org.gvsig.crs.Query; |
|
39 |
import org.gvsig.crs.gui.InfoCRSPanel; |
|
40 |
import org.gvsig.crs.ogr.Epsg2wkt; |
|
41 |
import org.gvsig.crs.ogr.GetCRSepsg; |
|
42 |
|
|
43 |
import com.iver.andami.PluginServices; |
|
44 |
import com.iver.cit.gvsig.gui.panels.ProjChooserPanel; |
|
45 |
|
|
46 |
public class testCRSSelectionPanel extends JFrame implements ItemListener { |
|
47 |
|
|
48 |
/** |
|
49 |
* |
|
50 |
*/ |
|
51 |
private static final long serialVersionUID = 1L; |
|
52 |
|
|
53 |
private JComboBox options = null; |
|
54 |
private JPanel Combopanel = null; |
|
55 |
private JPanel USGSpanel = null; |
|
56 |
|
|
57 |
final static String epsg = "EPSG"; |
|
58 |
final static String usgs = "USGS"; |
|
59 |
final static String esri = "ESRI"; |
|
60 |
|
|
61 |
String[] selection = {epsg, usgs, esri, "Nuevo CRS"}; |
|
62 |
|
|
63 |
boolean inAnApplet = true; |
|
64 |
testTransformationManualPanel manual = null; |
|
65 |
EPSGpanel ep = null; |
|
66 |
ESRIpanel esp = null; |
|
67 |
|
|
68 |
public JPanel principal = null; |
|
69 |
|
|
70 |
private JPanel buttonPane; |
|
71 |
private JButton accept; |
|
72 |
private JButton cancel; |
|
73 |
|
|
74 |
public testCRSSelectionPanel() { |
|
75 |
Container contentPane = getContentPane(); |
|
76 |
|
|
77 |
manual = new testTransformationManualPanel(); |
|
78 |
ep = new EPSGpanel(); |
|
79 |
esp = new ESRIpanel(); |
|
80 |
|
|
81 |
contentPane.add(vista(), BorderLayout.NORTH); |
|
82 |
|
|
83 |
contentPane.add(getButtonPane(), BorderLayout.SOUTH); |
|
84 |
|
|
85 |
addWindowListener(new WindowAdapter() { |
|
86 |
public void windowClosing(WindowEvent e) { |
|
87 |
if (inAnApplet) { |
|
88 |
dispose(); |
|
89 |
} else { |
|
90 |
System.exit(0); |
|
91 |
} |
|
92 |
} |
|
93 |
}); |
|
94 |
} |
|
95 |
|
|
96 |
public testCRSSelectionPanel(int i) { |
|
97 |
|
|
98 |
} |
|
99 |
|
|
100 |
public JPanel capa(){ |
|
101 |
JPanel p = new JPanel(); |
|
102 |
p.setPreferredSize(new Dimension(550, 320)); |
|
103 |
p.setLayout(new GridLayout(0,1)); |
|
104 |
p.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
|
105 |
p.setBorder( |
|
106 |
BorderFactory.createCompoundBorder( |
|
107 |
BorderFactory.createCompoundBorder( |
|
108 |
BorderFactory.createTitledBorder("Seleccione CRS de la capa"), |
|
109 |
BorderFactory.createEmptyBorder(1,1,1,1)), |
|
110 |
p.getBorder())); |
|
111 |
p.add(getCombopanel()); |
|
112 |
p.add(resto()); |
|
113 |
return p; |
|
114 |
} |
|
115 |
|
|
116 |
public JPanel vista(){ |
|
117 |
JPanel p = new JPanel(); |
|
118 |
p.setPreferredSize(new Dimension(550, 320)); |
|
119 |
p.setLayout(new GridLayout(0,1)); |
|
120 |
p.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
|
121 |
p.setBorder( |
|
122 |
BorderFactory.createCompoundBorder( |
|
123 |
BorderFactory.createCompoundBorder( |
|
124 |
BorderFactory.createTitledBorder("Seleccione CRS de la vista"), |
|
125 |
BorderFactory.createEmptyBorder(2,2,2,2)), |
|
126 |
p.getBorder())); |
|
127 |
p.add(getCombopanel()); |
|
128 |
p.add(resto()); |
|
129 |
return p; |
|
130 |
} |
|
131 |
|
|
132 |
public JPanel resto(){ |
|
133 |
manual = new testTransformationManualPanel(); |
|
134 |
ep = new EPSGpanel(); |
|
135 |
esp = new ESRIpanel(); |
|
136 |
|
|
137 |
principal = new JPanel(); |
|
138 |
principal.setLayout(new CardLayout()); |
|
139 |
principal.setPreferredSize(new Dimension(525, 230)); |
|
140 |
principal.add(epsg, ep.getJPanelEPSG()); |
|
141 |
principal.add(esri, esp.getJPanelESRI()); |
|
142 |
principal.add(usgs, getJPanelUSGS()); |
|
143 |
|
|
144 |
return principal; |
|
145 |
} |
|
146 |
|
|
147 |
public JPanel getCombopanel(){ |
|
148 |
if (Combopanel == null){ |
|
149 |
Combopanel = new JPanel(); |
|
150 |
Combopanel.setPreferredSize(new Dimension(525,30)); |
|
151 |
Combopanel.add(getLabel()); |
|
152 |
Combopanel.add(getComboCrs()); |
|
153 |
} |
|
154 |
|
|
155 |
return Combopanel; |
|
156 |
} |
|
157 |
|
|
158 |
private JLabel getLabel(){ |
|
159 |
JLabel tipo = new JLabel(); |
|
160 |
tipo.setPreferredSize(new Dimension(50,25)); |
|
161 |
tipo.setText(PluginServices.getText(this,"Tipo: ")); |
|
162 |
return tipo; |
|
163 |
} |
|
164 |
|
|
165 |
private JComboBox getComboCrs(){ |
|
166 |
if (options == null){ |
|
167 |
options = new JComboBox(selection); |
|
168 |
options.setPreferredSize(new Dimension(100,25)); |
|
169 |
options.setEditable(false); |
|
170 |
options.setSelectedIndex(0); |
|
171 |
options.addItemListener(this); |
|
172 |
} |
|
173 |
return options; |
|
174 |
} |
|
175 |
|
|
176 |
public void itemStateChanged(ItemEvent e) { |
|
177 |
CardLayout cl = (CardLayout)(principal.getLayout()); |
|
178 |
cl.show(principal, (String)e.getItem()); |
|
179 |
} |
|
180 |
|
|
181 |
public JPanel getJPanelUSGS() { |
|
182 |
if (USGSpanel == null){ |
|
183 |
USGSpanel = new JPanel(); |
|
184 |
USGSpanel.setLayout(new GridLayout(3,4)); |
|
185 |
USGSpanel.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
|
186 |
USGSpanel.setPreferredSize(new Dimension(525, 400)); |
|
187 |
} |
|
188 |
return USGSpanel; |
|
189 |
} |
|
190 |
|
|
191 |
private JPanel getButtonPane() { |
|
192 |
if(buttonPane == null) { |
|
193 |
buttonPane = new JPanel(); |
|
194 |
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
|
195 |
buttonPane.setPreferredSize(new Dimension(525,50)); |
|
196 |
buttonPane.add(getButtonCancel(),null); |
|
197 |
buttonPane.add(getButtonAccept(),null); |
|
198 |
} |
|
199 |
return buttonPane; |
|
200 |
} |
|
201 |
|
|
202 |
private JButton getButtonCancel() { |
|
203 |
if(cancel == null) { |
|
204 |
cancel = new JButton(); |
|
205 |
cancel.setText(PluginServices.getText(this,"Cancelar")); |
|
206 |
cancel.setPreferredSize(new Dimension(100,25)); |
|
207 |
cancel.setMnemonic('C'); |
|
208 |
cancel.setToolTipText("Cancel"); |
|
209 |
cancel.addActionListener(new java.awt.event.ActionListener() { |
|
210 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
211 |
cancelButton_actionPerformed(e); |
|
212 |
} |
|
213 |
}); |
|
214 |
} |
|
215 |
return cancel; |
|
216 |
} |
|
217 |
|
|
218 |
public void cancelButton_actionPerformed(ActionEvent e) { |
|
219 |
System.exit(0); |
|
220 |
} |
|
221 |
|
|
222 |
private JButton getButtonAccept() { |
|
223 |
if(accept == null) { |
|
224 |
accept = new JButton(); |
|
225 |
accept.setText(PluginServices.getText(this,"Aceptar")); |
|
226 |
accept.setPreferredSize(new Dimension(100,25)); |
|
227 |
accept.setMnemonic('A'); |
|
228 |
accept.setToolTipText("Accept"); |
|
229 |
accept.addActionListener(new java.awt.event.ActionListener() { |
|
230 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
231 |
acceptButton_actionPerformed(e); |
|
232 |
} |
|
233 |
}); |
|
234 |
} |
|
235 |
return accept; |
|
236 |
} |
|
237 |
|
|
238 |
public void acceptButton_actionPerformed(ActionEvent e) { |
|
239 |
System.exit(0); |
|
240 |
} |
|
241 |
|
|
242 |
|
|
243 |
/** |
|
244 |
* @param args |
|
245 |
*/ |
|
246 |
public static void main(String[] args) { |
|
247 |
testCRSSelectionPanel window = new testCRSSelectionPanel(); |
|
248 |
window.inAnApplet = false; |
|
249 |
|
|
250 |
window.setTitle("CRS Selection"); |
|
251 |
window.pack(); |
|
252 |
window.setResizable(false); |
|
253 |
window.setVisible(true); |
|
254 |
} |
|
255 |
} |
trunk/libraries/libJCRS/src-test/org/gvsig/crs/gui/EPSGpanel.java | ||
---|---|---|
1 |
package org.gvsig.crs.gui; |
|
2 |
import java.awt.Color; |
|
3 |
import java.awt.Dimension; |
|
4 |
import java.awt.FlowLayout; |
|
5 |
import java.awt.GridLayout; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.awt.event.KeyEvent; |
|
8 |
import java.awt.event.KeyListener; |
|
9 |
import java.sql.ResultSet; |
|
10 |
import java.sql.SQLException; |
|
11 |
|
|
12 |
import javax.swing.BorderFactory; |
|
13 |
import javax.swing.JButton; |
|
14 |
import javax.swing.JLabel; |
|
15 |
import javax.swing.JOptionPane; |
|
16 |
import javax.swing.JPanel; |
|
17 |
import javax.swing.JRadioButton; |
|
18 |
import javax.swing.JScrollPane; |
|
19 |
import javax.swing.JTable; |
|
20 |
import javax.swing.JTextField; |
|
21 |
import javax.swing.ListSelectionModel; |
|
22 |
import javax.swing.table.DefaultTableModel; |
|
23 |
import javax.swing.table.TableColumn; |
|
24 |
|
|
25 |
import org.cresques.cts.IProjection; |
|
26 |
import org.gvsig.crs.CrsException; |
|
27 |
import org.gvsig.crs.CrsFactory; |
|
28 |
import org.gvsig.crs.ICrs; |
|
29 |
import org.gvsig.crs.Query; |
|
30 |
import org.gvsig.crs.gui.InfoCRSPanel; |
|
31 |
import org.gvsig.crs.ogr.Epsg2wkt; |
|
32 |
import org.gvsig.crs.ogr.GetCRSepsg; |
|
33 |
|
|
34 |
import com.iver.andami.PluginServices; |
|
35 |
import com.iver.cit.gvsig.gui.panels.ProjChooserPanel; |
|
36 |
|
|
37 |
public class EPSGpanel extends JPanel{ |
|
38 |
|
|
39 |
/** |
|
40 |
* |
|
41 |
*/ |
|
42 |
private static final long serialVersionUID = 1L; |
|
43 |
public JPanel EPSGpanel = null; |
|
44 |
|
|
45 |
JLabel jLabel = null; |
|
46 |
JTextField crsTextFld = null; |
|
47 |
|
|
48 |
ProjChooserPanel pcp; |
|
49 |
|
|
50 |
String cadWKT = ""; |
|
51 |
|
|
52 |
int transf = 0; |
|
53 |
int epsg_code = 0; |
|
54 |
boolean source_yn = false; |
|
55 |
int source_cod = 0; |
|
56 |
int method_code = 0; |
|
57 |
int projection_conv_code = 0; |
|
58 |
int[] valid_method_code = {9800, 9801, 9802, 9803, 9804, 9805, 9806, 9807, 9808, 9809, 9810, |
|
59 |
9811, 9812, 9813, 9814, 9815, 9816, 9817}; |
|
60 |
boolean select = false; |
|
61 |
|
|
62 |
private JRadioButton codeRadioButton = null; |
|
63 |
private JRadioButton nameRadioButton = null; |
|
64 |
private JRadioButton areaRadioButton = null; |
|
65 |
private JPanel groupRadioButton = null; |
|
66 |
|
|
67 |
final static String epsg = "EPSG"; |
|
68 |
final static String usgs = "USGS"; |
|
69 |
final static String esri = "ESRI"; |
|
70 |
|
|
71 |
String[] selection = {epsg, usgs, esri, "Nuevo CRS"}; |
|
72 |
|
|
73 |
boolean inAnApplet = true; |
|
74 |
|
|
75 |
private JButton infoCrs = null; |
|
76 |
private JButton searchButton = null; |
|
77 |
private JTextField searchTextField = null; |
|
78 |
private JTable jTable = null; |
|
79 |
private JScrollPane jScrollPane = null; |
|
80 |
public DefaultTableModel dtm = null; |
|
81 |
public DefaultTableModel dtm2 = null; |
|
82 |
public String key; |
|
83 |
public int selectedRowTable = -1; |
|
84 |
public int selectedRowTable2 = -1; |
|
85 |
|
|
86 |
private int codeCRS = -1; |
|
87 |
|
|
88 |
testTransformationManualPanel manual = null; |
|
89 |
|
|
90 |
public EPSGpanel(){ |
|
91 |
|
|
92 |
} |
|
93 |
|
|
94 |
public JPanel getJPanelEPSG() { |
|
95 |
if (EPSGpanel == null){ |
|
96 |
EPSGpanel = new JPanel(); |
|
97 |
EPSGpanel.setLayout(new GridLayout(3,3)); |
|
98 |
EPSGpanel.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
|
99 |
|
|
100 |
EPSGpanel.add(getGroupRadioButton(), null); |
|
101 |
EPSGpanel.add(getSearchButton(), null); |
|
102 |
EPSGpanel.add(getSearchTextField(), null); |
|
103 |
EPSGpanel.add(getInfoCrs(), null); |
|
104 |
EPSGpanel.add(getJScrollPane(), null); |
|
105 |
} |
|
106 |
return EPSGpanel; |
|
107 |
} |
|
108 |
|
|
109 |
private void codeRadioButton_actionPerformed(ActionEvent e) { |
|
110 |
searchTextField.setText(""); |
|
111 |
nameRadioButton.setSelected(false); |
|
112 |
areaRadioButton.setSelected(false); |
|
113 |
} |
|
114 |
|
|
115 |
private JRadioButton getCodeRadioButton() { |
|
116 |
if (codeRadioButton == null) { |
|
117 |
codeRadioButton = new JRadioButton(); |
|
118 |
codeRadioButton.setText(PluginServices.getText(this,"Por c?digo"));//setText("By Code EPSG"); |
|
119 |
codeRadioButton.setSelected(true); |
|
120 |
codeRadioButton.addActionListener(new java.awt.event.ActionListener() { |
|
121 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
122 |
codeRadioButton_actionPerformed(e); |
|
123 |
} |
|
124 |
}); |
|
125 |
} |
|
126 |
return codeRadioButton; |
|
127 |
} |
|
128 |
|
|
129 |
private void nameRadioButton_actionPerformed(ActionEvent e) { |
|
130 |
searchTextField.setText(""); |
|
131 |
codeRadioButton.setSelected(false); |
|
132 |
areaRadioButton.setSelected(false); |
|
133 |
} |
|
134 |
|
|
135 |
private JRadioButton getNameRadioButton() { |
|
136 |
if (nameRadioButton == null) { |
|
137 |
nameRadioButton = new JRadioButton(); |
|
138 |
nameRadioButton.setText(PluginServices.getText(this,"Por nombre")); |
|
139 |
nameRadioButton.addActionListener(new java.awt.event.ActionListener() { |
|
140 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
141 |
nameRadioButton_actionPerformed(e); |
|
142 |
} |
|
143 |
}); |
|
144 |
} |
|
145 |
return nameRadioButton; |
|
146 |
} |
|
147 |
|
|
148 |
private void areaRadioButton_actionPerformed(ActionEvent e) { |
|
149 |
searchTextField.setText(""); |
|
150 |
codeRadioButton.setSelected(false); |
|
151 |
nameRadioButton.setSelected(false); |
|
152 |
} |
|
153 |
|
|
154 |
private JRadioButton getAreaRadioButton() { |
|
155 |
if (areaRadioButton == null) { |
|
156 |
areaRadioButton = new JRadioButton(); |
|
157 |
areaRadioButton.setText(PluginServices.getText(this,"Por ?rea")); |
|
158 |
areaRadioButton.addActionListener(new java.awt.event.ActionListener() { |
|
159 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
160 |
areaRadioButton_actionPerformed(e); |
|
161 |
} |
|
162 |
}); |
|
163 |
} |
|
164 |
return areaRadioButton; |
|
165 |
} |
|
166 |
|
|
167 |
private JPanel getGroupRadioButton() { |
|
168 |
if (groupRadioButton == null) { |
|
169 |
groupRadioButton = new JPanel(); |
|
170 |
groupRadioButton.setLayout(new GridLayout(1,0)); |
|
171 |
groupRadioButton.setPreferredSize(new Dimension(500,30)); |
|
172 |
groupRadioButton.add(getLabel()); |
|
173 |
groupRadioButton.add(getCodeRadioButton()); |
|
174 |
groupRadioButton.add(getNameRadioButton()); |
|
175 |
groupRadioButton.add(getAreaRadioButton()); |
|
176 |
} |
|
177 |
return groupRadioButton; |
|
178 |
} |
|
179 |
|
|
180 |
private JLabel getLabel(){ |
|
181 |
JLabel criterio = new JLabel(); |
|
182 |
criterio.setPreferredSize(new Dimension(100, 20)); |
|
183 |
criterio.setText(PluginServices.getText(this, "Criterio de b?squeda: ")); |
|
184 |
return criterio; |
|
185 |
} |
|
186 |
|
|
187 |
private void searchButton_actionPerformed(ActionEvent e) { |
|
188 |
|
|
189 |
} |
|
190 |
|
|
191 |
private JButton getSearchButton() { |
|
192 |
if (searchButton == null) { |
|
193 |
searchButton = new JButton(); |
|
194 |
searchButton.setPreferredSize(new Dimension(75,20)); |
|
195 |
searchButton.setText(PluginServices.getText(this,"Buscar")); |
|
196 |
searchButton.setMnemonic('S'); |
|
197 |
searchButton.setToolTipText("Search of a CRS by selected criterion"); |
|
198 |
searchButton.addActionListener(new java.awt.event.ActionListener() { |
|
199 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
200 |
searchTextField.setBackground(Color.white); |
|
201 |
if (searchTextField.getText().equals("")) { |
|
202 |
searchTextField.setBackground(new Color(255,204,204)); |
|
203 |
JOptionPane.showMessageDialog(EPSGpanel.this, |
|
204 |
"Fill the key-word of the search.", |
|
205 |
"Warning...", JOptionPane.WARNING_MESSAGE); |
|
206 |
} |
|
207 |
else { |
|
208 |
searchButton_actionPerformed(e); |
|
209 |
} |
|
210 |
} |
|
211 |
}); |
|
212 |
} |
|
213 |
return searchButton; |
|
214 |
} |
|
215 |
|
|
216 |
private JTextField getSearchTextField() { |
|
217 |
if (searchTextField == null) { |
|
218 |
searchTextField = new JTextField(); |
|
219 |
searchTextField.setPreferredSize(new Dimension(300,20)); |
|
220 |
} |
|
221 |
searchTextField.addKeyListener(new KeyListener() { |
|
222 |
public void keyPressed(KeyEvent e) { |
|
223 |
if (e.getKeyCode() == 10) { |
|
224 |
searchButton_actionPerformed(null); |
|
225 |
} |
|
226 |
if (codeRadioButton.isSelected()){ |
|
227 |
if ((e.getKeyCode() >= 48 && e.getKeyCode() <= 57) || e.getKeyCode() >= 96 && e.getKeyCode() <= 105 || |
|
228 |
(e.getKeyCode() >= 0 && e.getKeyCode()<= 31) || e.getKeyCode() == 127){ |
|
229 |
} |
|
230 |
else { |
|
231 |
JOptionPane.showMessageDialog(EPSGpanel.this, |
|
232 |
"Only number format.", |
|
233 |
"Warning...", JOptionPane.WARNING_MESSAGE); |
|
234 |
String aux = searchTextField.getText(); |
|
235 |
if (aux.length() == 1){ |
|
236 |
searchTextField.setText(""); |
|
237 |
} |
|
238 |
else { |
|
239 |
searchTextField.setText(aux.substring(0, aux.length()-1)); |
|
240 |
} |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
|
|
245 |
public void keyReleased(KeyEvent arg0) { |
|
246 |
} |
|
247 |
|
|
248 |
public void keyTyped(KeyEvent arg0) { |
|
249 |
} |
|
250 |
}); |
|
251 |
return searchTextField; |
|
252 |
} |
|
253 |
|
|
254 |
public JTable getJTable() { |
|
255 |
if (jTable == null) { |
|
256 |
String[] columnNames= {"Code of CRS","Name of CRS","Type of CRS","Name of Area","Description of Area"}; |
|
257 |
Object[][]data = {}; |
|
258 |
dtm = new DefaultTableModel(data, columnNames); |
|
259 |
jTable = new JTable(dtm); |
|
260 |
jTable.setCellSelectionEnabled(false); |
|
261 |
jTable.setRowSelectionAllowed(true); |
|
262 |
jTable.setColumnSelectionAllowed(false); |
|
263 |
jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
264 |
TableColumn column = null; |
|
265 |
for (int i = 0; i < 5; i++) { |
|
266 |
column = jTable.getColumnModel().getColumn(i); |
|
267 |
if (i == 0) { |
|
268 |
column.setPreferredWidth(40); //code column is shorter |
|
269 |
}else if (i == 2) { |
|
270 |
column.setPreferredWidth(80); |
|
271 |
} |
|
272 |
else { |
|
273 |
column.setPreferredWidth(160); |
|
274 |
} |
|
275 |
} |
|
276 |
/*ListSelectionModel rowSM = jTable.getSelectionModel(); |
|
277 |
rowSM.addListSelectionListener(new ListSelectionListener() { |
|
278 |
public void valueChanged(ListSelectionEvent e) { |
|
279 |
ListSelectionModel lsm = (ListSelectionModel)e.getSource(); |
|
280 |
if (lsm.isSelectionEmpty()) { |
|
281 |
selectedRowTable = -1; |
|
282 |
setCodeCRS(-1); |
|
283 |
if (transfPanel){ |
|
284 |
si = false; |
|
285 |
CrsView.withOutTrans.setEnabled(false); |
|
286 |
CrsView.nadgrids.setEnabled(false); |
|
287 |
CrsView.epsgTrans.setEnabled(false); |
|
288 |
CrsView.manualTrans.setEnabled(false); |
|
289 |
CrsView.next.setVisible(false); |
|
290 |
CrsView.accept.setVisible(true); |
|
291 |
} |
|
292 |
} |
|
293 |
else { |
|
294 |
selectedRowTable = lsm.getMinSelectionIndex(); |
|
295 |
setCodeCRS(Integer.parseInt((String)dtm.getValueAt(selectedRowTable,0))); |
|
296 |
setWKT(); |
|
297 |
|
|
298 |
if (transfPanel){ |
|
299 |
compareCRS(); |
|
300 |
} |
|
301 |
} |
|
302 |
infoCrs.setEnabled(true); |
|
303 |
} |
|
304 |
|
|
305 |
private void compareCRS() { |
|
306 |
int base = getCodeCRS(); |
|
307 |
String datum = ""; |
|
308 |
int datum_code = -1; |
|
309 |
String sentence = "SELECT source_geogcrs_code " + |
|
310 |
"FROM epsg_coordinatereferencesystem " + |
|
311 |
"WHERE coord_ref_sys_code = "+ base ; |
|
312 |
ResultSet result = Query.select(sentence,pcp.connect.getConnection()); |
|
313 |
int source = 0; |
|
314 |
try { |
|
315 |
result.next(); |
|
316 |
source = result.getInt("source_geogcrs_code"); |
|
317 |
} catch (SQLException e1) { |
|
318 |
e1.printStackTrace(); |
|
319 |
} |
|
320 |
|
|
321 |
if (source != 0){ |
|
322 |
base = source; |
|
323 |
} |
|
324 |
|
|
325 |
sentence = "SELECT datum_code " + |
|
326 |
"FROM epsg_coordinatereferencesystem " + |
|
327 |
"WHERE coord_ref_sys_code = "+ base ; |
|
328 |
result = Query.select(sentence,pcp.connect.getConnection()); |
|
329 |
|
|
330 |
try { |
|
331 |
result.next(); |
|
332 |
datum_code = result.getInt("datum_code"); |
|
333 |
} catch (SQLException e1) { |
|
334 |
e1.printStackTrace(); |
|
335 |
} |
|
336 |
|
|
337 |
sentence = "SELECT datum_name " + |
|
338 |
"FROM epsg_datum " + |
|
339 |
"WHERE datum_code = "+ datum_code ; |
|
340 |
result = Query.select(sentence,pcp.connect.getConnection()); |
|
341 |
|
|
342 |
try { |
|
343 |
result.next(); |
|
344 |
datum = result.getString("datum_name"); |
|
345 |
} catch (SQLException e1) { |
|
346 |
e1.printStackTrace(); |
|
347 |
} |
|
348 |
|
|
349 |
if (!((ICrs) View.m_MapControl.getProjection()).getCrsWkt().getDatumName().equals(datum.replaceAll(" ",""))){ |
|
350 |
si = true; |
|
351 |
CrsView.withOutTrans.setEnabled(true); |
|
352 |
CrsView.nadgrids.setEnabled(true); |
|
353 |
CrsView.epsgTrans.setEnabled(true); |
|
354 |
CrsView.manualTrans.setEnabled(true); |
|
355 |
CrsView.next.setVisible(true); |
|
356 |
CrsView.accept.setVisible(false); |
|
357 |
|
|
358 |
* logica necesaria para comprobar si los crs bases son iguales |
|
359 |
* y en ese caso deshabilitar opcion transformacion de |
|
360 |
* TransformationEpsgPanel |
|
361 |
|
|
362 |
} |
|
363 |
else { |
|
364 |
si = false; |
|
365 |
CrsView.withOutTrans.setEnabled(false); |
|
366 |
CrsView.nadgrids.setEnabled(false); |
|
367 |
CrsView.epsgTrans.setEnabled(false); |
|
368 |
CrsView.manualTrans.setEnabled(false); |
|
369 |
CrsView.next.setVisible(false); |
|
370 |
CrsView.accept.setVisible(true); |
|
371 |
} |
|
372 |
} |
|
373 |
});*/ |
|
374 |
} |
|
375 |
return jTable; |
|
376 |
|
|
377 |
} |
|
378 |
|
|
379 |
public void setCodeCRS(int code) { |
|
380 |
codeCRS = code; |
|
381 |
} |
|
382 |
|
|
383 |
public int getCodeCRS() { |
|
384 |
return codeCRS; |
|
385 |
} |
|
386 |
|
|
387 |
private JScrollPane getJScrollPane() { |
|
388 |
if (jScrollPane == null) { |
|
389 |
jScrollPane = new JScrollPane(); |
|
390 |
jScrollPane.setPreferredSize(new Dimension(500,150)); |
|
391 |
jScrollPane.setBorder( |
|
392 |
BorderFactory.createCompoundBorder( |
|
393 |
BorderFactory.createCompoundBorder( |
|
394 |
BorderFactory.createTitledBorder(PluginServices.getText(this,"Coordinate Reference Systems")), |
|
395 |
BorderFactory.createEmptyBorder(5,5,5,5)), |
|
396 |
jScrollPane.getBorder())); |
|
397 |
jScrollPane.setViewportView(getJTable()); |
|
398 |
} |
|
399 |
return jScrollPane; |
|
400 |
} |
|
401 |
|
|
402 |
public JButton getInfoCrs() { |
|
403 |
if(infoCrs == null) { |
|
404 |
infoCrs = new JButton(); |
|
405 |
infoCrs.setPreferredSize(new Dimension(75,20)); |
|
406 |
infoCrs.setText(PluginServices.getText(this,"InfoCrs")); |
|
407 |
infoCrs.setMnemonic('I'); |
|
408 |
infoCrs.setEnabled(false); |
|
409 |
infoCrs.setToolTipText("Mostrar la informacion del Crs selecionado"); |
|
410 |
infoCrs.addActionListener(new java.awt.event.ActionListener() { |
|
411 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
412 |
infoCrs_actionPerformed(e); |
|
413 |
} |
|
414 |
}); |
|
415 |
} |
|
416 |
return infoCrs; |
|
417 |
} |
|
418 |
|
|
419 |
private void infoCrs_actionPerformed(ActionEvent e) { |
|
420 |
InfoCRSPanel info = new InfoCRSPanel(getCrs()); |
|
421 |
info.setSize(new Dimension(550,350)); |
|
422 |
info.setLayout(new GridLayout(0,1)); |
|
423 |
info.setLayout(new FlowLayout(FlowLayout.LEFT,10,5)); |
|
424 |
PluginServices.getMDIManager().addWindow(info); |
|
425 |
} |
|
426 |
|
|
427 |
public ICrs getProjection() { |
|
428 |
return getCrs(); |
|
429 |
} |
|
430 |
public ICrs getCrs() { |
|
431 |
try { |
|
432 |
String txt = getWKT(); |
|
433 |
ICrs crs = new CrsFactory().getCRS(epsg_code, txt); |
|
434 |
return crs ; |
|
435 |
} catch (CrsException e) { |
|
436 |
e.printStackTrace(); |
|
437 |
} |
|
438 |
return null; |
|
439 |
} |
|
440 |
|
|
441 |
public void setWKT(){ |
|
442 |
Epsg2wkt wkt = null; |
|
443 |
|
|
444 |
epsg_code = getCodeCRS(); |
|
445 |
if (epsg_code != -1){ |
|
446 |
/* |
|
447 |
* ahora que he escogido, recojo toda la informacion que me va a hacer falta |
|
448 |
*/ |
|
449 |
String sentence = "SELECT source_geogcrs_code, projection_conv_code " + |
|
450 |
"FROM epsg_coordinatereferencesystem " + |
|
451 |
"WHERE coord_ref_sys_code = "+ epsg_code ; |
|
452 |
ResultSet result = Query.select(sentence,pcp.connect.getConnection()); |
|
453 |
|
|
454 |
try { |
|
455 |
result.next(); |
|
456 |
source_cod = result.getInt("source_geogcrs_code"); |
|
457 |
projection_conv_code = result.getInt("projection_conv_code"); |
|
458 |
} catch (SQLException e1) { |
|
459 |
e1.printStackTrace(); |
|
460 |
} |
|
461 |
|
|
462 |
if (source_cod != 0){ |
|
463 |
source_yn = false; |
|
464 |
} |
|
465 |
else source_yn = true; |
|
466 |
|
|
467 |
GetCRSepsg ep = new GetCRSepsg(epsg_code, source_yn, source_cod, projection_conv_code, pcp); |
|
468 |
ep.Getepsgdata(); |
|
469 |
|
|
470 |
if (source_yn){ |
|
471 |
wkt = new Epsg2wkt(ep ,0); |
|
472 |
} |
|
473 |
else { |
|
474 |
wkt = new Epsg2wkt(ep); |
|
475 |
} |
|
476 |
} |
|
477 |
else { |
|
478 |
JOptionPane.showMessageDialog(this, |
|
479 |
"No CRS selected.", |
|
480 |
"Warning...", JOptionPane.WARNING_MESSAGE); |
|
481 |
|
|
482 |
} |
|
483 |
cadWKT = wkt.getWKT(); |
|
484 |
} |
|
485 |
|
|
486 |
public String getWKT(){ |
|
487 |
return cadWKT; |
|
488 |
} |
|
489 |
|
|
490 |
public void setProjection(IProjection crs) { |
|
491 |
//setCrs((ICrs) crs); |
|
492 |
} |
|
493 |
|
|
494 |
} |
trunk/libraries/libJCRS/src-test/org/gvsig/crs/gui/CardWindow.java | ||
---|---|---|
1 |
package org.gvsig.crs.gui; |
|
2 |
/* |
|
3 |
* Swing version. |
|
4 |
*/ |
|
5 |
|
|
6 |
import java.awt.*; |
|
7 |
import java.awt.event.*; |
|
8 |
import javax.swing.*; |
|
9 |
|
|
10 |
public class CardWindow extends JFrame |
|
11 |
implements ItemListener { |
|
12 |
boolean inAnApplet = true; |
|
13 |
|
|
14 |
JPanel cards; |
|
15 |
final static String BUTTONPANEL = "JPanel with JButtons"; |
|
16 |
final static String TEXTPANEL = "JPanel with JTextField"; |
|
17 |
|
|
18 |
public CardWindow() { |
|
19 |
Container contentPane = getContentPane(); |
|
20 |
|
|
21 |
//Put the JComboBox in a JPanel to get a nicer look. |
|
22 |
String comboBoxItems[] = { BUTTONPANEL, TEXTPANEL }; |
|
23 |
JPanel cp = new JPanel(); |
|
24 |
JComboBox c = new JComboBox(comboBoxItems); |
|
25 |
c.setEditable(false); |
|
26 |
c.addItemListener(this); |
|
27 |
cp.add(c); |
|
28 |
|
|
29 |
//Use the default layout manager, BorderLayout |
|
30 |
contentPane.add(cp, BorderLayout.NORTH); |
|
31 |
|
|
32 |
cards = new JPanel(); |
|
33 |
cards.setLayout(new CardLayout()); |
|
34 |
|
|
35 |
JPanel p1 = new JPanel(); |
|
36 |
p1.add(new JButton("Button 1")); |
|
37 |
p1.add(new JButton("Button 2")); |
|
38 |
p1.add(new JButton("Button 3")); |
|
39 |
|
|
40 |
JPanel p2 = new JPanel(); |
|
41 |
p2.add(new JTextField("TextField", 20)); |
|
42 |
|
|
43 |
cards.add(BUTTONPANEL, p1); |
|
44 |
cards.add(TEXTPANEL, p2); |
|
45 |
contentPane.add(cards, BorderLayout.CENTER); |
|
46 |
|
|
47 |
addWindowListener(new WindowAdapter() { |
|
48 |
public void windowClosing(WindowEvent e) { |
|
49 |
if (inAnApplet) { |
|
50 |
dispose(); |
|
51 |
} else { |
|
52 |
System.exit(0); |
|
53 |
} |
|
54 |
} |
|
55 |
}); |
|
56 |
} |
|
57 |
|
|
58 |
public void itemStateChanged(ItemEvent evt) { |
|
59 |
CardLayout cl = (CardLayout)(cards.getLayout()); |
|
60 |
cl.show(cards, (String)evt.getItem()); |
|
61 |
} |
|
62 |
|
|
63 |
public static void main(String args[]) { |
|
64 |
CardWindow window = new CardWindow(); |
|
65 |
window.inAnApplet = false; |
|
66 |
|
|
67 |
window.setTitle("CardLayout"); |
|
68 |
window.pack(); |
|
69 |
window.setVisible(true); |
|
70 |
} |
|
71 |
} |
trunk/libraries/libJCRS/src-test/org/gvsig/crs/gui/USGSpanel.java | ||
---|---|---|
1 |
package org.gvsig.crs.gui; |
|
2 |
|
|
3 |
public class USGSpanel { |
|
4 |
|
|
5 |
public USGSpanel() { |
|
6 |
super(); |
|
7 |
// TODO Auto-generated constructor stub |
|
8 |
} |
|
9 |
|
|
10 |
} |
trunk/libraries/libJCRS/src-test/org/gvsig/crs/gui/ESRIpanel.java | ||
---|---|---|
1 |
package org.gvsig.crs.gui; |
|
2 |
import java.awt.BorderLayout; |
|
3 |
import java.awt.Dimension; |
|
4 |
import java.awt.FlowLayout; |
|
5 |
import java.awt.GridLayout; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.io.File; |
|
8 |
|
|
9 |
import javax.swing.JButton; |
|
10 |
import javax.swing.JFileChooser; |
|
11 |
import javax.swing.JFrame; |
|
12 |
import javax.swing.JLabel; |
|
13 |
import javax.swing.JPanel; |
|
14 |
import javax.swing.JTextField; |
|
15 |
|
|
16 |
import org.gvsig.crs.gui.TransformationNadgridsPanel; |
|
17 |
|
|
18 |
import com.iver.andami.PluginServices; |
|
19 |
|
|
20 |
public class ESRIpanel extends JFrame { |
|
21 |
|
|
22 |
private JPanel jPaneOpen; |
|
23 |
private JLabel open_esri; |
|
24 |
private JTextField jTextOpen; |
|
25 |
private JFileChooser openChooser; |
|
26 |
private JButton jButtonOpen; |
|
27 |
File f = new File("C:/Archivos de programa/FWTools1.0.0a7/data/Geographic Coordinate Systems"); |
|
28 |
|
|
29 |
public ESRIpanel() { |
|
30 |
// TODO Auto-generated constructor stub |
|
31 |
} |
|
32 |
|
|
33 |
public JPanel getJPanelESRI() { |
|
34 |
if(jPaneOpen == null) { |
|
35 |
jPaneOpen = new JPanel(); |
|
36 |
jPaneOpen.setPreferredSize(new Dimension(525,400)); |
|
37 |
jPaneOpen.setLayout(new GridLayout(2,2)); |
|
38 |
jPaneOpen.setLayout(new FlowLayout(FlowLayout.CENTER,5,5)); |
|
39 |
jPaneOpen.add(getOpenESRI(), null); |
|
40 |
jPaneOpen.add(getOpenTextField(), null); |
|
41 |
jPaneOpen.add(getButtonOpen(), null); |
|
42 |
|
|
43 |
} |
|
44 |
return jPaneOpen; |
|
45 |
} |
|
46 |
|
|
47 |
private JLabel getOpenESRI() { |
|
48 |
if(open_esri == null) { |
|
49 |
open_esri = new JLabel(); |
|
50 |
open_esri.setPreferredSize(new Dimension(80,20)); |
|
51 |
open_esri.setText(PluginServices.getText(this,"Abrir .prj:")); |
|
52 |
} |
|
53 |
return open_esri; |
|
54 |
} |
|
55 |
|
|
56 |
private JTextField getOpenTextField() { |
|
57 |
if(jTextOpen == null) { |
|
58 |
jTextOpen = new JTextField(); |
|
59 |
jTextOpen.setPreferredSize(new Dimension(200,20)); |
|
60 |
jTextOpen.setText(""); |
|
61 |
} |
|
62 |
return jTextOpen; |
|
63 |
} |
|
64 |
|
|
65 |
private JFileChooser getOpen(){ |
|
66 |
if(openChooser == null){ |
|
67 |
openChooser = new JFileChooser(); |
|
68 |
openChooser.setEnabled(false); |
|
69 |
} |
|
70 |
return openChooser; |
|
71 |
} |
|
72 |
|
|
73 |
private JButton getButtonOpen() { |
|
74 |
if(jButtonOpen == null) { |
|
75 |
jButtonOpen = new JButton(); |
|
76 |
jButtonOpen.setText(""); |
|
77 |
jButtonOpen.setPreferredSize(new Dimension(20,20)); |
|
78 |
jButtonOpen.addActionListener(new java.awt.event.ActionListener() { |
|
79 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
80 |
Open_actionPerformed(e); |
|
81 |
} |
|
82 |
}); |
|
83 |
} |
|
84 |
return jButtonOpen; |
|
85 |
} |
|
86 |
|
|
87 |
private void Open_actionPerformed(ActionEvent e){ |
|
88 |
jPaneOpen.add(getOpen(), null); |
|
89 |
openChooser.setCurrentDirectory(f); |
|
90 |
int returnVal = openChooser.showOpenDialog(ESRIpanel.this); |
|
91 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
|
92 |
File file = openChooser.getSelectedFile(); |
|
93 |
jTextOpen.setText(file.getAbsolutePath()); |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
} |
trunk/libraries/libJCRS/src-test/org/gvsig/crs/gui/testCRSViewPanel.java | ||
---|---|---|
1 |
package org.gvsig.crs.gui; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.CardLayout; |
|
5 |
import java.awt.Container; |
|
6 |
import java.awt.Dimension; |
|
7 |
import java.awt.FlowLayout; |
|
8 |
import java.awt.GridLayout; |
|
9 |
import java.awt.event.ActionEvent; |
|
10 |
import java.awt.event.ActionListener; |
|
11 |
import java.awt.event.WindowAdapter; |
|
12 |
import java.awt.event.WindowEvent; |
|
13 |
|
|
14 |
import javax.swing.BorderFactory; |
|
15 |
import javax.swing.JButton; |
|
16 |
import javax.swing.JComboBox; |
|
17 |
import javax.swing.JFrame; |
|
18 |
import javax.swing.JLabel; |
|
19 |
import javax.swing.JPanel; |
|
20 |
|
|
21 |
import com.iver.andami.PluginServices; |
|
22 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
23 |
|
|
24 |
public class testCRSViewPanel extends JFrame { |
|
25 |
|
|
26 |
private static final long serialVersionUID = 1L; |
|
27 |
|
|
28 |
boolean tra = false; //para que si tenemos seleccionada transformacion nos muestre los parametros |
|
29 |
boolean inAnApplet = true; |
|
30 |
|
|
31 |
private JButton cancel = null; |
|
32 |
public static JButton next = null; |
|
33 |
public static JButton accept = null; |
|
34 |
public static JButton before = null; |
|
35 |
private JPanel jPanelButton = null; |
|
36 |
|
|
37 |
int crs_target = -1; |
|
38 |
String datum_target = ""; |
|
39 |
|
|
40 |
int transformation_code = 0; |
|
41 |
|
|
42 |
private JPanel panel = null; |
|
43 |
testCRSSelectionPanel test = null; |
|
44 |
|
|
45 |
public JPanel principal = null; |
|
46 |
testTransformationManualPanel manual = null; |
|
47 |
testTransformationEpsgPanel epsg = null; |
|
48 |
testTransformationNadgridsPanel nads = null; |
|
49 |
|
|
50 |
Container contentPane = null; |
|
51 |
|
|
52 |
private JPanel Combopanel = null; |
|
53 |
private JComboBox options = null; |
|
54 |
|
|
55 |
String newSelection; |
|
56 |
|
|
57 |
public testCRSViewPanel() { |
|
58 |
contentPane = getContentPane(); |
|
59 |
|
|
60 |
test = new testCRSSelectionPanel(1); |
|
61 |
manual = new testTransformationManualPanel(); |
|
62 |
epsg = new testTransformationEpsgPanel(); |
|
63 |
nads = new testTransformationNadgridsPanel(); |
|
64 |
|
|
65 |
principal = new JPanel(); |
|
66 |
principal.setLayout(new CardLayout()); |
|
67 |
principal.add("primero", intermedio()); |
|
68 |
principal.add("manual", manual.getJPanel()); |
|
69 |
principal.add("epsg", epsg.getJPanel()); |
|
70 |
principal.add("nad", nads.getJPanel()); |
|
71 |
|
|
72 |
contentPane.add(principal, BorderLayout.CENTER); |
|
73 |
|
|
74 |
contentPane.add(getButtons(), BorderLayout.SOUTH); |
|
75 |
|
|
76 |
addWindowListener(new WindowAdapter() { |
|
77 |
public void windowClosing(WindowEvent e) { |
|
78 |
if (inAnApplet) { |
|
79 |
dispose(); |
|
80 |
} else { |
|
81 |
System.exit(0); |
|
82 |
} |
|
83 |
} |
|
84 |
}); |
|
85 |
} |
|
86 |
|
|
87 |
private JPanel intermedio(){ |
|
88 |
JPanel integro = new JPanel(); |
|
89 |
integro.setLayout(new GridLayout(0,1)); |
|
90 |
integro.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
|
91 |
integro.setPreferredSize(new Dimension(560,300)); |
|
92 |
|
|
93 |
integro.add(test.capa(), null); |
|
94 |
integro.add(getJPanel(), null); |
|
95 |
return integro; |
|
96 |
} |
|
97 |
|
|
98 |
|
|
99 |
private JPanel getJPanel() { |
|
100 |
if (panel == null){ |
|
101 |
panel = new JPanel(); |
|
102 |
panel.setPreferredSize(new Dimension(540,80)); |
|
103 |
panel.setLayout(new GridLayout(0,2)); |
|
104 |
panel.setLayout(new FlowLayout(FlowLayout.LEFT,10,10)); |
|
105 |
panel.add(getCombopanel(), null); |
|
106 |
//panel.add(getCheckButtonPane(), null); |
|
107 |
//panel.add(getButtons(), null); |
|
108 |
} |
|
109 |
return panel; |
|
110 |
} |
|
111 |
|
|
112 |
public JPanel getCombopanel(){ |
|
113 |
if (Combopanel == null){ |
|
114 |
Combopanel = new JPanel(); |
|
115 |
Combopanel.setPreferredSize(new Dimension(400,30)); |
|
116 |
Combopanel.add(getLabel()); |
|
117 |
Combopanel.add(getComboCrs()); |
|
118 |
} |
|
119 |
|
|
120 |
return Combopanel; |
|
121 |
} |
|
122 |
|
|
123 |
private JLabel getLabel(){ |
|
124 |
JLabel transLabel = new JLabel(); |
|
125 |
transLabel.setPreferredSize(new Dimension(180, 25)); |
|
126 |
transLabel.setText(PluginServices.getText(this, "Seleccione Transformaci?n: ")); |
|
127 |
return transLabel; |
|
128 |
} |
|
129 |
|
|
130 |
private JComboBox getComboCrs(){ |
|
131 |
if (options == null){ |
|
132 |
String[] selection = {"Sin transformacion", "Transformacion manual", |
|
133 |
"+nadgrids", "Transformacion EPSG"}; |
|
134 |
options = new JComboBox(selection); |
|
135 |
options.setPreferredSize(new Dimension(150,25)); |
|
136 |
options.setEditable(false); |
|
137 |
options.setSelectedIndex(0); |
|
138 |
newSelection = (String) options.getSelectedItem(); |
|
139 |
//options.addItemListener(this); |
|
140 |
} |
|
141 |
options.addActionListener(new ActionListener() { |
|
142 |
public void actionPerformed(ActionEvent e) { |
|
143 |
JComboBox cb = (JComboBox)e.getSource(); |
|
144 |
newSelection = (String)cb.getSelectedItem(); |
|
145 |
if (newSelection.equals("Sin transformacion")){ |
|
146 |
accept.setVisible(true); |
|
147 |
next.setVisible(false); |
|
148 |
} |
|
149 |
else { |
|
150 |
accept.setVisible(false); |
|
151 |
next.setVisible(true); |
|
152 |
} |
|
153 |
} |
|
154 |
}); |
|
155 |
return options; |
|
156 |
} |
|
157 |
|
|
158 |
private JPanel getButtons() { |
|
159 |
if(jPanelButton == null) { |
|
160 |
jPanelButton = new JPanel(); |
|
161 |
jPanelButton.setPreferredSize(new Dimension(550,50)); |
|
162 |
jPanelButton.setLayout(new GridLayout(0,1)); |
|
163 |
jPanelButton.setLayout(new FlowLayout(FlowLayout.RIGHT,5,5)); |
|
164 |
jPanelButton.add(getCancel(), null); |
|
165 |
jPanelButton.add(getBefore(), null); |
|
166 |
jPanelButton.add(getNext(), null); |
|
167 |
jPanelButton.add(getAccept(), null); |
|
168 |
} |
|
169 |
return jPanelButton; |
|
170 |
} |
|
171 |
|
|
172 |
private JButton getBefore(){ |
|
173 |
if(before == null) { |
|
174 |
before = new JButton(); |
|
175 |
before.setText(PluginServices.getText(this,"Anterior")); |
|
176 |
before.setMnemonic('B'); |
|
177 |
before.setPreferredSize(new Dimension(100,25)); |
|
178 |
before.setEnabled(false); |
|
179 |
before.addActionListener(new java.awt.event.ActionListener() { |
|
180 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
181 |
before_actionPerformed(e); |
|
182 |
} |
|
183 |
}); |
|
184 |
} |
|
185 |
return before; |
|
186 |
} |
|
187 |
|
|
188 |
private void before_actionPerformed(ActionEvent e) { |
|
189 |
CardLayout cl = (CardLayout)(principal.getLayout()); |
|
190 |
cl.show(principal, "primero"); |
|
191 |
next.setVisible(true); |
|
192 |
accept.setVisible(false); |
|
193 |
before.setEnabled(false); |
|
194 |
} |
|
195 |
|
|
196 |
private JButton getAccept() { |
|
197 |
if(accept == null) { |
|
198 |
accept = new JButton(); |
|
199 |
accept.setText(PluginServices.getText(this,"Finalizar")); |
|
200 |
accept.setMnemonic('O'); |
|
201 |
accept.setVisible(true); |
|
202 |
accept.setPreferredSize(new Dimension(100,25)); |
|
203 |
accept.addActionListener(new java.awt.event.ActionListener() { |
|
204 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
205 |
accept_actionPerformed(e); |
|
206 |
} |
|
207 |
}); |
|
208 |
} |
|
209 |
return accept; |
|
210 |
} |
|
211 |
|
|
212 |
private void accept_actionPerformed(ActionEvent e) { |
|
213 |
System.exit(0); |
|
214 |
} |
|
215 |
|
|
216 |
|
|
217 |
private JButton getNext() { |
|
218 |
if(next == null) { |
|
219 |
next = new JButton(); |
|
220 |
next.setText(PluginServices.getText(this,"Siguiente")); |
|
221 |
next.setMnemonic('S'); |
|
222 |
next.setVisible(false); |
|
223 |
next.setPreferredSize(new Dimension(100,25)); |
|
224 |
next.addActionListener(new java.awt.event.ActionListener() { |
|
225 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
226 |
next_actionPerformed(e); |
|
227 |
} |
|
228 |
}); |
|
229 |
} |
|
230 |
return next; |
|
231 |
} |
|
232 |
|
|
233 |
private void next_actionPerformed(ActionEvent e) { |
|
234 |
next.setVisible(false); |
|
235 |
accept.setVisible(true); |
|
236 |
before.setEnabled(true); |
|
237 |
if (newSelection.equals("Transformacion manual")) { |
|
238 |
CardLayout cl = (CardLayout)(principal.getLayout()); |
|
239 |
cl.show(principal, "manual"); |
|
240 |
} |
|
241 |
else if(newSelection.equals("+nadgrids")){ |
|
242 |
CardLayout cl = (CardLayout)(principal.getLayout()); |
|
243 |
cl.show(principal, "nad"); |
|
244 |
} |
|
245 |
else if(newSelection.equals("Transformacion EPSG")){ |
|
246 |
CardLayout cl = (CardLayout)(principal.getLayout()); |
|
247 |
cl.show(principal, "epsg"); |
|
248 |
} |
|
249 |
|
|
250 |
/*if(epsgTrans.isSelected() == true ){ //&& contentPane.getCodeCRS() != -1){ |
|
251 |
//PluginServices.getMDIManager().closeWindow(this); |
|
252 |
TransformationEpsgPanel tr = new TransformationEpsgPanel(contentPane.getWKT(),contentPane.getCodeCRS(), |
|
253 |
crs_target); |
|
254 |
tr.setSize(new Dimension(550, 400)); |
|
255 |
tr.setLayout(new GridLayout(2,2)); |
|
256 |
tr.setLayout(new FlowLayout(FlowLayout.LEFT,5,20)); |
|
257 |
PluginServices.getMDIManager().addWindow(tr); |
|
258 |
CardLayout cl = (CardLayout)(principal.getLayout()); |
|
259 |
cl.show(principal, "epsg"); |
|
260 |
next.setVisible(false); |
|
261 |
before.setVisible(true); |
|
262 |
|
|
263 |
}else if(nadgrids.isSelected() == true ){ //&& contentPane.getCodeCRS() != -1) { |
|
264 |
//PluginServices.getMDIManager().closeWindow(this); |
|
265 |
TransformationNadgridsPanel tn = new TransformationNadgridsPanel(contentPane.getWKT(),contentPane.getCodeCRS()); |
|
266 |
tn.setSize(new Dimension(550, 275)); |
|
267 |
tn.setLayout(new GridLayout(2,2)); |
|
268 |
tn.setLayout(new FlowLayout(FlowLayout.LEFT,5,10)); |
|
269 |
PluginServices.getMDIManager().addWindow(tn); |
|
270 |
CardLayout cl = (CardLayout)(principal.getLayout()); |
|
271 |
cl.show(principal, "nadgrids"); |
|
272 |
next.setVisible(false); |
|
273 |
before.setVisible(true); |
|
274 |
|
|
275 |
}else if(manualTrans.isSelected() == true ){ //&& contentPane.getCodeCRS() != -1) { |
|
276 |
CardLayout cl = (CardLayout)(principal.getLayout()); |
|
277 |
cl.show(principal, "manual"); |
|
278 |
next.setVisible(false); |
|
279 |
before.setVisible(true); |
|
280 |
}else if(withOutTrans.isSelected() == true && contentPane.getCodeCRS() != -1) { |
|
281 |
PluginServices.getMDIManager().closeWindow(this); |
|
282 |
WithoutTranformation wt = new WithoutTranformation(contentPane.getWKT(),contentPane.getCodeCRS()); |
|
283 |
wt.setSize(new Dimension(550, 200)); |
|
284 |
wt.setLayout(new GridLayout(2,2)); |
|
285 |
wt.setLayout(new FlowLayout(FlowLayout.LEFT,5,10)); |
|
286 |
PluginServices.getMDIManager().addWindow(wt); |
|
287 |
}*/ |
|
288 |
} |
|
289 |
|
|
290 |
|
|
291 |
private JButton getCancel() { |
|
292 |
if(cancel == null) { |
|
293 |
cancel = new JButton(); |
|
294 |
cancel.setText(PluginServices.getText(this,"Cancelar")); |
|
295 |
cancel.setMnemonic('C'); |
|
296 |
cancel.setPreferredSize(new Dimension(100,25)); |
|
297 |
cancel.addActionListener(new java.awt.event.ActionListener() { |
|
298 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
299 |
cancel_actionPerformed(e); |
|
300 |
} |
|
301 |
}); |
|
302 |
} |
|
303 |
return cancel; |
|
304 |
} |
|
305 |
|
|
306 |
private void cancel_actionPerformed(ActionEvent e) { |
|
307 |
//PluginServices.getMDIManager().closeWindow(this); |
|
308 |
System.exit(0); |
|
309 |
} |
|
310 |
|
|
311 |
public WindowInfo getWindowInfo() { |
|
312 |
WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODALDIALOG); |
|
313 |
m_viewinfo.setTitle(PluginServices.getText(this,"CrsView")); |
|
314 |
return m_viewinfo; |
|
315 |
} |
|
316 |
|
|
317 |
|
|
318 |
|
|
319 |
/** |
|
320 |
* @param args |
|
321 |
*/ |
|
322 |
public static void main(String[] args) { |
|
323 |
testCRSViewPanel test2 = new testCRSViewPanel(); |
|
324 |
|
|
325 |
test2.inAnApplet = false; |
|
326 |
|
|
327 |
test2.setTitle("CRS Transformation"); |
|
328 |
test2.pack(); |
|
329 |
test2.setResizable(false); |
|
330 |
test2.setVisible(true); |
|
331 |
} |
|
332 |
} |
trunk/libraries/libJCRS/src-test/org/gvsig/crs/gui/testTransformationNadgridsPanel.java | ||
---|---|---|
1 |
package org.gvsig.crs.gui; |
|
2 |
|
|
3 |
|
|
4 |
import java.awt.Component; |
|
5 |
import java.awt.Dimension; |
|
6 |
import java.awt.FlowLayout; |
|
7 |
import java.awt.GridLayout; |
|
8 |
import java.awt.event.ActionEvent; |
|
9 |
import java.io.File; |
|
10 |
|
|
11 |
import javax.swing.BorderFactory; |
|
12 |
import javax.swing.JButton; |
|
13 |
import javax.swing.JFileChooser; |
|
14 |
import javax.swing.JLabel; |
|
15 |
import javax.swing.JPanel; |
|
16 |
import javax.swing.JScrollPane; |
|
17 |
import javax.swing.JTextArea; |
|
18 |
import javax.swing.JTextField; |
|
19 |
|
|
20 |
import org.cresques.cts.IProjection; |
|
21 |
import org.cresques.ui.DefaultDialogPanel; |
|
22 |
import org.gvsig.crs.CrsFactory; |
|
23 |
import org.gvsig.crs.ICrs; |
|
24 |
|
|
25 |
import com.iver.andami.PluginServices; |
|
26 |
import com.iver.andami.ui.mdiManager.IWindow; |
|
27 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
|
28 |
import com.iver.cit.gvsig.gui.panels.ProjChooserPanelTransformation; |
|
29 |
|
|
30 |
public class testTransformationNadgridsPanel extends DefaultDialogPanel implements IWindow { |
|
31 |
|
|
32 |
private static final long serialVersionUID = 1L; |
|
33 |
|
|
34 |
private IProjection firstProj; |
|
35 |
private String nad = "+nadgrids=sped2et.gsb"; |
|
36 |
|
|
37 |
private JPanel buttonPane; |
|
38 |
private JButton accept; |
|
39 |
private JButton cancel; |
|
40 |
|
|
41 |
ProjChooserPanelTransformation pcpt; |
|
42 |
|
|
43 |
private String cadWKT = ""; |
|
44 |
private int codeEpsg; |
|
45 |
|
|
46 |
private JPanel jPaneOpen; |
|
47 |
private JLabel open_gsb; |
|
48 |
private JTextField jTextOpen; |
|
49 |
private JFileChooser openChooser; |
|
50 |
private JButton jButtonOpen; |
|
51 |
File f = new File("C:/Archivos de programa/FWTools1.0.0a7/proj_lib"); |
|
52 |
|
|
53 |
private JPanel panel; |
|
54 |
private JLabel wkt; |
|
55 |
private JTextArea info; |
|
56 |
private JScrollPane areaScrollPane; |
|
57 |
|
|
58 |
public testTransformationNadgridsPanel() { |
|
59 |
/*super(false); |
|
60 |
pcpt = new ProjChooserPanelTransformation(); |
|
61 |
cadWKT = cad; |
|
62 |
codeEpsg = code; |
|
63 |
this.setPreferredSize(new Dimension(680, 650)); |
|
64 |
this.setLayout(new GridLayout(2,2)); |
|
65 |
this.setLayout(new FlowLayout(FlowLayout.LEFT,5,10)); |
|
66 |
init(); */ |
|
67 |
} |
|
68 |
/* |
|
69 |
private void init() { |
|
70 |
this.add(getJPanel(), null); |
|
71 |
this.add(getOpenPanel(), null); |
|
72 |
this.add(getButtonPane(), null); |
|
73 |
}*/ |
|
74 |
|
|
75 |
public JPanel getJPanel(){ |
|
76 |
if (panel == null) { |
|
77 |
panel = new JPanel(); |
|
78 |
panel.setLayout(new GridLayout(1,2)); |
|
79 |
panel.setLayout(new FlowLayout(FlowLayout.LEADING,5,10)); |
|
80 |
panel.setPreferredSize(new Dimension(525, 110)); |
|
81 |
panel.setBorder( |
|
82 |
BorderFactory.createCompoundBorder( |
|
83 |
BorderFactory.createCompoundBorder( |
|
84 |
BorderFactory.createTitledBorder("+nadgrids"), |
|
85 |
BorderFactory.createEmptyBorder(2,2,2,2)), |
|
86 |
panel.getBorder())); |
|
87 |
panel.add(getLabel()); |
|
88 |
panel.add(getScrollPanelArea()); |
|
89 |
panel.add(getOpenPanel()); |
|
90 |
} |
|
91 |
return panel; |
|
92 |
} |
|
93 |
|
|
94 |
private JScrollPane getScrollPanelArea() { |
|
95 |
if(areaScrollPane == null) { |
|
96 |
areaScrollPane = new JScrollPane(getInfo()); |
|
97 |
areaScrollPane.setVerticalScrollBarPolicy( |
|
98 |
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); |
|
99 |
areaScrollPane.setPreferredSize(new Dimension(420, 100)); |
|
100 |
areaScrollPane.setBorder( |
|
101 |
BorderFactory.createCompoundBorder( |
|
102 |
BorderFactory.createCompoundBorder( |
|
103 |
BorderFactory.createTitledBorder("Wkt"), |
|
104 |
BorderFactory.createEmptyBorder(2,2,2,2)), |
|
105 |
areaScrollPane.getBorder())); |
|
106 |
} |
|
107 |
return areaScrollPane; |
|
108 |
} |
|
109 |
|
|
110 |
private Component getLabel() { |
|
111 |
if (wkt == null){ |
|
112 |
wkt = new JLabel(); |
|
113 |
wkt.setPreferredSize(new Dimension(90, 80)); |
|
114 |
wkt.setText(PluginServices.getText(this,"Cadena WKT: ")); |
|
115 |
} |
|
116 |
return wkt; |
|
117 |
} |
|
118 |
|
|
119 |
private Component getInfo() { |
|
120 |
if (info == null){ |
|
121 |
info = new JTextArea(); |
|
122 |
info.setLineWrap(true); |
|
123 |
info.setWrapStyleWord(true); |
|
124 |
info.setPreferredSize(new Dimension(400, 100)); |
|
125 |
info.setEditable(false); |
|
126 |
info.setText(cadWKT); |
|
127 |
} |
|
128 |
return info; |
|
129 |
} |
|
130 |
|
|
131 |
private JPanel getButtonPane() { |
|
132 |
if(buttonPane == null) { |
|
133 |
buttonPane = new JPanel(); |
|
134 |
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
|
135 |
buttonPane.setPreferredSize(new Dimension(525,50)); |
|
136 |
buttonPane.add(getButtonAccept(),null); |
|
137 |
buttonPane.add(getButtonCancel(),null); |
|
138 |
} |
|
139 |
return buttonPane; |
|
140 |
} |
|
141 |
|
|
142 |
private JButton getButtonCancel() { |
|
143 |
if(cancel == null) { |
|
144 |
cancel = new JButton(); |
|
145 |
cancel.setText(PluginServices.getText(this,"Cancelar")); |
|
146 |
cancel.setPreferredSize(new Dimension(100,25)); |
|
147 |
cancel.setMnemonic('C'); |
|
148 |
cancel.setToolTipText("Cancel"); |
|
149 |
cancel.addActionListener(new java.awt.event.ActionListener() { |
|
150 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
151 |
cancelButton_actionPerformed(e); |
|
152 |
} |
|
153 |
}); |
|
154 |
} |
|
155 |
return cancel; |
|
156 |
} |
|
157 |
|
|
158 |
public void cancelButton_actionPerformed(ActionEvent e) { |
|
159 |
PluginServices.getMDIManager().closeWindow(this); |
|
160 |
} |
|
161 |
|
|
162 |
private JButton getButtonAccept() { |
|
163 |
if(accept == null) { |
|
164 |
accept = new JButton(); |
|
165 |
accept.setText(PluginServices.getText(this,"Aceptar")); |
|
166 |
accept.setPreferredSize(new Dimension(100,25)); |
|
167 |
accept.setMnemonic('A'); |
|
168 |
accept.setToolTipText("Accept"); |
|
169 |
accept.addActionListener(new java.awt.event.ActionListener() { |
|
170 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
171 |
acceptButton_actionPerformed(e); |
|
172 |
} |
|
173 |
}); |
|
174 |
} |
|
175 |
return accept; |
|
176 |
} |
|
177 |
|
|
178 |
public void acceptButton_actionPerformed(ActionEvent e) { |
|
179 |
PluginServices.getMDIManager().closeWindow(this); |
|
180 |
} |
|
181 |
|
|
182 |
private JPanel getOpenPanel() { |
|
183 |
if(jPaneOpen == null) { |
|
184 |
jPaneOpen = new JPanel(); |
|
185 |
jPaneOpen.setPreferredSize(new Dimension(525,50)); |
|
186 |
jPaneOpen.setLayout(new GridLayout(2,2)); |
|
187 |
jPaneOpen.setLayout(new FlowLayout(FlowLayout.LEFT,5,5)); |
|
188 |
jPaneOpen.add(getOpenGsb(), null); |
|
189 |
jPaneOpen.add(getOpenTextField(), null); |
|
190 |
jPaneOpen.add(getButtonOpen(), null); |
|
191 |
// jPaneOpen.add(getOpen(), null); |
|
192 |
|
|
193 |
} |
|
194 |
return jPaneOpen; |
|
195 |
} |
|
196 |
|
|
197 |
private JLabel getOpenGsb() { |
|
198 |
if(open_gsb == null) { |
|
199 |
open_gsb = new JLabel(); |
|
200 |
open_gsb.setPreferredSize(new Dimension(80,20)); |
|
201 |
open_gsb.setText(PluginServices.getText(this,"Abrir .gsb:")); |
|
202 |
} |
|
203 |
return open_gsb; |
Also available in: Unified diff