Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / dxf / DXFMemoryDriver.java @ 6521

History | View | Annotate | Download (35.7 KB)

1
/*
2
 * @(#)DXFMemoryDriver    29-dic-2004
3
 *
4
 * @author jmorell (jose.morell@gmail.com)
5
 */
6
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
7
 *
8
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
9
 *
10
 * This program is free software; you can redistribute it and/or
11
 * modify it under the terms of the GNU General Public License
12
 * as published by the Free Software Foundation; either version 2
13
 * of the License, or (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program; if not, write to the Free Software
22
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
23
 *
24
 * For more information, contact:
25
 *
26
 *  Generalitat Valenciana
27
 *   Conselleria d'Infraestructures i Transport
28
 *   Av. Blasco Ib??ez, 50
29
 *   46010 VALENCIA
30
 *   SPAIN
31
 *
32
 *      +34 963862235
33
 *   gvsig@gva.es
34
 *      www.gvsig.gva.es
35
 *
36
 *    or
37
 *
38
 *   IVER T.I. S.A
39
 *   Salamanca 50
40
 *   46005 Valencia
41
 *   Spain
42
 *
43
 *   +34 963163400
44
 *   dac@iver.es
45
 */
46
package com.iver.cit.gvsig.fmap.drivers.dxf;
47

    
48
import java.awt.Color;
49
import java.awt.Font;
50
import java.awt.geom.Point2D;
51
import java.io.File;
52
import java.io.FileInputStream;
53
import java.io.FileNotFoundException;
54
import java.io.FileOutputStream;
55
import java.io.IOException;
56
import java.nio.channels.FileChannel;
57
import java.sql.Types;
58
import java.util.ArrayList;
59
import java.util.Date;
60
import java.util.Properties;
61

    
62
import org.cresques.cts.IProjection;
63
import org.cresques.geo.Point3D;
64
import org.cresques.io.DxfFile;
65
import org.cresques.px.IObjList;
66
import org.cresques.px.dxf.AcadColor;
67
import org.cresques.px.dxf.DxfFeatureMaker;
68
import org.cresques.px.dxf.DxfHeaderManager;
69
import org.cresques.px.gml.Feature;
70
import org.cresques.px.gml.LineString;
71
import org.cresques.px.gml.LineString3D;
72
import org.cresques.px.gml.Point;
73
import org.cresques.px.gml.Polygon;
74
import org.cresques.px.gml.Polygon3D;
75

    
76
import com.hardcode.gdbms.driver.DriverUtilities;
77
import com.hardcode.gdbms.engine.data.driver.DriverException;
78
import com.hardcode.gdbms.engine.data.driver.ObjectDriver;
79
import com.hardcode.gdbms.engine.data.edition.DataWare;
80
import com.hardcode.gdbms.engine.values.IntValue;
81
import com.hardcode.gdbms.engine.values.Value;
82
import com.hardcode.gdbms.engine.values.ValueFactory;
83
import com.iver.cit.gvsig.fmap.core.FPoint2D;
84
import com.iver.cit.gvsig.fmap.core.FPoint3D;
85
import com.iver.cit.gvsig.fmap.core.FPolygon2D;
86
import com.iver.cit.gvsig.fmap.core.FPolygon3D;
87
import com.iver.cit.gvsig.fmap.core.FPolyline2D;
88
import com.iver.cit.gvsig.fmap.core.FPolyline3D;
89
import com.iver.cit.gvsig.fmap.core.FShape;
90
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
91
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
92
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
93
import com.iver.cit.gvsig.fmap.crs.CRSFactory;
94
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
95
import com.iver.cit.gvsig.fmap.drivers.FieldDescription;
96
import com.iver.cit.gvsig.fmap.drivers.ILayerDefinition;
97
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition;
98
import com.iver.cit.gvsig.fmap.drivers.MemoryDriver;
99
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver;
100
import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend;
101
import com.iver.cit.gvsig.fmap.edition.EditionException;
102
import com.iver.cit.gvsig.fmap.edition.IRowEdited;
103
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter;
104
import com.iver.cit.gvsig.fmap.edition.IWriteable;
105
import com.iver.cit.gvsig.fmap.edition.IWriter;
106
import com.iver.cit.gvsig.fmap.edition.writers.dxf.DxfFieldsMapping;
107
import com.iver.cit.gvsig.fmap.edition.writers.dxf.DxfWriter;
108
import com.iver.cit.gvsig.fmap.rendering.Legend;
109
import com.iver.cit.gvsig.fmap.rendering.LegendFactory;
110
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend;
111

    
112
/**
113
 * @author jmorell (jose.morell@gmail.com)
114
 * @version 29-dic-2004
115
 */
116
public class DXFMemoryDriver extends MemoryDriver implements
117
                VectorialFileDriver, WithDefaultLegend, ISpatialWriter, IWriteable {
118
        private static String tempDirectoryPath = System
119
                        .getProperty("java.io.tmpdir");
120

    
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;
143

    
144
        private final static int ID_FIELD_FSHAPE = 1;
145

    
146
        private final static int ID_FIELD_ENTITY = 2;
147

    
148
        private final static int ID_FIELD_LAYER = 3;
149

    
150
        private final static int ID_FIELD_COLOR = 4;
151

    
152
        private final static int ID_FIELD_ELEVATION = 5;
153

    
154
        private final static int ID_FIELD_THICKNESS = 6;
155

    
156
        private final static int ID_FIELD_TEXT = 7;
157

    
158
        private final static int ID_FIELD_HEIGHTTEXT = 8;
159

    
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
        
236
        private DxfWriter dxfWriter = new DxfWriter();
237

    
238
        private File fTemp;
239

    
240
        VectorialUniqueValueLegend defaultLegend;
241

    
242
        private String path;
243

    
244
        private File m_Fich;
245

    
246
        private DxfFile.EntityFactory featureMaker;
247

    
248
        private DxfFile dxfFeatureFile;
249

    
250
        private IObjList.vector features;
251

    
252
        private DriverAttributes attr = new DriverAttributes();
253

    
254
        /**
255
         * Habilita la utilizaci?n del lector del HEADER del DXF.
256
         */
257
        private DxfFile.VarSettings headerManager;
258

    
259
        /*
260
         * (non-Javadoc)
261
         *
262
         * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#open(java.io.File)
263
         */
264
        public void open(File f) throws IOException {
265
                m_Fich = f;
266
        }
267

    
268
        public void initialize() throws IOException {
269
                float heightText = 10;
270

    
271
                attr.setLoadedInMemory(true);
272

    
273
                IProjection proj = CRSFactory.getCRS("EPSG:23030");
274
                featureMaker = new DxfFeatureMaker(proj);
275
                headerManager = new DxfHeaderManager();
276
                dxfFeatureFile = new DxfFile(proj, m_Fich.getAbsolutePath(),
277
                                featureMaker, headerManager);
278
                dxfFeatureFile.load();
279
                features = (IObjList.vector) ((DxfFeatureMaker) featureMaker)
280
                                .getObjects();
281
                String acadVersion = (String) ((DxfHeaderManager) headerManager)
282
                                .getAcadVersion();
283
                System.out.println("initialize(): acadVersion = " + acadVersion);
284
                if (!featureMaker.isDxf3DFile() && !headerManager.isWritedDxf3D()) { // y no
285
                                                                                                                                                                // est?n
286
                                                                                                                                                                // todos
287
                                                                                                                                                                // a
288
                                                                                                                                                                // 9999
289
                        Feature[] features2D = new Feature[features.size()];
290
                        for (int i = 0; i < features.size(); i++) {
291
                                Feature fea = (Feature) features.get(i);
292
                                if (fea.getGeometry() instanceof org.cresques.px.gml.Point3D) {
293
                                        Point point = (Point) fea.getGeometry();
294
                                        Point point2 = new Point();
295
                                        for (int j = 0; j < point.pointNr(); j++) {
296
                                                point2.add(point.get(j));
297
                                        }
298
                                        point2.setTextPoint(point.isTextPoint());
299
                                        fea.setGeometry(point2);
300
                                        features2D[i] = fea;
301
                                        // } else if (fea.getGeometry() instanceof InsPoint3D) {
302
                                        // InsPoint insPoint = (InsPoint)fea.getGeometry();
303
                                        // InsPoint insPoint2 = new InsPoint();
304
                                        // for (int j=0;j<insPoint.pointNr();j++) {
305
                                        // insPoint2.add(insPoint.get(j));
306
                                        // }
307
                                        // fea.setGeometry(insPoint2);
308
                                        // features2D[i] = fea;
309
                                } else if (fea.getGeometry() instanceof LineString3D) {
310
                                        LineString lineString = (LineString) fea.getGeometry();
311
                                        LineString lineString2 = new LineString();
312
                                        for (int j = 0; j < lineString.pointNr(); j++) {
313
                                                lineString2.add(lineString.get(j));
314
                                        }
315
                                        fea.setGeometry(lineString2);
316
                                        features2D[i] = fea;
317
                                } else if (fea.getGeometry() instanceof Polygon3D) {
318
                                        Polygon polygon = (Polygon) fea.getGeometry();
319
                                        Polygon polygon2 = new Polygon();
320
                                        for (int j = 0; j < polygon.pointNr(); j++) {
321
                                                polygon2.add(polygon.get(j));
322
                                        }
323
                                        fea.setGeometry(polygon2);
324
                                        features2D[i] = fea;
325
                                }
326
                        }
327
                        features.clear();
328
                        for (int i = 0; i < features2D.length; i++) {
329
                                features.add(features2D[i]);
330
                        }
331
                }
332
                // String acadVersion =
333
                // (String)((DxfHeaderManager)headerManager).getAcadVersion();
334
                // System.out.println("initialize(): acadVersion = " + acadVersion);
335

    
336
                int nAtt = featureMaker.getAttributes().size();
337

    
338
                // Campos de las MemoryLayer:
339
                Value[] auxRow = new Value[10 + nAtt];
340
                ArrayList arrayFields = new ArrayList();
341
                arrayFields.add("ID");
342
                arrayFields.add("FShape");
343
                arrayFields.add("Entity");
344
                arrayFields.add("Layer");
345
                arrayFields.add("Color");
346
                arrayFields.add("Elevation");
347
                arrayFields.add("Thickness");
348
                arrayFields.add("Text");
349
                arrayFields.add("HeightText");
350
                arrayFields.add("RotationText");
351
                for (int i = 0; i < nAtt; i++) {
352
                        String att[] = new String[2];
353
                        att = (String[]) featureMaker.getAttributes().get(i);
354
                        arrayFields.add(att[0]);
355
                }
356

    
357
                getTableModel().setColumnIdentifiers(arrayFields.toArray());
358

    
359
                for (int i = 0; i < features.size(); i++) {
360

    
361
                        auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(0.0);
362
                        auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0.0);
363
                        auxRow[ID_FIELD_TEXT] = ValueFactory.createNullValue();
364

    
365
                        Feature fea = (Feature) features.get(i);
366
                        if (fea.getGeometry() instanceof Point
367
                                        && !(fea.getGeometry() instanceof org.cresques.px.gml.Point3D)) {
368
                                Point point = (Point) fea.getGeometry();
369
                                Point2D pto = new Point2D.Double();
370
                                pto = (Point2D) point.get(0);
371
                                FShape nuevoShp;
372
                                if (point.isTextPoint()) {
373
                                        auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
374
                                        auxRow[ID_FIELD_FSHAPE] = ValueFactory
375
                                                        .createValue(new String("FPoint2D"));
376
                                        auxRow[ID_FIELD_ENTITY] = ValueFactory
377
                                                        .createValue(new String(fea.getProp("dxfEntity")));
378
                                        auxRow[ID_FIELD_LAYER] = ValueFactory
379
                                                        .createValue(new String(fea.getProp("layer")));
380
                                        int auxInt = Integer.parseInt(fea.getProp("color"));
381
                                        auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
382
                                        auxRow[ID_FIELD_TEXT] = ValueFactory
383
                                                        .createValue(new String(fea.getProp("text")));
384
                                        heightText = Float.parseFloat(fea.getProp("textHeight"));
385
                                        auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory
386
                                                        .createValue(heightText);
387
                                        double auxR = Double.parseDouble(fea
388
                                                        .getProp("textRotation"));
389
                                        auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory
390
                                                        .createValue(auxR);
391
                                        double auxE = Double.parseDouble(fea.getProp("elevation"));
392
                                        auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
393
                                        double auxT = Double.parseDouble(fea.getProp("thickness"));
394
                                        auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
395
                                        // Attributes
396
                                        for (int j = 0; j < nAtt; j++) {
397
                                                String[] attributes = new String[2];
398
                                                attributes = (String[]) featureMaker.getAttributes()
399
                                                                .get(j);
400
                                                auxRow[10 + j] = ValueFactory.createValue(new String(
401
                                                                (String) attributes[1]));
402
                                                if (!fea.getProp(attributes[0]).equals(attributes[1])) {
403
                                                        auxRow[10 + j] = ValueFactory
404
                                                                        .createValue(new String(fea
405
                                                                                        .getProp(attributes[0])));
406
                                                }
407
                                        }
408
                                        nuevoShp = new FPoint2D(pto.getX(), pto.getY());
409
                                        addShape(nuevoShp, auxRow);
410
                                } else {
411
                                        auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
412
                                        auxRow[ID_FIELD_FSHAPE] = ValueFactory
413
                                                        .createValue(new String("FPoint2D"));
414
                                        auxRow[ID_FIELD_ENTITY] = ValueFactory
415
                                                        .createValue(new String(fea.getProp("dxfEntity")));
416
                                        auxRow[ID_FIELD_LAYER] = ValueFactory
417
                                                        .createValue(new String(fea.getProp("layer")));
418
                                        int auxInt = Integer.parseInt(fea.getProp("color"));
419
                                        auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
420
                                        double auxE = Double.parseDouble(fea.getProp("elevation"));
421
                                        auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
422
                                        double auxT = Double.parseDouble(fea.getProp("thickness"));
423
                                        auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
424
                                        // Attributes
425
                                        for (int j = 0; j < nAtt; j++) {
426
                                                String[] attributes = new String[2];
427
                                                attributes = (String[]) featureMaker.getAttributes()
428
                                                                .get(j);
429
                                                auxRow[10 + j] = ValueFactory.createValue(new String(
430
                                                                (String) attributes[1]));
431
                                                if (!fea.getProp(attributes[0]).equals(attributes[1])) {
432
                                                        auxRow[10 + j] = ValueFactory
433
                                                                        .createValue(new String(fea
434
                                                                                        .getProp(attributes[0])));
435
                                                }
436
                                        }
437
                                        nuevoShp = new FPoint2D(pto.getX(), pto.getY());
438
                                        addShape(nuevoShp, auxRow);
439
                                }
440
                        } else if (fea.getGeometry() instanceof org.cresques.px.gml.Point3D) {
441
                                org.cresques.px.gml.Point3D point = (org.cresques.px.gml.Point3D) fea
442
                                                .getGeometry();
443
                                Point3D pto = new Point3D();
444
                                pto = (Point3D) point.getPoint3D(0);
445
                                FShape nuevoShp;
446
                                if (point.isTextPoint()) {
447
                                        auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
448
                                        auxRow[ID_FIELD_FSHAPE] = ValueFactory
449
                                                        .createValue(new String("FPoint3D"));
450
                                        auxRow[ID_FIELD_ENTITY] = ValueFactory
451
                                                        .createValue(new String(fea.getProp("dxfEntity")));
452
                                        auxRow[ID_FIELD_LAYER] = ValueFactory
453
                                                        .createValue(new String(fea.getProp("layer")));
454
                                        int auxInt = Integer.parseInt(fea.getProp("color"));
455
                                        auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
456
                                        auxRow[ID_FIELD_TEXT] = ValueFactory
457
                                                        .createValue(new String(fea.getProp("text")));
458
                                        heightText = Float.parseFloat(fea.getProp("textHeight"));
459
                                        auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory
460
                                                        .createValue(heightText);
461
                                        double auxR = Double.parseDouble(fea
462
                                                        .getProp("textRotation"));
463
                                        auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory
464
                                                        .createValue(auxR);
465
                                        double auxE = Double.parseDouble(fea.getProp("elevation"));
466
                                        auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
467
                                        double auxT = Double.parseDouble(fea.getProp("thickness"));
468
                                        auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
469
                                        // Attributes
470
                                        for (int j = 0; j < nAtt; j++) {
471
                                                String[] attributes = new String[2];
472
                                                attributes = (String[]) featureMaker.getAttributes()
473
                                                                .get(j);
474
                                                auxRow[10 + j] = ValueFactory.createValue(new String(
475
                                                                (String) attributes[1]));
476
                                                if (!fea.getProp(attributes[0]).equals(attributes[1])) {
477
                                                        auxRow[10 + j] = ValueFactory
478
                                                                        .createValue(new String(fea
479
                                                                                        .getProp(attributes[0])));
480
                                                }
481
                                        }
482
                                        nuevoShp = new FPoint3D(pto.getX(), pto.getY(), pto.getZ());
483
                                        addShape(nuevoShp, auxRow);
484
                                } else {
485
                                        auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
486
                                        auxRow[ID_FIELD_FSHAPE] = ValueFactory
487
                                                        .createValue(new String("FPoint3D"));
488
                                        auxRow[ID_FIELD_ENTITY] = ValueFactory
489
                                                        .createValue(new String(fea.getProp("dxfEntity")));
490
                                        auxRow[ID_FIELD_LAYER] = ValueFactory
491
                                                        .createValue(new String(fea.getProp("layer")));
492
                                        int auxInt = Integer.parseInt(fea.getProp("color"));
493
                                        auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
494
                                        double auxE = Double.parseDouble(fea.getProp("elevation"));
495
                                        auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
496
                                        double auxT = Double.parseDouble(fea.getProp("thickness"));
497
                                        auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
498
                                        // Attributes
499
                                        for (int j = 0; j < nAtt; j++) {
500
                                                String[] attributes = new String[2];
501
                                                attributes = (String[]) featureMaker.getAttributes()
502
                                                                .get(j);
503
                                                auxRow[10 + j] = ValueFactory.createValue(new String(
504
                                                                (String) attributes[1]));
505
                                                if (!fea.getProp(attributes[0]).equals(attributes[1])) {
506
                                                        auxRow[10 + j] = ValueFactory
507
                                                                        .createValue(new String(fea
508
                                                                                        .getProp(attributes[0])));
509
                                                }
510
                                        }
511
                                        nuevoShp = new FPoint3D(pto.getX(), pto.getY(), pto.getZ());
512
                                        addShape(nuevoShp, auxRow);
513
                                }
514
                                /*
515
                                 * } else if (fea.getGeometry() instanceof InsPoint &&
516
                                 * !(fea.getGeometry() instanceof InsPoint3D)) { InsPoint
517
                                 * insPoint = (InsPoint)fea.getGeometry(); Point2D pto = new
518
                                 * Point2D.Double(); pto = (Point2D)insPoint.get(0);
519
                                 * auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
520
                                 * auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new
521
                                 * String("PointZ")); auxRow[ID_FIELD_ENTITY] =
522
                                 * ValueFactory.createValue(new
523
                                 * String(fea.getProp("dxfEntity"))); auxRow[ID_FIELD_LAYER] =
524
                                 * ValueFactory.createValue(new String(fea.getProp("layer")));
525
                                 * int auxInt = Integer.parseInt(fea.getProp("color"));
526
                                 * auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
527
                                 * double auxE = Double.parseDouble(fea.getProp("elevation"));
528
                                 * auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); //
529
                                 * Attributes for (int j=0;j<nAtt;j++) { String[] attributes =
530
                                 * new String[2]; attributes =
531
                                 * (String[])featureMaker.getAttributes().get(j); auxRow[9+j] =
532
                                 * ValueFactory.createValue(new String((String)attributes[1]));
533
                                 * if (!fea.getProp(attributes[0]).equals(attributes[1])) {
534
                                 * auxRow[9+j] = ValueFactory.createValue(new
535
                                 * String(fea.getProp(attributes[0]))); } } FShape nuevoShp =
536
                                 * new FPoint2D(pto.getX(),pto.getY()); addShape(nuevoShp,
537
                                 * auxRow); } else if (fea.getGeometry() instanceof InsPoint3D) {
538
                                 * InsPoint3D insPoint = (InsPoint3D)fea.getGeometry(); Point3D
539
                                 * pto = new Point3D(); pto = (Point3D)insPoint.getPoint3D(0);
540
                                 * auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
541
                                 * auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new
542
                                 * String("PointZ")); auxRow[ID_FIELD_ENTITY] =
543
                                 * ValueFactory.createValue(new
544
                                 * String(fea.getProp("dxfEntity"))); auxRow[ID_FIELD_LAYER] =
545
                                 * ValueFactory.createValue(new String(fea.getProp("layer")));
546
                                 * int auxInt = Integer.parseInt(fea.getProp("color"));
547
                                 * auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
548
                                 * double auxE = Double.parseDouble(fea.getProp("elevation"));
549
                                 * auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE); //
550
                                 * Attributes for (int j=0;j<nAtt;j++) { String[] attributes =
551
                                 * new String[2]; attributes =
552
                                 * (String[])featureMaker.getAttributes().get(j); auxRow[9+j] =
553
                                 * ValueFactory.createValue(new String((String)attributes[1]));
554
                                 * if (!fea.getProp(attributes[0]).equals(attributes[1])) {
555
                                 * auxRow[9+j] = ValueFactory.createValue(new
556
                                 * String(fea.getProp(attributes[0]))); } } FShape nuevoShp =
557
                                 * new FPoint3D(pto.getX(),pto.getY(),pto.getZ());
558
                                 * addShape(nuevoShp, auxRow);
559
                                 */
560
                        } else if (fea.getGeometry() instanceof LineString
561
                                        && !(fea.getGeometry() instanceof LineString3D)) {
562
                                GeneralPathX genPathX = new GeneralPathX();
563
                                Point2D[] pts = new Point2D[fea.getGeometry().pointNr()];
564
                                for (int j = 0; j < fea.getGeometry().pointNr(); j++) {
565
                                        pts[j] = (Point2D) fea.getGeometry().get(j);
566
                                }
567
                                genPathX.moveTo(pts[0].getX(), pts[0].getY());
568
                                for (int j = 1; j < pts.length; j++) {
569
                                        genPathX.lineTo(pts[j].getX(), pts[j].getY());
570
                                }
571
                                // double[] elevations = new double[pts.length];
572
                                // for (int j=0;j<pts.length;j++) {
573
                                // elevations[j]=pts[j].getZ();
574
                                // }
575
                                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
576
                                auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String(
577
                                                "FPolyline2D"));
578
                                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(
579
                                                fea.getProp("dxfEntity")));
580
                                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(
581
                                                fea.getProp("layer")));
582
                                int auxInt = Integer.parseInt(fea.getProp("color"));
583
                                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
584
                                double auxE = Double.parseDouble(fea.getProp("elevation"));
585
                                auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
586
                                double auxT = Double.parseDouble(fea.getProp("thickness"));
587
                                auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
588
                                // Attributes
589
                                for (int j = 0; j < nAtt; j++) {
590
                                        String[] attributes = new String[2];
591
                                        attributes = (String[]) featureMaker.getAttributes().get(j);
592
                                        auxRow[10 + j] = ValueFactory.createValue(new String(
593
                                                        (String) attributes[1]));
594
                                        if (!fea.getProp(attributes[0]).equals(attributes[1])) {
595
                                                auxRow[10 + j] = ValueFactory.createValue(new String(
596
                                                                fea.getProp(attributes[0])));
597
                                        }
598
                                }
599
                                FShape nuevoShp = new FPolyline2D(genPathX);
600
                                addShape(nuevoShp, auxRow);
601
                        } else if (fea.getGeometry() instanceof LineString3D) {
602
                                GeneralPathX genPathX = new GeneralPathX();
603
                                Point3D[] pts = new Point3D[fea.getGeometry().pointNr()];
604
                                for (int j = 0; j < fea.getGeometry().pointNr(); j++) {
605
                                        pts[j] = ((LineString3D) fea.getGeometry()).getPoint3D(j);
606
                                }
607
                                genPathX.moveTo(pts[0].getX(), pts[0].getY());
608
                                for (int j = 1; j < pts.length; j++) {
609
                                        genPathX.lineTo(pts[j].getX(), pts[j].getY());
610
                                }
611
                                double[] elevations = new double[pts.length];
612
                                for (int j = 0; j < pts.length; j++) {
613
                                        elevations[j] = pts[j].getZ();
614
                                }
615
                                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
616
                                auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String(
617
                                                "FPolyline3D"));
