Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / dgn / DgnMemoryDriver.java @ 843

History | View | Annotate | Download (20.9 KB)

1
package com.iver.cit.gvsig.fmap.drivers.dgn;
2

    
3
import java.awt.Color;
4
import java.awt.Font;
5
import java.awt.geom.AffineTransform;
6
import java.awt.geom.Arc2D;
7
import java.io.File;
8
import java.io.IOException;
9
import java.util.ArrayList;
10

    
11
import com.hardcode.gdbms.engine.data.DriverException;
12
import com.hardcode.gdbms.engine.data.ReadDriver;
13
import com.hardcode.gdbms.engine.values.IntValue;
14
import com.hardcode.gdbms.engine.values.Value;
15
import com.hardcode.gdbms.engine.values.ValueFactory;
16
import com.iver.cit.gvsig.fmap.core.FPoint2D;
17
import com.iver.cit.gvsig.fmap.core.FPoint3D;
18
import com.iver.cit.gvsig.fmap.core.FPolygon2D;
19
import com.iver.cit.gvsig.fmap.core.FPolyline2D;
20
import com.iver.cit.gvsig.fmap.core.FShape;
21
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
22
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
23
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
24
import com.iver.cit.gvsig.fmap.drivers.MemoryDriver;
25
import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend;
26
import com.iver.cit.gvsig.fmap.rendering.Legend;
27
import com.iver.cit.gvsig.fmap.rendering.LegendFactory;
28
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend;
29

    
30

    
31
/**
32
 * DOCUMENT ME!
33
 *
34
 * @author Vicente Caballero Navarro
35
 */
36
public class DgnMemoryDriver extends MemoryDriver implements WithDefaultLegend {
37
        private final int ID_FIELD_ID=0;
38
        private final int ID_FIELD_ENTITY=1;
39
        private final int ID_FIELD_LAYER=2;
40
        private final int ID_FIELD_COLOR=3;
41
        private final int ID_FIELD_HEIGHTTEXT=4;
42
        private final int ID_FIELD_ROTATIONTEXT=5;
43
        private final int ID_FIELD_TEXT=6;
44
        
45

    
46
        DGNReader m_DgnReader;
47
        VectorialUniqueValueLegend defaultLegend;
48
        
49
        
50
        private String path;
51
        private File m_Fich;
52

    
53

    
54
        
55
    /**
56
     * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#open(java.io.File)
57
     */
58
    public void open(File f) throws IOException {
59
            m_Fich = f;
60
    }
61

    
62
    /**
63
     * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#initialize()
64
     */
65
    public void initialize() throws IOException {
66
            
67
                float heightText = 10;
68

    
69
            
70
            m_DgnReader = new DGNReader(m_Fich.getAbsolutePath());
71
            
72
            Value [] auxRow = new Value[7];
73
            Value [] cellRow = new Value[7];
74
            Value [] complexRow = new Value[7];
75
                ArrayList arrayFields = new ArrayList();
76
                arrayFields.add("ID");
77
                arrayFields.add("Entity");
78
                arrayFields.add("Layer");
79
                arrayFields.add("Color");
80
                arrayFields.add("HeightText");
81
                arrayFields.add("RotationText");
82
                arrayFields.add("Text");
83
            
84
            
85
            getTableModel().setColumnIdentifiers(arrayFields.toArray());
86
                
87
                
88
                // Ahora las rellenamos.
89
                FShape aux;
90
                boolean bElementoCompuesto = false, bEsPoligono = false;
91
                boolean bInsideCell = false;
92
                boolean bFirstHoleEntity = false;
93
                boolean bConnect = false; // Se usa para que los pol?gonos cierren bien cuando son formas compuestas
94
                int contadorSubElementos =0, numSubElementos = 0;
95
                int complex_index_fill_color= -1;
96
                int nClass; // Para filtrar los elementos de construcci?n, etc.
97
                GeneralPathX elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
98
                for (int id=0; id < m_DgnReader.getNumEntities(); id++)
99
                {
100
                        // System.out.println("Elemento " + id + " de " + m_DgnReader.getNumEntities());
101
                        m_DgnReader.DGNGotoElement(id);
102
                DGNElemCore elemento = m_DgnReader.DGNReadElement();
103
                nClass= 0;
104
            auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(0);
105
            auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0);
106
            auxRow[ID_FIELD_TEXT] = ValueFactory.createNullValue();
107

    
108
                if (elemento.properties != 0)
109
                        nClass = elemento.properties & DGNFileHeader.DGNPF_CLASS;
110
                if ((elemento != null) && (elemento.deleted == 0) && (nClass == 0)) //Leer un elemento
111
                 {
112
                        aux = null;
113
                        // if ((elemento.element_id > 3800) && (elemento.element_id < 3850))
114
                        //         m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(),elemento,""); 
115
                        
116
                        if ((elemento.stype == DGNFileHeader.DGNST_MULTIPOINT) || (elemento.stype == DGNFileHeader.DGNST_ARC)
117
                                        || (elemento.stype == DGNFileHeader.DGNST_CELL_HEADER)
118
                                                || (elemento.stype == DGNFileHeader.DGNST_SHARED_CELL_DEFN)
119
                                                || (elemento.stype == DGNFileHeader.DGNST_COMPLEX_HEADER))
120
                        {
121
                                if (elemento.complex != 0)
122
                                {
123
                                        bElementoCompuesto = true;
124
                                }
125
                                else
126
                                {                                
127
                                        if (bElementoCompuesto)
128
                                        {                                                
129
                                                if (bInsideCell)
130
                                                {
131
                                                        auxRow[ID_FIELD_ENTITY] = cellRow[ID_FIELD_ENTITY];
132
                                                }
133
                                                else
134
                                                {
135
                                                        auxRow = complexRow;
136
                                                }
137
                                                // System.err.println("Entidad compuesta. bInsideCell = " + bInsideCell + " auxRow = " + auxRow[ID_FIELD_ENTITY]);
138
                                                addShape(new FPolyline2D(elementoCompuesto), auxRow);
139
                                                if (bEsPoligono)
140
                                                {
141
                                                                if (complex_index_fill_color != -1)
142
                                                                        auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(complex_index_fill_color);
143

    
144
                                                        addShape(new FPolygon2D(elementoCompuesto), auxRow);
145
                                                }
146
                                                elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
147
                                        }
148
                                        // System.err.println("Entidad simple");
149
                                        bElementoCompuesto = false;
150
                                        bEsPoligono = false;
151
                                        bConnect = false;
152
                                        // elementoCompuesto = new GeneralPathX();
153
                                        bInsideCell = false;
154
                                }
155
                        }
156
                    switch (elemento.stype)
157
                                {
158
                                        case DGNFileHeader.DGNST_SHARED_CELL_DEFN:
159
                                                bInsideCell = true;
160
                                                cellRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id);
161
                                cellRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level);
162
                                cellRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
163
                                cellRow[ID_FIELD_ENTITY] = ValueFactory.createValue("Shared Cell");
164
                                                break;
165
                                        case DGNFileHeader.DGNST_CELL_HEADER:
166
                                                bInsideCell = true;
167
                                                DGNElemCellHeader psCellHeader = (DGNElemCellHeader) elemento;
168
                                                cellRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id);
169
                                cellRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level);
