Statistics
| Revision:

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

History | View | Annotate | Download (21.3 KB)

1
/* ALL THIS WORK ABOUT DGN IS BASED IN DGNLib, from Frank Warmerdam
2
 * It is a java port, and is incompleted, just to let gvSIG
3
 * display DGN's. His DGNLib is more advanced, and must be
4
 * used as reference.
5
 * DGNLib:  http://dgnlib.maptools.org/
6
 * 
7
 * (Thanks, Frank :). For this, and for your very good job with 
8
 * shapefiles. And also for GDAL!!!!
9
 */
10

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

    
53
import java.awt.Color;
54
import java.awt.Font;
55
import java.awt.geom.AffineTransform;
56
import java.awt.geom.Arc2D;
57
import java.io.File;
58
import java.io.IOException;
59
import java.util.ArrayList;
60

    
61
import com.hardcode.gdbms.engine.data.driver.DriverException;
62
import com.hardcode.gdbms.engine.data.driver.ObjectDriver;
63
import com.hardcode.gdbms.engine.values.IntValue;
64
import com.hardcode.gdbms.engine.values.Value;
65
import com.hardcode.gdbms.engine.values.ValueFactory;
66
import com.iver.cit.gvsig.fmap.core.FPoint2D;
67
import com.iver.cit.gvsig.fmap.core.FPoint3D;
68
import com.iver.cit.gvsig.fmap.core.FPolygon2D;
69
import com.iver.cit.gvsig.fmap.core.FPolyline2D;
70
import com.iver.cit.gvsig.fmap.core.FShape;
71
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
72
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
73
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
74
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
75
import com.iver.cit.gvsig.fmap.drivers.MemoryDriver;
76
import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend;
77
import com.iver.cit.gvsig.fmap.rendering.Legend;
78
import com.iver.cit.gvsig.fmap.rendering.LegendFactory;
79
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend;
80

    
81

    
82
/**
83
 * Driver DGN que trabaja directamente cargando el fichero en memoria.
84
 *
85
 * @author Vicente Caballero Navarro
86
 */