618
                                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(
619
                                                fea.getProp("dxfEntity")));
620
                                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(
621
                                                fea.getProp("layer")));
622
                                int auxInt = Integer.parseInt(fea.getProp("color"));
623
                                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
624
                                if (fea.getProp("elevation") != null) {
625
                                        double auxE = Double.parseDouble(fea.getProp("elevation"));
626
                                        auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
627
                                }
628
                                double auxT = Double.parseDouble(fea.getProp("thickness"));
629
                                auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
630
                                // Attributes
631
                                for (int j = 0; j < nAtt; j++) {
632
                                        String[] attributes = new String[2];
633
                                        attributes = (String[]) featureMaker.getAttributes().get(j);
634
                                        auxRow[10 + j] = ValueFactory.createValue(new String(
635
                                                        (String) attributes[1]));
636
                                        if (!fea.getProp(attributes[0]).equals(attributes[1])) {
637
                                                auxRow[10 + j] = ValueFactory.createValue(new String(
638
                                                                fea.getProp(attributes[0])));
639
                                        }
640
                                }
641
                                FShape nuevoShp = new FPolyline3D(genPathX, elevations);
642
                                addShape(nuevoShp, auxRow);
643
                        } else if (fea.getGeometry() instanceof Polygon
644
                                        && !(fea.getGeometry() instanceof Polygon3D)) {
645
                                GeneralPathX genPathX = new GeneralPathX();
646
                                // 050112: A?ado una posici?n m?s para el punto que cierra y
647
                                // creo el objeto firstPt.
648
                                Point2D firstPt = new Point2D.Double();
649
                                firstPt = (Point2D) fea.getGeometry().get(0);
650
                                Point2D[] pts = new Point2D[fea.getGeometry().pointNr() + 1];
651
                                for (int j = 0; j < fea.getGeometry().pointNr(); j++) {
652
                                        pts[j] = (Point2D) fea.getGeometry().get(j);
653
                                }
654
                                // 050112: A?ado el primer punto al final para cerrar los
655
                                // pol?gonos.
656
                                pts[fea.getGeometry().pointNr()] = firstPt;
657
                                genPathX.moveTo(pts[0].getX(), pts[0].getY());
658
                                for (int j = 1; j < pts.length; j++) {
659
                                        genPathX.lineTo(pts[j].getX(), pts[j].getY());
660
                                }
661
                                // double[] elevations = new double[pts.length];
662
                                // for (int j=0;j<pts.length;j++) {
663
                                // elevations[j]=pts[j].getZ();
664
                                // }
665
                                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
666
                                auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String(
667
                                                "FPolygon2D"));