170
                                cellRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
171
                                cellRow[ID_FIELD_ENTITY] = ValueFactory.createValue("Cell");
172
                                complex_index_fill_color = m_DgnReader.DGNGetShapeFillInfo(elemento);
173
                                // System.err.println("Cell Header " + complex_index_fill_color);
174
                                                break;
175
        
176
                                        case DGNFileHeader.DGNST_COMPLEX_HEADER:
177
                                                // bElementoCompuesto = true;
178
                                                // System.err.println("Complex Header");
179
                                                contadorSubElementos = 0;
180
                                                DGNElemComplexHeader psComplexHeader = (DGNElemComplexHeader) elemento;
181
                                                numSubElementos = psComplexHeader.numelems;
182
                                                complexRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id);
183
                                complexRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level);
184
                                complexRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
185
                                complexRow[ID_FIELD_ENTITY] = ValueFactory.createValue("Complex");
186
                                
187
                                                
188
                                                if (psComplexHeader.type == DGNFileHeader.DGNT_COMPLEX_SHAPE_HEADER)
189
                                                {
190
                                                        bEsPoligono = true;
191
                                                        // Si es un agujero, no conectamos con el anterior
192
                                                        if ((psComplexHeader.properties & 0x8000) != 0)
193
                                                                bFirstHoleEntity = true;
194
                                                        else
195
                                                        {
196
                                                                // Miramos si tiene color de relleno
197
                                                                // complex_index_fill_color = -1;
198
                                                                // if (elemento.attr_bytes > 0) {
199
                                                                        complex_index_fill_color = m_DgnReader.DGNGetShapeFillInfo(elemento);
200
                                                                        // System.err.println("complex shape fill color = " + elemento.color);
201
                                                                // }
202
                                                                
203
                                                        }
204
                                                        bConnect = true;
205
                                                }
206
                                                else
207
                                                {
208
                                                        bEsPoligono = false;
209
                                                        bConnect = false;
210
                                                }
