root / branches / v2_0_0_prep / extensions / extDalTransformEventTheme / src / org / gvsig / app / eventtheme / daltransform / EventThemeTransformPanel.java @ 38767
History | View | Annotate | Download (9.01 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2009 {Iver T.I.} {Task}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.app.eventtheme.daltransform; |
29 |
|
30 |
import java.awt.BorderLayout; |
31 |
import java.awt.Insets; |
32 |
import java.awt.event.ActionEvent; |
33 |
import java.awt.event.ActionListener; |
34 |
|
35 |
import javax.swing.JButton; |
36 |
import javax.swing.JLabel; |
37 |
import javax.swing.JPanel; |
38 |
import javax.swing.JTextField; |
39 |
|
40 |
import org.cresques.cts.IProjection; |
41 |
|
42 |
import org.gvsig.andami.PluginServices; |
43 |
import org.gvsig.app.gui.panels.CRSSelectPanel; |
44 |
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel; |
45 |
import org.gvsig.app.project.ProjectPreferences; |
46 |
import org.gvsig.daltransform.swing.impl.AbstractDataTransformWizardPanel; |
47 |
import org.gvsig.daltransform.swing.impl.components.FeatureTypeCombo; |
48 |
import org.gvsig.daltransform.swing.impl.components.NumericFeatureTypeAttributesCombo; |
49 |
import org.gvsig.fmap.crs.CRSFactory; |
50 |
|
51 |
|
52 |
/**
|
53 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
54 |
*/
|
55 |
public class EventThemeTransformPanel extends AbstractDataTransformWizardPanel implements ActionListener { |
56 |
private JLabel nameLabel; |
57 |
private JTextField nameText; |
58 |
private NumericFeatureTypeAttributesCombo xCombo;
|
59 |
private JLabel xLabel; |
60 |
private NumericFeatureTypeAttributesCombo yCombo;
|
61 |
private JLabel yLabel; |
62 |
private FeatureTypeCombo featureTypeCombo;
|
63 |
private JLabel featureTypeLabel; |
64 |
private JPanel northPanel = null; |
65 |
private JTextField projectionText; |
66 |
private JLabel projectionLabel; |
67 |
private JButton projectionButton = null; |
68 |
|
69 |
public EventThemeTransformPanel() {
|
70 |
super();
|
71 |
initComponents(); |
72 |
initLabels(); |
73 |
initProjection(); |
74 |
featureTypeCombo.addActionListener(this);
|
75 |
projectionButton.addActionListener(this);
|
76 |
} |
77 |
|
78 |
private void initProjection() { |
79 |
ProjectPreferences prefs = new ProjectPreferences();
|
80 |
projectionText.setText(prefs.getDefaultProjection().getAbrev()); |
81 |
} |
82 |
|
83 |
private void initLabels() { |
84 |
featureTypeLabel.setText(PluginServices.getText(this, "events_feature_type_field") + ":"); |
85 |
xLabel.setText(PluginServices.getText(this, "events_x_field") + ":"); |
86 |
yLabel.setText(PluginServices.getText(this, "events_y_field") + ":"); |
87 |
nameLabel.setText(PluginServices.getText(this, "events_geom_field") + ":"); |
88 |
projectionLabel.setText(PluginServices.getText(this, "projection") + ":"); |
89 |
projectionButton.setText("...");
|
90 |
} |
91 |
|
92 |
private void initComponents() { |
93 |
java.awt.GridBagConstraints gridBagConstraints; |
94 |
|
95 |
featureTypeCombo = new FeatureTypeCombo();
|
96 |
featureTypeLabel = new javax.swing.JLabel();
|
97 |
xLabel = new javax.swing.JLabel();
|
98 |
xCombo = new NumericFeatureTypeAttributesCombo();
|
99 |
yLabel = new javax.swing.JLabel();
|
100 |
yCombo = new NumericFeatureTypeAttributesCombo();
|
101 |
nameLabel = new javax.swing.JLabel();
|
102 |
nameText = new javax.swing.JTextField();
|
103 |
northPanel= new JPanel(); |
104 |
projectionText = new JTextField(); |
105 |
projectionLabel = new JLabel(); |
106 |
projectionButton = new JButton(); |
107 |
projectionButton.setSize(25, 25); |
108 |
projectionText.setEnabled(false);
|
109 |
|
110 |
setLayout(new BorderLayout()); |
111 |
northPanel.setLayout(new java.awt.GridBagLayout());
|
112 |
|
113 |
// gridBagConstraints = new java.awt.GridBagConstraints();
|
114 |
// gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
|
115 |
// gridBagConstraints.insets = new Insets(5,2,2,2);
|
116 |
// northPanel.add(featureTypeLabel, gridBagConstraints);
|
117 |
//
|
118 |
// featureTypeCombo.setModel(new javax.swing.DefaultComboBoxModel());
|
119 |
// gridBagConstraints = new java.awt.GridBagConstraints();
|
120 |
// gridBagConstraints.gridx = 0;
|
121 |
// gridBagConstraints.gridy = 1;
|
122 |
// gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
|
123 |
// gridBagConstraints.weightx = 1.0;
|
124 |
// gridBagConstraints.insets = new Insets(2,2,5,2);
|
125 |
// northPanel.add(featureTypeCombo, gridBagConstraints);
|
126 |
|
127 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
128 |
gridBagConstraints.gridx = 0;
|
129 |
gridBagConstraints.gridy = 0;
|
130 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
131 |
gridBagConstraints.gridwidth = 2;
|
132 |
gridBagConstraints.insets = new Insets(5,2,2,2); |
133 |
northPanel.add(xLabel, gridBagConstraints); |
134 |
|
135 |
xCombo.setModel(new javax.swing.DefaultComboBoxModel());
|
136 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
137 |
gridBagConstraints.gridx = 0;
|
138 |
gridBagConstraints.gridy = 1;
|
139 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
140 |
gridBagConstraints.gridwidth = 2;
|
141 |
gridBagConstraints.insets = new Insets(2,2,5,2); |
142 |
gridBagConstraints.weightx = 1.0;
|
143 |
northPanel.add(xCombo, gridBagConstraints); |
144 |
|
145 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
146 |
gridBagConstraints.gridx = 0;
|
147 |
gridBagConstraints.gridy = 2;
|
148 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
149 |
gridBagConstraints.insets = new Insets(5,2,2,2); |
150 |
gridBagConstraints.gridwidth = 2;
|
151 |
northPanel.add(yLabel, gridBagConstraints); |
152 |
|
153 |
yCombo.setModel(new javax.swing.DefaultComboBoxModel());
|
154 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
155 |
gridBagConstraints.gridx = 0;
|
156 |
gridBagConstraints.gridy = 3;
|
157 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
158 |
gridBagConstraints.weightx = 1.0;
|
159 |
gridBagConstraints.insets = new Insets(2,2,5,2); |
160 |
gridBagConstraints.gridwidth = 2;
|
161 |
northPanel.add(yCombo, gridBagConstraints); |
162 |
|
163 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
164 |
gridBagConstraints.gridx = 0;
|
165 |
gridBagConstraints.gridy = 4;
|
166 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
167 |
gridBagConstraints.insets = new Insets(5,2,2,2); |
168 |
gridBagConstraints.gridwidth = 2;
|
169 |
northPanel.add(nameLabel, gridBagConstraints); |
170 |
|
171 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
172 |
gridBagConstraints.gridx = 0;
|
173 |
gridBagConstraints.gridy = 5;
|
174 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
175 |
gridBagConstraints.weightx = 1.0;
|
176 |
gridBagConstraints.insets = new Insets(2,2,5,2); |
177 |
gridBagConstraints.gridwidth = 2;
|
178 |
northPanel.add(nameText, gridBagConstraints); |
179 |
|
180 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
181 |
gridBagConstraints.gridx = 0;
|
182 |
gridBagConstraints.gridy = 6;
|
183 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
184 |
gridBagConstraints.gridwidth = 2;
|
185 |
gridBagConstraints.insets = new Insets(5,2,2,2); |
186 |
northPanel.add(projectionLabel, gridBagConstraints); |
187 |
|
188 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
189 |
gridBagConstraints.gridx = 0;
|
190 |
gridBagConstraints.gridy = 7;
|
191 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
192 |
gridBagConstraints.weightx = 1.0;
|
193 |
gridBagConstraints.gridwidth = 1;
|
194 |
gridBagConstraints.insets = new Insets(2,2,5,2); |
195 |
northPanel.add(projectionText, gridBagConstraints); |
196 |
|
197 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
198 |
gridBagConstraints.gridx = 1;
|
199 |
gridBagConstraints.gridy = 7;
|
200 |
gridBagConstraints.gridwidth = 1;
|
201 |
gridBagConstraints.insets = new Insets(2,2,5,2); |
202 |
northPanel.add(projectionButton, gridBagConstraints); |
203 |
|
204 |
add(northPanel, BorderLayout.NORTH);
|
205 |
} |
206 |
|
207 |
/* (non-Javadoc)
|
208 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
209 |
*/
|
210 |
public void actionPerformed(ActionEvent event) { |
211 |
if (event == null){ |
212 |
return;
|
213 |
} |
214 |
if (event.getSource() == featureTypeCombo){
|
215 |
Object obj = featureTypeCombo.getSelectedItem();
|
216 |
if (obj != null){ |
217 |
xCombo.addFeatureAttributes(featureTypeCombo.getSelectedFeatureType()); |
218 |
yCombo.addFeatureAttributes(featureTypeCombo.getSelectedFeatureType()); |
219 |
} |
220 |
}else if (event.getSource() == projectionButton){ |
221 |
ISelectCrsPanel panel = CRSSelectPanel.getUIFactory().getSelectCrsPanel( |
222 |
CRSFactory.getCRS(projectionText.getText()), false);
|
223 |
PluginServices.getMDIManager().addWindow(panel); |
224 |
if (panel.isOkPressed()) {
|
225 |
IProjection proj = panel.getProjection(); |
226 |
projectionText.setText(proj.getAbrev()); |
227 |
} |
228 |
} |
229 |
} |
230 |
|
231 |
public String getGeometryName(){ |
232 |
return nameText.getText();
|
233 |
} |
234 |
|
235 |
public String getXName(){ |
236 |
return xCombo.getSelectedFeatureAttributeDescriptor().getName();
|
237 |
} |
238 |
|
239 |
public String getYName(){ |
240 |
return yCombo.getSelectedFeatureAttributeDescriptor().getName();
|
241 |
} |
242 |
|
243 |
/*
|
244 |
* (non-Javadoc)
|
245 |
* @see org.gvsig.app.daltransform.impl.AbstractDataTransformWizardPanel#updatePanel()
|
246 |
*/
|
247 |
public void updatePanel() { |
248 |
featureTypeCombo.addFeatureStore(getFeatureStore()); |
249 |
actionPerformed(null);
|
250 |
} |
251 |
|
252 |
public IProjection getProjection() {
|
253 |
return CRSFactory.getCRS(projectionText.getText());
|
254 |
} |
255 |
} |