668
                                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(
669
                                                fea.getProp("dxfEntity")));
670
                                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(
671
                                                fea.getProp("layer")));
672
                                int auxInt = Integer.parseInt(fea.getProp("color"));
673
                                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
674
                                double auxE = Double.parseDouble(fea.getProp("elevation"));
675
                                auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
676
                                double auxT = Double.parseDouble(fea.getProp("thickness"));
677
                                auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
678
                                // Attributes
679
                                for (int j = 0; j < nAtt; j++) {
680
                                        String[] attributes = new String[2];
681
                                        attributes = (String[]) featureMaker.getAttributes().get(j);
682
                                        auxRow[10 + j] = ValueFactory.createValue(new String(
683
                                                        (String) attributes[1]));
684
                                        if (!fea.getProp(attributes[0]).equals(attributes[1])) {
685
                                                auxRow[10 + j] = ValueFactory.createValue(new String(
686
                                                                fea.getProp(attributes[0])));
687
                                        }
688
                                }
689
                                FShape nuevoShp = new FPolygon2D(genPathX);
690
                                addShape(nuevoShp, auxRow);
691
                        } else if (fea.getGeometry() instanceof Polygon3D) {
692
                                GeneralPathX genPathX = new GeneralPathX();
693
                                // 050112: A?ado una posici?n m?s para el punto que cierra y
694
                                // creo el objeto firstPt.
695
                                Point3D firstPt = new Point3D();
696
                                firstPt = (Point3D) ((Polygon3D) fea.getGeometry())
697
                                                .getPoint3D(0);
698
                                Point3D[] pts = new Point3D[fea.getGeometry().pointNr() + 1];
699
                                for (int j = 0; j < fea.getGeometry().pointNr(); j++) {
700
                                        pts[j] = (Point3D) ((Polygon3D) fea.getGeometry())
701
                                                        .getPoint3D(j);
702
                                }
703
                                // 050112: A?ado el primer punto al final para cerrar los
704
                                // pol?gonos.
705
                                pts[fea.getGeometry().pointNr()] = firstPt;
706
                                genPathX.moveTo(pts[0].getX(), pts[0].getY());
707
                                for (int j = 1; j < pts.length; j++) {
708
                                        genPathX.lineTo(pts[j].getX(), pts[j].getY());
709
                                }
710
                                double[] elevations = new double[pts.length];
711
                                for (int j = 0; j < pts.length; j++) {
712
                                        elevations[j] = pts[j].getZ();
713
                                }
714
                                auxRow[ID_FIELD_ID] = ValueFactory.createValue(i);
715
                                auxRow[ID_FIELD_FSHAPE] = ValueFactory.createValue(new String(
716
                                                "FPolygon3D"));
717
                                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(new String(
718
                                                fea.getProp("dxfEntity")));
719
                                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(new String(
720
                                                fea.getProp("layer")));
721
                                int auxInt = Integer.parseInt(fea.getProp("color"));
722
                                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(auxInt);
723
                                if (fea.getProp("elevation") != null) {
724
                                        double auxE = Double.parseDouble(fea.getProp("elevation"));
725
                                        auxRow[ID_FIELD_ELEVATION] = ValueFactory.createValue(auxE);
726
                                }
727
                                double auxT = Double.parseDouble(fea.getProp("thickness"));
728
                                auxRow[ID_FIELD_THICKNESS] = ValueFactory.createValue(auxT);
729
                                // Attributes
730
                                for (int j = 0; j < nAtt; j++) {
731
                                        String[] attributes = new String[2];
732
                                        attributes = (String[]) featureMaker.getAttributes().get(j);
733
                                        auxRow[10 + j] = ValueFactory.createValue(new String(
734
                                                        (String) attributes[1]));
735
                                        if (!fea.getProp(attributes[0]).equals(attributes[1])) {
736
                                                auxRow[10 + j] = ValueFactory.createValue(new String(
737
                                                                fea.getProp(attributes[0])));
738
                                        }
739
                                }
740
                                FShape nuevoShp = new FPolygon3D(genPathX, elevations);
741
                                addShape(nuevoShp, auxRow);
742
                        } else {
743
                                // System.out.println("Detectado feature desconocido");
744
                        }
