Statistics
| Revision:

svn-gvsig-desktop / branches / v10 / extensions / extAnnotations / src / com / iver / cit / gvsig / fmap / layers / Annotation_Mapping.java @ 11743

History | View | Annotate | Download (7.23 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.fmap.layers;
44

    
45
import java.awt.Color;
46
import java.awt.Font;
47
import java.sql.Types;
48

    
49

    
50
/**
51
 * Mapping of annotation's layers.
52
 *
53
 * @author Vicente Caballero Navarro
54
 */
55
public class Annotation_Mapping {
56
    public static String DEFAULTTEXT = "";
57
    public static String DEFAULTTYPEFONT = "Arial";
58
    public static int DEFAULTROTATE = 0;
59
    public static int DEFAULTSTYLEFONT = Font.PLAIN;
60
    public static int DEFAULTHEIGHT = 10;
61
    public static int DEFAULTCOLOR = Color.black.getRGB();
62
    public static String TEXT = "Text";
63
    public static String ROTATE = "Rotate";
64
    public static String COLOR = "Color";
65
    public static String HEIGHT = "Height";
66
    public static String TYPEFONT = "TypeFont";
67
    public static String STYLEFONT = "StyleFont";
68
    private static int TYPETEXT = Types.VARCHAR;
69
    private static int TYPEROTATE = Types.DOUBLE;
70
    private static int TYPECOLOR = Types.INTEGER;
71
    private static int TYPEHEIGHT = Types.DOUBLE;
72
    private static int TYPETYPEFONT = Types.VARCHAR;
73
    private static int TYPESTYLEFONT = Types.INTEGER;
74
    public static int NUMCOLUMNS = 6;
75
    private int columnText = -1;
76
    private int columnRotate = -1;
77
    private int columnColor = -1;
78
    private int columnHeight = -1;
79
    private int columnTypeFont = -1;
80
    private int columnStyleFont = -1;
81

    
82
    /**
83
     * DOCUMENT ME!
84
     *
85
     * @return DOCUMENT ME!
86
     */
87
    public int getColumnColor() {
88
        return columnColor;
89
    }
90

    
91
    /**
92
     * DOCUMENT ME!
93
     *
94
     * @param columnColor DOCUMENT ME!
95
     */
96
    public void setColumnColor(int columnColor) {
97
        this.columnColor = columnColor;
98
    }
99

    
100
    /**
101
     * DOCUMENT ME!
102
     *
103
     * @return DOCUMENT ME!
104
     */
105
    public int getColumnHeight() {
106
        return columnHeight;
107
    }
108

    
109
    /**
110
     * DOCUMENT ME!
111
     *
112
     * @param columnHeight DOCUMENT ME!
113
     */
114
    public void setColumnHeight(int columnHeight) {
115
        this.columnHeight = columnHeight;
116
    }
117

    
118
    /**
119
     * DOCUMENT ME!
120
     *
121
     * @return DOCUMENT ME!
122
     */
123
    public int getColumnRotate() {
124
        return columnRotate;
125
    }
126

    
127
    /**
128
     * DOCUMENT ME!
129
     *
130
     * @param columnRotate DOCUMENT ME!
131
     */
132
    public void setColumnRotate(int columnRotate) {
133
        this.columnRotate = columnRotate;
134
    }
135

    
136
    /**
137
     * DOCUMENT ME!
138
     *
139
     * @return DOCUMENT ME!
140
     */
141
    public int getColumnStyleFont() {
142
        return columnStyleFont;
143
    }
144

    
145
    /**
146
     * DOCUMENT ME!
147
     *
148
     * @param columnStyleFont DOCUMENT ME!
149
     */
150
    public void setColumnStyleFont(int columnStyleFont) {
151
        this.columnStyleFont = columnStyleFont;
152
    }
153

    
154
    /**
155
     * DOCUMENT ME!
156
     *
157
     * @return DOCUMENT ME!
158
     */
159
    public int getColumnText() {
160
        return columnText;
161
    }
162

    
163
    /**
164
     * DOCUMENT ME!
165
     *
166
     * @param columnText DOCUMENT ME!
167
     */
168
    public void setColumnText(int columnText) {
169
        this.columnText = columnText;
170
    }
171

    
172
    /**
173
     * DOCUMENT ME!
174
     *
175
     * @return DOCUMENT ME!
176
     */
177
    public int getColumnTypeFont() {
178
        return columnTypeFont;
179
    }
180

    
181
    /**
182
     * DOCUMENT ME!
183
     *
184
     * @param columnTypeFont DOCUMENT ME!
185
     */
186
    public void setColumnTypeFont(int columnTypeFont) {
187
        this.columnTypeFont = columnTypeFont;
188
    }
189

    
190
    // public XMLEntity getXMLEntity() {
191
    // XMLEntity xml=new XMLEntity();
192
    // xml.putProperty("className",this.getClass().getName());
193
    // xml.putProperty("columnText",columnText);
194
    // xml.putProperty("columnRotate",columnRotate);
195
    // xml.putProperty("columnColor",columnColor);
196
    // xml.putProperty("columnHeight",columnHeight);
197
    // xml.putProperty("columnTypeFont",columnTypeFont);
198
    // xml.putProperty("columnStyleFont",columnStyleFont);
199
    // return xml;
200
    // }
201
    // public static Annotation_Mapping createFromXML(XMLEntity xml) {
202
    // Annotation_Mapping m=new Annotation_Mapping();
203
    // m.setColumnText(xml.getIntProperty("columnText"));
204
    // m.setColumnRotate(xml.getIntProperty("columnRotate"));
205
    // m.setColumnColor(xml.getIntProperty("columnColor"));
206
    // m.setColumnHeight(xml.getIntProperty("columnHeight"));
207
    // m.setColumnTypeFont(xml.getIntProperty("columnTypeFont"));
208
    // m.setColumnStyleFont(xml.getIntProperty("columnStyleFont"));
209
    // return m;
210
    // }
211
    public static int getType(String column) {
212
        if (column.equals(TEXT)) {
213
            return TYPETEXT;
214
        } else if (column.equals(COLOR)) {
215
            return TYPECOLOR;
216
        } else if (column.equals(ROTATE)) {
217
            return TYPEROTATE;
218
        } else if (column.equals(COLOR)) {
219
            return TYPECOLOR;
220
        } else if (column.equals(HEIGHT)) {
221
            return TYPEHEIGHT;
222
        } else if (column.equals(TYPEFONT)) {
223
            return TYPETYPEFONT;
224
        } else if (column.equals(STYLEFONT)) {
225
            return TYPESTYLEFONT;
226
        }
227

    
228
        return Types.VARCHAR;
229
    }
230

    
231
    /**
232
     * DOCUMENT ME!
233
     *
234
     * @param al DOCUMENT ME!
235
     *
236
     * @throws com.hardcode.gdbms.engine.data.driver.DriverException DOCUMENT
237
     *         ME!
238
     */
239
    public static void addAnnotationMapping(Annotation_Layer al)
240
        throws com.hardcode.gdbms.engine.data.driver.DriverException {
241
        Annotation_Mapping am = new Annotation_Mapping();
242
        SelectableDataSource sds = al.getSource().getRecordset();
243
        int numFields = sds.getFieldCount();
244

    
245
        for (int i = 0; i < numFields; i++) {
246
            String nameField = sds.getFieldName(i);
247

    
248
            if (nameField.equalsIgnoreCase(COLOR)) {
249
                am.setColumnColor(i);
250
            } else if (nameField.equalsIgnoreCase(HEIGHT)) {
251
                am.setColumnHeight(i);
252
            } else if (nameField.equalsIgnoreCase(ROTATE)) {
253
                am.setColumnRotate(i);
254
            } else if (nameField.equalsIgnoreCase(STYLEFONT)) {
255
                am.setColumnStyleFont(i);
256
            } else if (nameField.equalsIgnoreCase(TEXT)) {
257
                am.setColumnText(i);
258
            } else if (nameField.equalsIgnoreCase(TYPEFONT)) {
259
                am.setColumnTypeFont(i);
260
            }
261
        }
262

    
263
        al.setMapping(am);
264
    }
265
}