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