745
                }
746

    
747
                defaultLegend = LegendFactory
748
                                .createVectorialUniqueValueLegend(getShapeType());
749
                defaultLegend.setFieldName("Color");
750
                defaultLegend.setLabelField("Text");
751
                defaultLegend.setDefaultSymbol(new FSymbol(getShapeType()));
752
                defaultLegend.getDefaultSymbol().setShapeVisible(false);
753
                defaultLegend.getDefaultSymbol().setFontSizeInPixels(false);
754
                defaultLegend.getDefaultSymbol().setFont(
755
                                new Font("SansSerif", Font.PLAIN, 9));
756
                defaultLegend.getDefaultSymbol().setFontColor(Color.BLACK);
757
                defaultLegend.getDefaultSymbol().setFontSize(heightText);
758
                defaultLegend.getDefaultSymbol().setStyle(
759
                                FConstant.SYMBOL_STYLE_DGNSPECIAL);
760
                defaultLegend.getDefaultSymbol().setSize(3);
761
                defaultLegend.getDefaultSymbol().setSizeInPixels(true);
762

    
763
                defaultLegend.setLabelHeightField("HeightText");
764
                defaultLegend.setLabelRotationField("RotationText");
765

    
766
                ObjectDriver rs = this;
767
                IntValue clave;