211
                                                break;
212
                                        case DGNFileHeader.DGNST_MULTIPOINT:
213
                                                // OJO: Si lo que viene en este multipoint es un elemento con type=11 (curve), se trata de una "parametric
214
                                                // spline curve". La vamos a tratar como si no fuera curva, pero seg?n la documentaci?n, los 2 primeros puntos
215
                                                // y los 2 ?ltimos puntos definen "endpoint derivatives" y NO se muestran.
216
                                                // TODAV?A HAY UN PEQUE?O FALLO CON EL FICHERO dgn-sample.dgn, pero lo dejo por ahora.
217
                                                // Es posible que tenga que ver con lo de los arcos (arco distorsionado), que
218
                                                // todav?a no est? metido.
219
                               DGNElemMultiPoint psLine = (DGNElemMultiPoint) elemento;                                                                        
220
                                
221
                                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level);
222
                                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
223
                                
224
                                if ((psLine.num_vertices == 2) && (psLine.vertices[0].x == psLine.vertices[1].x)
225
                                                && (psLine.vertices[0].y == psLine.vertices[1].y))
226
                                {
227
                                        auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue("Point");
228
                                        addShape(new FPoint3D(psLine.vertices[0].x,
229
                                                        psLine.vertices[0].y,psLine.vertices[0].z), auxRow);
230
                                }
231
                                else
232
                                {
233
                                       GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
234
                                       if (psLine.type == DGNFileHeader.DGNT_CURVE)
235
                                       {
236
                                                       psLine.num_vertices = psLine.num_vertices - 4;
237
                                                       for (int aux_n = 0; aux_n < psLine.num_vertices; aux_n++)
238
                                                       {
239
                                                               psLine.vertices[aux_n] = psLine.vertices[aux_n+2];
240
                                                       }
241
                                       }
242
                                       if ((psLine.type == DGNFileHeader.DGNT_SHAPE)
243
                                                       && ((psLine.properties & 0x8000) != 0))
244
                                       {
245
                                                       // Invertimos el orden porque es un agujero
246
                                               elShape.moveTo(psLine.vertices[psLine.num_vertices-1].x,
247
                                                               psLine.vertices[psLine.num_vertices-1].y);
248
                                               for (int i = psLine.num_vertices-2; i >= 0; i--)
249
                                                               elShape.lineTo( psLine.vertices[i].x,
250
                                                                               psLine.vertices[i].y);
251
                                       }
252
                                       else
253
                                       {
254
                                               elShape.moveTo(psLine.vertices[0].x, psLine.vertices[0].y);
255
                                               for (int i = 1; i < psLine.num_vertices; i++)
256
                                                               elShape.lineTo( psLine.vertices[i].x,
257
                                                                               psLine.vertices[i].y);
258
                                       }
259
                                                       
260
                                       auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id);
261
                                        auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue("Multipoint");
262
                                        
263
                                        
264
                                        if ((psLine.vertices[0].x == psLine.vertices[psLine.num_vertices-1].x)
265
                                                        && (psLine.vertices[0].y == psLine.vertices[psLine.num_vertices-1].y))
266
                                        {
267
                                                // Lo a?adimos tambi?n como pol?gono
268
                                                bEsPoligono = true;
269
                                                                // Miramos si tiene color de relleno
270
                                                                if (elemento.attr_bytes > 0) {
271
                                                                        elemento.color = m_DgnReader.DGNGetShapeFillInfo(elemento);
272
                                                                        // System.err.println("fill color = " + elemento.color);
273
                                                                        if (elemento.color != -1)
274
                                                                                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
275
                                                                }
276
                                                
277
                                                if (elemento.complex == 0)
278
                                                        addShape(new FPolygon2D(elShape), auxRow);
279
                                        }
280
                                        if (elemento.complex != 0)
281
                                                // Si es un agujero o 
282
                                                // es la primera entidad del agujero, lo a?adimos sin unir al anterior
283
                                                if (bFirstHoleEntity || ((psLine.type == DGNFileHeader.DGNT_SHAPE) && ((psLine.properties & 0x8000) != 0)))
284
                                               {
285
                                                                        elementoCompuesto.append(elShape, false);
286
                                                                        bFirstHoleEntity = false;
287
                                                }
288
                                                else
289
                                                                        elementoCompuesto.append(elShape, bConnect);                                                        
290
                                        else                                        
291
                                                addShape(new FPolyline2D(elShape), auxRow);
292
                                }                                        
293
                                
294
                                break;
295
                        case DGNFileHeader.DGNST_ARC: 
296
                           // m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(), elemento,"");
