Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extAnnotations / src / com / iver / cit / gvsig / project / documents / gui / Annotation_Modify.java @ 24191

History | View | Annotate | Download (4.78 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.fmap.rendering.styling.labeling.AttrInTableLabelingStrategy;
57
import com.iver.cit.gvsig.gui.panels.annotation.ConfigureLabel;
58

    
59

    
60
/**
61
 * Dialog to create a new annotation layer.
62
 *
63
 * @author Vicente Caballero Navarro
64
 */
65
public class Annotation_Modify extends FinishAction {
66
    private JWizardComponents myWizardComponents;
67
    private Annotation_Layer layerAnnotation;
68

    
69
    public Annotation_Modify(JWizardComponents wizardComponents,
70
        MapContext map, Annotation_Layer layerAnnotation) {
71
        super(wizardComponents);
72
        this.layerAnnotation = layerAnnotation;
73
        myWizardComponents = wizardComponents;
74
    }
75

    
76
    /**
77
     * DOCUMENT ME!
78
     */
79
    public void performAction() {
80
        myWizardComponents.getFinishButton().setEnabled(false);
81

    
82
        Annotation_FieldSelect panel1 = (Annotation_FieldSelect) myWizardComponents.getWizardPanel(0);
83
        Annotation_ConfigureLabel panel2 = (Annotation_ConfigureLabel) myWizardComponents.getWizardPanel(1);
84

    
85
        SelectableDataSource source;
86
        Annotation_Mapping mapping = new Annotation_Mapping();
87

    
88
        try {
89
            source = this.layerAnnotation.getRecordset();
90

    
91
            mapping.setColumnText(source.getFieldIndexByName(panel1.getField()));
92

    
93
            if (!panel2.getAngleFieldName().equals(ConfigureLabel.TEXT_FOR_DEFAULT_VALUE)) {
94
                mapping.setColumnRotate(source.getFieldIndexByName(
95
                        panel2.getAngleFieldName()));
96
            }
97

    
98
            if (!panel2.getColorFieldName().equals(ConfigureLabel.TEXT_FOR_DEFAULT_VALUE)) {
99
                mapping.setColumnColor(source.getFieldIndexByName(
100
                        panel2.getColorFieldName()));
101
            }
102

    
103
            if (!panel2.getSizeFieldName().equals(ConfigureLabel.TEXT_FOR_DEFAULT_VALUE)) {
104
                mapping.setColumnHeight(source.getFieldIndexByName(
105
                        panel2.getSizeFieldName()));
106
            }
107
//            AttrInTableLabelingStrategy labeling = new AttrInTableLabelingStrategy();
108
            ((Annotation_Legend)layerAnnotation.getLegend()).setUnits(panel2.getCmbUnits().getSelectedUnitIndex());
109
//                labeling.setUnit(panel2.getCmbUnits().getSelectedUnitIndex());
110
//                this.layerAnnotation.setLabelingStrategy(labeling);
111
//            ((FSymbol) this.layerAnnotation.getLegend().getDefaultSymbol()).setFontSizeInPixels(panel2.sizeUnitsInPixels());
112

    
113
            this.layerAnnotation.deleteSpatialIndex();
114

    
115
            if (!panel2.getFontFieldName().equals(ConfigureLabel.TEXT_FOR_DEFAULT_VALUE)) {
116
                mapping.setColumnTypeFont(source.getFieldIndexByName(
117
                        panel2.getFontFieldName()));
118
            }
119
        } catch (ReadDriverException e) {
120
                NotificationManager.addError(e);
121
                }
122

    
123
        try {
124
                        this.layerAnnotation.setMapping(mapping);
125
                } catch (LegendLayerException e) {
126
                        NotificationManager.addError(e);
127
                } catch (ReadDriverException e) {
128
                        NotificationManager.addError(e);
129
                }
130

    
131
        this.myWizardComponents.getCancelAction().performAction();
132
    }
133
}