87
public class DgnMemoryDriver extends MemoryDriver implements WithDefaultLegend {
88
        private final int ID_FIELD_ID = 0;
89
        private final int ID_FIELD_ENTITY = 1;
90
        private final int ID_FIELD_LAYER = 2;
91
        private final int ID_FIELD_COLOR = 3;
92
        private final int ID_FIELD_HEIGHTTEXT = 4;
93
        private final int ID_FIELD_ROTATIONTEXT = 5;
94
        private final int ID_FIELD_TEXT = 6;
95
        DGNReader m_DgnReader;
96
        VectorialUniqueValueLegend defaultLegend;
97
        private String path;
98
        private File m_Fich;
99
        private DriverAttributes attr = new DriverAttributes();
100
        
101
        /**
102
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#open(java.io.File)
103
         */
104
        public void open(File f) throws IOException {
105
                m_Fich = f;
106
        }
107

    
108
        /**
109
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#initialize()
110
         */
111
        public void initialize() throws IOException {
112
                float heightText = 10;
113
                
114
                attr.setLoadedInMemory(true);
115

    
116
                m_DgnReader = new DGNReader(m_Fich.getAbsolutePath());
117

    
118
                Value[] auxRow = new Value[7];
119
                Value[] cellRow = new Value[7];
120
                Value[] complexRow = new Value[7];
121
                ArrayList arrayFields = new ArrayList();
122
                arrayFields.add("ID");
123
                arrayFields.add("Entity");
124
                arrayFields.add("Layer");
125
                arrayFields.add("Color");
126
                arrayFields.add("HeightText");
127
                arrayFields.add("RotationText");
128
                arrayFields.add("Text");
129

    
130
                getTableModel().setColumnIdentifiers(arrayFields.toArray());
131

    
132
                // Ahora las rellenamos.
133
                FShape aux;
134
                boolean bElementoCompuesto = false;
135
                boolean bEsPoligono = false;
136
                boolean bInsideCell = false;
137
                boolean bFirstHoleEntity = false;
138
                boolean bConnect = false; // Se usa para que los pol?gonos cierren bien cuando son formas compuestas
139
                int contadorSubElementos = 0;
140
                int numSubElementos = 0;
141
                int complex_index_fill_color = -1;
142
                int nClass; // Para filtrar los elementos de construcci?n, etc.
143
                GeneralPathX elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
144

    
145
                for (int id = 0; id < m_DgnReader.getNumEntities(); id++) {
146
                        // System.out.println("Elemento " + id + " de " + m_DgnReader.getNumEntities());
147
                        m_DgnReader.DGNGotoElement(id);
148

    
149
                        DGNElemCore elemento = m_DgnReader.DGNReadElement();
150
                        nClass = 0;
151
                        auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(0);
152
                        auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(0);
153
                        auxRow[ID_FIELD_TEXT] = ValueFactory.createNullValue();
154

    
155
                        if (elemento.properties != 0) {
156
                                nClass = elemento.properties & DGNFileHeader.DGNPF_CLASS;
157
                        }
158

    
159
                        if ((elemento != null) && (elemento.deleted == 0) && (nClass == 0)) //Leer un elemento
160
                         {
161
                                aux = null;
162

    
163
                                // if ((elemento.element_id > 3800) && (elemento.element_id < 3850))
164
                                //         m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(),elemento,""); 
165
                                if ((elemento.stype == DGNFileHeader.DGNST_MULTIPOINT) ||
166
                                                (elemento.stype == DGNFileHeader.DGNST_ARC) ||
167
                                                (elemento.stype == DGNFileHeader.DGNST_CELL_HEADER) ||
168
                                                (elemento.stype == DGNFileHeader.DGNST_SHARED_CELL_DEFN) ||
169
                                                (elemento.stype == DGNFileHeader.DGNST_COMPLEX_HEADER)) {
170
                                        if (elemento.complex != 0) {
171
                                                bElementoCompuesto = true;
172
                                        } else {
173
                                                if (bElementoCompuesto) {
174
                                                        if (bInsideCell) {
175
                                                                auxRow[ID_FIELD_ENTITY] = cellRow[ID_FIELD_ENTITY];
176
                                                        } else {
177
                                                                auxRow = complexRow;
178
                                                        }
179

    
180
                                                        // System.err.println("Entidad compuesta. bInsideCell = " + bInsideCell + " auxRow = " + auxRow[ID_FIELD_ENTITY]);
181
                                                        addShape(new FPolyline2D(elementoCompuesto), auxRow);
182

    
183
                                                        if (bEsPoligono) {
184
                                                                if (complex_index_fill_color != -1) {
185
                                                                        auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(complex_index_fill_color);
186
                                                                }
187

    
188
                                                                addShape(new FPolygon2D(elementoCompuesto),
189
                                                                        auxRow);
190
                                                        }
191

    
192
                                                        elementoCompuesto = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
193
                                                }
194

    
195
                                                // System.err.println("Entidad simple");
196
                                                bElementoCompuesto = false;
197
                                                bEsPoligono = false;
198
                                                bConnect = false;
199

    
200
                                                // elementoCompuesto = new GeneralPathX();
201
                                                bInsideCell = false;
202
                                        }
203
                                }
204

    
205
                                switch (elemento.stype) {
206
                                        case DGNFileHeader.DGNST_SHARED_CELL_DEFN:
207
                                                bInsideCell = true;
208
                                                cellRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id);
209
                                                cellRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level);
210
                                                cellRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
211
                                                cellRow[ID_FIELD_ENTITY] = ValueFactory.createValue(
212
                                                                "Shared Cell");
213

    
214
                                                break;
215

    
216
                                        case DGNFileHeader.DGNST_CELL_HEADER:
217
                                                bInsideCell = true;
218

    
219
                                                DGNElemCellHeader psCellHeader = (DGNElemCellHeader) elemento;
220
                                                cellRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id);
221
                                                cellRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level);
222
                                                cellRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
223
                                                cellRow[ID_FIELD_ENTITY] = ValueFactory.createValue(
224
                                                                "Cell");
225
                                                complex_index_fill_color = m_DgnReader.DGNGetShapeFillInfo(elemento);
226

    
227
                                                // System.err.println("Cell Header " + complex_index_fill_color);
228
                                                break;
229

    
230
                                        case DGNFileHeader.DGNST_COMPLEX_HEADER:
231

    
232
                                                // bElementoCompuesto = true;
233
                                                // System.err.println("Complex Header");
234
                                                contadorSubElementos = 0;
235

    
236
                                                DGNElemComplexHeader psComplexHeader = (DGNElemComplexHeader) elemento;
237
                                                numSubElementos = psComplexHeader.numelems;
238
                                                complexRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id);
239
                                                complexRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level);
240
                                                complexRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
241
                                                complexRow[ID_FIELD_ENTITY] = ValueFactory.createValue(
242
                                                                "Complex");