297
                           DGNElemArc psArc = (DGNElemArc) elemento;
298
                           // La definici?n de arco de MicroStation es distinta a la de Java.
299
                           // En el dgn el origin se entiende que es el centro del arco,
300
                           // y a la hora de crear un Arc2D las 2 primeras coordenadas son
301
                           // la esquina inferior izquierda del rect?ngulo que rodea al arco.
302
                        
303
                           // 1.- Creamos la elipse sin rotaci?n.
304
                           // 2.- Creamos el arco
305
                           // 3.- Rotamos el resultado
306
                                /* System.out.println("Arco con primari axis: " + psArc.primary_axis +
307
                                                " start angle: " + psArc.startang + " sweepang = " + psArc.sweepang);
308
                                System.out.println("secondaria axis: " + psArc.secondary_axis +
309
                                                                 " rotation = " + psArc.rotation); */ 
310
                        
311
                           AffineTransform mT = AffineTransform.getRotateInstance(
312
                                           Math.toRadians(psArc.rotation), psArc.origin.x, psArc.origin.y);
313
                           // mT.preConcatenate(AffineTransform.getScaleInstance(100.0,100.0));
314
                            Arc2D.Double elArco = new Arc2D.Double(
315
                                            psArc.origin.x - psArc.primary_axis, psArc.origin.y - psArc.secondary_axis,                            
316
                            2.0 * psArc.primary_axis, 2.0 * psArc.secondary_axis,
317
                            -psArc.startang, -psArc.sweepang, Arc2D.OPEN);
318
                           // Ellipse2D.Double elArco = new Ellipse2D.Double(psArc.origin.x - psArc.primary_axis,
319
                           //                 psArc.origin.y - psArc.secondary_axis,2.0 * psArc.primary_axis, 2.0 * psArc.secondary_axis);
320
                            GeneralPathX elShapeArc = new GeneralPathX(elArco);
321
                            // Transformamos el GeneralPahtX porque si transformamos elArco nos lo convierte
322
                            // a GeneralPath y nos guarda las coordenadas en float, con la correspondiente p?rdida de precisi?n
323
                            elShapeArc.transform(mT);
324
                           if (m_DgnReader.getInfo().dimension == 3) {
325
                                   //Aqu? podr?amos hacer cosas con la coordenada Z
326
                           }
327
                           
328
                           auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id);
329
                               auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue("Arc");
330
                               auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level);
331
                               auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
332
                               
333
                               /* Line2D.Double ejeMayor = new Line2D.Double(psArc.origin.x - psArc.primary_axis, psArc.origin.y, 
334
                                               psArc.origin.x + psArc.primary_axis, psArc.origin.y);
335
                            
336
                               lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, new GeneralPathX(ejeMayor)), auxRow); */
337
                            // lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, elShapeArc), auxRow);
338
                               if (elemento.complex != 0)
339
                               {
340
                                               // Esto es una posible fuente de fallos si detr?s de una
341
                                           // elipse vienen m?s cosas pegadas. Deber?amos volver
342
                                               // a conectar una vez pasada la elipse.
343
                                          if (elemento.type == DGNFileHeader.DGNT_ELLIPSE)
344
                                                          bConnect = false;
345

    
346
                                          // SI LA ELIPSE ES UN AGUJERO, SE A?ADE SIN PEGAR
347
                                          // Y EL ELEMENTO ES UN POLIGONO                                          
348
                                       if (bFirstHoleEntity || ((elemento.type == DGNFileHeader.DGNT_SHAPE)
349
                                                       && ((elemento.properties & 0x8000) != 0)))
350
                                       {
351
                                                                elementoCompuesto.append(elShapeArc, false);
352
                                                                bFirstHoleEntity = false;
353
                                       }
354
                                        else
355
                                                                elementoCompuesto.append(elShapeArc, bConnect);                                                        
356
                               }
357
                                    else        
358
                                    {
359
                                            addShape(new FPolyline2D(elShapeArc), auxRow);
360
                                            if (psArc.type == DGNFileHeader.DGNT_ELLIPSE)
361
                                                    addShape(new FPolygon2D(elShapeArc), auxRow);
362
                                    }
363
                                                            
364
                                    // System.err.println("Entra un Arco");
365
                            break;
366

    
367
                        case DGNFileHeader.DGNST_TEXT: 
368
                            DGNElemText psText = (DGNElemText) elemento;
369
                                FPoint2D elShapeTxt = new FPoint3D(
370
                                                psText.origin.x, psText.origin.y,psText.origin.z);
371
                                                                
372
                                auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id);
373
                                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue("Text");
374
                                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level);
375
                                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