768
                FSymbol theSymbol = null;
769

    
770
                try {
771
                        // TODO: Provisional hasta que cambiemos los s?mbolos.
772
                        /*
773
                         * BufferedImage bi= new BufferedImage(5, 5,
774
                         * BufferedImage.TYPE_INT_ARGB); Graphics2D big =
775
                         * bi.createGraphics(); Color color=new Color(0,0,0,0);
776
                         * big.setBackground(color); big.clearRect(0, 0, 5, 5); Paint
777
                         * fillProv = null; Rectangle2D rProv = new Rectangle();
778
                         * rProv.setFrame(0, 0,5,5); fillProv = new TexturePaint(bi,rProv);
779
                         */
780

    
781
                        for (long j = 0; j < rs.getRowCount(); j++) {
782
                                clave = (IntValue) rs.getFieldValue(j, ID_FIELD_COLOR);
783
                                if (defaultLegend.getSymbolByValue(clave) == null) {
784
                                        theSymbol = new FSymbol(getShapeType());
785
                                        theSymbol.setDescription(clave.toString());
786
                                        theSymbol.setColor(AcadColor.getColor(clave.getValue()));
787
                                        // theSymbol.setFill(fillProv);
788
                                        // 050202, jmorell: Asigna los colores de Autocad a los
789
                                        // bordes
790
                                        // de los pol?gonos.
791
                                        theSymbol.setOutlineColor(AcadColor.getColor(clave
792
                                                        .getValue()));
793

    
794
                                        theSymbol.setStyle(FConstant.SYMBOL_STYLE_DGNSPECIAL);
795
                                        theSymbol.setSize(3);
796
                                        theSymbol.setSizeInPixels(true);
797

    
798
                                        defaultLegend.addSymbol(clave, theSymbol);
799
                                }
800
                        } // for
801
                } catch (DriverException e) {
802
                        e.printStackTrace();
803
                        throw new IOException(
804
                                        "Error al poner la leyenda por defecto en el DXF");
805
                }
