Revision 6521 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dxf/DXFMemoryDriver.java
DXFMemoryDriver.java | ||
---|---|---|
54 | 54 |
import java.io.FileOutputStream; |
55 | 55 |
import java.io.IOException; |
56 | 56 |
import java.nio.channels.FileChannel; |
57 |
import java.sql.Types; |
|
57 | 58 |
import java.util.ArrayList; |
59 |
import java.util.Date; |
|
58 | 60 |
import java.util.Properties; |
59 | 61 |
|
60 | 62 |
import org.cresques.cts.IProjection; |
... | ... | |
90 | 92 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
91 | 93 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
92 | 94 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
95 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
|
93 | 96 |
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition; |
94 | 97 |
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition; |
95 | 98 |
import com.iver.cit.gvsig.fmap.drivers.MemoryDriver; |
... | ... | |
115 | 118 |
private static String tempDirectoryPath = System |
116 | 119 |
.getProperty("java.io.tmpdir"); |
117 | 120 |
|
118 |
private final int ID_FIELD_ID = 0; |
|
121 |
/* |
|
122 |
* azabala, bug 666: |
|
123 |
* retoco los ID para que sean static, y a?ado un FieldDescription[] por |
|
124 |
* defecto, ya que todos los ficheros DXF comparten el mismo esquema. |
|
125 |
* TODO Unificar el mecanismo de FieldDescription con el de |
|
126 |
* arrayFields. ArrayList arrayFields es util para el TableModel, pero el |
|
127 |
* problema es que el tipo de dato de todas las columnas es Object.class, mientras |
|
128 |
* que LayerDefinition si que tiene una verdadera descripcion del esquema |
|
129 |
* a emplear |
|
130 |
* |
|
131 |
* arrayFields.add("ID"); |
|
132 |
arrayFields.add("FShape"); |
|
133 |
arrayFields.add("Entity"); |
|
134 |
arrayFields.add("Layer"); |
|
135 |
arrayFields.add("Color"); |
|
136 |
arrayFields.add("Elevation"); |
|
137 |
arrayFields.add("Thickness"); |
|
138 |
arrayFields.add("Text"); |
|
139 |
arrayFields.add("HeightText"); |
|
140 |
arrayFields.add("RotationText"); |
|
141 |
*/ |
|
142 |
private final static int ID_FIELD_ID = 0; |
|
119 | 143 |
|
120 |
private final int ID_FIELD_FSHAPE = 1; |
|
144 |
private final static int ID_FIELD_FSHAPE = 1;
|
|
121 | 145 |
|
122 |
private final int ID_FIELD_ENTITY = 2; |
|
146 |
private final static int ID_FIELD_ENTITY = 2;
|
|
123 | 147 |
|
124 |
private final int ID_FIELD_LAYER = 3; |
|
148 |
private final static int ID_FIELD_LAYER = 3;
|
|
125 | 149 |
|
126 |
private final int ID_FIELD_COLOR = 4; |
|
150 |
private final static int ID_FIELD_COLOR = 4;
|
|
127 | 151 |
|
128 |
private final int ID_FIELD_ELEVATION = 5; |
|
152 |
private final static int ID_FIELD_ELEVATION = 5;
|
|
129 | 153 |
|
130 |
private final int ID_FIELD_THICKNESS = 6; |
|
154 |
private final static int ID_FIELD_THICKNESS = 6;
|
|
131 | 155 |
|
132 |
private final int ID_FIELD_TEXT = 7; |
|
156 |
private final static int ID_FIELD_TEXT = 7;
|
|
133 | 157 |
|
134 |
private final int ID_FIELD_HEIGHTTEXT = 8; |
|
158 |
private final static int ID_FIELD_HEIGHTTEXT = 8;
|
|
135 | 159 |
|
136 |
private final int ID_FIELD_ROTATIONTEXT = 9; |
|
137 |
|
|
160 |
private final static int ID_FIELD_ROTATIONTEXT = 9; |
|
161 |
|
|
162 |
private final static FieldDescription[] fields = new FieldDescription[10]; |
|
163 |
static{ |
|
164 |
FieldDescription fieldDesc = new FieldDescription(); |
|
165 |
fieldDesc.setFieldName("ID"); |
|
166 |
fieldDesc.setFieldType(Types.INTEGER); |
|
167 |
fieldDesc.setFieldLength(20); |
|
168 |
fieldDesc.setFieldDecimalCount(0); |
|
169 |
fields[0] = fieldDesc; |
|
170 |
|
|
171 |
fieldDesc = new FieldDescription(); |
|
172 |
fieldDesc.setFieldName("FShape"); |
|
173 |
fieldDesc.setFieldType(Types.VARCHAR); |
|
174 |
fieldDesc.setFieldLength(254); |
|
175 |
fieldDesc.setFieldDecimalCount(0); |
|
176 |
fields[1] = fieldDesc; |
|
177 |
|
|
178 |
fieldDesc = new FieldDescription(); |
|
179 |
fieldDesc.setFieldName("Entity"); |
|
180 |
fieldDesc.setFieldType(Types.VARCHAR); |
|
181 |
fieldDesc.setFieldLength(254); |
|
182 |
fieldDesc.setFieldDecimalCount(0); |
|
183 |
fields[2] = fieldDesc; |
|
184 |
|
|
185 |
fieldDesc = new FieldDescription(); |
|
186 |
fieldDesc.setFieldName("Layer"); |
|
187 |
fieldDesc.setFieldType(Types.VARCHAR); |
|
188 |
fieldDesc.setFieldLength(254); |
|
189 |
fieldDesc.setFieldDecimalCount(0); |
|
190 |
fields[3] = fieldDesc; |
|
191 |
|
|
192 |
fieldDesc = new FieldDescription(); |
|
193 |
fieldDesc.setFieldName("Color"); |
|
194 |
fieldDesc.setFieldType(Types.DOUBLE); |
|
195 |
fieldDesc.setFieldLength(20); |
|
196 |
fieldDesc.setFieldDecimalCount(5); |
|
197 |
fields[4] = fieldDesc; |
|
198 |
|
|
199 |
fieldDesc = new FieldDescription(); |
|
200 |
fieldDesc.setFieldName("Elevation"); |
|
201 |
fieldDesc.setFieldType(Types.DOUBLE); |
|
202 |
fieldDesc.setFieldLength(20); |
|
203 |
fieldDesc.setFieldDecimalCount(5); |
|
204 |
fields[5] = fieldDesc; |
|
205 |
|
|
206 |
fieldDesc = new FieldDescription(); |
|
207 |
fieldDesc.setFieldName("Thickness"); |
|
208 |
fieldDesc.setFieldType(Types.DOUBLE); |
|
209 |
fieldDesc.setFieldLength(20); |
|
210 |
fieldDesc.setFieldDecimalCount(5); |
|
211 |
fields[6] = fieldDesc; |
|
212 |
|
|
213 |
fieldDesc = new FieldDescription(); |
|
214 |
fieldDesc.setFieldName("Text"); |
|
215 |
fieldDesc.setFieldType(Types.VARCHAR); |
|
216 |
fieldDesc.setFieldLength(254); |
|
217 |
fieldDesc.setFieldDecimalCount(0); |
|
218 |
fields[7] = fieldDesc; |
|
219 |
|
|
220 |
fieldDesc = new FieldDescription(); |
|
221 |
fieldDesc.setFieldName("Height"); |
|
222 |
fieldDesc.setFieldType(Types.DOUBLE); |
|
223 |
fieldDesc.setFieldLength(20); |
|
224 |
fieldDesc.setFieldDecimalCount(5); |
|
225 |
fields[8] = fieldDesc; |
|
226 |
|
|
227 |
fieldDesc = new FieldDescription(); |
|
228 |
fieldDesc.setFieldName("Rotation"); |
|
229 |
fieldDesc.setFieldType(Types.DOUBLE); |
|
230 |
fieldDesc.setFieldLength(20); |
|
231 |
fieldDesc.setFieldDecimalCount(5); |
|
232 |
fields[9] = fieldDesc; |
|
233 |
|
|
234 |
} |
|
235 |
|
|
138 | 236 |
private DxfWriter dxfWriter = new DxfWriter(); |
139 | 237 |
|
140 | 238 |
private File fTemp; |
... | ... | |
859 | 957 |
public boolean canWriteAttribute(int sqlType) { |
860 | 958 |
return dxfWriter.canWriteAttribute(sqlType); |
861 | 959 |
} |
960 |
|
|
961 |
/** |
|
962 |
* Returns de field type of the specified field index. |
|
963 |
* @return field type of i field |
|
964 |
*/ |
|
965 |
public int getFieldType(int i) throws DriverException { |
|
966 |
//azabala: we overwrite MemoryDriver because type resolution |
|
967 |
//is based in first register value (it could be null) |
|
968 |
if(i >= fields.length) |
|
969 |
throw new DriverException("Excedido el numero de campos del dxf"); |
|
970 |
return fields[i].getFieldType(); |
|
971 |
} |
|
862 | 972 |
|
863 | 973 |
/* |
864 | 974 |
* (non-Javadoc) |
Also available in: Unified diff