svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / legend / gui / General.java @ 40558
History | View | Annotate | Download (26.9 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.project.documents.view.legend.gui; |
25 |
|
26 |
import java.awt.BorderLayout; |
27 |
import java.awt.ComponentOrientation; |
28 |
import java.awt.Dimension; |
29 |
import java.awt.FlowLayout; |
30 |
import java.awt.GridLayout; |
31 |
import java.awt.SystemColor; |
32 |
import java.awt.event.ActionEvent; |
33 |
import java.awt.event.ActionListener; |
34 |
import java.text.NumberFormat; |
35 |
import java.text.ParseException; |
36 |
|
37 |
import javax.swing.BorderFactory; |
38 |
import javax.swing.ButtonGroup; |
39 |
import javax.swing.JCheckBox; |
40 |
import javax.swing.JLabel; |
41 |
import javax.swing.JPanel; |
42 |
import javax.swing.JRadioButton; |
43 |
import javax.swing.JScrollPane; |
44 |
import javax.swing.JTextArea; |
45 |
import javax.swing.JTextField; |
46 |
import javax.swing.border.BevelBorder; |
47 |
import javax.swing.border.EtchedBorder; |
48 |
import javax.swing.border.TitledBorder; |
49 |
|
50 |
import org.cresques.cts.ICoordTrans; |
51 |
import org.cresques.cts.IProjection; |
52 |
import org.gvsig.andami.PluginServices; |
53 |
import org.gvsig.andami.messages.NotificationManager; |
54 |
import org.gvsig.fmap.dal.DataStoreParameters; |
55 |
import org.gvsig.fmap.dal.exception.DataException; |
56 |
import org.gvsig.fmap.dal.exception.ReadException; |
57 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
58 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
59 |
import org.gvsig.fmap.geom.primitive.Envelope; |
60 |
import org.gvsig.fmap.geom.type.GeometryType; |
61 |
import org.gvsig.fmap.geom.type.GeometryTypeNotSupportedException; |
62 |
import org.gvsig.fmap.geom.type.GeometryTypeNotValidException; |
63 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
64 |
import org.gvsig.fmap.mapcontext.layers.FLyrDefault; |
65 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
66 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
67 |
import org.gvsig.gui.beans.swing.JBlank; |
68 |
import org.gvsig.tools.locator.LocatorException; |
69 |
|
70 |
|
71 |
|
72 |
|
73 |
/**
|
74 |
* This class implements an useful and intuitive graphic interface to change some
|
75 |
* properties of the layer. This class extends AbstractThemeManager. The properties
|
76 |
* that allow modified are the name of the layer, the scale, if the user want to use
|
77 |
* Spatial index or not and the HyperLink. Also shows a scroll with a little resume
|
78 |
* with the properties of the layer.
|
79 |
* @author jmorell
|
80 |
*
|
81 |
* TODO To change the template for this generated type comment go to
|
82 |
* Window - Preferences - Java - Code Style - Code Templates
|
83 |
*/
|
84 |
public class General extends AbstractThemeManagerPage { |
85 |
|
86 |
private static final long serialVersionUID = 1L; |
87 |
private FLayer layer;
|
88 |
private NumberFormat nf = NumberFormat.getInstance(); |
89 |
private JPanel pnlLayerName = null; |
90 |
private GridBagLayoutPanel pnlScale = null; |
91 |
private JPanel pnlProperties = null; |
92 |
private JLabel lblLayerName = null; |
93 |
private JTextField txtLayerName = null; |
94 |
private JTextField txtMaxScale = null; |
95 |
private JTextArea propertiesTextArea = null; |
96 |
private JRadioButton rdBtnShowAlways = null; |
97 |
private JRadioButton rdBtnDoNotShow = null; |
98 |
private JTextField txtMinScale = null; |
99 |
private JCheckBox jCheckBoxSpatialIndex = null; |
100 |
|
101 |
// private ViewDocument view;
|
102 |
// private JTextField txtLinkExtension = null;
|
103 |
// private JComboBox cmbLinkField = null;
|
104 |
// private JComboBox cmbLinkType = null;
|
105 |
// private JPanel pnlHyperLink;
|
106 |
// private JLabel lblLinkExtension;
|
107 |
// private JLabel lblLinkField;
|
108 |
// private JPanel pnlFieldAndExtension;
|
109 |
// private JPanel pnlHyperLinkAction;
|
110 |
//
|
111 |
// private JLabel lblDefaultAction;
|
112 |
private JScrollPane scrlProperties; |
113 |
|
114 |
/**
|
115 |
* This is the default constructor.
|
116 |
*/
|
117 |
public General() {
|
118 |
super();
|
119 |
initialize(); |
120 |
} |
121 |
/**
|
122 |
* This method initializes this
|
123 |
*
|
124 |
* @return void
|
125 |
*/
|
126 |
private void initialize() { |
127 |
this.setLayout(new BorderLayout()); |
128 |
GridBagLayoutPanel aux = new GridBagLayoutPanel();
|
129 |
aux.addComponent(getPnlLayerName()); |
130 |
aux.addComponent(new JBlank(10, 10)); |
131 |
aux.addComponent(getJCheckBoxSpatialIndex()); |
132 |
aux.addComponent("", getPnlScale());
|
133 |
JPanel aux2 = new JPanel(new GridLayout(1,2)); |
134 |
aux2.add(getPnlProperties()); |
135 |
// aux2.add(getPnlHyperLink());
|
136 |
aux.addComponent(aux2); |
137 |
|
138 |
|
139 |
|
140 |
aux.setPreferredSize(getPreferredSize()); |
141 |
this.add(aux, BorderLayout.CENTER); |
142 |
this.add(new JBlank(5, 10), BorderLayout.WEST); |
143 |
this.add(new JBlank(5, 10), BorderLayout.EAST); |
144 |
|
145 |
} |
146 |
|
147 |
|
148 |
/**
|
149 |
* Sets the necessary properties in the panel. This properties are
|
150 |
* extracted from the layer. With this properties fills the TextFields,
|
151 |
* ComboBoxes and the rest of GUI components.
|
152 |
* @param FLayer layer,
|
153 |
*/
|
154 |
public void setModel(FLayer layer) { |
155 |
this.layer = layer;
|
156 |
|
157 |
if (layer instanceof FLyrVect) { |
158 |
// FLyrVect lyrVect = (FLyrVect) layer;
|
159 |
|
160 |
|
161 |
//TODO
|
162 |
// if(lyrVect.getISpatialIndex() == null) {
|
163 |
// getJCheckBoxSpatialIndex().setSelected(false);
|
164 |
// } else {
|
165 |
// getJCheckBoxSpatialIndex().setSelected(true);
|
166 |
// }
|
167 |
} |
168 |
if (layer.getMinScale() != -1) { |
169 |
getTxtMaxScale().setText(nf.format(layer.getMinScale())); |
170 |
} |
171 |
if (layer.getMaxScale() != -1) { |
172 |
getTxtMinScale().setText(nf.format(layer.getMaxScale())); |
173 |
} |
174 |
if (layer.getMinScale() == -1 && layer.getMaxScale() == -1) { |
175 |
getRdBtnShowAlways().setSelected(true);
|
176 |
txtMaxScale.setEnabled(false);
|
177 |
txtMinScale.setEnabled(false);
|
178 |
|
179 |
} else {
|
180 |
getRdBtnDoNotShowWhen().setSelected(true);
|
181 |
txtMaxScale.setEnabled(true);
|
182 |
txtMinScale.setEnabled(true);
|
183 |
} |
184 |
txtLayerName.setText(layer.getName()); |
185 |
showLayerInfo(); |
186 |
|
187 |
|
188 |
// if (PluginServices.getMainFrame() != null) {
|
189 |
// if (PluginServices.getMDIManager().getActiveWindow() instanceof AbstractViewPanel ){
|
190 |
// AbstractViewPanel theView = (AbstractViewPanel)PluginServices.getMDIManager().getActiveWindow();
|
191 |
// view = theView.getModel();
|
192 |
// try {
|
193 |
// if (layer instanceof FLyrVect) {
|
194 |
// FLyrVect ad = (FLyrVect) layer;
|
195 |
// FeatureStore fs;
|
196 |
// fs = ad.getFeatureStore();
|
197 |
// FeatureType ftype = fs.getDefaultFeatureType();
|
198 |
// String[] names = new String[ftype.size()];
|
199 |
// Iterator iter = ftype.iterator();
|
200 |
// int i=0;
|
201 |
// while (iter.hasNext()){
|
202 |
// names[i] = ((FeatureAttributeDescriptor)iter.next()).getName();
|
203 |
// i++;
|
204 |
// }
|
205 |
// DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(names);
|
206 |
// cmbLinkField.setModel(defaultModel);
|
207 |
//
|
208 |
// if (layer.getLinkProperties().getField()!=null) {
|
209 |
// cmbLinkField.setSelectedItem(layer.getLinkProperties().getField());
|
210 |
// } else {
|
211 |
// cmbLinkField.setSelectedItem(view.getSelectedField());
|
212 |
// }
|
213 |
// } else {
|
214 |
// cmbLinkField = new JComboBox();
|
215 |
// }
|
216 |
// } catch (DataException e) {
|
217 |
// NotificationManager.addError("No se pudo obtener la tabla", e);
|
218 |
// }
|
219 |
//
|
220 |
//
|
221 |
// if(layer.getLinkProperties().getExt()!=null) {
|
222 |
// getTxtLinkExtension().setText(layer.getLinkProperties().getExt());
|
223 |
// }
|
224 |
//
|
225 |
// getCmbLinkType().addItem(PluginServices.getText(this,
|
226 |
// "Enlazar_a_ficheros_de_imagen"));
|
227 |
// getCmbLinkType().addItem(PluginServices.getText(this,
|
228 |
// "Enlazar_a_fichero_de_texto"));
|
229 |
//
|
230 |
// getCmbLinkType().addItem(PluginServices.getText(this,
|
231 |
// "Enlazar_a_documento_PDF"));
|
232 |
// getCmbLinkType().addItem(PluginServices.getText(this,
|
233 |
// "Enlazar_a_imagen_SVG"));
|
234 |
//
|
235 |
// if (layer.getLinkProperties().getType()!=-1) {
|
236 |
// getCmbLinkType().setSelectedIndex(layer.getLinkProperties().getType());
|
237 |
// }
|
238 |
//
|
239 |
// }
|
240 |
// }
|
241 |
|
242 |
} |
243 |
|
244 |
/**
|
245 |
* This method initializes jPanel
|
246 |
*
|
247 |
* @return javax.swing.JPanel
|
248 |
*/
|
249 |
private JPanel getPnlLayerName() { |
250 |
if (pnlLayerName == null) { |
251 |
lblLayerName = new JLabel(); |
252 |
pnlLayerName = new JPanel(); |
253 |
lblLayerName.setText(PluginServices.getText(this,"Nombre") + ":"); |
254 |
lblLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN);
|
255 |
pnlLayerName.setComponentOrientation(ComponentOrientation.UNKNOWN);
|
256 |
pnlLayerName.add(lblLayerName, null);
|
257 |
pnlLayerName.add(getTxtLayerName(), null);
|
258 |
} |
259 |
return pnlLayerName;
|
260 |
} |
261 |
/**
|
262 |
* This method initializes jPanel1
|
263 |
*
|
264 |
* @return javax.swing.JPanel
|
265 |
*/
|
266 |
private GridBagLayoutPanel getPnlScale() {
|
267 |
if (pnlScale == null) { |
268 |
pnlScale = new GridBagLayoutPanel();
|
269 |
pnlScale.setBorder(BorderFactory.createTitledBorder(
|
270 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
271 |
PluginServices.getText(this, "rango_de_escalas"), |
272 |
TitledBorder.DEFAULT_JUSTIFICATION,
|
273 |
TitledBorder.DEFAULT_POSITION, null, null) |
274 |
); |
275 |
ButtonGroup buttonGroup = new ButtonGroup(); |
276 |
buttonGroup.add(getRdBtnShowAlways()); |
277 |
buttonGroup.add(getRdBtnDoNotShowWhen()); |
278 |
pnlScale.addComponent(getRdBtnShowAlways()); |
279 |
pnlScale.addComponent(getRdBtnDoNotShowWhen()); |
280 |
JPanel aux;
|
281 |
|
282 |
|
283 |
aux = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
284 |
aux.add(getTxtMaxScale()); |
285 |
aux.add(new JLabel("(" + PluginServices.getText(this,"escala_maxima") + ")")); |
286 |
|
287 |
GridBagLayoutPanel aux2; |
288 |
aux2 = new GridBagLayoutPanel();
|
289 |
aux2.addComponent(PluginServices.getText( |
290 |
this,"este_por_encima_de")+" 1:", |
291 |
aux); |
292 |
aux = new JPanel(new FlowLayout(FlowLayout.LEFT)); |
293 |
aux.add(getTxtMinScale()); |
294 |
aux.add(new JLabel("(" + PluginServices.getText(this,"escala_minima") + ")")); |
295 |
|
296 |
aux2.addComponent(PluginServices.getText( |
297 |
this,"este_por_debajo_de_")+" 1:", |
298 |
aux); |
299 |
|
300 |
pnlScale.addComponent(new JBlank(20, 1), aux2); |
301 |
|
302 |
pnlScale.addComponent(new JBlank(20, 1), aux2); |
303 |
|
304 |
} |
305 |
return pnlScale;
|
306 |
} |
307 |
/**
|
308 |
* This method initializes jPanel2, this contains the ScrollPane with the
|
309 |
* properies.
|
310 |
*
|
311 |
* @return javax.swing.JPanel
|
312 |
*/
|
313 |
private JPanel getPnlProperties() { |
314 |
if (pnlProperties == null) { |
315 |
pnlProperties = new JPanel(); |
316 |
pnlProperties.setBorder(BorderFactory.createTitledBorder(
|
317 |
BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), |
318 |
PluginServices.getText(this, "propiedades"), |
319 |
TitledBorder.DEFAULT_JUSTIFICATION,
|
320 |
TitledBorder.DEFAULT_POSITION, null, null) |
321 |
); |
322 |
pnlProperties.add(getScrlProperties(), null);
|
323 |
} |
324 |
return pnlProperties;
|
325 |
} |
326 |
|
327 |
/**
|
328 |
* This method initializes jTextField
|
329 |
*
|
330 |
* @return javax.swing.JTextField
|
331 |
*/
|
332 |
private JTextField getTxtLayerName() { |
333 |
if (txtLayerName == null) { |
334 |
txtLayerName = new JTextField(25); |
335 |
txtLayerName.setEditable(false);
|
336 |
} |
337 |
return txtLayerName;
|
338 |
} |
339 |
|
340 |
/**
|
341 |
* This method initializes TxtMaxScale
|
342 |
* @return jTextField1
|
343 |
*/
|
344 |
private JTextField getTxtMaxScale() { |
345 |
if (txtMaxScale == null) { |
346 |
txtMaxScale = new JTextField(15); |
347 |
txtMaxScale.setEnabled(false);
|
348 |
} |
349 |
return txtMaxScale;
|
350 |
} |
351 |
/**
|
352 |
* This method initilizes TxtArea, in this TextArea sets the text with
|
353 |
* the properties of the layer
|
354 |
* @return
|
355 |
*/
|
356 |
private JTextArea getPropertiesTextArea() { |
357 |
if (propertiesTextArea == null) { |
358 |
propertiesTextArea = new JTextArea(); |
359 |
propertiesTextArea.setEditable(false);
|
360 |
propertiesTextArea.setBackground(SystemColor.control);
|
361 |
|
362 |
} |
363 |
return propertiesTextArea;
|
364 |
} |
365 |
|
366 |
/**
|
367 |
* This method initializes jScrollPane
|
368 |
*
|
369 |
* @return javax.swing.JScrollPane
|
370 |
*/
|
371 |
private JScrollPane getScrlProperties() { |
372 |
if (scrlProperties == null) { |
373 |
scrlProperties = new JScrollPane(); |
374 |
scrlProperties.setViewportView(getPropertiesTextArea()); |
375 |
scrlProperties.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); |
376 |
scrlProperties.setPreferredSize(new Dimension(350, 180)); |
377 |
} |
378 |
return scrlProperties;
|
379 |
} |
380 |
/**
|
381 |
* This method initializes jRadioButton
|
382 |
*
|
383 |
* @return javax.swing.JRadioButton
|
384 |
*/
|
385 |
private JRadioButton getRdBtnShowAlways() { |
386 |
if (rdBtnShowAlways == null) { |
387 |
rdBtnShowAlways = new JRadioButton(); |
388 |
rdBtnShowAlways.setText(PluginServices.getText(this,"Mostrar_siempre")); |
389 |
rdBtnShowAlways.setSelected(true);
|
390 |
rdBtnShowAlways.addActionListener(new ActionListener() { |
391 |
public void actionPerformed(ActionEvent e) { |
392 |
txtMaxScale.setEnabled(false);
|
393 |
txtMinScale.setEnabled(false);
|
394 |
} |
395 |
}); |
396 |
} |
397 |
return rdBtnShowAlways;
|
398 |
} |
399 |
/**
|
400 |
* This method initializes jRadioButton1
|
401 |
*
|
402 |
* @return javax.swing.JRadioButton
|
403 |
*/
|
404 |
private JRadioButton getRdBtnDoNotShowWhen() { |
405 |
if (rdBtnDoNotShow == null) { |
406 |
rdBtnDoNotShow = new JRadioButton(); |
407 |
rdBtnDoNotShow.setText(PluginServices.getText(this,"No_mostrar_la_capa_cuando_la_escala")); |
408 |
rdBtnDoNotShow.addActionListener(new ActionListener() { |
409 |
public void actionPerformed(ActionEvent e) { |
410 |
txtMaxScale.setEnabled(true);
|
411 |
txtMinScale.setEnabled(true);
|
412 |
} |
413 |
}); |
414 |
} |
415 |
return rdBtnDoNotShow;
|
416 |
} |
417 |
/**
|
418 |
* This method initializes jTextField2
|
419 |
*
|
420 |
* @return javax.swing.JTextField
|
421 |
*/
|
422 |
private JTextField getTxtMinScale() { |
423 |
if (txtMinScale == null) { |
424 |
txtMinScale = new JTextField(15); |
425 |
txtMinScale.setEnabled(false);
|
426 |
} |
427 |
return txtMinScale;
|
428 |
} |
429 |
|
430 |
private String getLayerName(){ |
431 |
return txtLayerName.getText().toString();
|
432 |
} |
433 |
// /**
|
434 |
// * This method initializes jPanel3, this panel contains the components of the
|
435 |
// * HyperLink
|
436 |
// *
|
437 |
// * @return javax.swing.JPanel
|
438 |
// */
|
439 |
// private JPanel getPnlHyperLink() {
|
440 |
// if (pnlHyperLink == null) {
|
441 |
// pnlHyperLink = new JPanel();
|
442 |
// pnlHyperLink.setBorder(BorderFactory.createTitledBorder(
|
443 |
// BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
|
444 |
// PluginServices.getText(this, "Hiperenlace"),
|
445 |
// TitledBorder.DEFAULT_JUSTIFICATION,
|
446 |
// TitledBorder.DEFAULT_POSITION, null, null)
|
447 |
// );
|
448 |
// JPanel aux = new JPanel(new BorderLayout());
|
449 |
// pnlHyperLink.setLayout(new BorderLayout());
|
450 |
// aux.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
|
451 |
// aux.add(getPnlFieldAndExtension(), BorderLayout.NORTH);
|
452 |
// aux.add(getPnlHyperLinkAction(), BorderLayout.CENTER);
|
453 |
// pnlHyperLink.add(aux);
|
454 |
// }
|
455 |
// return pnlHyperLink;
|
456 |
// }
|
457 |
//
|
458 |
//
|
459 |
// private JPanel getPnlFieldAndExtension() {
|
460 |
// if (pnlFieldAndExtension == null) {
|
461 |
// lblLinkExtension = new JLabel();
|
462 |
// lblLinkExtension.setText(" \t \t"+PluginServices.getText(this,"extension"));
|
463 |
// lblLinkField = new JLabel();
|
464 |
// lblLinkField.setText(PluginServices.getText(this, "Campo"));
|
465 |
// pnlFieldAndExtension = new JPanel();
|
466 |
// pnlFieldAndExtension.add(lblLinkField, null);
|
467 |
// pnlFieldAndExtension.add(getCmbLinkField(), null);
|
468 |
// pnlFieldAndExtension.add(lblLinkExtension, null);
|
469 |
// pnlFieldAndExtension.add(getTxtLinkExtension(), null);
|
470 |
// }
|
471 |
// return pnlFieldAndExtension;
|
472 |
// }
|
473 |
// /**
|
474 |
// * This method initializes jPanel8. This panel contains the ComboBox to select
|
475 |
// * the action, (type of HyperLink)
|
476 |
// *
|
477 |
// * @return javax.swing.JPanel
|
478 |
// */
|
479 |
// private JPanel getPnlHyperLinkAction() {
|
480 |
// if (pnlHyperLinkAction == null) {
|
481 |
// lblDefaultAction = new JLabel();
|
482 |
// lblDefaultAction.setText(PluginServices.getText(this, "Accion_Predefinida") + " ");
|
483 |
// pnlHyperLinkAction = new JPanel();
|
484 |
// pnlHyperLinkAction.add(lblDefaultAction, null);
|
485 |
// pnlHyperLinkAction.add(getCmbLinkType(), null);
|
486 |
// }
|
487 |
// return pnlHyperLinkAction;
|
488 |
// }
|
489 |
// /**
|
490 |
// * This method initializes jComboBox
|
491 |
// *
|
492 |
// * @return javax.swing.JComboBox
|
493 |
// */
|
494 |
// private JComboBox getCmbLinkField() {
|
495 |
// if (cmbLinkField == null) {
|
496 |
// cmbLinkField = new JComboBox();
|
497 |
// }
|
498 |
// return cmbLinkField;
|
499 |
// }
|
500 |
// /**
|
501 |
// * This method initializes jTextField
|
502 |
// *
|
503 |
// * @return javax.swing.JTextField
|
504 |
// */
|
505 |
// private JTextField getTxtLinkExtension() {
|
506 |
// if (txtLinkExtension == null) {
|
507 |
// txtLinkExtension = new JTextField();
|
508 |
// txtLinkExtension.setPreferredSize(new Dimension(40,20));
|
509 |
// }
|
510 |
// return txtLinkExtension;
|
511 |
// }
|
512 |
// /**
|
513 |
// * This method initializes jComboBox1
|
514 |
// *
|
515 |
// * @return javax.swing.JComboBox
|
516 |
// */
|
517 |
// private JComboBox getCmbLinkType() {
|
518 |
// if (cmbLinkType == null) {
|
519 |
// cmbLinkType = new JComboBox();
|
520 |
// }
|
521 |
// return cmbLinkType;
|
522 |
// }
|
523 |
//
|
524 |
// /**
|
525 |
// * @return Returns the view.
|
526 |
// */
|
527 |
// private ViewDocument getView() {
|
528 |
// return view;
|
529 |
// }
|
530 |
/**
|
531 |
* This method initializes jCheckBox
|
532 |
*
|
533 |
* @return javax.swing.JCheckBox
|
534 |
*/
|
535 |
private JCheckBox getJCheckBoxSpatialIndex() { |
536 |
if (jCheckBoxSpatialIndex == null) { |
537 |
jCheckBoxSpatialIndex = new JCheckBox(); |
538 |
jCheckBoxSpatialIndex.setBounds(2, 33, 242, 23); |
539 |
jCheckBoxSpatialIndex.setText(PluginServices.getText(this,"Usar_indice_espacial")); |
540 |
} |
541 |
return jCheckBoxSpatialIndex;
|
542 |
} |
543 |
|
544 |
// /**
|
545 |
// * Returns the selected Type in the ComboBox
|
546 |
// */
|
547 |
// private int getLinkType() {
|
548 |
// return getCmbLinkType().getSelectedIndex();
|
549 |
//
|
550 |
// }
|
551 |
//
|
552 |
// /**
|
553 |
// * Returns the Selected Field in the ComboBox
|
554 |
// */
|
555 |
// private String getSelectedLinkField() {
|
556 |
// return (String) getCmbLinkField().getSelectedItem();
|
557 |
// }
|
558 |
//
|
559 |
// /**
|
560 |
// * Returns the Extension in the TextField
|
561 |
// */
|
562 |
// private String getExtensionLink() {
|
563 |
// return getTxtLinkExtension().getText();
|
564 |
// }
|
565 |
//
|
566 |
// /**
|
567 |
// * Returns true or false if the CheckBox is marked or not
|
568 |
// */
|
569 |
// private boolean isSpatialIndexSelected() {
|
570 |
// return getJCheckBoxSpatialIndex().isSelected();
|
571 |
// }
|
572 |
|
573 |
/**
|
574 |
* Add the information of the layer to the textArea
|
575 |
*/
|
576 |
private void showLayerInfo() { |
577 |
try {
|
578 |
String info = ((FLyrDefault)layer).getInfoString();
|
579 |
if (info == null) { |
580 |
StringBuffer buff= new StringBuffer(); |
581 |
Envelope fullExtentViewPort = layer.getFullEnvelope(); |
582 |
IProjection viewPortProj = layer.getMapContext().getProjection(); |
583 |
buff.append(PluginServices.getText(this,"Extent")); |
584 |
buff.append(" ");
|
585 |
buff.append(viewPortProj.getAbrev()); |
586 |
buff.append(" (" + PluginServices.getText(this, "view_projection") + "):\n\t"); |
587 |
buff.append(PluginServices.getText(this,"Superior") + ":\t" + fullExtentViewPort.getMaximum(1) + "\n\t"); |
588 |
buff.append(PluginServices.getText(this,"Inferior") + ":\t" + fullExtentViewPort.getMinimum(1) + "\n\t"); |
589 |
buff.append(PluginServices.getText(this,"Izquierda") + ":\t" + fullExtentViewPort.getMinimum(0) + "\n\t"); |
590 |
buff.append(PluginServices.getText(this,"Derecha") + ":\t" + fullExtentViewPort.getMaximum(0) + "\n"); |
591 |
// show layer native projection
|
592 |
if (layer.getProjection() != null |
593 |
&& !layer.getProjection().getAbrev().equals( |
594 |
viewPortProj.getAbrev())) { |
595 |
IProjection nativeLayerProj = layer.getProjection(); |
596 |
ICoordTrans ct = viewPortProj.getCT(nativeLayerProj); |
597 |
// Rectangle2D r=new Rectangle2D.Double(fullExtentViewPort.getMinimum(0),fullExtentViewPort.getMinimum(1),fullExtentViewPort.getLength(0),fullExtentViewPort.getLength(1));
|
598 |
// Rectangle2D nativeLayerExtent = ct.convert(r);
|
599 |
Envelope nativeLayerExtent = fullExtentViewPort.convert(ct); |
600 |
buff.append(PluginServices.getText(this,"Extent") + " "); |
601 |
buff.append(nativeLayerProj.getAbrev()); |
602 |
buff.append(" (" + PluginServices.getText(this, "layer_native_projection") + "):\n\t"); |
603 |
buff.append(PluginServices.getText(this, "Superior") |
604 |
+ ":\t" + nativeLayerExtent.getMaximum(1) + "\n\t"); |
605 |
buff.append(PluginServices.getText(this, "Inferior") |
606 |
+ ":\t" + nativeLayerExtent.getMinimum(1) + "\n\t"); |
607 |
buff.append(PluginServices.getText(this, "Izquierda") |
608 |
+ ":\t" + nativeLayerExtent.getMinimum(0) + "\n\t"); |
609 |
buff.append(PluginServices.getText(this, "Derecha") + ":\t" |
610 |
+ nativeLayerExtent.getMaximum(0) + "\n"); |
611 |
|
612 |
} |
613 |
if (layer instanceof FLyrVect) { |
614 |
FeatureStore fStore=((FLyrVect)layer).getFeatureStore(); |
615 |
// if (rv instanceof VectorialEditableAdapter) {
|
616 |
// rv=((VectorialEditableAdapter) ((FLyrVect)layer).getSource()).getOriginalAdapter();
|
617 |
// }
|
618 |
|
619 |
buff.append(PluginServices.getText(this,"Origen_de_datos") + ": "); |
620 |
buff.append(fStore.getName()); |
621 |
info=buff.toString(); |
622 |
|
623 |
DataStoreParameters parameters=fStore.getParameters(); |
624 |
if (parameters instanceof FilesystemStoreParameters) { |
625 |
info = info + "\n" +
|
626 |
PluginServices.getText(this, "fichero") |
627 |
+ ": "
|
628 |
+ ((FilesystemStoreParameters) parameters) |
629 |
.getFile(); |
630 |
// FIXME
|
631 |
// }else if (parameters instanceof DBParameters){
|
632 |
// info = info + "\n" + fStore.getName() + "\n";
|
633 |
//
|
634 |
// try {
|
635 |
// info = info +
|
636 |
// PluginServices.getText(this,"url") +": " + ((DBParameters)parameters).getHost() + "\n";
|
637 |
// } catch (Exception e) {
|
638 |
// //TODO: Que hacer aqui?
|
639 |
// e.printStackTrace();
|
640 |
// }
|
641 |
//
|
642 |
// info = info +
|
643 |
// PluginServices.getText(this, "Tabla")
|
644 |
// + ": "
|
645 |
// + ((DBStoreParameters) parameters)
|
646 |
// .getTableName() + "\n";
|
647 |
}else{
|
648 |
info = info + "\n" + fStore.getName() + "\n"; |
649 |
} |
650 |
// if (rv instanceof VectorialFileAdapter) {
|
651 |
// info = info + "\n" + rv.getDriver().getName() + "\n" +
|
652 |
// PluginServices.getText(this,"fichero") +": " + ((VectorialFileAdapter)rv).getFile();
|
653 |
//
|
654 |
// } else if (rv instanceof VectorialDBAdapter) {
|
655 |
// DBLayerDefinition dbdef = ((VectorialDBAdapter) rv).getLyrDef();
|
656 |
// info = info + "\n" + rv.getDriver().getName() + "\n";
|
657 |
//
|
658 |
// try {
|
659 |
// info = info +
|
660 |
// PluginServices.getText(this,"url") +": " + dbdef.getConnection().getURL() + "\n";
|
661 |
// } catch (Exception e) {
|
662 |
// //TODO: Que hacer aqui?
|
663 |
// e.printStackTrace();
|
664 |
// }
|
665 |
//
|
666 |
// info = info +
|
667 |
// PluginServices.getText(this,"Tabla") +": " + dbdef.getTableName() + "\n";
|
668 |
// } else if (rv instanceof VectorialAdapter){
|
669 |
// info = info + "\n" + rv.getDriver().getName() + "\n";
|
670 |
// }
|
671 |
String sGeomType= "Unknow"; |
672 |
|
673 |
try {
|
674 |
GeometryType geomType = ((FLyrVect)layer).getTypeVectorLayer(); |
675 |
sGeomType = geomType.getName(); |
676 |
} catch (LocatorException e) {
|
677 |
NotificationManager.addError(e); |
678 |
} catch (GeometryTypeNotSupportedException e) {
|
679 |
NotificationManager.showMessageWarning("Not supported GeometryType", e);
|
680 |
} catch (GeometryTypeNotValidException e) {
|
681 |
NotificationManager.showMessageWarning("Not valid GeometryType", e);
|
682 |
} |
683 |
|
684 |
info += "\n" + PluginServices.getText(this,"type")+ ": "+sGeomType + "\n"; |
685 |
|
686 |
} else {
|
687 |
info=buff.toString(); |
688 |
info = info + PluginServices.getText(this,"Origen_de_datos") + ": " + layer.getName(); |
689 |
} |
690 |
|
691 |
} |
692 |
getPropertiesTextArea().setText(info); |
693 |
|
694 |
} catch (ReadException e) {
|
695 |
NotificationManager.addError(e.getMessage(), e); |
696 |
} catch (DataException e) {
|
697 |
NotificationManager.addError(e.getMessage(), e); |
698 |
} |
699 |
|
700 |
} |
701 |
|
702 |
/**
|
703 |
* Returns true or false if the scale is activa
|
704 |
*/
|
705 |
private boolean isScaleActive() { |
706 |
return getRdBtnDoNotShowWhen().isSelected();
|
707 |
} |
708 |
|
709 |
// /**
|
710 |
// * Instanciates a ITask (@see com.iver.utiles.swing.threads.ITask)
|
711 |
// * to create a spatial index for the selected layer in background.
|
712 |
// * This task also allow to monitor process evolution, and to cancel
|
713 |
// * this process.
|
714 |
// */
|
715 |
// private IMonitorableTask getCreateSpatialIndexTask() throws DataException {
|
716 |
// // FIXME REVISAR ESTO (Quizas lanzar TaskException)
|
717 |
// return new CreateSpatialIndexMonitorableTask((FLyrVect)layer);
|
718 |
// }
|
719 |
|
720 |
public void acceptAction() { |
721 |
// // Implementaci?n para hacer funcionar el hyperlink ...
|
722 |
// //com.iver.cit.gvsig.gui.View theView = (com.iver.cit.gvsig.gui.View)PluginServices.getMDIManager().getActiveView();
|
723 |
// //ProjectView view = theView.getModel();
|
724 |
// if (PluginServices.getMainFrame() != null)
|
725 |
// {
|
726 |
// ViewDocument view = getView();
|
727 |
// view.setTypeLink(getLinkType());
|
728 |
// if (getSelectedLinkField()!=null)
|
729 |
// {
|
730 |
// view.setSelectedField(getSelectedLinkField().toString().trim());
|
731 |
// view.setExtLink(getExtensionLink());
|
732 |
//
|
733 |
// }
|
734 |
// }
|
735 |
|
736 |
|
737 |
} |
738 |
|
739 |
public void cancelAction() { |
740 |
// does nothing
|
741 |
} |
742 |
|
743 |
/**
|
744 |
* When we press the apply button, sets the new properties of the layer thar the
|
745 |
* user modified using the UI components
|
746 |
*/
|
747 |
public void applyAction() { |
748 |
if (isScaleActive()) {
|
749 |
try {
|
750 |
layer.setMinScale((nf.parse(getTxtMaxScale().getText())).doubleValue()); |
751 |
} catch (ParseException ex) { |
752 |
if (getTxtMaxScale().getText().compareTo("") == 0) { |
753 |
layer.setMinScale(-1);
|
754 |
} else {
|
755 |
System.err.print(ex.getLocalizedMessage());
|
756 |
} |
757 |
} |
758 |
|
759 |
try {
|
760 |
layer.setMaxScale((nf.parse(getTxtMinScale().getText())).doubleValue()); |
761 |
} catch (ParseException ex) { |
762 |
if (getTxtMinScale().getText().compareTo("") == 0) { |
763 |
layer.setMaxScale(-1);
|
764 |
} else {
|
765 |
System.err.print(ex.getLocalizedMessage());
|
766 |
} |
767 |
} |
768 |
|
769 |
} else {
|
770 |
layer.setMinScale(-1);
|
771 |
layer.setMaxScale(-1);
|
772 |
} |
773 |
|
774 |
if (!getLayerName().equals(layer.getName())){
|
775 |
layer.setName(getLayerName()); |
776 |
} |
777 |
|
778 |
// if (layer instanceof FLyrVect){
|
779 |
// FLyrVect lyrVect = (FLyrVect) layer;
|
780 |
// if (isSpatialIndexSelected()) {
|
781 |
// // TODO
|
782 |
//
|
783 |
// if(lyrVect.getISpatialIndex() == null) {
|
784 |
// //AZABALA
|
785 |
// try {
|
786 |
// PluginServices.
|
787 |
// cancelableBackgroundExecution(getCreateSpatialIndexTask());
|
788 |
// } catch (ReadDriverException e) {
|
789 |
// // TODO Auto-generated catch block
|
790 |
// NotificationManager.addError(e.getMessage(), e);
|
791 |
// }
|
792 |
// }
|
793 |
// }
|
794 |
// //AZABALA
|
795 |
// /*
|
796 |
// * If we unselect the spatial index checkbox...Must we delete
|
797 |
// * spatial index file, or we only have to put Spatial Index
|
798 |
// * reference to null?. I have followed the second choice
|
799 |
// */
|
800 |
// else{
|
801 |
//// lyrVect.deleteSpatialIndex();
|
802 |
// }
|
803 |
//
|
804 |
//
|
805 |
// }
|
806 |
// //Codigo relacionado
|
807 |
// if (layer instanceof FLyrVect ){
|
808 |
// FLyrVect vectlyr=(FLyrVect) layer;
|
809 |
// if (getSelectedLinkField()!=null){
|
810 |
// vectlyr.getLinkProperties().setExt(getExtensionLink());
|
811 |
// vectlyr.getLinkProperties().setField(getSelectedLinkField().toString().trim());
|
812 |
// vectlyr.getLinkProperties().setType(getLinkType());
|
813 |
//
|
814 |
// System.out.println("Link Properties");
|
815 |
// System.out.println("Extensi?n: " + vectlyr.getLinkProperties().getExt());
|
816 |
// System.out.println("Campo: " + vectlyr.getLinkProperties().getField());
|
817 |
// System.out.println("Tipo: " + vectlyr.getLinkProperties().getType());
|
818 |
// }
|
819 |
// }
|
820 |
} |
821 |
|
822 |
/*
|
823 |
* (non-Javadoc)
|
824 |
* @see java.awt.Component#getName()
|
825 |
*/
|
826 |
public String getName() { |
827 |
return PluginServices.getText(this,"General"); |
828 |
} |
829 |
} // @jve:decl-index=0:visual-constraint="10,10"
|
830 |
|