Statistics
| Revision:

root / trunk / extensions / extAnnotations / src / com / iver / cit / gvsig / fmap / layers / Annotation_Mapping.java @ 11536

History | View | Annotate | Download (5.11 KB)

1
package com.iver.cit.gvsig.fmap.layers;
2

    
3
import java.awt.Color;
4
import java.awt.Font;
5

    
6
import java.sql.Types;
7

    
8

    
9
/**
10
 * Mapping of annotation's layers.
11
 *
12
 * @author Vicente Caballero Navarro
13
 */
14
public class Annotation_Mapping {
15
    public static String DEFAULTTEXT = "";
16
        public static String DEFAULTTYPEFONT = "Arial";
17
        public static int DEFAULTROTATE = 0;
18
    public static int DEFAULTSTYLEFONT = Font.PLAIN;
19
    public static int DEFAULTHEIGHT = 10;
20
    public static int DEFAULTCOLOR = Color.black.getRGB();
21
    public static String TEXT = "Text";
22
    public static String ROTATE = "Rotate";
23
    public static String COLOR = "Color";
24
    public static String HEIGHT = "Height";
25
    public static String TYPEFONT = "TypeFont";
26
    public static String STYLEFONT = "StyleFont";
27
    private static int TYPETEXT = Types.VARCHAR;
28
    private static int TYPEROTATE = Types.DOUBLE;
29
    private static int TYPECOLOR = Types.INTEGER;
30
    private static int TYPEHEIGHT = Types.DOUBLE;
31
    private static int TYPETYPEFONT = Types.VARCHAR;
32
    private static int TYPESTYLEFONT = Types.INTEGER;
33
    public static int NUMCOLUMNS = 6;
34
    private int columnText = -1;
35
    private int columnRotate = -1;
36
    private int columnColor = -1;
37
    private int columnHeight = -1;
38
    private int columnTypeFont = -1;
39
    private int columnStyleFont = -1;
40

    
41
    public int getColumnColor() {
42
        return columnColor;
43
    }
44

    
45
    public void setColumnColor(int columnColor) {
46
        this.columnColor = columnColor;
47
    }
48

    
49
    public int getColumnHeight() {
50
        return columnHeight;
51
    }
52

    
53
    public void setColumnHeight(int columnHeight) {
54
        this.columnHeight = columnHeight;
55
    }
56

    
57
    public int getColumnRotate() {
58
        return columnRotate;
59
    }
60

    
61
    public void setColumnRotate(int columnRotate) {
62
        this.columnRotate = columnRotate;
63
    }
64

    
65
    public int getColumnStyleFont() {
66
        return columnStyleFont;
67
    }
68

    
69
    public void setColumnStyleFont(int columnStyleFont) {
70
        this.columnStyleFont = columnStyleFont;
71
    }
72

    
73
    public int getColumnText() {
74
        return columnText;
75
    }
76

    
77
    public void setColumnText(int columnText) {
78
        this.columnText = columnText;
79
    }
80

    
81
    public int getColumnTypeFont() {
82
        return columnTypeFont;
83
    }
84

    
85
    public void setColumnTypeFont(int columnTypeFont) {
86
        this.columnTypeFont = columnTypeFont;
87
    }
88

    
89
    //public XMLEntity getXMLEntity() {
90
    //        XMLEntity xml=new XMLEntity();
91
    //        xml.putProperty("className",this.getClass().getName());
92
    //        xml.putProperty("columnText",columnText);
93
    //        xml.putProperty("columnRotate",columnRotate);
94
    //        xml.putProperty("columnColor",columnColor);
95
    //        xml.putProperty("columnHeight",columnHeight);
96
    //        xml.putProperty("columnTypeFont",columnTypeFont);
97
    //        xml.putProperty("columnStyleFont",columnStyleFont);
98
    //        return xml;
99
    //}
100
    //public static Annotation_Mapping createFromXML(XMLEntity xml) {
101
    //        Annotation_Mapping m=new Annotation_Mapping();
102
    //        m.setColumnText(xml.getIntProperty("columnText"));
103
    //        m.setColumnRotate(xml.getIntProperty("columnRotate"));
104
    //        m.setColumnColor(xml.getIntProperty("columnColor"));
105
    //        m.setColumnHeight(xml.getIntProperty("columnHeight"));
106
    //        m.setColumnTypeFont(xml.getIntProperty("columnTypeFont"));
107
    //        m.setColumnStyleFont(xml.getIntProperty("columnStyleFont"));
108
    //        return m;
109
    //}
110
    public static int getType(String column) {
111
        if (column.equals(TEXT)) {
112
            return TYPETEXT;
113
        } else if (column.equals(COLOR)) {
114
            return TYPECOLOR;
115
        } else if (column.equals(ROTATE)) {
116
            return TYPEROTATE;
117
        } else if (column.equals(COLOR)) {
118
            return TYPECOLOR;
119
        } else if (column.equals(HEIGHT)) {
120
            return TYPEHEIGHT;
121
        } else if (column.equals(TYPEFONT)) {
122
            return TYPETYPEFONT;
123
        } else if (column.equals(STYLEFONT)) {
124
            return TYPESTYLEFONT;
125
        }
126

    
127
        return Types.VARCHAR;
128
    }
129

    
130
    /**
131
     * DOCUMENT ME!
132
     *
133
     * @param al DOCUMENT ME!
134
     *
135
     * @throws com.hardcode.gdbms.engine.data.driver.DriverException DOCUMENT ME!
136
     */
137
    public static void addAnnotationMapping(Annotation_Layer al)
138
        throws com.hardcode.gdbms.engine.data.driver.DriverException {
139
        Annotation_Mapping am = new Annotation_Mapping();
140
        SelectableDataSource sds = al.getSource().getRecordset();
141
        int numFields = sds.getFieldCount();
142

    
143
        for (int i = 0; i < numFields; i++) {
144
            String nameField = sds.getFieldName(i);
145

    
146
            if (nameField.equalsIgnoreCase(COLOR)) {
147
                am.setColumnColor(i);
148
            } else if (nameField.equalsIgnoreCase(HEIGHT)) {
149
                am.setColumnHeight(i);
150
            } else if (nameField.equalsIgnoreCase(ROTATE)) {
151
                am.setColumnRotate(i);
152
            } else if (nameField.equalsIgnoreCase(STYLEFONT)) {
153
                am.setColumnStyleFont(i);
154
            } else if (nameField.equalsIgnoreCase(TEXT)) {
155
                am.setColumnText(i);
156
            } else if (nameField.equalsIgnoreCase(TYPEFONT)) {
157
                am.setColumnTypeFont(i);
158
            }
159
        }
160

    
161
        al.setMapping(am);
162
    }
163
}