root / branches / v10 / extensions / extAnnotations / src / com / iver / cit / gvsig / fmap / layers / Annotation_Mapping.java @ 11613
History | View | Annotate | Download (4.58 KB)
1 |
package com.iver.cit.gvsig.fmap.layers; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.Font; |
5 |
import java.sql.Types; |
6 |
|
7 |
/**
|
8 |
* Mapping of annotation's layers.
|
9 |
*
|
10 |
* @author Vicente Caballero Navarro
|
11 |
*/
|
12 |
public class Annotation_Mapping { |
13 |
public static String DEFAULTTEXT = ""; |
14 |
|
15 |
public static String DEFAULTTYPEFONT = "Arial"; |
16 |
|
17 |
public static int DEFAULTROTATE = 0; |
18 |
|
19 |
public static int DEFAULTSTYLEFONT = Font.PLAIN; |
20 |
|
21 |
public static int DEFAULTHEIGHT = 10; |
22 |
|
23 |
public static int DEFAULTCOLOR = Color.black.getRGB(); |
24 |
|
25 |
public static String TEXT = "Text"; |
26 |
|
27 |
public static String ROTATE = "Rotate"; |
28 |
|
29 |
public static String COLOR = "Color"; |
30 |
|
31 |
public static String HEIGHT = "Height"; |
32 |
|
33 |
public static String TYPEFONT = "TypeFont"; |
34 |
|
35 |
public static String STYLEFONT = "StyleFont"; |
36 |
|
37 |
private static int TYPETEXT = Types.VARCHAR; |
38 |
|
39 |
private static int TYPEROTATE = Types.DOUBLE; |
40 |
|
41 |
private static int TYPECOLOR = Types.INTEGER; |
42 |
|
43 |
private static int TYPEHEIGHT = Types.DOUBLE; |
44 |
|
45 |
private static int TYPETYPEFONT = Types.VARCHAR; |
46 |
|
47 |
private static int TYPESTYLEFONT = Types.INTEGER; |
48 |
|
49 |
public static int NUMCOLUMNS = 6; |
50 |
|
51 |
private int columnText = -1; |
52 |
|
53 |
private int columnRotate = -1; |
54 |
|
55 |
private int columnColor = -1; |
56 |
|
57 |
private int columnHeight = -1; |
58 |
|
59 |
private int columnTypeFont = -1; |
60 |
|
61 |
private int columnStyleFont = -1; |
62 |
|
63 |
public int getColumnColor() { |
64 |
return columnColor;
|
65 |
} |
66 |
|
67 |
public void setColumnColor(int columnColor) { |
68 |
this.columnColor = columnColor;
|
69 |
} |
70 |
|
71 |
public int getColumnHeight() { |
72 |
return columnHeight;
|
73 |
} |
74 |
|
75 |
public void setColumnHeight(int columnHeight) { |
76 |
this.columnHeight = columnHeight;
|
77 |
} |
78 |
|
79 |
public int getColumnRotate() { |
80 |
return columnRotate;
|
81 |
} |
82 |
|
83 |
public void setColumnRotate(int columnRotate) { |
84 |
this.columnRotate = columnRotate;
|
85 |
} |
86 |
|
87 |
public int getColumnStyleFont() { |
88 |
return columnStyleFont;
|
89 |
} |
90 |
|
91 |
public void setColumnStyleFont(int columnStyleFont) { |
92 |
this.columnStyleFont = columnStyleFont;
|
93 |
} |
94 |
|
95 |
public int getColumnText() { |
96 |
return columnText;
|
97 |
} |
98 |
|
99 |
public void setColumnText(int columnText) { |
100 |
this.columnText = columnText;
|
101 |
} |
102 |
|
103 |
public int getColumnTypeFont() { |
104 |
return columnTypeFont;
|
105 |
} |
106 |
|
107 |
public void setColumnTypeFont(int columnTypeFont) { |
108 |
this.columnTypeFont = columnTypeFont;
|
109 |
} |
110 |
|
111 |
// public XMLEntity getXMLEntity() {
|
112 |
// XMLEntity xml=new XMLEntity();
|
113 |
// xml.putProperty("className",this.getClass().getName());
|
114 |
// xml.putProperty("columnText",columnText);
|
115 |
// xml.putProperty("columnRotate",columnRotate);
|
116 |
// xml.putProperty("columnColor",columnColor);
|
117 |
// xml.putProperty("columnHeight",columnHeight);
|
118 |
// xml.putProperty("columnTypeFont",columnTypeFont);
|
119 |
// xml.putProperty("columnStyleFont",columnStyleFont);
|
120 |
// return xml;
|
121 |
// }
|
122 |
// public static Annotation_Mapping createFromXML(XMLEntity xml) {
|
123 |
// Annotation_Mapping m=new Annotation_Mapping();
|
124 |
// m.setColumnText(xml.getIntProperty("columnText"));
|
125 |
// m.setColumnRotate(xml.getIntProperty("columnRotate"));
|
126 |
// m.setColumnColor(xml.getIntProperty("columnColor"));
|
127 |
// m.setColumnHeight(xml.getIntProperty("columnHeight"));
|
128 |
// m.setColumnTypeFont(xml.getIntProperty("columnTypeFont"));
|
129 |
// m.setColumnStyleFont(xml.getIntProperty("columnStyleFont"));
|
130 |
// return m;
|
131 |
// }
|
132 |
public static int getType(String column) { |
133 |
if (column.equals(TEXT)) {
|
134 |
return TYPETEXT;
|
135 |
} else if (column.equals(COLOR)) { |
136 |
return TYPECOLOR;
|
137 |
} else if (column.equals(ROTATE)) { |
138 |
return TYPEROTATE;
|
139 |
} else if (column.equals(COLOR)) { |
140 |
return TYPECOLOR;
|
141 |
} else if (column.equals(HEIGHT)) { |
142 |
return TYPEHEIGHT;
|
143 |
} else if (column.equals(TYPEFONT)) { |
144 |
return TYPETYPEFONT;
|
145 |
} else if (column.equals(STYLEFONT)) { |
146 |
return TYPESTYLEFONT;
|
147 |
} |
148 |
|
149 |
return Types.VARCHAR; |
150 |
} |
151 |
|
152 |
/**
|
153 |
* DOCUMENT ME!
|
154 |
*
|
155 |
* @param al
|
156 |
* DOCUMENT ME!
|
157 |
*
|
158 |
* @throws com.hardcode.gdbms.engine.data.driver.DriverException
|
159 |
* DOCUMENT ME!
|
160 |
*/
|
161 |
public static void addAnnotationMapping(Annotation_Layer al) |
162 |
throws com.hardcode.gdbms.engine.data.driver.DriverException {
|
163 |
Annotation_Mapping am = new Annotation_Mapping();
|
164 |
SelectableDataSource sds = al.getSource().getRecordset(); |
165 |
int numFields = sds.getFieldCount();
|
166 |
|
167 |
for (int i = 0; i < numFields; i++) { |
168 |
String nameField = sds.getFieldName(i);
|
169 |
|
170 |
if (nameField.equalsIgnoreCase(COLOR)) {
|
171 |
am.setColumnColor(i); |
172 |
} else if (nameField.equalsIgnoreCase(HEIGHT)) { |
173 |
am.setColumnHeight(i); |
174 |
} else if (nameField.equalsIgnoreCase(ROTATE)) { |
175 |
am.setColumnRotate(i); |
176 |
} else if (nameField.equalsIgnoreCase(STYLEFONT)) { |
177 |
am.setColumnStyleFont(i); |
178 |
} else if (nameField.equalsIgnoreCase(TEXT)) { |
179 |
am.setColumnText(i); |
180 |
} else if (nameField.equalsIgnoreCase(TYPEFONT)) { |
181 |
am.setColumnTypeFont(i); |
182 |
} |
183 |
} |
184 |
|
185 |
al.setMapping(am); |
186 |
} |
187 |
} |