806
        }
807

    
808
        /*
809
         * (non-Javadoc)
810
         *
811
         * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#accept(java.io.File)
812
         */
813
        public boolean accept(File f) {
814
                return f.getName().toUpperCase().endsWith("DXF");
815
        }
816

    
817
        /*
818
         * (non-Javadoc)
819
         *
820
         * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#getShapeType()
821
         */
822
        public int getShapeType() {
823
                return FShape.MULTI;
824
        }
825

    
826
        /*
827
         * (non-Javadoc)
828
         *
829
         * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#getName()
830
         */
831
        public String getName() {
832
                return "gvSIG DXF Memory Driver";
833
        }
834

    
835
        /*
836
         * (non-Javadoc)
837
         *
838
         * @see com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend#getDefaultLegend()
839
         */
840
        public Legend getDefaultLegend() {
841
                return defaultLegend;
842
        }
843

    
844
        /*
845
         * (non-Javadoc)
846
         *
847
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getDriverAttributes()
848
         */
849
        public DriverAttributes getDriverAttributes() {
850
                return attr;
851
        }
852

    
853
        /**
854
         * @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#getPrimaryKeys()
855
         */
856
        public int[] getPrimaryKeys() throws DriverException {
857
                return null;
858
        }
859

    
860
        /**
861
         * @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#write(com.hardcode.gdbms.engine.data.edition.DataWare)
862
         */
