Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / drivers / dgn / DgnMemoryDriver.java @ 711

History | View | Annotate | Download (21.3 KB)

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

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

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

    
26

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

    
42
        DGNReader m_DgnReader;
43
        
44
        
45
        private String path;
46
        private File m_Fich;
47

    
48

    
49
        
50
    /**
51
     * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#open(java.io.File)
52
     */
53
    public void open(File f) throws IOException {
54
            m_Fich = f;
55
    }
56

    
57
    /**
58
     * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#initialize()
59
     */
60
    public void initialize() throws IOException {
61
            
62
                float heightText = 10;
63

    
64
            
65
            m_DgnReader = new DGNReader(m_Fich.getAbsolutePath());
66
            
67
            Value [] auxRow = new Value[7];
68
            Value [] cellRow = new Value[7];
69
            Value [] complexRow = new Value[7];
70
                ArrayList arrayFields = new ArrayList();
71
                arrayFields.add("ID");
72
                arrayFields.add("Entity");
73
                arrayFields.add("Layer");
74
                arrayFields.add("Color");
75
                arrayFields.add("HeightText");
76
                arrayFields.add("RotationText");
77
                arrayFields.add("Text");
78
            
79
            
80
            getTableModel().setColumnIdentifiers(arrayFields.toArray());
81
                
82
                
83
                // Ahora las rellenamos.
84
                FShape aux;
85
                boolean bElementoCompuesto = false, bEsPoligono = false;
86
                boolean bInsideCell = false;
87
                boolean bFirstHoleEntity = false;
88
                boolean bConnect = false; // Se usa para que los pol?gonos cierren bien cuando son formas compuestas
89
                int contadorSubElementos =0, numSubElementos = 0;
90
                int complex_index_fill_color= -1;
91
                int nClass; // Para filtrar los elementos de construcci?n, etc.
92
                GeneralPathX elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
93
                for (int id=0; id < m_DgnReader.getNumEntities(); id++)
94
                {
95
                        // System.out.println("Elemento " + id + " de " + m_DgnReader.getNumEntities());
96
                        m_DgnReader.DGNGotoElement(id);
97
                DGNElemCore elemento = m_DgnReader.DGNReadElement();
98
                nClass= 0;
99
                if (elemento.properties != 0)
100
                        nClass = elemento.properties & DGNFileHeader.DGNPF_CLASS;
101
                if ((elemento != null) && (elemento.deleted == 0) && (nClass == 0)) //Leer un elemento
102
                 {
103
                        aux = null;
104
                        // if ((elemento.element_id > 3800) && (elemento.element_id < 3850))
105
                        //         m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(),elemento,""); 
106
                        
107
                        if ((elemento.stype == DGNFileHeader.DGNST_MULTIPOINT) || (elemento.stype == DGNFileHeader.DGNST_ARC)
108
                                        || (elemento.stype == DGNFileHeader.DGNST_CELL_HEADER)
109
                                                || (elemento.stype == DGNFileHeader.DGNST_SHARED_CELL_DEFN)
110
                                                || (elemento.stype == DGNFileHeader.DGNST_COMPLEX_HEADER))
111
                        {
112
                                if (elemento.complex != 0)
113
                                {
114
                                        bElementoCompuesto = true;
115
                                }
116
                                else
117
                                {                                
118
                                        if (bElementoCompuesto)
119
                                        {                                                
120
                                                if (bInsideCell)
121
                                                {
122
                                                        auxRow[ID_FIELD_ENTITY] = cellRow[ID_FIELD_ENTITY];
123
                                                }
124
                                                else
125
                                                {
126
                                                        auxRow = complexRow;
127
                                                }
128
                                                // System.err.println("Entidad compuesta. bInsideCell = " + bInsideCell + " auxRow = " + auxRow[ID_FIELD_ENTITY]);
129
                                                addShape(new FPolyline2D(elementoCompuesto), auxRow);
130
                                                if (bEsPoligono)
131
                                                {
132
                                                                if (complex_index_fill_color != -1)
133
                                                                        auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(complex_index_fill_color);
134

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

    
337
                                          // SI LA ELIPSE ES UN AGUJERO, SE A?ADE SIN PEGAR
338
                                          // Y EL ELEMENTO ES UN POLIGONO                                          
339
                                       if (bFirstHoleEntity || ((elemento.type == DGNFileHeader.DGNT_SHAPE)
340
                                                       && ((elemento.properties & 0x8000) != 0)))
341
                                       {
342
                                                                elementoCompuesto.append(elShapeArc, false);
343
                                                                bFirstHoleEntity = false;
344
                                       }
345
                                        else
346
                                                                elementoCompuesto.append(elShapeArc, bConnect);                                                        
347
                               }
348
                                    else        
349
                                    {
350
                                            addShape(new FPolyline2D(elShapeArc), auxRow);
351
                                            if (psArc.type == DGNFileHeader.DGNT_ELLIPSE)
352
                                                    addShape(new FPolygon2D(elShapeArc), auxRow);
353
                                    }
354
                                                            
355
                                    // System.err.println("Entra un Arco");
356
                            break;
357

    
358
                        case DGNFileHeader.DGNST_TEXT: 
359
                            DGNElemText psText = (DGNElemText) elemento;
360
                                FPoint2D elShapeTxt = new FPoint3D(
361
                                                psText.origin.x, psText.origin.y,psText.origin.z);
362
                                                                
363
                                auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id);
364
                                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue("Text");
365
                                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level);
366
                                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
367
                                heightText = (float) psText.height_mult;
368
                                auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(heightText);
369
                                auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(psText.rotation);
370
                                auxRow[ID_FIELD_TEXT] = ValueFactory.createValue(psText.string); // .trim();
371
                                addShape(elShapeTxt, 
372
                                                auxRow);
373
                                
374
                                // System.out.println("Rotaci?n texto: " + psText.rotation + "Altura Texto = " + heightText);
375

    
376

    
377
                                /* System.out.println("  origin=(" + psText.origin.x +
378
                                    ", " + psText.origin.y + ") rotation=" +
379
                                    psText.rotation + "\n" + "  font=" +
380
                                    psText.font_id + " just=" +
381
                                    psText.justification + "length_mult=" +
382
                                    psText.length_mult + " height_mult=" +
383
                                    psText.height_mult + "\n" + "  string =" +
384
                                    new String(psText.string).toString().trim() +
385
                                    "\n"); */ 
386
                                break;
387
                                /* default:
388
                                        m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(), elemento, "");
389
                                        */
390
                                
391
                            } // switch
392
                
393
                            
394
                                } // if
395
                        
396
                } // for
397

    
398
                if (bElementoCompuesto)
399
                {
400
                        if (bInsideCell)
401
                        {
402
                                auxRow = cellRow;
403
                        }
404
                        else
405
                        {
406
                                auxRow = complexRow;
407
                        }
408
                        // System.err.println("Entidad compuesta. bInsideCell = " + bInsideCell + " auxRow = " + auxRow[ID_FIELD_ENTITY]);                        
409
                        addShape(new FPolyline2D(elementoCompuesto), auxRow);
410
                        if (bEsPoligono)
411
                        {
412
                                if (complex_index_fill_color != -1)
413
                                        auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(complex_index_fill_color);
414

    
415
                                addShape(new FPolygon2D(elementoCompuesto), auxRow);
416
                        }
417
                }
418
                
419
                /* Legend rendererLines = lyrLines.getLegend();
420
                rendererLines.setField("Color");
421
                rendererLines.setLegendType(FConstant.LEGEND_TYPE_VALUE);
422
        FRecordset rs = lyrLines.getRecordset();
423
                rendererLines.m_symbolList = new TreeMap(
424
                                new Comparator() {
425
                                        public int compare(Object o1, Object o2)
426
                                        {
427
                                                int resul = -1;
428
                                                if ((o1 != null) && (o2 != null))
429
                                                {
430
                                                        double d2 = Double.parseDouble((String)o2);
431
                                                        double d1 = Double.parseDouble((String)o1);
432
                                                        resul = (int) (d1-d2);
433
                                                }
434
                                                return resul;
435
                                        }
436
                                }                
437
                        ); 
438
        
439
                String clave;
440
                FSymbol theSymbol = null;
441
                
442
                for (int j = 0; j < lyrLines.m_NumShapes; j++)
443
                {
444
                        rs.moveTo(j);
445

446
                        clave =rs.getFieldValueAsString(ID_FIELD_COLOR);
447

448
                        ////Comprobar que no esta repetido y no hace falta introducir en el hashtable el campo junto con el simbolo.
449
                        if (!rendererLines.m_symbolList.containsKey(clave)) {
450
                                //si no esta creado el simbolo se crea
451
                                theSymbol = new FSymbol(lyrLines.m_shapeType);                                
452
                                theSymbol.m_Descrip = clave.toString();
453
                                theSymbol.m_Color = m_DgnReader.DGNLookupColor(rs.getFieldValueAsNumber(ID_FIELD_COLOR).intValue());
454
                                rendererLines.addSymbol(clave, theSymbol);                                                                
455
                        }
456
                        
457
                        lyrLines.m_legendValues[j] = rs.getFieldValueAsString(ID_FIELD_COLOR);
458
                } // for
459

460
                Legend rendererPoly = lyrPolygons.getLegend();
461
                rendererPoly.setField("Color");
462
                rendererPoly.setLegendType(FConstant.LEGEND_TYPE_VALUE);
463
        rs = lyrPolygons.getRecordset();
464
        
465
        rendererPoly.m_symbolList = new TreeMap(
466
                                new Comparator() {
467
                                        public int compare(Object o1, Object o2)
468
                                        {
469
                                                int resul = -1;
470
                                                if ((o1 != null) && (o2 != null))
471
                                                {
472
                                                        double d2 = Double.parseDouble((String)o2);
473
                                                        double d1 = Double.parseDouble((String)o1);
474
                                                        resul = (int) (d1-d2);
475
                                                }
476
                                                return resul;
477
                                        }
478
                                }                
479
                        );  
480
                        
481
                
482
                for (int j = 0; j < lyrPolygons.m_NumShapes; j++)
483
                {
484
                        rs.moveTo(j);
485

486
                        clave =rs.getFieldValueAsString(ID_FIELD_COLOR);
487

488
                        ////Comprobar que no esta repetido y no hace falta introducir en el hashtable el campo junto con el simbolo.
489
                        if (!rendererPoly.m_symbolList.containsKey(clave)) {
490
                                //si no esta creado el simbolo se crea
491
                                theSymbol = new FSymbol(lyrPolygons.m_shapeType);                                
492
                                theSymbol.m_Descrip = clave.toString();
493
                                theSymbol.m_Color = m_DgnReader.DGNLookupColor(rs.getFieldValueAsNumber(ID_FIELD_COLOR).intValue());
494
                                rendererPoly.addSymbol(clave, theSymbol);                                                                
495
                        }
496
                        
497
                        lyrPolygons.m_legendValues[j] = rs.getFieldValueAsString(ID_FIELD_COLOR);
498
                } // for
499
            */
500
    }
501

    
502

    
503
    /**
504
         * @see com.hardcode.driverManager.Driver#getType()
505
         */
506
        public String getName() {
507
                return "gvSIG DGN Memory Driver";
508
        }
509

    
510
        /**
511
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#accept(java.io.File)
512
         */
513
        public boolean accept(File f) {
514
                return f.getName().toUpperCase().endsWith("DGN");
515
        }
516

    
517
}