243

    
244
                                                if (psComplexHeader.type == DGNFileHeader.DGNT_COMPLEX_SHAPE_HEADER) {
245
                                                        bEsPoligono = true;
246

    
247
                                                        // Si es un agujero, no conectamos con el anterior
248
                                                        if ((psComplexHeader.properties & 0x8000) != 0) {
249
                                                                bFirstHoleEntity = true;
250
                                                        } else {
251
                                                                // Miramos si tiene color de relleno
252
                                                                // complex_index_fill_color = -1;
253
                                                                // if (elemento.attr_bytes > 0) {
254
                                                                complex_index_fill_color = m_DgnReader.DGNGetShapeFillInfo(elemento);
255

    
256
                                                                // System.err.println("complex shape fill color = " + elemento.color);
257
                                                                // }
258
                                                        }
259

    
260
                                                        bConnect = true;
261
                                                } else {
262
                                                        bEsPoligono = false;
263
                                                        bConnect = false;
264
                                                }
265

    
266
                                                break;
267

    
268
                                        case DGNFileHeader.DGNST_MULTIPOINT:
269

    
270
                                                // OJO: Si lo que viene en este multipoint es un elemento con type=11 (curve), se trata de una "parametric
271
                                                // spline curve". La vamos a tratar como si no fuera curva, pero seg?n la documentaci?n, los 2 primeros puntos
272
                                                // y los 2 ?ltimos puntos definen "endpoint derivatives" y NO se muestran.
273
                                                // TODAV?A HAY UN PEQUE?O FALLO CON EL FICHERO dgn-sample.dgn, pero lo dejo por ahora.
274
                                                // Es posible que tenga que ver con lo de los arcos (arco distorsionado), que
275
                                                // todav?a no est? metido.
276
                                                DGNElemMultiPoint psLine = (DGNElemMultiPoint) elemento;
277
                                                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level);
278
                                                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
279

    
280
                                                if ((psLine.num_vertices == 2) &&
281
                                                                (psLine.vertices[0].x == psLine.vertices[1].x) &&
282
                                                                (psLine.vertices[0].y == psLine.vertices[1].y)) {
283
                                                        auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(
284
                                                                        "Point");
285
                                                        addShape(new FPoint3D(psLine.vertices[0].x,
286
                                                                        psLine.vertices[0].y, psLine.vertices[0].z),
287
                                                                auxRow);
288
                                                } else {
289
                                                        GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD);
290

    
291
                                                        if (psLine.type == DGNFileHeader.DGNT_CURVE) {
292
                                                                psLine.num_vertices = psLine.num_vertices - 4;
293

    
294
                                                                for (int aux_n = 0;
295
                                                                                aux_n < psLine.num_vertices; aux_n++) {
296
                                                                        psLine.vertices[aux_n] = psLine.vertices[aux_n +
297
                                                                                2];
298
                                                                }
299
                                                        }
300

    
301
                                                        if ((psLine.type == DGNFileHeader.DGNT_SHAPE) &&
302
                                                                        ((psLine.properties & 0x8000) != 0)) {
303
                                                                // Invertimos el orden porque es un agujero
304
                                                                elShape.moveTo(psLine.vertices[psLine.num_vertices -
305
                                                                        1].x,
306
                                                                        psLine.vertices[psLine.num_vertices - 1].y);
307

    
308
                                                                for (int i = psLine.num_vertices - 2; i >= 0;
309
                                                                                i--)
310
                                                                        elShape.lineTo(psLine.vertices[i].x,
311
                                                                                psLine.vertices[i].y);
312
                                                        } else {
313
                                                                elShape.moveTo(psLine.vertices[0].x,
314
                                                                        psLine.vertices[0].y);
315

    
316
                                                                for (int i = 1; i < psLine.num_vertices; i++)
317
                                                                        elShape.lineTo(psLine.vertices[i].x,
318
                                                                                psLine.vertices[i].y);
319
                                                        }
320

    
321
                                                        auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id);
322
                                                        auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(
323
                                                                        "Multipoint");
