svn-gvsig-desktop / trunk / extensions / extAnnotations / src / com / iver / cit / gvsig / project / documents / gui / Annotation_Modify.java @ 28606
History | View | Annotate | Download (4.69 KB)
1 |
|
---|---|
2 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
3 |
*
|
4 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
19 |
*
|
20 |
* For more information, contact:
|
21 |
*
|
22 |
* Generalitat Valenciana
|
23 |
* Conselleria d'Infraestructures i Transport
|
24 |
* Av. Blasco Ib??ez, 50
|
25 |
* 46010 VALENCIA
|
26 |
* SPAIN
|
27 |
*
|
28 |
* +34 963862235
|
29 |
* gvsig@gva.es
|
30 |
* www.gvsig.gva.es
|
31 |
*
|
32 |
* or
|
33 |
*
|
34 |
* IVER T.I. S.A
|
35 |
* Salamanca 50
|
36 |
* 46005 Valencia
|
37 |
* Spain
|
38 |
*
|
39 |
* +34 963163400
|
40 |
* dac@iver.es
|
41 |
*/
|
42 |
|
43 |
package com.iver.cit.gvsig.project.documents.gui; |
44 |
|
45 |
import jwizardcomponent.FinishAction; |
46 |
import jwizardcomponent.JWizardComponents; |
47 |
|
48 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
49 |
import com.iver.andami.messages.NotificationManager; |
50 |
import com.iver.cit.gvsig.exceptions.layers.LegendLayerException; |
51 |
import com.iver.cit.gvsig.fmap.MapContext; |
52 |
import com.iver.cit.gvsig.fmap.layers.Annotation_Layer; |
53 |
import com.iver.cit.gvsig.fmap.layers.Annotation_Mapping; |
54 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
55 |
import com.iver.cit.gvsig.fmap.rendering.Annotation_Legend; |
56 |
import com.iver.cit.gvsig.gui.panels.annotation.ConfigureLabel; |
57 |
|
58 |
|
59 |
/**
|
60 |
* Dialog to create a new annotation layer.
|
61 |
*
|
62 |
* @author Vicente Caballero Navarro
|
63 |
*/
|
64 |
public class Annotation_Modify extends FinishAction { |
65 |
private JWizardComponents myWizardComponents;
|
66 |
private Annotation_Layer layerAnnotation;
|
67 |
|
68 |
public Annotation_Modify(JWizardComponents wizardComponents,
|
69 |
MapContext map, Annotation_Layer layerAnnotation) { |
70 |
super(wizardComponents);
|
71 |
this.layerAnnotation = layerAnnotation;
|
72 |
myWizardComponents = wizardComponents; |
73 |
} |
74 |
|
75 |
/**
|
76 |
* DOCUMENT ME!
|
77 |
*/
|
78 |
public void performAction() { |
79 |
myWizardComponents.getFinishButton().setEnabled(false);
|
80 |
|
81 |
Annotation_FieldSelect panel1 = (Annotation_FieldSelect) myWizardComponents.getWizardPanel(0);
|
82 |
Annotation_ConfigureLabel panel2 = (Annotation_ConfigureLabel) myWizardComponents.getWizardPanel(1);
|
83 |
|
84 |
SelectableDataSource source; |
85 |
Annotation_Mapping mapping = new Annotation_Mapping();
|
86 |
|
87 |
try {
|
88 |
source = this.layerAnnotation.getRecordset();
|
89 |
|
90 |
mapping.setColumnText(source.getFieldIndexByName(panel1.getField())); |
91 |
|
92 |
if (!panel2.getAngleFieldName().equals(ConfigureLabel.TEXT_FOR_DEFAULT_VALUE)) {
|
93 |
mapping.setColumnRotate(source.getFieldIndexByName( |
94 |
panel2.getAngleFieldName())); |
95 |
} |
96 |
|
97 |
if (!panel2.getColorFieldName().equals(ConfigureLabel.TEXT_FOR_DEFAULT_VALUE)) {
|
98 |
mapping.setColumnColor(source.getFieldIndexByName( |
99 |
panel2.getColorFieldName())); |
100 |
} |
101 |
|
102 |
if (!panel2.getSizeFieldName().equals(ConfigureLabel.TEXT_FOR_DEFAULT_VALUE)) {
|
103 |
mapping.setColumnHeight(source.getFieldIndexByName( |
104 |
panel2.getSizeFieldName())); |
105 |
} |
106 |
// AttrInTableLabelingStrategy labeling = new AttrInTableLabelingStrategy();
|
107 |
((Annotation_Legend)layerAnnotation.getLegend()).setUnits(panel2.getCmbUnits().getSelectedUnitIndex()); |
108 |
// labeling.setUnit(panel2.getCmbUnits().getSelectedUnitIndex());
|
109 |
// this.layerAnnotation.setLabelingStrategy(labeling);
|
110 |
// ((FSymbol) this.layerAnnotation.getLegend().getDefaultSymbol()).setFontSizeInPixels(panel2.sizeUnitsInPixels());
|
111 |
|
112 |
this.layerAnnotation.deleteSpatialIndex();
|
113 |
|
114 |
if (!panel2.getFontFieldName().equals(ConfigureLabel.TEXT_FOR_DEFAULT_VALUE)) {
|
115 |
mapping.setColumnTypeFont(source.getFieldIndexByName( |
116 |
panel2.getFontFieldName())); |
117 |
} |
118 |
} catch (ReadDriverException e) {
|
119 |
NotificationManager.addError(e); |
120 |
} |
121 |
|
122 |
try {
|
123 |
this.layerAnnotation.setMapping(mapping);
|
124 |
} catch (LegendLayerException e) {
|
125 |
NotificationManager.addError(e); |
126 |
} catch (ReadDriverException e) {
|
127 |
NotificationManager.addError(e); |
128 |
} |
129 |
|
130 |
this.myWizardComponents.getCancelAction().performAction();
|
131 |
} |
132 |
} |