Revision 43891 branches/org.gvsig.desktop-2018a/org.gvsig.desktop.plugin/org.gvsig.geodb.app/org.gvsig.geodb.app.mainplugin/src/main/java/org/gvsig/geodb/vectorialdb/wizard/UserTableSettingsVectorialPanel.java
UserTableSettingsVectorialPanel.java | ||
---|---|---|
21 | 21 |
* For any additional information, do not hesitate to contact us |
22 | 22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
23 | 23 |
*/ |
24 |
|
|
25 | 24 |
package org.gvsig.geodb.vectorialdb.wizard; |
26 | 25 |
|
27 | 26 |
import java.awt.Insets; |
... | ... | |
56 | 55 |
import org.gvsig.fmap.mapcontrol.MapControl; |
57 | 56 |
import org.gvsig.i18n.Messages; |
58 | 57 |
|
58 |
public class UserTableSettingsVectorialPanel extends UserTableSettingsPanel { |
|
59 | 59 |
|
60 |
public class UserTableSettingsVectorialPanel extends UserTableSettingsPanel { |
|
61 | 60 |
private static Logger logger = LoggerFactory |
62 |
.getLogger(UserTableSettingsPanel.class.getName());
|
|
61 |
.getLogger(UserTableSettingsPanel.class.getName());
|
|
63 | 62 |
|
64 | 63 |
private FieldComboItem[] geos; |
65 |
private JComboBox geomComboBox = null;
|
|
64 |
private JComboBox geomComboBox = null;
|
|
66 | 65 |
private JLabel geomLabel = null; |
67 |
private JLabel waLabel = null;
|
|
68 |
private JLabel topLabel = null;
|
|
69 |
private JTextField topTextField = null;
|
|
70 |
private JTextField bottomTextField = null;
|
|
71 |
private JTextField rightTextField = null;
|
|
72 |
private JTextField leftTextField = null;
|
|
73 |
private JLabel bottomLabel = null;
|
|
74 |
private JLabel rightLabel = null;
|
|
75 |
private JLabel leftLabel = null;
|
|
76 |
private JButton getviewButton = null;
|
|
77 |
private JCheckBox activateWACheckBox = null;
|
|
66 |
private JLabel waLabel = null;
|
|
67 |
private JLabel topLabel = null;
|
|
68 |
private JTextField topTextField = null;
|
|
69 |
private JTextField bottomTextField = null;
|
|
70 |
private JTextField rightTextField = null;
|
|
71 |
private JTextField leftTextField = null;
|
|
72 |
private JLabel bottomLabel = null;
|
|
73 |
private JLabel rightLabel = null;
|
|
74 |
private JLabel leftLabel = null;
|
|
75 |
private JButton getviewButton = null;
|
|
76 |
private JCheckBox activateWACheckBox = null;
|
|
78 | 77 |
private MapControl mControl = null; |
79 |
private CRSSelectPanel panelProj;
|
|
80 |
|
|
78 |
private CRSSelectPanel panelProj;
|
|
79 |
|
|
81 | 80 |
private IProjection proposedProjection = null; |
82 | 81 |
// private IProjection currentProj; |
83 |
|
|
84 |
private JPanel this_panel = null; |
|
85 | 82 |
|
83 |
private JPanel this_panel = null; |
|
84 |
|
|
86 | 85 |
public UserTableSettingsVectorialPanel(FieldComboItem[] idComboItems, |
87 |
FieldComboItem[] geoComboItems, String initialLayerName, |
|
88 |
MapControl mapc, boolean empty, WizardVectorialDB _p, |
|
89 |
DBStoreParameters parameters, |
|
90 |
IProjection proposed_proj) { |
|
91 |
super(); |
|
92 |
|
|
93 |
this_panel = this; |
|
94 |
setInitValues(idComboItems, initialLayerName, empty, _p, parameters); |
|
86 |
FieldComboItem[] geoComboItems, String initialLayerName, |
|
87 |
MapControl mapc, boolean empty, WizardVectorialDB _p, |
|
88 |
DBStoreParameters parameters, |
|
89 |
IProjection proposed_proj) { |
|
90 |
super(); |
|
95 | 91 |
|
92 |
this_panel = this; |
|
93 |
setInitValues(idComboItems, initialLayerName, empty, _p, parameters); |
|
94 |
|
|
96 | 95 |
mControl = mapc; |
97 |
geos = geoComboItems;
|
|
98 |
proposedProjection = proposed_proj;
|
|
99 |
initialize(empty);
|
|
100 |
}
|
|
96 |
geos = geoComboItems;
|
|
97 |
proposedProjection = proposed_proj;
|
|
98 |
initialize(empty);
|
|
99 |
}
|
|
101 | 100 |
|
102 | 101 |
protected void initialize(boolean _empty) { |
103 |
super.initialize(_empty);
|
|
102 |
super.initialize(_empty);
|
|
104 | 103 |
setBorder(javax.swing.BorderFactory.createTitledBorder(null, |
105 |
PluginServices.getText(this, "_Table_settings"),
|
|
106 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
|
107 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
|
108 |
leftLabel = new JLabel();
|
|
109 |
// leftLabel.setBounds(new java.awt.Rectangle(375, 175, 111, 16));
|
|
110 |
leftLabel.setBounds(new java.awt.Rectangle(80+70, 200, 70, 16));
|
|
111 |
leftLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
|
|
112 |
leftLabel.setText(PluginServices.getText(this, "xmin"));
|
|
113 |
rightLabel = new JLabel();
|
|
114 |
rightLabel.setBounds(new java.awt.Rectangle(75+150, 200, 70, 16));
|
|
115 |
rightLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
|
|
116 |
rightLabel.setText(PluginServices.getText(this, "xmax"));
|
|
117 |
bottomLabel = new JLabel();
|
|
118 |
bottomLabel.setBounds(new java.awt.Rectangle(70+230, 200, 70, 16));
|
|
119 |
bottomLabel
|
|
120 |
.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
|
|
121 |
bottomLabel.setText(PluginServices.getText(this, "ymin"));
|
|
122 |
topLabel = new JLabel();
|
|
123 |
topLabel.setBounds(new java.awt.Rectangle(65+310, 200, 70, 16));
|
|
124 |
topLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
|
|
125 |
topLabel.setText(PluginServices.getText(this, "ymax"));
|
|
126 |
waLabel = new JLabel();
|
|
127 |
// waLabel.setBounds(new java.awt.Rectangle(40, 145, 131, 21));
|
|
128 |
waLabel.setBounds(new java.awt.Rectangle(30, 215, 125, 21));
|
|
129 |
waLabel.setText(PluginServices.getText(this, "_Working_area"));
|
|
130 |
geomLabel = new JLabel();
|
|
131 |
// geomLabel.setBounds(new java.awt.Rectangle(240, 55, 111, 21));
|
|
132 |
geomLabel.setBounds(new java.awt.Rectangle(8, 140, 160, 21));
|
|
133 |
geomLabel.setText(PluginServices.getText(this, "_Geo_field"));
|
|
104 |
PluginServices.getText(this, "_Table_settings"),
|
|
105 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
|
|
106 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
|
107 |
leftLabel = new JLabel();
|
|
108 |
// leftLabel.setBounds(new java.awt.Rectangle(375, 175, 111, 16));
|
|
109 |
leftLabel.setBounds(new java.awt.Rectangle(80 + 70, 200, 70, 16));
|
|
110 |
leftLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
|
|
111 |
leftLabel.setText(PluginServices.getText(this, "xmin"));
|
|
112 |
rightLabel = new JLabel();
|
|
113 |
rightLabel.setBounds(new java.awt.Rectangle(75 + 150, 200, 70, 16));
|
|
114 |
rightLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
|
|
115 |
rightLabel.setText(PluginServices.getText(this, "xmax"));
|
|
116 |
bottomLabel = new JLabel();
|
|
117 |
bottomLabel.setBounds(new java.awt.Rectangle(70 + 230, 200, 70, 16));
|
|
118 |
bottomLabel
|
|
119 |
.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
|
|
120 |
bottomLabel.setText(PluginServices.getText(this, "ymin"));
|
|
121 |
topLabel = new JLabel();
|
|
122 |
topLabel.setBounds(new java.awt.Rectangle(65 + 310, 200, 70, 16));
|
|
123 |
topLabel.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
|
|
124 |
topLabel.setText(PluginServices.getText(this, "ymax"));
|
|
125 |
waLabel = new JLabel();
|
|
126 |
// waLabel.setBounds(new java.awt.Rectangle(40, 145, 131, 21));
|
|
127 |
waLabel.setBounds(new java.awt.Rectangle(30, 215, 125, 21));
|
|
128 |
waLabel.setText(PluginServices.getText(this, "_Working_area"));
|
|
129 |
geomLabel = new JLabel();
|
|
130 |
// geomLabel.setBounds(new java.awt.Rectangle(240, 55, 111, 21));
|
|
131 |
geomLabel.setBounds(new java.awt.Rectangle(8, 140, 160, 21));
|
|
132 |
geomLabel.setText(PluginServices.getText(this, "_Geo_field"));
|
|
134 | 133 |
|
135 |
add(getGeomComboBox(), null);
|
|
136 |
add(geomLabel, null);
|
|
137 |
add(waLabel, null);
|
|
138 |
add(topLabel, null);
|
|
139 |
add(getTopTextField(), null);
|
|
140 |
add(getBottomTextField(), null);
|
|
141 |
add(getRightTextField(), null);
|
|
142 |
add(getLeftTextField(), null);
|
|
143 |
add(bottomLabel, null);
|
|
144 |
add(rightLabel, null);
|
|
145 |
add(leftLabel, null);
|
|
146 |
add(getGetviewButton(), null);
|
|
147 |
add(getActivateWACheckBox(), null);
|
|
148 |
loadValues(_empty);
|
|
149 |
}
|
|
134 |
add(getGeomComboBox(), null);
|
|
135 |
add(geomLabel, null);
|
|
136 |
add(waLabel, null);
|
|
137 |
add(topLabel, null);
|
|
138 |
add(getTopTextField(), null);
|
|
139 |
add(getBottomTextField(), null);
|
|
140 |
add(getRightTextField(), null);
|
|
141 |
add(getLeftTextField(), null);
|
|
142 |
add(bottomLabel, null);
|
|
143 |
add(rightLabel, null);
|
|
144 |
add(leftLabel, null);
|
|
145 |
add(getGetviewButton(), null);
|
|
146 |
add(getActivateWACheckBox(), null);
|
|
147 |
loadValues(_empty);
|
|
148 |
}
|
|
150 | 149 |
|
151 | 150 |
private CRSSelectPanel getJPanelProj(IProjection pro) { |
152 |
if (panelProj == null) {
|
|
153 |
panelProj = CRSSelectPanel.getPanel(pro);
|
|
151 |
if (panelProj == null) {
|
|
152 |
panelProj = CRSSelectPanel.getPanel(pro);
|
|
154 | 153 |
|
155 |
panelProj.setTransPanelActive(true); |
|
156 |
panelProj.setBounds(8, 165, 477, 21); |
|
157 |
panelProj.addActionListener(new java.awt.event.ActionListener() { |
|
158 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
159 |
if (panelProj.isOkPressed()) { |
|
160 |
AddLayerDialog |
|
161 |
.setLastProjection(panelProj.getCurProj()); |
|
162 |
} |
|
163 |
} |
|
164 |
}); |
|
165 |
} |
|
166 |
return panelProj; |
|
167 |
} |
|
154 |
panelProj.setTransPanelActive(true); |
|
155 |
panelProj.setBounds(8, 165, 477, 21); |
|
156 |
// panelProj.addActionListener(new java.awt.event.ActionListener() { |
|
157 |
// public void actionPerformed(java.awt.event.ActionEvent e) { |
|
158 |
// if (panelProj.isOkPressed()) { |
|
159 |
// AddLayerDialog.setLastProjection(panelProj.getCurProj()); |
|
160 |
// } |
|
161 |
// } |
|
162 |
// }); |
|
163 |
} |
|
164 |
return panelProj; |
|
165 |
} |
|
168 | 166 |
|
169 |
|
|
170 | 167 |
public boolean hasValidValues() { |
171 |
if (!super.hasValidValues()) {
|
|
172 |
return false;
|
|
173 |
}
|
|
168 |
if (!super.hasValidValues()) {
|
|
169 |
return false;
|
|
170 |
}
|
|
174 | 171 |
|
175 |
if ((activateWACheckBox.isSelected()) && (getWorkingArea() == null)) {
|
|
176 |
return false;
|
|
177 |
}
|
|
172 |
if ((activateWACheckBox.isSelected()) && (getWorkingArea() == null)) {
|
|
173 |
return false;
|
|
174 |
}
|
|
178 | 175 |
|
179 |
return true;
|
|
180 |
}
|
|
176 |
return true;
|
|
177 |
}
|
|
181 | 178 |
|
182 | 179 |
private JComboBox getGeomComboBox() { |
183 |
if (geomComboBox == null) {
|
|
184 |
geomComboBox = new JComboBox();
|
|
185 |
// geomComboBox.setBounds(new java.awt.Rectangle(355, 55, 131, 21));
|
|
186 |
geomComboBox.setBounds(new java.awt.Rectangle(150, 140, 335, 21));
|
|
187 |
geomComboBox.addActionListener(new ActionListener() {
|
|
180 |
if (geomComboBox == null) {
|
|
181 |
geomComboBox = new JComboBox();
|
|
182 |
// geomComboBox.setBounds(new java.awt.Rectangle(355, 55, 131, 21));
|
|
183 |
geomComboBox.setBounds(new java.awt.Rectangle(150, 140, 335, 21));
|
|
184 |
geomComboBox.addActionListener(new ActionListener() {
|
|
188 | 185 |
public void actionPerformed(ActionEvent e) { |
189 |
|
|
186 |
|
|
190 | 187 |
if (panelProj == null) { |
191 | 188 |
return; |
192 | 189 |
} |
... | ... | |
195 | 192 |
* SRS chooser |
196 | 193 |
*/ |
197 | 194 |
FieldComboItem fci = (FieldComboItem) geomComboBox.getSelectedItem(); |
198 |
|
|
195 |
|
|
199 | 196 |
if (fci == null) { |
200 | 197 |
return; |
201 | 198 |
} |
202 |
|
|
199 |
|
|
203 | 200 |
IProjection iproj = fci.getProjection(); |
204 | 201 |
if (iproj != null) { |
205 | 202 |
/* |
... | ... | |
210 | 207 |
add(getJPanelProj(iproj), null); |
211 | 208 |
} |
212 | 209 |
} |
213 |
});
|
|
214 |
}
|
|
210 |
});
|
|
211 |
}
|
|
215 | 212 |
|
216 |
return geomComboBox;
|
|
217 |
}
|
|
213 |
return geomComboBox;
|
|
214 |
}
|
|
218 | 215 |
|
219 |
private JTextField getTopTextField() {
|
|
220 |
if (topTextField == null) {
|
|
221 |
topTextField = new JTextField();
|
|
222 |
topTextField.addKeyListener(this);
|
|
223 |
// topTextField.setBounds(new java.awt.Rectangle(15, 190, 111, 21));
|
|
224 |
topTextField.setBounds(new java.awt.Rectangle(65+310, 215, 70, 21));
|
|
225 |
}
|
|
216 |
private JTextField getTopTextField() {
|
|
217 |
if (topTextField == null) {
|
|
218 |
topTextField = new JTextField();
|
|
219 |
topTextField.addKeyListener(this);
|
|
220 |
// topTextField.setBounds(new java.awt.Rectangle(15, 190, 111, 21));
|
|
221 |
topTextField.setBounds(new java.awt.Rectangle(65 + 310, 215, 70, 21));
|
|
222 |
}
|
|
226 | 223 |
|
227 |
return topTextField;
|
|
228 |
}
|
|
224 |
return topTextField;
|
|
225 |
}
|
|
229 | 226 |
|
230 |
private JTextField getBottomTextField() {
|
|
231 |
if (bottomTextField == null) {
|
|
232 |
bottomTextField = new JTextField();
|
|
233 |
bottomTextField.addKeyListener(this);
|
|
234 |
bottomTextField
|
|
235 |
.setBounds(new java.awt.Rectangle(70+230, 215, 70, 21));
|
|
236 |
}
|
|
227 |
private JTextField getBottomTextField() {
|
|
228 |
if (bottomTextField == null) {
|
|
229 |
bottomTextField = new JTextField();
|
|
230 |
bottomTextField.addKeyListener(this);
|
|
231 |
bottomTextField
|
|
232 |
.setBounds(new java.awt.Rectangle(70 + 230, 215, 70, 21));
|
|
233 |
}
|
|
237 | 234 |
|
238 |
return bottomTextField;
|
|
239 |
}
|
|
235 |
return bottomTextField;
|
|
236 |
}
|
|
240 | 237 |
|
241 |
private JTextField getRightTextField() {
|
|
242 |
if (rightTextField == null) {
|
|
243 |
rightTextField = new JTextField();
|
|
244 |
rightTextField.addKeyListener(this);
|
|
245 |
rightTextField.setBounds(new java.awt.Rectangle(75+150, 215, 70, 21));
|
|
246 |
}
|
|
238 |
private JTextField getRightTextField() {
|
|
239 |
if (rightTextField == null) {
|
|
240 |
rightTextField = new JTextField();
|
|
241 |
rightTextField.addKeyListener(this);
|
|
242 |
rightTextField.setBounds(new java.awt.Rectangle(75 + 150, 215, 70, 21));
|
|
243 |
}
|
|
247 | 244 |
|
248 |
return rightTextField;
|
|
249 |
}
|
|
245 |
return rightTextField;
|
|
246 |
}
|
|
250 | 247 |
|
251 |
private JTextField getLeftTextField() {
|
|
252 |
if (leftTextField == null) {
|
|
253 |
leftTextField = new JTextField();
|
|
254 |
leftTextField.addKeyListener(this);
|
|
255 |
leftTextField.setBounds(new java.awt.Rectangle(80+70, 215, 70, 21));
|
|
256 |
}
|
|
248 |
private JTextField getLeftTextField() {
|
|
249 |
if (leftTextField == null) {
|
|
250 |
leftTextField = new JTextField();
|
|
251 |
leftTextField.addKeyListener(this);
|
|
252 |
leftTextField.setBounds(new java.awt.Rectangle(80 + 70, 215, 70, 21));
|
|
253 |
}
|
|
257 | 254 |
|
258 |
return leftTextField;
|
|
259 |
}
|
|
255 |
return leftTextField;
|
|
256 |
}
|
|
260 | 257 |
|
261 |
private JButton getGetviewButton() {
|
|
262 |
if (getviewButton == null) {
|
|
263 |
getviewButton = new org.gvsig.gui.beans.swing.JButton();
|
|
264 |
getviewButton.addActionListener(this);
|
|
265 |
//getviewButton.setBounds(new java.awt.Rectangle(195, 145, 111, 26));
|
|
266 |
getviewButton.setBounds(new java.awt.Rectangle(455, 205, 31, 31));
|
|
267 |
ImageIcon ii = IconThemeHelper.getImageIcon("geodb-get-view-extent");
|
|
258 |
private JButton getGetviewButton() {
|
|
259 |
if (getviewButton == null) {
|
|
260 |
getviewButton = new org.gvsig.gui.beans.swing.JButton();
|
|
261 |
getviewButton.addActionListener(this);
|
|
262 |
//getviewButton.setBounds(new java.awt.Rectangle(195, 145, 111, 26));
|
|
263 |
getviewButton.setBounds(new java.awt.Rectangle(455, 205, 31, 31));
|
|
264 |
ImageIcon ii = IconThemeHelper.getImageIcon("geodb-get-view-extent"); |
|
268 | 265 |
// ImageIcon ii = IconThemeHelper.getImageIcon("geodb-connection-add"); |
269 |
|
|
270 |
getviewButton.setMargin(new Insets(1,1,1,1)); |
|
271 |
getviewButton.setIcon(ii); |
|
272 |
getviewButton.setToolTipText( |
|
273 |
Messages.getText("_Get_view_extent")); |
|
274 |
getviewButton.setEnabled(false); |
|
275 |
} |
|
276 | 266 |
|
277 |
return getviewButton; |
|
278 |
} |
|
267 |
getviewButton.setMargin(new Insets(1, 1, 1, 1)); |
|
268 |
getviewButton.setIcon(ii); |
|
269 |
getviewButton.setToolTipText( |
|
270 |
Messages.getText("_Get_view_extent")); |
|
271 |
getviewButton.setEnabled(false); |
|
272 |
} |
|
279 | 273 |
|
280 |
private JCheckBox getActivateWACheckBox() { |
|
281 |
if (activateWACheckBox == null) { |
|
282 |
activateWACheckBox = new JCheckBox(); |
|
283 |
activateWACheckBox.addActionListener(this); |
|
274 |
return getviewButton; |
|
275 |
} |
|
276 |
|
|
277 |
private JCheckBox getActivateWACheckBox() { |
|
278 |
if (activateWACheckBox == null) { |
|
279 |
activateWACheckBox = new JCheckBox(); |
|
280 |
activateWACheckBox.addActionListener(this); |
|
284 | 281 |
// activateWACheckBox |
285 | 282 |
// .setBounds(new java.awt.Rectangle(15, 145, 21, 21)); |
286 |
activateWACheckBox
|
|
287 |
.setBounds(new java.awt.Rectangle(5, 215, 21, 21));
|
|
283 |
activateWACheckBox
|
|
284 |
.setBounds(new java.awt.Rectangle(5, 215, 21, 21));
|
|
288 | 285 |
|
289 |
}
|
|
286 |
}
|
|
290 | 287 |
|
291 |
return activateWACheckBox;
|
|
292 |
}
|
|
288 |
return activateWACheckBox;
|
|
289 |
}
|
|
293 | 290 |
|
294 |
protected void loadValues(boolean is_empty) {
|
|
295 |
super.loadValues(is_empty);
|
|
296 |
if (is_empty) {
|
|
297 |
enableAlphaControls(false);
|
|
298 |
enableSpatialControls(false);
|
|
299 |
getActivateWACheckBox().setSelected(false);
|
|
300 |
} else {
|
|
301 |
enableAlphaControls(true);
|
|
302 |
enableSpatialControls(true);
|
|
291 |
protected void loadValues(boolean is_empty) { |
|
292 |
super.loadValues(is_empty);
|
|
293 |
if (is_empty) {
|
|
294 |
enableAlphaControls(false);
|
|
295 |
enableSpatialControls(false);
|
|
296 |
getActivateWACheckBox().setSelected(false);
|
|
297 |
} else {
|
|
298 |
enableAlphaControls(true);
|
|
299 |
enableSpatialControls(true);
|
|
303 | 300 |
|
304 |
getGeomComboBox().removeAllItems();
|
|
301 |
getGeomComboBox().removeAllItems();
|
|
305 | 302 |
|
306 |
for (int i = 0; i < geos.length; i++) {
|
|
307 |
getGeomComboBox().addItem(geos[i]);
|
|
308 |
}
|
|
309 |
add(getJPanelProj(proposedProjection), null);
|
|
310 |
}
|
|
311 |
}
|
|
303 |
for (int i = 0; i < geos.length; i++) {
|
|
304 |
getGeomComboBox().addItem(geos[i]);
|
|
305 |
}
|
|
306 |
add(getJPanelProj(proposedProjection), null);
|
|
307 |
}
|
|
308 |
}
|
|
312 | 309 |
|
313 | 310 |
public void enableSpatialControls(boolean enable) { |
314 |
super.enableSpatialControls(enable);
|
|
315 |
getGeomComboBox().setEnabled(enable);
|
|
311 |
super.enableSpatialControls(enable);
|
|
312 |
getGeomComboBox().setEnabled(enable);
|
|
316 | 313 |
|
317 |
getActivateWACheckBox().setEnabled(enable);
|
|
314 |
getActivateWACheckBox().setEnabled(enable);
|
|
318 | 315 |
|
319 |
boolean there_is_view = ((mControl != null) &&
|
|
320 |
(mControl.getViewPort().getAdjustedEnvelope() != null));
|
|
316 |
boolean there_is_view = ((mControl != null)
|
|
317 |
&& (mControl.getViewPort().getAdjustedEnvelope() != null));
|
|
321 | 318 |
|
322 |
getGetviewButton().setEnabled(enable && there_is_view);
|
|
323 |
getTopTextField().setEnabled(enable);
|
|
324 |
getBottomTextField().setEnabled(enable);
|
|
325 |
getRightTextField().setEnabled(enable);
|
|
326 |
getLeftTextField().setEnabled(enable);
|
|
327 |
}
|
|
319 |
getGetviewButton().setEnabled(enable && there_is_view);
|
|
320 |
getTopTextField().setEnabled(enable);
|
|
321 |
getBottomTextField().setEnabled(enable);
|
|
322 |
getRightTextField().setEnabled(enable);
|
|
323 |
getLeftTextField().setEnabled(enable);
|
|
324 |
}
|
|
328 | 325 |
|
329 | 326 |
public void actionPerformed(ActionEvent e) { |
330 |
super.actionPerformed(e);
|
|
331 |
Object src = e.getSource();
|
|
327 |
super.actionPerformed(e);
|
|
328 |
Object src = e.getSource();
|
|
332 | 329 |
|
333 | 330 |
if (src == getviewButton) { |
334 |
getViewIntoFourBounds();
|
|
335 |
parent.checkFinishable();
|
|
336 |
}
|
|
331 |
getViewIntoFourBounds();
|
|
332 |
parent.checkFinishable();
|
|
333 |
}
|
|
337 | 334 |
|
338 |
if (src == activateWACheckBox) {
|
|
339 |
enableWASettings(activateWACheckBox.isSelected());
|
|
340 |
parent.checkFinishable();
|
|
341 |
}
|
|
342 |
}
|
|
335 |
if (src == activateWACheckBox) {
|
|
336 |
enableWASettings(activateWACheckBox.isSelected());
|
|
337 |
parent.checkFinishable();
|
|
338 |
}
|
|
339 |
}
|
|
343 | 340 |
|
344 | 341 |
private void enableWASettings(boolean b) { |
345 |
getviewButton.setEnabled(b
|
|
346 |
&& (mControl.getViewPort().getAdjustedEnvelope() != null));
|
|
347 |
rightTextField.setEnabled(b);
|
|
348 |
leftTextField.setEnabled(b);
|
|
349 |
topTextField.setEnabled(b);
|
|
350 |
bottomTextField.setEnabled(b);
|
|
351 |
}
|
|
342 |
getviewButton.setEnabled(b
|
|
343 |
&& (mControl.getViewPort().getAdjustedEnvelope() != null));
|
|
344 |
rightTextField.setEnabled(b);
|
|
345 |
leftTextField.setEnabled(b);
|
|
346 |
topTextField.setEnabled(b);
|
|
347 |
bottomTextField.setEnabled(b);
|
|
348 |
}
|
|
352 | 349 |
|
353 | 350 |
private void getViewIntoFourBounds() { |
354 |
Envelope rect = mControl.getViewPort().getAdjustedEnvelope();
|
|
355 |
|
|
356 |
IProjection viewProj = mControl.getViewPort().getProjection();
|
|
357 |
IProjection srcProj = this.getProjection();
|
|
358 |
if (viewProj == null || srcProj == null) {
|
|
359 |
messageDialog(Messages.getText(
|
|
360 |
"_Unable_to_reproject_viewport_Default_bounds_used"),
|
|
361 |
JOptionPane.WARNING_MESSAGE);
|
|
362 |
setLargeArea(srcProj);
|
|
363 |
} else {
|
|
364 |
try {
|
|
365 |
ICoordTrans ct = null;
|
|
366 |
if (viewProj.getAbrev().compareToIgnoreCase(
|
|
367 |
srcProj.getAbrev()) != 0) {
|
|
368 |
/*
|
|
351 |
Envelope rect = mControl.getViewPort().getAdjustedEnvelope();
|
|
352 |
|
|
353 |
IProjection viewProj = mControl.getViewPort().getProjection();
|
|
354 |
IProjection srcProj = this.getProjection();
|
|
355 |
if (viewProj == null || srcProj == null) {
|
|
356 |
messageDialog(Messages.getText(
|
|
357 |
"_Unable_to_reproject_viewport_Default_bounds_used"),
|
|
358 |
JOptionPane.WARNING_MESSAGE);
|
|
359 |
setLargeArea(srcProj);
|
|
360 |
} else {
|
|
361 |
try {
|
|
362 |
ICoordTrans ct = null;
|
|
363 |
if (viewProj.getAbrev().compareToIgnoreCase(
|
|
364 |
srcProj.getAbrev()) != 0) {
|
|
365 |
/*
|
|
369 | 366 |
* Reprojection needed |
370 |
*/ |
|
371 |
ct = viewProj.getCT(srcProj); |
|
372 |
rect = rect.convert(ct); |
|
373 |
} |
|
374 |
topTextField.setText(getFormattedDouble(rect.getMaximum(1))); |
|
375 |
bottomTextField.setText(getFormattedDouble(rect.getMinimum(1))); |
|
376 |
rightTextField.setText(getFormattedDouble(rect.getMaximum(0))); |
|
377 |
leftTextField.setText(getFormattedDouble(rect.getMinimum(0))); |
|
378 |
if (ct != null) { |
|
379 |
messageDialog(Messages.getText( |
|
380 |
"_Viewport_bounds_reprojected_to_datasource_CRS"), |
|
381 |
JOptionPane.WARNING_MESSAGE); |
|
382 |
} |
|
383 |
} catch (Exception exc) { |
|
384 |
messageDialog(Messages.getText( |
|
385 |
"_Unable_to_reproject_viewport_Default_bounds_used"), |
|
386 |
JOptionPane.WARNING_MESSAGE); |
|
387 |
setLargeArea(srcProj); |
|
388 |
} |
|
389 |
} |
|
390 |
|
|
391 |
} |
|
367 |
*/ |
|
368 |
ct = viewProj.getCT(srcProj); |
|
369 |
rect = rect.convert(ct); |
|
370 |
} |
|
371 |
topTextField.setText(getFormattedDouble(rect.getMaximum(1))); |
|
372 |
bottomTextField.setText(getFormattedDouble(rect.getMinimum(1))); |
|
373 |
rightTextField.setText(getFormattedDouble(rect.getMaximum(0))); |
|
374 |
leftTextField.setText(getFormattedDouble(rect.getMinimum(0))); |
|
375 |
if (ct != null) { |
|
376 |
messageDialog(Messages.getText( |
|
377 |
"_Viewport_bounds_reprojected_to_datasource_CRS"), |
|
378 |
JOptionPane.WARNING_MESSAGE); |
|
379 |
} |
|
380 |
} catch (Exception exc) { |
|
381 |
messageDialog(Messages.getText( |
|
382 |
"_Unable_to_reproject_viewport_Default_bounds_used"), |
|
383 |
JOptionPane.WARNING_MESSAGE); |
|
384 |
setLargeArea(srcProj); |
|
385 |
} |
|
386 |
} |
|
392 | 387 |
|
388 |
} |
|
389 |
|
|
393 | 390 |
private void setLargeArea(IProjection proj) { |
394 |
|
|
391 |
|
|
395 | 392 |
if (proj == null || proj.isProjected()) { |
396 | 393 |
topTextField.setText(getFormattedDouble(20000000d)); |
397 | 394 |
bottomTextField.setText(getFormattedDouble(-20000000d)); |
... | ... | |
406 | 403 |
} |
407 | 404 |
|
408 | 405 |
private void messageDialog(String msg, int msgType) { |
409 |
|
|
406 |
|
|
410 | 407 |
JOptionPane.showMessageDialog( |
411 |
ApplicationLocator.getManager().getRootComponent(), |
|
412 |
msg, |
|
413 |
Messages.getText("_Working_area"), |
|
414 |
msgType); |
|
408 |
ApplicationLocator.getManager().getRootComponent(),
|
|
409 |
msg,
|
|
410 |
Messages.getText("_Working_area"),
|
|
411 |
msgType);
|
|
415 | 412 |
} |
416 | 413 |
|
417 | 414 |
public Envelope getWorkingArea() { |
418 |
if (!activateWACheckBox.isSelected()) {
|
|
419 |
return null;
|
|
420 |
}
|
|
415 |
if (!activateWACheckBox.isSelected()) {
|
|
416 |
return null;
|
|
417 |
}
|
|
421 | 418 |
|
422 |
double maxx;
|
|
423 |
double maxy;
|
|
424 |
double minx;
|
|
425 |
double miny;
|
|
419 |
double maxx;
|
|
420 |
double maxy;
|
|
421 |
double minx;
|
|
422 |
double miny;
|
|
426 | 423 |
|
427 |
try {
|
|
428 |
maxx = Double.parseDouble(rightTextField.getText());
|
|
429 |
miny = Double.parseDouble(bottomTextField.getText());
|
|
430 |
minx = Double.parseDouble(leftTextField.getText());
|
|
431 |
maxy = Double.parseDouble(topTextField.getText());
|
|
432 |
} catch (NumberFormatException nfe) {
|
|
433 |
logger.info("Not valid value in working area: " + nfe.getMessage());
|
|
434 |
return null;
|
|
435 |
}
|
|
436 |
GeometryManager geoMan = GeometryLocator.getGeometryManager();
|
|
424 |
try {
|
|
425 |
maxx = Double.parseDouble(rightTextField.getText());
|
|
426 |
miny = Double.parseDouble(bottomTextField.getText());
|
|
427 |
minx = Double.parseDouble(leftTextField.getText());
|
|
428 |
maxy = Double.parseDouble(topTextField.getText());
|
|
429 |
} catch (NumberFormatException nfe) {
|
|
430 |
logger.info("Not valid value in working area: " + nfe.getMessage());
|
|
431 |
return null;
|
|
432 |
}
|
|
433 |
GeometryManager geoMan = GeometryLocator.getGeometryManager();
|
|
437 | 434 |
|
438 |
try {
|
|
439 |
return geoMan.createEnvelope(minx, miny, maxx, maxy,
|
|
440 |
SUBTYPES.GEOM2D);
|
|
441 |
} catch (CreateEnvelopeException e) {
|
|
442 |
// FIXME Exception
|
|
443 |
throw new RuntimeException(e);
|
|
444 |
}
|
|
445 |
}
|
|
435 |
try {
|
|
436 |
return geoMan.createEnvelope(minx, miny, maxx, maxy,
|
|
437 |
SUBTYPES.GEOM2D);
|
|
438 |
} catch (CreateEnvelopeException e) {
|
|
439 |
// FIXME Exception
|
|
440 |
throw new RuntimeException(e);
|
|
441 |
}
|
|
442 |
}
|
|
446 | 443 |
|
447 | 444 |
public boolean combosHaveItems() { |
448 |
if (!super.combosHaveItems()) {
|
|
449 |
return false;
|
|
450 |
}
|
|
445 |
if (!super.combosHaveItems()) {
|
|
446 |
return false;
|
|
447 |
}
|
|
451 | 448 |
|
452 |
if (getGeomComboBox().getItemCount() == 0) {
|
|
453 |
return false;
|
|
454 |
}
|
|
449 |
if (getGeomComboBox().getItemCount() == 0) {
|
|
450 |
return false;
|
|
451 |
}
|
|
455 | 452 |
|
456 |
return true;
|
|
457 |
}
|
|
453 |
return true;
|
|
454 |
}
|
|
458 | 455 |
|
459 | 456 |
public void repaint() { |
460 |
super.repaint();
|
|
461 |
getGeomComboBox().updateUI();
|
|
462 |
}
|
|
457 |
super.repaint();
|
|
458 |
getGeomComboBox().updateUI();
|
|
459 |
}
|
|
463 | 460 |
|
464 | 461 |
public String getGeoFieldName() { |
465 |
if (getGeomComboBox().getSelectedItem() == null) { |
|
466 |
return null; |
|
467 |
} |
|
468 |
return getGeomComboBox().getSelectedItem().toString(); |
|
469 |
} |
|
462 |
if (getGeomComboBox().getSelectedItem() == null) { |
|
463 |
return null; |
|
464 |
} |
|
465 |
return getGeomComboBox().getSelectedItem().toString(); |
|
466 |
} |
|
467 |
|
|
470 | 468 |
public IProjection getProjection() { |
471 |
return panelProj.getCurProj();
|
|
472 |
}
|
|
469 |
return panelProj.getCurProj();
|
|
470 |
}
|
|
473 | 471 |
|
472 |
public ICoordTrans getCoordTrans() { |
|
473 |
// TODO: Implementar con el nuevo API |
|
474 |
return null; |
|
475 |
} |
|
476 |
|
|
474 | 477 |
} |
Also available in: Unified diff