324

    
325
                                                        if ((psLine.vertices[0].x == psLine.vertices[psLine.num_vertices -
326
                                                                        1].x) &&
327
                                                                        (psLine.vertices[0].y == psLine.vertices[psLine.num_vertices -
328
                                                                        1].y)) {
329
                                                                // Lo a?adimos tambi?n como pol?gono
330
                                                                bEsPoligono = true;
331

    
332
                                                                // Miramos si tiene color de relleno
333
                                                                if (elemento.attr_bytes > 0) {
334
                                                                        elemento.color = m_DgnReader.DGNGetShapeFillInfo(elemento);
335

    
336
                                                                        // System.err.println("fill color = " + elemento.color);
337
                                                                        if (elemento.color != -1) {
338
                                                                                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
339
                                                                        }
340
                                                                }
341

    
342
                                                                if (elemento.complex == 0) {
343
                                                                        addShape(new FPolygon2D(elShape), auxRow);
344
                                                                }
345
                                                        }
346

    
347
                                                        if (elemento.complex != 0) {
348
                                                                // Si es un agujero o 
349
                                                                // es la primera entidad del agujero, lo a?adimos sin unir al anterior
350
                                                                if (bFirstHoleEntity ||
351
                                                                                ((psLine.type == DGNFileHeader.DGNT_SHAPE) &&
352
                                                                                ((psLine.properties & 0x8000) != 0))) {
353
                                                                        elementoCompuesto.append(elShape, false);
354
                                                                        bFirstHoleEntity = false;
355
                                                                } else {
356
                                                                        elementoCompuesto.append(elShape, bConnect);
357
                                                                }
358
                                                        } else {
359
                                                                addShape(new FPolyline2D(elShape), auxRow);
360
                                                        }
361
                                                }
362

    
363
                                                break;
364

    
365
                                        case DGNFileHeader.DGNST_ARC:
366

    
367
                                                // m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(), elemento,"");
368
                                                DGNElemArc psArc = (DGNElemArc) elemento;
369

    
370
                                                // La definici?n de arco de MicroStation es distinta a la de Java.
371
                                                // En el dgn el origin se entiende que es el centro del arco,
372
                                                // y a la hora de crear un Arc2D las 2 primeras coordenadas son
373
                                                // la esquina inferior izquierda del rect?ngulo que rodea al arco.
374
                                                // 1.- Creamos la elipse sin rotaci?n.
375
                                                // 2.- Creamos el arco
376
                                                // 3.- Rotamos el resultado
377

    
378
                                                /* System.out.println("Arco con primari axis: " + psArc.primary_axis +
379
                                                   " start angle: " + psArc.startang + " sweepang = " + psArc.sweepang);
380
                                                   System.out.println("secondaria axis: " + psArc.secondary_axis +
381
                                                                                    " rotation = " + psArc.rotation); */
382
                                                AffineTransform mT = AffineTransform.getRotateInstance(Math.toRadians(
383
                                                                        psArc.rotation), psArc.origin.x,
384
                                                                psArc.origin.y);
385

    
386
                                                // mT.preConcatenate(AffineTransform.getScaleInstance(100.0,100.0));
387
                                                Arc2D.Double elArco = new Arc2D.Double(psArc.origin.x -
388
                                                                psArc.primary_axis,
389
                                                                psArc.origin.y - psArc.secondary_axis,
390
                                                                2.0 * psArc.primary_axis,
391
                                                                2.0 * psArc.secondary_axis, -psArc.startang,
392
                                                                -psArc.sweepang, Arc2D.OPEN);
393

    
394
                                                // Ellipse2D.Double elArco = new Ellipse2D.Double(psArc.origin.x - psArc.primary_axis,
395
                                                //                 psArc.origin.y - psArc.secondary_axis,2.0 * psArc.primary_axis, 2.0 * psArc.secondary_axis);
396
                                                GeneralPathX elShapeArc = new GeneralPathX(elArco);
397

    
398
                                                // Transformamos el GeneralPahtX porque si transformamos elArco nos lo convierte
399
                                                // a GeneralPath y nos guarda las coordenadas en float, con la correspondiente p?rdida de precisi?n
400
                                                elShapeArc.transform(mT);
401

    
402
                                                if (m_DgnReader.getInfo().dimension == 3) {
403
                                                        //Aqu? podr?amos hacer cosas con la coordenada Z
404
                                                }
405

    
406
                                                auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id);
407
                                                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(
408
                                                                "Arc");
409
                                                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level);
410
                                                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
411

    
412
                                                /* Line2D.Double ejeMayor = new Line2D.Double(psArc.origin.x - psArc.primary_axis, psArc.origin.y,
413
                                                   psArc.origin.x + psArc.primary_axis, psArc.origin.y);
414
                                                
415
                                                   lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, new GeneralPathX(ejeMayor)), auxRow); */