376
                                heightText = (float) psText.height_mult;
377
                                auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(heightText);
378
                                auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(psText.rotation);
379
                                auxRow[ID_FIELD_TEXT] = ValueFactory.createValue(psText.string); // .trim();
380
                                addShape(elShapeTxt, 
381
                                                auxRow);
382
                                
383
                                // System.out.println("Rotaci?n texto: " + psText.rotation + "Altura Texto = " + heightText);
384

    
385

    
386
                                /* System.out.println("  origin=(" + psText.origin.x +
387
                                    ", " + psText.origin.y + ") rotation=" +
388
                                    psText.rotation + "\n" + "  font=" +
389
                                    psText.font_id + " just=" +
390
                                    psText.justification + "length_mult=" +
391
                                    psText.length_mult + " height_mult=" +
392
                                    psText.height_mult + "\n" + "  string =" +
393
                                    new String(psText.string).toString().trim() +
394
                                    "\n"); */ 
395
                                break;
396
                                /* default:
397
                                        m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(), elemento, "");
398
                                        */
399
                                
400
                            } // switch
401
                
402
                            
403
                                } // if
404
                        
405
                } // for
406

    
407
                if (bElementoCompuesto)
408
                {
409
                        if (bInsideCell)
410
                        {
411
                                auxRow = cellRow;
412
                        }
413
                        else
414
                        {
415
                                auxRow = complexRow;
416
                        }
417
                        // System.err.println("Entidad compuesta. bInsideCell = " + bInsideCell + " auxRow = " + auxRow[ID_FIELD_ENTITY]);                        
418
                        addShape(new FPolyline2D(elementoCompuesto), auxRow);
419
                        if (bEsPoligono)
420
                        {
421
                                if (complex_index_fill_color != -1)
422
                                        auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(complex_index_fill_color);
423

    
424
                                addShape(new FPolygon2D(elementoCompuesto), auxRow);
425
                        }
426
                }
427
                
428
                defaultLegend = LegendFactory.createVectorialUniqueValueLegend(getShapeType());
429
                defaultLegend.setFieldName("Color");
430
                defaultLegend.setLabelField("Text");
431
                defaultLegend.setDefaultSymbol(new FSymbol(getShapeType()));
432
                defaultLegend.getDefaultSymbol().setShapeVisible(false);
433
                defaultLegend.getDefaultSymbol().setFontSizeInPixels(false);
434
                defaultLegend.getDefaultSymbol().setFont(new Font("SansSerif", Font.PLAIN, 9));
435
                defaultLegend.getDefaultSymbol().setFontColor(Color.BLACK);
436
                defaultLegend.getDefaultSymbol().setFontSize(heightText);
437
                defaultLegend.getDefaultSymbol().setStyle(FConstant.SYMBOL_STYLE_MARKER_SQUARE);
438
                
439
                defaultLegend.setLabelHeightField("HeightText");
440
                defaultLegend.setLabelRotationField("RotationText");
441
        ReadDriver rs = this;
442
                IntValue clave;
443
                FSymbol theSymbol = null;
444
                
445
                try {
446
                        for (long j = 0; j < rs.getRowCount(); j++)
447
                        {
448
                                clave =(IntValue) rs.getFieldValue(j,ID_FIELD_COLOR);
449
                                if (defaultLegend.getSymbolByValue(clave) == null)
450
                                {
451
                                        theSymbol = new FSymbol(getShapeType());        
452
                                        theSymbol.setDescription(clave.toString());
453
                                        theSymbol.setColor(m_DgnReader.DGNLookupColor(clave.getValue()));
454
                                        theSymbol.setStyle(FConstant.SYMBOL_STYLE_MARKER_SQUARE);
455
                                        defaultLegend.addSymbol(clave, theSymbol);
456
                                }
457
                        } // for
458
                } catch (DriverException e) {
459
                        e.printStackTrace();
460
                        throw new IOException("Error al poner la legenda por defecto en el DGN");
461
                }
462
            
463
    }
464
    public int getShapeType()
465
    {
466
                return FShape.MULTI;
467
        }
468
    /**
469
         * @see com.hardcode.driverManager.Driver#getType()
470
         */
471
        public String getName() {
472
                return "gvSIG DGN Memory Driver";
473
        }
474

    
475
        /**
476
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#accept(java.io.File)
477
         */
478
        public boolean accept(File f) {
479
                return f.getName().toUpperCase().endsWith("DGN");
480
        }
481

    
482
        /* (non-Javadoc)
483
         * @see com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend#getDefaultLegend()
484
         */
485
        public Legend getDefaultLegend() {
486
                return defaultLegend;
487
        }
488

    
489
}