863
        public void write(DataWare arg0) throws DriverException {
864
                // TODO Auto-generated method stub
865

    
866
        }
867

    
868
        /*
869
         * (non-Javadoc)
870
         *
871
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#close()
872
         */
873
        public void close() throws IOException {
874
                // TODO Auto-generated method stub
875

    
876
        }
877

    
878
        public File getFile() {
879
                return m_Fich;
880
        }
881

    
882
        public boolean canWriteGeometry(int gvSIGgeometryType) {
883
                return dxfWriter.canWriteGeometry(gvSIGgeometryType);
884
        }
885

    
886
        public void initialize(ITableDefinition layerDef) throws EditionException {
887
                int aux = (int) (Math.random() * 1000);
888
                fTemp = new File(tempDirectoryPath + "/tmpDxf" + aux + ".dxf");
889
                dxfWriter.setFile(fTemp);
890

    
891
                dxfWriter.initialize(layerDef);
892
                /*
893
                 * arrayFields.add("ID"); arrayFields.add("FShape");
894
                 * arrayFields.add("Entity"); arrayFields.add("Layer");
895
                 * arrayFields.add("Color"); arrayFields.add("Elevation");
896
                 * arrayFields.add("Thickness"); arrayFields.add("Text");
897
                 * arrayFields.add("HeightText"); arrayFields.add("RotationText");
898
                 */
899

    
900
                DxfFieldsMapping fieldsMapping = new DxfFieldsMapping();
901
                fieldsMapping.setLayerField("Layer");
902
                fieldsMapping.setColorField("Color");
903
                fieldsMapping.setElevationField("Elevation");
904
                fieldsMapping.setThicknessField("Thickness");
905
                fieldsMapping.setTextField("Text");
906
                fieldsMapping.setHeightText("HeightText");
907
                fieldsMapping.setRotationText("Layer");
908
                dxfWriter.setFieldMapping(fieldsMapping);
909
                dxfWriter.setProjection(((ILayerDefinition)layerDef).getProjection());
910
        }