416

    
417
                                                // lyrLines.addShape(new FShape(FConstant.SHAPE_TYPE_POLYLINE, elShapeArc), auxRow);
418
                                                if (elemento.complex != 0) {
419
                                                        // Esto es una posible fuente de fallos si detr?s de una
420
                                                        // elipse vienen m?s cosas pegadas. Deber?amos volver
421
                                                        // a conectar una vez pasada la elipse.
422
                                                        if (elemento.type == DGNFileHeader.DGNT_ELLIPSE) {
423
                                                                bConnect = false;
424
                                                        }
425

    
426
                                                        // SI LA ELIPSE ES UN AGUJERO, SE A?ADE SIN PEGAR
427
                                                        // Y EL ELEMENTO ES UN POLIGONO                                          
428
                                                        if (bFirstHoleEntity ||
429
                                                                        ((elemento.type == DGNFileHeader.DGNT_SHAPE) &&
430
                                                                        ((elemento.properties & 0x8000) != 0))) {
431
                                                                elementoCompuesto.append(elShapeArc, false);
432
                                                                bFirstHoleEntity = false;
433
                                                        } else {
434
                                                                elementoCompuesto.append(elShapeArc, bConnect);
435
                                                        }
436
                                                } else {
437
                                                        addShape(new FPolyline2D(elShapeArc), auxRow);
438

    
439
                                                        if (psArc.type == DGNFileHeader.DGNT_ELLIPSE) {
440
                                                                addShape(new FPolygon2D(elShapeArc), auxRow);
441
                                                        }
442
                                                }
443

    
444
                                                // System.err.println("Entra un Arco");
445
                                                break;
446

    
447
                                        case DGNFileHeader.DGNST_TEXT:
448

    
449
                                                DGNElemText psText = (DGNElemText) elemento;
450
                                                FPoint2D elShapeTxt = new FPoint3D(psText.origin.x,
451
                                                                psText.origin.y, psText.origin.z);
452

    
453
                                                auxRow[ID_FIELD_ID] = ValueFactory.createValue(elemento.element_id);
454
                                                auxRow[ID_FIELD_ENTITY] = ValueFactory.createValue(
455
                                                                "Text");
456
                                                auxRow[ID_FIELD_LAYER] = ValueFactory.createValue(elemento.level);
457
                                                auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(elemento.color);
458
                                                heightText = (float) psText.height_mult;
459
                                                auxRow[ID_FIELD_HEIGHTTEXT] = ValueFactory.createValue(heightText);
460
                                                auxRow[ID_FIELD_ROTATIONTEXT] = ValueFactory.createValue(psText.rotation);
461
                                                auxRow[ID_FIELD_TEXT] = ValueFactory.createValue(psText.string); // .trim();
462
                                                addShape(elShapeTxt, auxRow);
463

    
464
                                                // System.out.println("Rotaci?n texto: " + psText.rotation + "Altura Texto = " + heightText);
465

    
466
                                                /* System.out.println("  origin=(" + psText.origin.x +
467
                                                   ", " + psText.origin.y + ") rotation=" +
468
                                                   psText.rotation + "\n" + "  font=" +
469
                                                   psText.font_id + " just=" +
470
                                                   psText.justification + "length_mult=" +
471
                                                   psText.length_mult + " height_mult=" +
472
                                                   psText.height_mult + "\n" + "  string =" +
473
                                                   new String(psText.string).toString().trim() +
474
                                                   "\n"); */
475
                                                break;
476

    
477
                                        /* default:
478
                                           m_DgnReader.DGNDumpElement(m_DgnReader.getInfo(), elemento, "");
479
                                         */
480
                                } // switch
481
                        } // if
482
                } // for
483

    
484
                if (bElementoCompuesto) {
485
                        if (bInsideCell) {
486
                                auxRow = cellRow;
487
                        } else {
488
                                auxRow = complexRow;
489
                        }
490

    
491
                        // System.err.println("Entidad compuesta. bInsideCell = " + bInsideCell + " auxRow = " + auxRow[ID_FIELD_ENTITY]);                        
492
                        addShape(new FPolyline2D(elementoCompuesto), auxRow);
493

    
494
                        if (bEsPoligono) {
495
                                if (complex_index_fill_color != -1) {
496
                                        auxRow[ID_FIELD_COLOR] = ValueFactory.createValue(complex_index_fill_color);
497
                                }
498

    
499
                                addShape(new FPolygon2D(elementoCompuesto), auxRow);
500
                        }
501
                }