911

    
912
        public void preProcess() throws EditionException {
913
                dxfWriter.preProcess();
914
        }
915

    
916
        public void process(IRowEdited row) throws EditionException {
917
                dxfWriter.process(row);
918
        }
919

    
920
        public void postProcess() throws EditionException {
921
                dxfWriter.postProcess();
922
                try {
923

    
924
                        // close();
925

    
926
                        // Dxf
927
                        FileChannel fcinDxf = new FileInputStream(fTemp).getChannel();
928
                        FileChannel fcoutDxf = new FileOutputStream(m_Fich).getChannel();
929
                        DriverUtilities.copy(fcinDxf, fcoutDxf);
930

    
931
                        // Borramos los temporales
932
                        fTemp.delete();
933
                        reload();
934

    
935
                } catch (FileNotFoundException e) {
936
                        e.printStackTrace();
937
                        throw new EditionException(e);
938
                } catch (IOException e) {
939
                        e.printStackTrace();
940
                        throw new EditionException(e);
941
                } catch (DriverException e) {
942
                        e.printStackTrace();
943
                        throw new EditionException(e);                        
944
                }
945

    
946
        }
947

    
948
        public String getCapability(String capability) {
949
                return dxfWriter.getCapability(capability);
950
        }
951

    
952
        public void setCapabilities(Properties capabilities) {
953
                dxfWriter.setCapabilities(capabilities);
954

    
955
        }
956

    
957
        public boolean canWriteAttribute(int sqlType) {
958
                return dxfWriter.canWriteAttribute(sqlType);
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
        }
972

    
973
        /*
974
         * (non-Javadoc)
975
         *
976
         * @see com.iver.cit.gvsig.fmap.drivers.MemoryDriver#reLoad()
977
         */
978
        public void reload() throws IOException, DriverException {
979
                super.reload();
980
                try {
981
                        initialize();
982
                } catch (IOException e) {
983
                        e.printStackTrace();
984
                        throw new IOException("DXF: Error reloading " + path + " file.");
985
                }
986
        }
987

    
988
        public void setFlatness(double flatness) {
989
                // TODO Auto-generated method stub
990

    
991
        }
992

    
993
        public boolean isWritable() {
994
                return m_Fich.canWrite();
995
        }
996

    
997
        public IWriter getWriter() {
998
                return this;
999
        }
1000

    
1001
        public ITableDefinition getTableDefinition() {
1002
                return dxfWriter.getTableDefinition();
1003
        }
1004

    
1005
        public boolean canAlterTable() {
1006
                return false;
1007
        }
1008

    
1009
}