502

    
503
                defaultLegend = LegendFactory.createVectorialUniqueValueLegend(getShapeType());
504
                defaultLegend.setFieldName("Color");
505
                defaultLegend.setLabelField("Text");
506
                defaultLegend.setDefaultSymbol(new FSymbol(getShapeType()));
507
                defaultLegend.getDefaultSymbol().setShapeVisible(false);
508
                defaultLegend.getDefaultSymbol().setFontSizeInPixels(false);
509
                defaultLegend.getDefaultSymbol().setFont(new Font("SansSerif",
510
                                Font.PLAIN, 9));
511
                defaultLegend.getDefaultSymbol().setFontColor(Color.BLACK);
512
                defaultLegend.getDefaultSymbol().setFontSize(heightText);
513
                defaultLegend.getDefaultSymbol().setStyle(FConstant.SYMBOL_STYLE_DGNSPECIAL);
514
                defaultLegend.getDefaultSymbol().setSize(3);
515
                defaultLegend.getDefaultSymbol().setSizeInPixels(true);
516

    
517
                defaultLegend.setLabelHeightField("HeightText");
518
                defaultLegend.setLabelRotationField("RotationText");
519

    
520
                ObjectDriver rs = this;
521
                IntValue clave;
522
                FSymbol theSymbol = null;
523

    
524
                try {
525
                    // TODO: Provisional hasta que cambiemos los s?mbolos.
526
                    /* BufferedImage bi= new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
527
                   Graphics2D big = bi.createGraphics();
528
                   Color color=new Color(0,0,0,0);
529
                   big.setBackground(color);
530
                   big.clearRect(0, 0, 1, 1);
531
                   Paint fillProv = null; 
532
                   Rectangle2D rProv = new Rectangle();
533
                   rProv.setFrame(0, 0,1,1); 
534
                   fillProv = new TexturePaint(bi,rProv); */                    
535
                        for (long j = 0; j < rs.getRowCount(); j++) {
536
                                clave = (IntValue) rs.getFieldValue(j, ID_FIELD_COLOR);
537

    
538
                                if (defaultLegend.getSymbolByValue(clave) == null) {
539
                                        theSymbol = new FSymbol(getShapeType());
540
                                        theSymbol.setDescription(clave.toString());
541
                                        Color c = m_DgnReader.DGNLookupColor(
542
                                                        clave.getValue());
543
                                        // Le ponemos transparencia para que los pol?gonos no
544
                                        // tapen del todo. (Est? dentro del DGNLookupColor
545
                                        // c.
546
                                        theSymbol.setColor(c);
547
                                        // theSymbol.setFill(fillProv);
548
                                        theSymbol.setStyle(FConstant.SYMBOL_STYLE_DGNSPECIAL);
549
                                        theSymbol.setSize(3);
550
                                        theSymbol.setSizeInPixels(true);
551
                                        
552
                                        // theSymbol.setStyle(FConstant.SYMBOL_STYLE_FILL_TRANSPARENT);
553
                                        defaultLegend.addSymbol(clave, theSymbol);
554
                                }
555
                        } // for
556
                } catch (DriverException e) {
557
                        e.printStackTrace();
558
                        throw new IOException(
559
                                "Error al poner la leyenda por defecto en el DGN");
560
                }
561
        }
562

    
563
        /**
564
         * Devuelve el tipo de shape que contiene el formato DGN.
565
         *
566
         * @return Entero que representa el tipo de shape.
567
         */
568
        public int getShapeType() {
569
                return FShape.MULTI;
570
        }
571

    
572
        /**
573
         * @see com.hardcode.driverManager.Driver#getType()
574
         */
575
        public String getName() {
576
                return "gvSIG DGN Memory Driver";
577
        }
578

    
579
        /**
580
         * @see com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver#accept(java.io.File)
581
         */
582
        public boolean accept(File f) {
583
                return f.getName().toUpperCase().endsWith("DGN");
584
        }
585

    
586
        /* (non-Javadoc)
587
         * @see com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend#getDefaultLegend()
588
         */
589
        public Legend getDefaultLegend() {
590
                return defaultLegend;
591
        }
592

    
593
    /* (non-Javadoc)
594
     * @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getDriverAttributes()
595
     */
596
    public DriverAttributes getDriverAttributes() {
597
        return attr;
598
    }
599

    
600
    /**
601
     * @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#getPrimaryKeys()
602
     */
603
    public int[] getPrimaryKeys() throws DriverException {
604
        return null;
605
    }
606
}