Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libDXF / src / org / gvsig / dxf / px / dxf / DxfEntityMaker.java @ 35497

History | View | Annotate | Download (83.7 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.gvsig.dxf.px.dxf;
25

    
26
import java.awt.geom.Point2D;
27
import java.util.Vector;
28

    
29
import org.cresques.cts.ICoordTrans;
30
import org.cresques.cts.IProjection;
31
import org.cresques.geo.Projected;
32
import org.cresques.px.Extent;
33
import org.gvsig.dxf.geo.Point3D;
34
import org.gvsig.dxf.io.DxfFile;
35
import org.gvsig.dxf.io.DxfGroup;
36
import org.gvsig.dxf.io.DxfGroupVector;
37
import org.gvsig.dxf.px.IObjList;
38

    
39

    
40
/**
41
 * La clase DxfEntityMaker facilita la creaci�n de entidades en un modelo de datos
42
 * CAD. La creaci�n se realiza partiendo de las entidades obtenidas de un fichero DXF.
43
 * @author jmorell
44
 */
45
public class DxfEntityMaker implements DxfFile.EntityFactory, Projected {
46
    IProjection proj = null;
47
    DxfEntity lastEntity = null;
48
    DxfEntityList entities = null;
49
    Vector blkList = null;
50
    DxfBlock blk = null;
51
    DxfTable layers = null;
52
    double bulge = 0.0;
53
    double xtruX = 0.0;
54
    double xtruY = 0.0;
55
    double xtruZ = 1.0;
56
    int polylineFlag = 0;
57
    Point2D firstPt = new Point2D.Double();
58
    boolean addingToBlock = false;
59
    int iterator = 0;
60

    
61
    // jmorell, 050406: implementaci�n inicial de los ATTRIBS para el piloto ...
62
    private Vector attributes = null;
63
    
64
    /**
65
     * Constructor de DxfEntityMaker.
66
     * @param proj, proyecci�n cartogr�fica en la que se encontrar�n las entidades
67
     * que creemos.
68
     */
69
    public DxfEntityMaker(IProjection proj) {
70
        this.proj = proj;
71
        layers = new DxfTable();
72
        entities = new DxfEntityList(proj);
73
        blkList = new Vector();
74

    
75
        // jmorell, 050406: implementaci�n inicial de los ATTRIBS para el piloto ...
76
        attributes = new Vector();
77
    }
78
    
79
    /* (non-Javadoc)
80
     * @see org.cresques.io.DxfFile.EntityFactory#getBlkList()
81
     */
82
    public Vector getBlkList() {
83
        return blkList;
84
    }
85
    
86
    /* (non-Javadoc)
87
     * @see org.cresques.io.DxfFile.EntityFactory#getObjects()
88
     */
89
    public IObjList getObjects() {
90
        return entities;
91
    }
92
    
93
    /* (non-Javadoc)
94
     * @see org.cresques.io.DxfFile.EntityFactory#getExtent()
95
     */
96
    public Extent getExtent() {
97
        return entities.getExtent();
98
    }
99
    
100
    /* (non-Javadoc)
101
     * @see org.cresques.io.DxfFile.EntityFactory#setAddingToBlock(boolean)
102
     */
103
    public void setAddingToBlock(boolean a) {
104
        addingToBlock = a;
105
    }
106
    
107
    /* (non-Javadoc)
108
     * @see org.cresques.io.DxfFile.EntityFactory#createLayer(org.cresques.io.DxfGroupVector)
109
     */
110
    public void createLayer(DxfGroupVector grp) throws Exception {
111
        int color = grp.getDataAsInt(62);
112
        DxfLayer layer = new DxfLayer(grp.getDataAsString(2),
113
                                      Math.abs(grp.getDataAsInt(62)));
114

    
115
        if (color < 0) {
116
            layer.isOff = true;
117
        }
118

    
119
        layer.lType = grp.getDataAsString(6);
120
        layer.setFlags(grp.getDataAsInt(70));
121

    
122
        // compruebo flags
123
        if ((layer.flags & 0x01) == 0x01) {
124
            layer.frozen = true;
125
        }
126

    
127
        if ((layer.flags & 0x02) == 0x02) {
128
            layer.frozen = true;
129
        }
130

    
131
        DxfFile.logger.debug("LAYER color=" + layer.getColor());
132

    
133
        layers.add(layer);
134
    }
135
    
136
    /* (non-Javadoc)
137
     * @see org.cresques.io.DxfFile.EntityFactory#createPolyline(org.cresques.io.DxfGroupVector)
138
     */
139
    public void createPolyline(DxfGroupVector grp) throws Exception {
140
        DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
141
        DxfPolyline entity = new DxfPolyline(proj, layer);
142

    
143
        if (grp.hasCode(5)) {
144
            String hexS = grp.getDataAsString(5);
145
            Integer hexI = Integer.decode("0x" + hexS);
146
            int hexi = hexI.intValue();
147
            entity.setHandle(hexi);
148
        } else {
149
            entity.setHandle(entities.size() + 40);
150
        }
151

    
152
        if (grp.hasCode(100)) {
153
            entity.setSubclassMarker(grp.getDataAsString(100));
154
        }
155

    
156
        double x = 0.0;
157
        double y = 0.0;
158
        double z = 0.0;
159
        double thickness = 0;
160

    
161
        if (grp.hasCode(10)) {
162
            x = grp.getDataAsDouble(10);
163
        }
164

    
165
        if (grp.hasCode(20)) {
166
            y = grp.getDataAsDouble(20);
167
        }
168

    
169
        if (grp.hasCode(30)) {
170
            z = grp.getDataAsDouble(30);
171
            entity.setElevation(z);
172
        }
173

    
174
        /*if (grp.hasCode(39))
175
                thickness = grp.getDataAsDouble(39);*/
176
        if (grp.hasCode(62)) {
177
            entity.dxfColor = grp.getDataAsInt(62);
178
        } else {
179
            //entity.dxfColor = 0;
180
        }
181

    
182
        if (grp.hasCode(66)) {
183
            entity.entitiesFollow = grp.getDataAsInt(66);
184
        }
185

    
186
        if (grp.hasCode(70)) {
187
            entity.flags = grp.getDataAsInt(70);
188
        }
189

    
190
        if (grp.hasCode(210)) {
191
            xtruX = grp.getDataAsDouble(210);
192
        }
193

    
194
        if (grp.hasCode(220)) {
195
            xtruY = grp.getDataAsDouble(220);
196
        }
197

    
198
        if (grp.hasCode(230)) {
199
            xtruZ = grp.getDataAsDouble(230);
200
        }
201

    
202
        if ((entity.flags & 0x01) == 0x01) {
203
            entity.closed = true;
204
        }
205

    
206
        lastEntity = entity;
207
    }
208
    
209
    /* (non-Javadoc)
210
     * @see org.cresques.io.DxfFile.EntityFactory#endSeq(org.cresques.io.DxfGroupVector)
211
     */
212
    public void endSeq() throws Exception {
213
        if (lastEntity instanceof DxfPolyline) {
214
            DxfPolyline polyline = (DxfPolyline) lastEntity;
215

    
216
            if (polyline.closed) {
217
                ((DxfPolyline) lastEntity).add(firstPt);
218

    
219
                if (bulge > 0) {
220
                    int cnt = ((DxfPolyline) lastEntity).pts.size();
221

    
222
                    if ((((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
223
                                                                            2))).getX() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
224
                                                                                                                                              1))).getX()) &&
225
                            (((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
226
                                                                                2))).getY() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
227
                                                                                                                                                  1))).getY())) {
228
                        // no se construye el arco
229
                    } else {
230
                        Vector arc = DxfPolyline.createArc((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
231
                                                                                                         2)),
232
                                                           (Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
233
                                                                                                         1)),
234
                                                           bulge);
235
                        ((DxfPolyline) lastEntity).pts.remove(cnt - 1);
236

    
237
                        for (int i = 0; i < arc.size(); i++) {
238
                            Point2D pt = proj.createPoint(((Point2D) arc.get(i)).getX(),
239
                                                          ((Point2D) arc.get(i)).getY());
240
                            ((DxfPolyline) lastEntity).add(pt);
241

    
242
                            if (((DxfPolyline) lastEntity).pts.size() == 1) {
243
                                firstPt = pt;
244
                            }
245
                        }
246
                    }
247

    
248
                    bulge = 0.0;
249
                } else if (bulge < 0) {
250
                    int cnt = ((DxfPolyline) lastEntity).pts.size();
251

    
252
                    if ((((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
253
                                                                            2))).getX() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
254
                                                                                                                                              1))).getX()) &&
255
                            (((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
256
                                                                                2))).getY() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
257
                                                                                                                                                  1))).getY())) {
258
                        // no se construye el arco
259
                    } else {
260
                        Vector arc = DxfPolyline.createArc((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
261
                                                                                                         2)),
262
                                                           (Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
263
                                                                                                         1)),
264
                                                           bulge);
265
                        ((DxfPolyline) lastEntity).pts.remove(cnt - 1);
266

    
267
                        for (int i = arc.size() - 1; i >= 0; i--) {
268
                            Point2D pt = proj.createPoint(((Point2D) arc.get(i)).getX(),
269
                                                          ((Point2D) arc.get(i)).getY());
270
                            ((DxfPolyline) lastEntity).add(pt);
271

    
272
                            if (((DxfPolyline) lastEntity).pts.size() == 1) {
273
                                firstPt = pt;
274
                            }
275
                        }
276
                    }
277

    
278
                    bulge = 0.0;
279
                }
280
            }
281

    
282
            // 050315, jmorell: Para leer Polylines estas tb deben tener vector de bulges.
283
            for (int i = 0; i < ((DxfPolyline) lastEntity).pts.size(); i++) {
284
                // jmorell, 050405: intentando leer DxfPolylines con bulges para el
285
                // piloto ...
286
                //polyline.addBulge(new Double(0));
287
                ((DxfPolyline) lastEntity).addBulge(new Double(0));
288
            }
289

    
290
            //((DxfPolyline)lastEntity).addBulge(new Double(bulge));
291
            //lastEntity.setHandle(entities.size()+40);
292
            if (addingToBlock == false) {
293
                entities.add(lastEntity);
294
            } else {
295
                blk.add(lastEntity);
296

    
297
            }
298

    
299
            lastEntity = null;
300
        } else if (lastEntity instanceof DxfInsert) {
301
            // Se trata de un SEQEND despues de un ATTRIB
302
            gestionaInsert((DxfInsert) lastEntity, lastEntity.getLayer());
303

    
304
            if (addingToBlock == false) {
305
                entities.add(lastEntity);
306
            } else {
307
                blk.add(lastEntity);
308
            }
309

    
310
            lastEntity = null;
311
        } else {
312
            // Caso no contemplado
313
        }
314

    
315
        xtruX = 0.0;
316
        xtruY = 0.0;
317
        xtruZ = 1.0;
318
        bulge = 0.0;
319
    }
320
    
321
    /* (non-Javadoc)
322
     * @see org.cresques.io.DxfFile.EntityFactory#addVertex(org.cresques.io.DxfGroupVector)
323
     */
324
    public void addVertex(DxfGroupVector grp) throws Exception {
325
        double x = 0.0;
326
        double y = 0.0;
327
        double z = 0.0;
328
        int flags = 0;
329
        x = grp.getDataAsDouble(10);
330
        y = grp.getDataAsDouble(20);
331

    
332
        if (grp.hasCode(30)) {
333
            z = grp.getDataAsDouble(30);
334
        }
335

    
336
        if (grp.hasCode(70)) {
337
            flags = grp.getDataAsInt(70);
338
        }
339

    
340
        //bulge = 0.0;
341
        if (bulge == 0.0) {
342
            if (grp.hasCode(42)) {
343
                bulge = grp.getDataAsDouble(42);
344

    
345
                //bulge = 0.0;
346
            } else {
347
                bulge = 0.0;
348
            }
349

    
350
            Point3D point_in = new Point3D(x, y, z);
351
            Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
352
            Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
353

    
354
            if (((flags & 0x80) == 0x80) && ((flags & 0x40) == 0)) {
355
                int[] face = { 0, 0, 0, 0 };
356
                face[0] = grp.getDataAsInt(71);
357
                face[1] = grp.getDataAsInt(72);
358
                face[2] = grp.getDataAsInt(73);
359
                face[3] = grp.getDataAsInt(74);
360
                ((DxfPolyline) lastEntity).addFace(face);
361
            } else {
362
                x = point_out.getX();
363
                y = point_out.getY();
364
                z = point_out.getZ();
365

    
366
                Point2D ptaux = proj.createPoint(x, y);
367
                Point3D pt = new Point3D(ptaux.getX(), ptaux.getY(), z);
368
                ((DxfPolyline) lastEntity).add(pt);
369

    
370
                if (((DxfPolyline) lastEntity).pts.size() == 1) {
371
                    firstPt = pt;
372
                }
373
            }
374
        } else if (bulge > 0.0) {
375
            double bulge_aux = 0.0;
376

    
377
            if (grp.hasCode(42)) {
378
                bulge_aux = grp.getDataAsDouble(42);
379
            } else {
380
                bulge_aux = 0.0;
381
            }
382

    
383
            Point3D point_in = new Point3D(x, y, z);
384
            Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
385
            Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
386
            x = point_out.getX();
387
            y = point_out.getY();
388
            z = point_out.getZ();
389

    
390
            Point2D ptaux = proj.createPoint(x, y);
391
            Point3D pt = new Point3D(ptaux.getX(), ptaux.getY(), z);
392
            ((DxfPolyline) lastEntity).add(pt);
393

    
394
            if (((DxfPolyline) lastEntity).pts.size() == 1) {
395
                firstPt = pt;
396
            }
397

    
398
            int cnt = ((DxfPolyline) lastEntity).pts.size();
399

    
400
            if ((((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - 2))).getX() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
401
                                                                                                                                        1))).getX()) &&
402
                    (((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - 2))).getY() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
403
                                                                                                                                            1))).getY())) {
404
                // no se construye el arco
405
            } else {
406
                Vector arc = DxfPolyline.createArc((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
407
                                                                                                 2)),
408
                                                   (Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
409
                                                                                                 1)),
410
                                                   bulge);
411
                ((DxfPolyline) lastEntity).pts.remove(cnt - 1);
412

    
413
                for (int i = 0; i < arc.size(); i++) {
414
                    ptaux = proj.createPoint(((Point2D) arc.get(i)).getX(),
415
                                          ((Point2D) arc.get(i)).getY());
416
                    pt = new Point3D(ptaux.getX(), ptaux.getY(), z);
417
                    ((DxfPolyline) lastEntity).add(pt);
418

    
419
                    if (((DxfPolyline) lastEntity).pts.size() == 1) {
420
                        firstPt = pt;
421
                    }
422
                }
423
            }
424

    
425
            bulge = bulge_aux;
426
        } else { //si el bulge es menor que cero.
427

    
428
            double bulge_aux = 0.0;
429

    
430
            if (grp.hasCode(42)) {
431
                bulge_aux = grp.getDataAsDouble(42); // * (-1.0);
432
            } else {
433
                bulge_aux = 0.0;
434
            }
435

    
436
            Point3D point_in = new Point3D(x, y, z);
437
            Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
438
            Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
439
            x = point_out.getX();
440
            y = point_out.getY();
441
            z = point_out.getZ();
442

    
443
            Point2D ptaux = proj.createPoint(x, y);
444
            Point3D pt = new Point3D(ptaux.getX(), ptaux.getY(), z);
445
            ((DxfPolyline) lastEntity).add(pt);
446

    
447
            if (((DxfPolyline) lastEntity).pts.size() == 1) {
448
                firstPt = pt;
449
            }
450

    
451
            int cnt = ((DxfPolyline) lastEntity).pts.size();
452

    
453
            if ((((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - 2))).getX() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
454
                                                                                                                                        1))).getX()) &&
455
                    (((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt - 2))).getY() == ((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
456
                                                                                                                                            1))).getY())) {
457
                // no se construye el arco
458
            } else {
459
                Vector arc = DxfPolyline.createArc((Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
460
                                                                                                 2)),
461
                                                   (Point2D) (((DxfPolyline) lastEntity).pts.get(cnt -
462
                                                                                                 1)),
463
                                                   bulge);
464
                ((DxfPolyline) lastEntity).pts.remove(cnt - 1);
465

    
466
                for (int i = arc.size() - 1; i >= 0; i--) {
467
                    ptaux = proj.createPoint(((Point2D) arc.get(i)).getX(),
468
                                          ((Point2D) arc.get(i)).getY());
469
                    pt = new Point3D(ptaux.getX(), ptaux.getY(), z);
470
                    ((DxfPolyline) lastEntity).add(pt);
471

    
472
                    if (((DxfPolyline) lastEntity).pts.size() == 1) {
473
                        firstPt = pt;
474
                    }
475
                }
476
            }
477

    
478
            bulge = bulge_aux;
479
        }
480

    
481
        /*if (grp.hasCode(5)) {
482
                String hexS = grp.getDataAsString(5);
483
                Integer hexI = Integer.decode("0x" + hexS);
484
                int hexi = hexI.intValue();
485
                lastEntity.setHandle(hexi);
486
        } else {
487
                lastEntity.setHandle(entities.size()+40);
488
        }*/
489
    }
490
    
491
    /* (non-Javadoc)
492
     * @see org.cresques.io.DxfFile.EntityFactory#createLwPolyline(org.cresques.io.DxfGroupVector)
493
     */
494
    public void createLwPolyline(DxfGroupVector grp) throws Exception {
495
        double x = 0.0;
496
        double y = 0.0;
497
        double elev = 0.0;
498
        DxfGroup g = null;
499
        double extx = 0.0;
500
        double exty = 0.0;
501
        double extz = 1.0;
502

    
503
        DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
504
        DxfLwPolyline entity = new DxfLwPolyline(proj, layer);
505
        
506
        if (grp.hasCode(38)) {
507
            entity.setElevation(grp.getDataAsDouble(38));
508
        }
509

    
510
        if (grp.hasCode(5)) {
511
            String hexS = grp.getDataAsString(5);
512
            Integer hexI = Integer.decode("0x" + hexS);
513
            int hexi = hexI.intValue();
514
            entity.setHandle(hexi);
515
        } else {
516
            entity.setHandle(entities.size() + 40);
517
        }
518

    
519
        if (grp.hasCode(210)) {
520
            extx = grp.getDataAsDouble(210);
521
        }
522

    
523
        if (grp.hasCode(220)) {
524
            exty = grp.getDataAsDouble(220);
525
        }
526

    
527
        if (grp.hasCode(230)) {
528
            extz = grp.getDataAsDouble(230);
529
        }
530

    
531
        double bulge = 0;
532
        boolean isNewCoord = false;
533

    
534
        for (int i = 0; i < grp.size(); i++) {
535
            bulge = 0;
536
            isNewCoord = false;
537
            g = (DxfGroup) grp.get(i);
538

    
539
            if (g.getCode() == 10) {
540
                x = ((Double) g.getData()).doubleValue();
541
            } else if (g.getCode() == 20) {
542
                y = ((Double) g.getData()).doubleValue();
543

    
544
                // A�adiendo extrusion a LwPolyline ...
545
                Point3D point_in1 = new Point3D(x, y, elev);
546
                Point3D xtru = new Point3D(extx, exty, extz);
547
                Point3D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru);
548
                x = point_out1.getX();
549
                y = point_out1.getY();
550
                elev = point_out1.getZ();
551

    
552
                //
553
                //if (y <= 1.0) throw new Exception("Y == "+y);
554
                entity.add(proj.createPoint(x, y));
555
                entity.addBulge(new Double(0));
556
                x = 0.0;
557
                y = 0.0;
558
                isNewCoord = true;
559
            } else if (g.getCode() == 42) {
560
                //entity.addBulge((Double)g.getData());
561
                entity.getBulges().remove(entity.getBulges().size() - 1);
562
                entity.getBulges().add((Double) g.getData());
563
                bulge = ((Double) g.getData()).doubleValue();
564
            }
565

    
566
            /*if (bulge == 0 && isNewCoord) {
567
                    entity.addBulge(new Double(0));
568
            }*/
569
        }
570

    
571
        if (grp.hasCode(62)) {
572
            entity.dxfColor = grp.getDataAsInt(62);
573
        } else {
574
            //entity.dxfColor = 0;
575
        }
576

    
577
        if (grp.hasCode(70)) {
578
            entity.flags = grp.getDataAsInt(70);
579

    
580
        }
581

    
582
        if ((entity.flags & 0x01) == 0x01) {
583
            entity.closed = true;
584
        }
585

    
586
        if (addingToBlock == false) {
587
            entities.add(entity);
588
        } else {
589
            blk.add(entity);
590
        }
591
    }
592
    
593
    /* (non-Javadoc)
594
     * @see org.cresques.io.DxfFile.EntityFactory#createLine(org.cresques.io.DxfGroupVector)
595
     */
596
    public void createLine(DxfGroupVector grp) throws Exception {
597
        double x = 0.0;
598
        double y = 0.0;
599
        double z1 = 0.0;
600
        double z2 = 0.0;
601
        DxfGroup g = null;
602
        Point2D pt1 = null;
603
        Point2D pt2 = null;
604
        DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
605
        double extx = 0.0;
606
        double exty = 0.0;
607
        double extz = 1.0;
608

    
609
        x = grp.getDataAsDouble(10);
610
        y = grp.getDataAsDouble(20);
611

    
612
        if (grp.hasCode(30)) {
613
            z1 = grp.getDataAsDouble(30);
614
        }
615

    
616
        pt1 = proj.createPoint(x, y);
617
        x = grp.getDataAsDouble(11);
618
        y = grp.getDataAsDouble(21);
619

    
620
        if (grp.hasCode(31)) {
621
            z2 = grp.getDataAsDouble(31);
622
        }
623

    
624
        pt2 = proj.createPoint(x, y);
625

    
626
        if (grp.hasCode(210)) {
627
            extx = grp.getDataAsDouble(210);
628
        }
629

    
630
        if (grp.hasCode(220)) {
631
            exty = grp.getDataAsInt(220);
632
        }
633

    
634
        if (grp.hasCode(230)) {
635
            extz = grp.getDataAsInt(230);
636
        }
637

    
638
        Point3D point_in1 = new Point3D(pt1.getX(), pt1.getY(), z1);
639
        Point3D point_in2 = new Point3D(pt2.getX(), pt2.getY(), z2);
640
        Point3D xtru = new Point3D(extx, exty, extz);
641
        Point2D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru);
642
        Point2D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru);
643
        pt1.setLocation(point_out1);
644
        pt2.setLocation(point_out2);
645

    
646
        DxfLine entity = new DxfLine(proj, layer, pt1, pt2);
647

    
648
        if (grp.hasCode(5)) {
649
            String hexS = grp.getDataAsString(5);
650
            Integer hexI = Integer.decode("0x" + hexS);
651
            int hexi = hexI.intValue();
652
            entity.setHandle(hexi);
653
        } else {
654
            entity.setHandle(entities.size() + 40);
655
        }
656

    
657
        if (grp.hasCode(62)) {
658
            entity.dxfColor = grp.getDataAsInt(62);
659
        } else {
660
            //entity.dxfColor = 0;
661
        }
662

    
663
        if (addingToBlock == false) {
664
            entities.add(entity);
665
        } else {
666
            blk.add(entity);
667
        }
668
    }
669
    
670
    /* (non-Javadoc)
671
     * @see org.cresques.io.DxfFile.EntityFactory#createText(org.cresques.io.DxfGroupVector)
672
     */
673
    public void createText(DxfGroupVector grp) throws Exception {
674
        double x = 0.0;
675
        double y = 0.0;
676
        double z = 0.0;
677
        double h = 0.0;
678
        double rot = 0.0;
679
        DxfGroup g = null;
680

    
681
        //OJO! El segundo punto es opcional ...
682
        Point2D pt1 = null;
683

    
684
        //OJO! El segundo punto es opcional ...
685
        Point2D pt2 = null;
686
        String txt = null;
687
        DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
688

    
689
        txt = grp.getDataAsString(1);
690

    
691
        DxfText entity = new DxfText(proj, layer, txt);
692
        double extx = 0.0;
693
        double exty = 0.0;
694
        double extz = 1.0;
695

    
696
        x = grp.getDataAsDouble(10);
697
        y = grp.getDataAsDouble(20);
698
        z = grp.getDataAsDouble(30);
699

    
700
        if (grp.hasCode(5)) {
701
            String hexS = grp.getDataAsString(5);
702
            Integer hexI = Integer.decode("0x" + hexS);
703
            int hexi = hexI.intValue();
704
            entity.setHandle(hexi);
705
        } else {
706
            entity.setHandle(entities.size() + 40);
707
        }
708

    
709
        if (grp.hasCode(210)) {
710
            extx = grp.getDataAsDouble(210);
711
        }
712

    
713
        if (grp.hasCode(220)) {
714
            exty = grp.getDataAsDouble(220);
715
        }
716

    
717
        if (grp.hasCode(230)) {
718
            extz = grp.getDataAsDouble(230);
719
        }
720

    
721
        Point3D point_in = new Point3D(x, y, z);
722
        Point3D xtru = new Point3D(extx, exty, extz);
723
        Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
724
        x = point_out.getX();
725
        y = point_out.getY();
726
        z = point_out.getZ();
727

    
728
        entity.setPt(proj.createPoint(x, y));
729

    
730
        //entity.setPt1(proj.createPoint(x, y));
731
        if (grp.hasCode(11)) {
732
            entity.setTwoPointsFlag(true);
733
            entity.setPt1(proj.createPoint(entity.getPt().getX(),
734
                                           entity.getPt().getY()));
735
            x = grp.getDataAsDouble(11);
736
            y = grp.getDataAsDouble(21);
737
            z = grp.getDataAsDouble(31);
738

    
739
            point_in = new Point3D(x, y, z);
740
            point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
741
            x = point_out.getX();
742
            y = point_out.getY();
743
            z = point_out.getZ();
744

    
745
            entity.setPt2(proj.createPoint(x, y));
746
        }
747

    
748
        entity.setHeight(grp.getDataAsDouble(40));
749

    
750
        if (grp.hasCode(50)) {
751
            entity.setRotation(grp.getDataAsDouble(50));
752

    
753
        }
754

    
755
        if (grp.hasCode(62)) {
756
            entity.dxfColor = grp.getDataAsInt(62);
757
        } else {
758
            //entity.dxfColor = 0;
759
        }
760

    
761
        if (grp.hasCode(72)) {
762
            entity.align = grp.getDataAsInt(72);
763
        }
764

    
765
        if (addingToBlock == false) {
766
            entities.add(entity);
767
        } else {
768
            blk.add(entity);
769
        }
770
    }
771

    
772
    /* (non-Javadoc)
773
     * @see org.cresques.io.DxfFile.EntityFactory#createMText(org.cresques.io.DxfGroupVector)
774
     */
775
    public void createMText(DxfGroupVector v) throws Exception {
776
        // TODO Auto-generated method stub
777
    }
778
    
779
    /* (non-Javadoc)
780
     * @see org.cresques.io.DxfFile.EntityFactory#createPoint(org.cresques.io.DxfGroupVector)
781
     */
782
    public void createPoint(DxfGroupVector grp) throws Exception {
783
        double x = 0.0; //, h= 0.0, rot= 0.0;
784
        double y = 0.0; //, h= 0.0, rot= 0.0;
785
        double z = 0.0; //, h= 0.0, rot= 0.0;
786
        DxfGroup g = null;
787
        Point2D pt = null;
788
        DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
789
        double extx = 0.0;
790
        double exty = 0.0;
791
        double extz = 1.0;
792

    
793
        DxfPoint entity = new DxfPoint(proj, layer);
794

    
795
        if (grp.hasCode(5)) {
796
            String hexS = grp.getDataAsString(5);
797
            Integer hexI = Integer.decode("0x" + hexS);
798
            int hexi = hexI.intValue();
799
            entity.setHandle(hexi);
800
        } else {
801
            entity.setHandle(entities.size() + 40);
802
        }
803

    
804
        x = grp.getDataAsDouble(10);
805
        y = grp.getDataAsDouble(20);
806

    
807
        if (grp.hasCode(30)) {
808
            z = grp.getDataAsDouble(30);
809
        }
810

    
811
        if (grp.hasCode(62)) {
812
            entity.dxfColor = grp.getDataAsInt(62);
813
        } else {
814
            //entity.dxfColor = 0;
815
        }
816

    
817
        if (grp.hasCode(210)) {
818
            extx = grp.getDataAsDouble(210);
819
        }
820

    
821
        if (grp.hasCode(220)) {
822
            exty = grp.getDataAsInt(220);
823
        }
824

    
825
        if (grp.hasCode(230)) {
826
            extz = grp.getDataAsInt(230);
827
        }
828

    
829
        Point3D point_in = new Point3D(x, y, z);
830
        Point3D xtru = new Point3D(extx, exty, extz);
831
        Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
832
        x = point_out.getX();
833
        y = point_out.getY();
834
        entity.setPt(proj.createPoint(x, y));
835

    
836
        if (addingToBlock == false) {
837
            entities.add(entity);
838
        } else {
839
            blk.add(entity);
840
        }
841
    }
842
    
843
    /* (non-Javadoc)
844
     * @see org.cresques.io.DxfFile.EntityFactory#createCircle(org.cresques.io.DxfGroupVector)
845
     */
846
    public void createCircle(DxfGroupVector grp) throws Exception {
847
        double x = 0.0;
848

    
849
        double y = 0.0;
850

    
851
        double z = 0.0;
852
        double r = 0.0;
853
        DxfGroup g = null;
854
        DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
855
        double extx = 0.0;
856
        double exty = 0.0;
857
        double extz = 1.0;
858

    
859
        x = grp.getDataAsDouble(10);
860
        y = grp.getDataAsDouble(20);
861

    
862
        if (grp.hasCode(30)) {
863
            z = grp.getDataAsDouble(30);
864
        }
865

    
866
        if (grp.hasCode(40)) {
867
            r = grp.getDataAsDouble(40);
868
        }
869

    
870
        if (grp.hasCode(210)) {
871
            extx = grp.getDataAsDouble(210);
872
        }
873

    
874
        if (grp.hasCode(220)) {
875
            exty = grp.getDataAsDouble(220);
876
        }
877

    
878
        if (grp.hasCode(230)) {
879
            extz = grp.getDataAsDouble(230);
880
        }
881

    
882
        Point3D point_in = new Point3D(x, y, z);
883
        Point3D xtru = new Point3D(extx, exty, extz);
884
        Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
885
        x = point_out.getX();
886
        y = point_out.getY();
887

    
888
        Point2D center = proj.createPoint(x, y);
889
        Point2D[] pts = new Point2D[360];
890
        int angulo = 0;
891

    
892
        for (angulo = 0; angulo < 360; angulo++) {
893
            pts[angulo] = new Point2D.Double(center.getX(), center.getY());
894
            pts[angulo].setLocation(pts[angulo].getX() +
895
                                    (r * Math.sin((angulo * Math.PI) / (double) 180.0)),
896
                                    pts[angulo].getY() +
897
                                    (r * Math.cos((angulo * Math.PI) / (double) 180.0)));
898

    
899
            if (pts.length == 1) {
900
                firstPt = pts[angulo];
901
            }
902
        }
903

    
904
        DxfCircle entity = new DxfCircle(proj, layer, pts);
905

    
906
        if (grp.hasCode(5)) {
907
            String hexS = grp.getDataAsString(5);
908
            Integer hexI = Integer.decode("0x" + hexS);
909
            int hexi = hexI.intValue();
910
            entity.setHandle(hexi);
911
        } else {
912
            entity.setHandle(entities.size() + 40);
913
        }
914

    
915
        entity.setCenter(new Point2D.Double(x, y));
916

    
917
        entity.setRadius(r);
918

    
919
        if (grp.hasCode(62)) {
920
            entity.dxfColor = grp.getDataAsInt(62);
921
        } else {
922
            //entity.dxfColor = 0;
923
        }
924

    
925
        if (addingToBlock == false) {
926
            entities.add(entity);
927
        } else {
928
            blk.add(entity);
929
        }
930
    }
931
    
932
    /* (non-Javadoc)
933
     * @see org.cresques.io.DxfFile.EntityFactory#createEllipse(org.cresques.io.DxfGroupVector)
934
     */
935
    public void createEllipse(DxfGroupVector grp) throws Exception {
936
        double incX = 0.0;
937
        double incY = 0.0;
938
        double incZ = 0.0;
939
        double xc = 0.0;
940
        double yc = 0.0;
941
        double zc = 0.0;
942
        double mMAxisRatio = 0.0;
943
        DxfGroup g = null;
944
        DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
945
        double extx = 0.0;
946
        double exty = 0.0;
947
        double extz = 1.0;
948

    
949
        xc = grp.getDataAsDouble(10);
950
        yc = grp.getDataAsDouble(20);
951

    
952
        if (grp.hasCode(30)) {
953
            zc = grp.getDataAsDouble(30);
954
        }
955

    
956
        if (grp.hasCode(210)) {
957
            extx = grp.getDataAsDouble(210);
958
        }
959

    
960
        if (grp.hasCode(220)) {
961
            exty = grp.getDataAsDouble(220);
962
        }
963

    
964
        if (grp.hasCode(230)) {
965
            extz = grp.getDataAsDouble(230);
966
        }
967

    
968
        Point3D point_in = new Point3D(xc, yc, zc);
969
        Point3D xtru = new Point3D(extx, exty, extz);
970
        Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
971
        xc = point_out.getX();
972
        yc = point_out.getY();
973
        zc = point_out.getZ();
974

    
975
        incX = grp.getDataAsDouble(11);
976
        incY = grp.getDataAsDouble(21);
977

    
978
        if (grp.hasCode(31)) {
979
            incZ = grp.getDataAsDouble(31);
980
        }
981

    
982
        if (grp.hasCode(40)) {
983
            mMAxisRatio = grp.getDataAsDouble(40);
984
        }
985

    
986
        Point2D pt2 = new Point2D.Double(xc + incX, yc + incY);
987
        Point2D pt1 = new Point2D.Double(xc - incX, yc - incY);
988
        double majorAxisLength = pt1.distance(pt2);
989
        double minorAxisLength = majorAxisLength * mMAxisRatio;
990

    
991
        DxfEllipse entity = new DxfEllipse(proj, layer, pt1, pt2,
992
                                           minorAxisLength);
993

    
994
        if (grp.hasCode(5)) {
995
            String hexS = grp.getDataAsString(5);
996
            Integer hexI = Integer.decode("0x" + hexS);
997
            int hexi = hexI.intValue();
998
            entity.setHandle(hexi);
999
        } else {
1000
            entity.setHandle(entities.size() + 40);
1001
        }
1002

    
1003
        if (grp.hasCode(62)) {
1004
            entity.dxfColor = grp.getDataAsInt(62);
1005
        } else {
1006
            //entity.dxfColor = 0;
1007
        }
1008

    
1009
        if (addingToBlock == false) {
1010
            entities.add(entity);
1011
        } else {
1012
            blk.add(entity);
1013
        }
1014
    }
1015
    
1016
    /* (non-Javadoc)
1017
     * @see org.cresques.io.DxfFile.EntityFactory#createArc(org.cresques.io.DxfGroupVector)
1018
     */
1019
    public void createArc(DxfGroupVector grp) throws Exception {
1020
        double x = 0.0;
1021
        double y = 0.0;
1022
        double z = 0.0;
1023
        double r = 0.0;
1024
        double empieza = 0.0;
1025
        double acaba = 0.0;
1026
        DxfGroup g = null;
1027
        DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
1028
        double extx = 0.0;
1029
        double exty = 0.0;
1030
        double extz = 1.0;
1031

    
1032
        x = grp.getDataAsDouble(10);
1033
        y = grp.getDataAsDouble(20);
1034

    
1035
        if (grp.hasCode(30)) {
1036
            z = grp.getDataAsDouble(30);
1037
        }
1038

    
1039
        if (grp.hasCode(40)) {
1040
            r = grp.getDataAsDouble(40);
1041
        }
1042

    
1043
        if (grp.hasCode(50)) {
1044
            empieza = grp.getDataAsDouble(50);
1045
        }
1046

    
1047
        if (grp.hasCode(51)) {
1048
            acaba = grp.getDataAsDouble(51);
1049
        }
1050

    
1051
        if (grp.hasCode(210)) {
1052
            extx = grp.getDataAsDouble(210);
1053
        }
1054

    
1055
        if (grp.hasCode(220)) {
1056
            exty = grp.getDataAsDouble(220);
1057
        }
1058

    
1059
        if (grp.hasCode(230)) {
1060
            extz = grp.getDataAsDouble(230);
1061
        }
1062

    
1063
        Point3D point_in = new Point3D(x, y, z);
1064
        Point3D xtru = new Point3D(extx, exty, extz);
1065
        Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
1066
        x = point_out.getX();
1067
        y = point_out.getY();
1068

    
1069
        Point2D center = proj.createPoint(x, y);
1070

    
1071
        int iempieza = (int) empieza;
1072
        int iacaba = (int) acaba;
1073

    
1074
        double angulo = 0;
1075
        Point2D[] pts = null;
1076

    
1077
        if (empieza <= acaba) {
1078
            pts = new Point2D[(iacaba - iempieza) + 2];
1079
            angulo = empieza;
1080
            pts[0] = new Point2D.Double(center.getX() +
1081
                                        (r * Math.cos((angulo * Math.PI) / (double) 180.0)),
1082
                                        center.getY() +
1083
                                        (r * Math.sin((angulo * Math.PI) / (double) 180.0)));
1084

    
1085
            for (int i = 1; i <= ((iacaba - iempieza) + 1); i++) {
1086
                angulo = (double) (iempieza + i);
1087
                pts[i] = new Point2D.Double(center.getX() +
1088
                                            (r * Math.cos((angulo * Math.PI) / (double) 180.0)),
1089
                                            center.getY() +
1090
                                            (r * Math.sin((angulo * Math.PI) / (double) 180.0)));
1091
            }
1092

    
1093
            angulo = acaba;
1094
            pts[(iacaba - iempieza) + 1] = new Point2D.Double(center.getX() +
1095
                                                              (r * Math.cos((angulo * Math.PI) / (double) 180.0)),
1096
                                                              center.getY() +
1097
                                                              (r * Math.sin((angulo * Math.PI) / (double) 180.0)));
1098
        } else {
1099
            pts = new Point2D[(360 - iempieza) + iacaba + 2];
1100
            angulo = empieza;
1101

    
1102
            pts[0] = new Point2D.Double(center.getX() +
1103
                                        (r * Math.cos((angulo * Math.PI) / (double) 180.0)),
1104
                                        center.getY() +
1105
                                        (r * Math.sin((angulo * Math.PI) / (double) 180.0)));
1106

    
1107
            for (int i = 1; i <= (360 - iempieza); i++) {
1108
                angulo = (double) (iempieza + i);
1109
                pts[i] = new Point2D.Double(center.getX() +
1110
                                            (r * Math.cos((angulo * Math.PI) / (double) 180.0)),
1111
                                            center.getY() +
1112
                                            (r * Math.sin((angulo * Math.PI) / (double) 180.0)));
1113
            }
1114

    
1115
            for (int i = (360 - iempieza) + 1;
1116
                     i <= ((360 - iempieza) + iacaba); i++) {
1117
                angulo = (double) (i - (360 - iempieza));
1118
                pts[i] = new Point2D.Double(center.getX() +
1119
                                            (r * Math.cos((angulo * Math.PI) / (double) 180.0)),
1120
                                            center.getY() +
1121
                                            (r * Math.sin((angulo * Math.PI) / (double) 180.0)));
1122
            }
1123

    
1124
            angulo = acaba;
1125
            pts[(360 - iempieza) + iacaba + 1] = new Point2D.Double(center.getX() +
1126
                                                                    (r * Math.cos((angulo * Math.PI) / (double) 180.0)),
1127
                                                                    center.getY() +
1128
                                                                    (r * Math.sin((angulo * Math.PI) / (double) 180.0)));
1129
        }
1130

    
1131
        DxfArc entity = new DxfArc(proj, layer, pts);
1132

    
1133
        if (grp.hasCode(5)) {
1134
            String hexS = grp.getDataAsString(5);
1135
            Integer hexI = Integer.decode("0x" + hexS);
1136
            int hexi = hexI.intValue();
1137
            entity.setHandle(hexi);
1138
        } else {
1139
            entity.setHandle(entities.size() + 40);
1140
        }
1141

    
1142
        // 050223, jmorell: Establecimiento de los par�metros del arco.
1143
        entity.setCentralPoint(pts[(pts.length) / 2]);
1144

    
1145
        entity.setInit(pts[0]);
1146
        entity.setEnd(pts[pts.length - 1]);
1147

    
1148
        entity.setCenter(center);
1149
        entity.setRadius(r);
1150
        entity.setInitAngle(empieza);
1151

    
1152
        entity.setEndAngle(acaba);
1153

    
1154
        if (grp.hasCode(62)) {
1155
            entity.dxfColor = grp.getDataAsInt(62);
1156
        } else {
1157
            //entity.dxfColor = 0;
1158
        }
1159

    
1160
        if (addingToBlock == false) {
1161
            entities.add(entity);
1162
        } else {
1163
            blk.add(entity);
1164
        }
1165
    }
1166

    
1167
    /* (non-Javadoc)
1168
     * @see org.cresques.io.DxfFile.EntityFactory#createInsert(org.cresques.io.DxfGroupVector)
1169
     */
1170
    public void createInsert(DxfGroupVector grp) throws Exception {
1171
        double x = 0.0;
1172
        double y = 0.0;
1173
        double z = 0.0;
1174
        DxfGroup g = null;
1175
        Point2D pt = new Point2D.Double(0.0, 0.0);
1176
        Point2D scaleFactor = new Point2D.Double(1.0, 1.0);
1177
        double rotAngle = 0.0;
1178
        String blockName = "";
1179
        double extx = 0.0;
1180
        double exty = 0.0;
1181
        double extz = 1.0;
1182

    
1183
        DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
1184

    
1185
        DxfInsert entity = new DxfInsert(proj, layer);
1186
        DxfPoint secondEntity = new DxfPoint(proj, layer);
1187

    
1188
        // jmorell, 050406: implementaci�n inicial de los ATTRIBS para el piloto ...
1189
        int attributesFollowFlag = 0;
1190

    
1191
        if (grp.hasCode(2)) {
1192
            blockName = grp.getDataAsString(2);
1193
            entity.setBlockName(blockName);
1194
        }
1195

    
1196
        if (grp.hasCode(10)) {
1197
            x = grp.getDataAsDouble(10);
1198
        }
1199

    
1200
        if (grp.hasCode(20)) {
1201
            y = grp.getDataAsDouble(20);
1202
        }
1203

    
1204
        if (grp.hasCode(30)) {
1205
            z = grp.getDataAsDouble(30);
1206
        }
1207

    
1208
        if (grp.hasCode(41)) {
1209
            scaleFactor.setLocation(grp.getDataAsDouble(41), scaleFactor.getY());
1210
            entity.setScaleFactor(scaleFactor);
1211
        } else {
1212
            entity.setScaleFactor(scaleFactor);
1213
        }
1214

    
1215
        if (grp.hasCode(42)) {
1216
            scaleFactor.setLocation(scaleFactor.getX(), grp.getDataAsDouble(42));
1217
            entity.setScaleFactor(scaleFactor);
1218
        } else {
1219
            entity.setScaleFactor(scaleFactor);
1220
        }
1221

    
1222
        if (grp.hasCode(43)) {
1223
            // TODO La coordenada z
1224
        }
1225

    
1226
        if (grp.hasCode(50)) {
1227
            rotAngle = grp.getDataAsDouble(50);
1228
            entity.setRotAngle(rotAngle);
1229
        }
1230

    
1231
        if (grp.hasCode(62)) {
1232
            entity.dxfColor = grp.getDataAsInt(62);
1233
        } else {
1234
            //entity.dxfColor = 0;
1235
        }
1236

    
1237
        if (grp.hasCode(66)) {
1238
            attributesFollowFlag = grp.getDataAsInt(66);
1239

    
1240
        }
1241

    
1242
        if (grp.hasCode(210)) {
1243
            extx = grp.getDataAsDouble(210);
1244
        }
1245

    
1246
        if (grp.hasCode(220)) {
1247
            exty = grp.getDataAsDouble(220);
1248
        }
1249

    
1250
        if (grp.hasCode(230)) {
1251
            extz = grp.getDataAsDouble(230);
1252
        }
1253

    
1254
        Point3D point_in = new Point3D(x, y, z);
1255
        Point3D xtru = new Point3D(extx, exty, extz);
1256
        Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
1257
        x = point_out.getX();
1258
        y = point_out.getY();
1259

    
1260
        entity.setBlkList(blkList);
1261

    
1262
        entity.encuentraBloque(blockName);
1263

    
1264
        entity.setPt(proj.createPoint(x, y));
1265
        secondEntity.setPt(proj.createPoint(x, y));
1266

    
1267
        if ((entity.getBlockFound() == true) && (attributesFollowFlag != 1)) {
1268
            gestionaInsert(entity, layer);
1269
        }
1270

    
1271
        if (attributesFollowFlag == 1) {
1272
            lastEntity = entity;
1273
        } else {
1274
            if (addingToBlock == false) {
1275
                entities.add(secondEntity);
1276
            } else if ((addingToBlock == true) && (entity.blockFound == true)) {
1277
                blk.add(entity);
1278
            }
1279
        }
1280
    }
1281
    
1282
    /* (non-Javadoc)
1283
     * @see org.cresques.io.DxfFile.EntityFactory#createSolid(org.cresques.io.DxfGroupVector)
1284
     */
1285
    public void createSolid(DxfGroupVector grp) throws Exception {
1286
        double x = 0.0;
1287
        double y = 0.0;
1288
        double z1 = 0.0;
1289
        double z2 = 0.0;
1290
        double z3 = 0.0;
1291
        double z4 = 0.0;
1292
        DxfGroup g = null;
1293

    
1294
        //Point2D pt1 = null, pt2 = null, pt3 = null, pt4 = null;
1295
        Point2D[] pts = new Point2D[4];
1296
        DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
1297
        double extx = 0.0;
1298
        double exty = 0.0;
1299
        double extz = 1.0;
1300

    
1301
        x = grp.getDataAsDouble(10);
1302
        y = grp.getDataAsDouble(20);
1303

    
1304
        if (grp.hasCode(30)) {
1305
            z1 = grp.getDataAsDouble(30);
1306
        }
1307

    
1308
        pts[0] = proj.createPoint(x, y);
1309
        x = grp.getDataAsDouble(11);
1310
        y = grp.getDataAsDouble(21);
1311

    
1312
        if (grp.hasCode(31)) {
1313
            z2 = grp.getDataAsDouble(31);
1314
        }
1315

    
1316
        pts[1] = proj.createPoint(x, y);
1317
        x = grp.getDataAsDouble(12);
1318
        y = grp.getDataAsDouble(22);
1319

    
1320
        if (grp.hasCode(32)) {
1321
            z3 = grp.getDataAsDouble(32);
1322
        }
1323

    
1324
        pts[2] = proj.createPoint(x, y);
1325
        x = grp.getDataAsDouble(13);
1326
        y = grp.getDataAsDouble(23);
1327

    
1328
        if (grp.hasCode(33)) {
1329
            z2 = grp.getDataAsDouble(33);
1330
        }
1331

    
1332
        pts[3] = proj.createPoint(x, y);
1333

    
1334
        if (grp.hasCode(210)) {
1335
            extx = grp.getDataAsDouble(210);
1336
        }
1337

    
1338
        if (grp.hasCode(220)) {
1339
            exty = grp.getDataAsDouble(220);
1340
        }
1341

    
1342
        if (grp.hasCode(230)) {
1343
            extz = grp.getDataAsDouble(230);
1344
        }
1345

    
1346
        Point3D point_in1 = new Point3D(pts[0].getX(), pts[0].getY(), z1);
1347
        Point3D point_in2 = new Point3D(pts[1].getX(), pts[1].getY(), z2);
1348
        Point3D point_in3 = new Point3D(pts[2].getX(), pts[2].getY(), z3);
1349
        Point3D point_in4 = new Point3D(pts[3].getX(), pts[3].getY(), z4);
1350
        Point3D xtru = new Point3D(extx, exty, extz);
1351
        Point2D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru);
1352
        Point2D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru);
1353
        Point2D point_out3 = DxfCalXtru.CalculateXtru(point_in3, xtru);
1354
        Point2D point_out4 = DxfCalXtru.CalculateXtru(point_in4, xtru);
1355
        pts[0].setLocation(point_out1);
1356
        pts[1].setLocation(point_out2);
1357
        pts[2].setLocation(point_out3);
1358
        pts[3].setLocation(point_out4);
1359

    
1360
        DxfSolid entity = new DxfSolid(proj, layer, pts);
1361

    
1362
        if (grp.hasCode(62)) {
1363
            entity.dxfColor = grp.getDataAsInt(62);
1364
        } else {
1365
            //entity.dxfColor = 0;
1366
        }
1367

    
1368
        if (addingToBlock == false) {
1369
            entities.add(entity);
1370
        } else {
1371
            blk.add(entity);
1372
        }
1373
    }
1374
    
1375
    /* (non-Javadoc)
1376
     * @see org.cresques.io.DxfFile.EntityFactory#createSpline(org.cresques.io.DxfGroupVector)
1377
     */
1378
    /**
1379
     * Los Splines estan implementados como LwPolylines. Se pintan las lineas
1380
     * entre los vertices pero no se aplica la curvatura Spline.
1381
     * TODO: Contemplar la curvatura spline para Splines.
1382
     */
1383
    public void createSpline(DxfGroupVector grp) throws Exception {
1384
        double x = 0.0;
1385
        double y = 0.0;
1386
        double elev = 0.0;
1387
        DxfGroup g = null;
1388

    
1389
        DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
1390
        DxfLwPolyline entity = new DxfLwPolyline(proj, layer);
1391

    
1392
        for (int i = 0; i < grp.size(); i++) {
1393
            g = (DxfGroup) grp.get(i);
1394

    
1395
            if (g.getCode() == 10) {
1396
                x = ((Double) g.getData()).doubleValue();
1397
            } else if (g.getCode() == 20) {
1398
                y = ((Double) g.getData()).doubleValue();
1399

    
1400
                //if (y <= 1.0) throw new Exception("Y == "+y);
1401
                entity.add(proj.createPoint(x, y));
1402
                x = 0.0;
1403
                y = 0.0;
1404
            }
1405
        }
1406

    
1407
        if (grp.hasCode(62)) {
1408
            entity.dxfColor = grp.getDataAsInt(62);
1409
        } else {
1410
            //entity.dxfColor = 0;
1411
        }
1412

    
1413
        if (grp.hasCode(70)) {
1414
            entity.flags = grp.getDataAsInt(70);
1415
        }
1416

    
1417
        if ((entity.flags & 0x01) == 0x01) {
1418
            entity.closed = true;
1419
        }
1420

    
1421
        if (addingToBlock == false) {
1422
            entities.add(entity);
1423
        } else {
1424
            blk.add(entity);
1425
        }
1426
    }
1427
    
1428
    /* (non-Javadoc)
1429
     * @see org.cresques.io.DxfFile.EntityFactory#createBlock(org.cresques.io.DxfGroupVector)
1430
     */
1431
    public void createBlock(DxfGroupVector grp) throws Exception {
1432
        DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
1433
        blk = new DxfBlock(proj);
1434

    
1435
        Point2D basePoint = new Point2D.Double();
1436
        String blockName = "";
1437

    
1438
        addingToBlock = true;
1439

    
1440
        blkList.add(iterator, blk);
1441

    
1442
        if (grp.hasCode(1)) {
1443
            blockName = grp.getDataAsString(1);
1444
            blk.setBlkName(blockName);
1445
        }
1446

    
1447
        if (grp.hasCode(2)) {
1448
            blockName = grp.getDataAsString(2);
1449
            blk.setBlkName(blockName);
1450
        }
1451

    
1452
        if (grp.hasCode(3)) {
1453
            blockName = grp.getDataAsString(3);
1454
            blk.setBlkName(blockName);
1455
        }
1456

    
1457
        if (grp.hasCode(10)) {
1458
            basePoint = new Point2D.Double(grp.getDataAsDouble(10),
1459
                                           basePoint.getY());
1460
            blk.setBPoint(basePoint);
1461
        }
1462

    
1463
        if (grp.hasCode(20)) {
1464
            basePoint = new Point2D.Double(basePoint.getX(),
1465
                                           grp.getDataAsDouble(20));
1466
            blk.setBPoint(basePoint);
1467
        }
1468

    
1469
        if (grp.hasCode(30)) {
1470
            // TODO Contemplar la coordenada z
1471
        }
1472

    
1473
        if (grp.hasCode(70)) {
1474
            blk.flags = grp.getDataAsInt(70);
1475
        }
1476
    }
1477
    
1478
    /* (non-Javadoc)
1479
     * @see org.cresques.io.DxfFile.EntityFactory#endBlk(org.cresques.io.DxfGroupVector)
1480
     */
1481
    public void endBlk(DxfGroupVector grp) throws Exception {
1482
        //DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
1483
        setAddingToBlock(false);
1484
        iterator = iterator + 1;
1485
    }
1486
    
1487
    /* (non-Javadoc)
1488
     * @see org.cresques.io.DxfFile.EntityFactory#testBlocks()
1489
     */
1490
    public void testBlocks() {
1491
        Vector blkList = getBlkList();
1492
        DxfBlock dxfBlock = null;
1493
        DxfEntity dxfEntity = null;
1494
        DxfLine dxfLine = null;
1495
        DxfInsert dxfInsert = null;
1496
        Point2D point1 = new Point2D.Double();
1497
        Point2D point2 = new Point2D.Double();
1498

    
1499
        for (int i = 0; i < blkList.size(); i++) {
1500
            dxfBlock = (DxfBlock) blkList.get(i);
1501

    
1502
            int aux = dxfBlock.getBlkElements().size();
1503

    
1504
            for (int j = 0; j < aux; j++) {
1505
                dxfEntity = (DxfEntity) dxfBlock.getBlkElements().get(j);
1506

    
1507
                if (dxfEntity instanceof DxfLine) {
1508
                    dxfLine = (DxfLine) dxfEntity;
1509
                    point1 = dxfLine.getPts()[0];
1510
                    point2 = dxfLine.getPts()[1];
1511

    
1512
                } else if (dxfEntity instanceof DxfInsert) {
1513
                    dxfInsert = (DxfInsert) dxfEntity;
1514

    
1515
                    String nomBlock = dxfInsert.getBlockName();
1516

    
1517
                    if (dxfInsert.getBlockFound() == false) {
1518
                        boolean aux_bool = dxfInsert.encuentraBloque(nomBlock);
1519
                        gestionaInsert(dxfInsert, dxfInsert.getDxfLayer());
1520
                        dxfBlock.add(dxfInsert);
1521
                    }
1522
                }
1523
            }
1524
        }
1525
    }
1526
    
1527
    /**
1528
     * Establece la proyecci�n cartogr�fica en la que se van a crear las entidades.
1529
     * @param p, Proyecci�n cartogr�fica.
1530
     */
1531
    public void setProjection(IProjection proj) {
1532
        this.proj = proj;
1533
    }
1534
    
1535
    /**
1536
     * Devuelve la proyecci�n cartogr�fica en la que se encuentran las entidades.
1537
     * @return IProjection, proyecci�n cartogr�fica.
1538
     */
1539
    public IProjection getProjection() {
1540
        return proj;
1541
    }
1542
    
1543
    /**
1544
     * Permite reproyectar las entidades creadas dado un conjunto de coordenadas de
1545
     * transformaci�n.
1546
     * @param rp, coordenadas de transformaci�n.
1547
     */
1548
    public void reProject(ICoordTrans rp) {
1549
        entities.reProject(rp);
1550
        setProjection(rp.getPDest());
1551
    }
1552
    
1553
    /**
1554
     * Devuelve las entidades creadas.
1555
     * @return DxfEntityList
1556
     */
1557
    public DxfEntityList getEntities() {
1558
        return entities;
1559
    }
1560
    
1561
    /**
1562
     * Devuelve las capas del DXF en forma de DxfTable.
1563
     * @return DxfTable
1564
     */
1565
    public DxfTable getLayers() {
1566
        return layers;
1567
    }
1568
    
1569
    /**
1570
     * Devuelve el bloque activo.
1571
     * @return DxfBlock
1572
     */
1573
    public DxfBlock getBlk() {
1574
        return blk;
1575
    }
1576
    
1577
    /**
1578
     * M�todo que permite incluir en la lista general de objetos los objetos que se
1579
     * encuentran dentro del bloque referenciado por cada DxfInsert.
1580
     * @param entity, el punto de inserci�n.
1581
     * @param layer, la capa en la que se encuentra.
1582
     */
1583
    public void gestionaInsert(DxfInsert entity, DxfLayer layer) {
1584
        DxfEntity dxfEntity = null;
1585
        DxfLine dxfLine = null;
1586
        DxfInsert dxfInsert = null;
1587
        DxfPolyline dxfPolyline = null;
1588
        DxfArc dxfArc = null;
1589
        DxfCircle dxfCircle = null;
1590
        DxfLwPolyline dxfLwPolyline = null;
1591
        DxfPoint dxfPoint = null;
1592
        DxfText dxfText = null;
1593
        DxfSolid dxfSolid = null;
1594

    
1595
        // jmorell, 050406: intentando corregir cosas que salen fuera de sitio ...
1596
        double bPointX = 0.0;
1597
        double bPointY = 0.0;
1598

    
1599
        //if (entity.getBlockFound() == true) {
1600
        bPointX = entity.block.bPoint.getX();
1601
        bPointY = entity.block.bPoint.getY();
1602

    
1603
        //}
1604
        double sFactorX = entity.getScaleFactor().getX();
1605
        double sFactorY = entity.getScaleFactor().getY();
1606
        double rAngleGra = entity.getRotAngle();
1607
        double rAngleRad = (rAngleGra * Math.PI) / 180.0;
1608

    
1609
        for (int i = 0; i < entity.block.size(); i++) {
1610
            dxfEntity = (DxfEntity) entity.block.get(i);
1611

    
1612
            Point2D point1 = new Point2D.Double();
1613
            Point2D point2 = new Point2D.Double();
1614
            Point2D point11 = new Point2D.Double();
1615
            Point2D point22 = new Point2D.Double();
1616
            Point2D pointAux = null;
1617

    
1618
            if (dxfEntity instanceof DxfLine) {
1619
                dxfLine = (DxfLine) dxfEntity;
1620
                point1 = dxfLine.getPts()[0];
1621

    
1622
                //double laX = entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((point1.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point1.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX());
1623
                //double laY = entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY());
1624
                pointAux = new Point2D.Double(point1.getX() - bPointX,
1625
                                              point1.getY() - bPointY);
1626

    
1627
                double laX = entity.pt.getX() +
1628
                             (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1629
                             ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1630
                double laY = entity.pt.getY() +
1631
                             (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1632
                             ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1633
                point11.setLocation(laX, laY);
1634
                point2 = dxfLine.getPts()[1];
1635
                pointAux = new Point2D.Double(point2.getX() - bPointX,
1636
                                              point2.getY() - bPointY);
1637
                laX = entity.pt.getX() +
1638
                      (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1639
                      ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1640
                laY = entity.pt.getY() +
1641
                      (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1642
                      ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1643
                point22.setLocation(laX, laY);
1644

    
1645
                DxfLine dxfLinee = new DxfLine(proj, layer, point11, point22);
1646

    
1647
                if (addingToBlock == false) {
1648
                    entities.add(dxfLinee);
1649
                }
1650
            } else if (dxfEntity instanceof DxfInsert) {
1651
                dxfInsert = (DxfInsert) dxfEntity;
1652
                point1 = dxfInsert.pt;
1653
                pointAux = new Point2D.Double(point1.getX() - bPointX,
1654
                                              point1.getY() - bPointY);
1655

    
1656
                //point11.setLocation(entity.pt.getX() - entity.block.bPoint.getX() + ((point1.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point1.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - entity.block.bPoint.getY() + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
1657
                //point11.setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((point1.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point1.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
1658
                double laX = entity.pt.getX() +
1659
                             (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1660
                             ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1661
                double laY = entity.pt.getY() +
1662
                             (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1663
                             ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1664
                point11.setLocation(laX, laY);
1665

    
1666
                DxfInsert dxfInsertt = new DxfInsert(proj, layer);
1667

    
1668
                dxfInsertt.pt = point11;
1669

    
1670
                dxfInsertt.blkList = dxfInsert.blkList;
1671
                dxfInsertt.block = dxfInsert.block;
1672
                dxfInsertt.blockName = dxfInsert.blockName;
1673
                dxfInsertt.rotAngle = dxfInsert.rotAngle;
1674
                dxfInsertt.layer = dxfInsert.layer;
1675
                dxfInsertt.proj = dxfInsert.proj;
1676

    
1677
                Point2D newScale = new Point2D.Double(dxfInsert.getScaleFactor()
1678
                                                               .getX() * sFactorX,
1679
                                                      dxfInsert.getScaleFactor()
1680
                                                               .getY() * sFactorY);
1681
                dxfInsertt.setScaleFactor(newScale);
1682

    
1683
                //dxfInsertt.scaleFactor = new Point2D.Double(dxfInsert.scaleFactor.getX() * entity.scaleFactor.getX(), dxfInsert.scaleFactor.getY() * entity.scaleFactor.getY());
1684
                gestionaInsert(dxfInsertt, layer);
1685
            } else if (dxfEntity instanceof DxfPolyline) {
1686
                dxfPolyline = (DxfPolyline) dxfEntity;
1687

    
1688
                DxfPolyline dxfPolylinee = new DxfPolyline(proj, layer);
1689

    
1690
                if (dxfPolyline.closed) {
1691
                    dxfPolylinee.closed = true;
1692
                }
1693

    
1694
                Point2D[] points = new Point2D[dxfPolyline.pts.size()];
1695
                Point2D[] pointss = new Point2D[dxfPolyline.pts.size()];
1696

    
1697
                for (int j = 0; j < dxfPolyline.pts.size(); j++) {
1698
                    points[j] = (Point2D) dxfPolyline.pts.get(j);
1699
                    pointss[j] = new Point2D.Double();
1700

    
1701
                    //pointss[j].setLocation(entity.pt.getX() - entity.block.bPoint.getX() + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - entity.block.bPoint.getY() + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
1702
                    //pointss[j].setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
1703
                    pointAux = new Point2D.Double(points[j].getX() - bPointX,
1704
                                                  points[j].getY() - bPointY);
1705

    
1706
                    double laX = entity.pt.getX() +
1707
                                 (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1708
                                 ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1709
                    double laY = entity.pt.getY() +
1710
                                 (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1711
                                 ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1712
                    pointss[j].setLocation(laX, laY);
1713

    
1714
                    //pointss[j].setLocation(entity.pt.getX() + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
1715
                    dxfPolylinee.add(pointss[j]);
1716

    
1717
                    // jmorell, 050405: Bulges en Dxfpolyline para el piloto
1718
                    dxfPolylinee.addBulge((Double) dxfPolyline.getBulges().get(j));
1719
                }
1720

    
1721
                if (addingToBlock == false) {
1722
                    entities.add(dxfPolylinee);
1723
                }
1724
            } else if (dxfEntity instanceof DxfArc) {
1725
                dxfArc = (DxfArc) dxfEntity;
1726

    
1727
                Point2D[] points = new Point2D[dxfArc.pts.length];
1728
                Point2D[] pointss = new Point2D[dxfArc.pts.length];
1729

    
1730
                for (int j = 0; j < dxfArc.pts.length; j++) {
1731
                    points[j] = (Point2D) dxfArc.pts[j];
1732
                    pointss[j] = new Point2D.Double();
1733
                    pointAux = new Point2D.Double(points[j].getX() - bPointX,
1734
                                                  points[j].getY() - bPointY);
1735

    
1736
                    double laX = entity.pt.getX() +
1737
                                 (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1738
                                 ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1739
                    double laY = entity.pt.getY() +
1740
                                 (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1741
                                 ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1742
                    pointss[j].setLocation(laX, laY);
1743

    
1744
                    //pointss[j].setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
1745
                }
1746

    
1747
                DxfArc dxfArcc = new DxfArc(proj, layer, pointss);
1748

    
1749
                // 050315, jmorell: Para que no se pierdan las propiedades en el
1750
                //                                        caso de objetos dentro de bloques.
1751
                pointAux = new Point2D.Double(dxfArc.getCentralPoint().getX() -
1752
                                              bPointX,
1753
                                              dxfArc.getCentralPoint().getY() -
1754
                                              bPointY);
1755

    
1756
                double laX = entity.pt.getX() +
1757
                             (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1758
                             ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1759
                double laY = entity.pt.getY() +
1760
                             (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1761
                             ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1762
                pointAux.setLocation(laX, laY);
1763
                dxfArcc.setCentralPoint(pointAux);
1764
                pointAux = new Point2D.Double(dxfArc.getInit().getX() -
1765
                                              bPointX,
1766
                                              dxfArc.getInit().getY() -
1767
                                              bPointY);
1768
                laX = entity.pt.getX() +
1769
                      (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1770
                      ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1771
                laY = entity.pt.getY() +
1772
                      (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1773
                      ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1774
                pointAux.setLocation(laX, laY);
1775
                dxfArcc.setInit(pointAux);
1776
                pointAux = new Point2D.Double(dxfArc.getEnd().getX() - bPointX,
1777
                                              dxfArc.getEnd().getY() - bPointY);
1778
                laX = entity.pt.getX() +
1779
                      (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1780
                      ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1781
                laY = entity.pt.getY() +
1782
                      (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1783
                      ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1784
                pointAux.setLocation(laX, laY);
1785
                dxfArcc.setEnd(pointAux);
1786
                pointAux = new Point2D.Double(dxfArc.getCenter().getX() -
1787
                                              bPointX,
1788
                                              dxfArc.getCenter().getY() -
1789
                                              bPointY);
1790
                laX = entity.pt.getX() +
1791
                      (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1792
                      ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1793
                laY = entity.pt.getY() +
1794
                      (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1795
                      ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1796
                pointAux.setLocation(laX, laY);
1797
                dxfArcc.setCenter(pointAux);
1798
                dxfArcc.setRadius(dxfArc.getRadius() * sFactorX);
1799

    
1800
                // TODO �Como afectan las rotaciones del insert al init y el end angle?
1801
                dxfArcc.setInitAngle(dxfArc.getInitAngle());
1802
                dxfArcc.setEndAngle(dxfArc.getEndAngle());
1803

    
1804
                if (addingToBlock == false) {
1805
                    entities.add(dxfArcc);
1806
                }
1807
            } else if (dxfEntity instanceof DxfCircle) {
1808
                dxfCircle = (DxfCircle) dxfEntity;
1809

    
1810
                Point2D[] points = new Point2D[dxfCircle.pts.length];
1811
                Point2D[] pointss = new Point2D[dxfCircle.pts.length];
1812

    
1813
                for (int j = 0; j < dxfCircle.pts.length; j++) {
1814
                    points[j] = (Point2D) dxfCircle.pts[j];
1815
                    pointss[j] = new Point2D.Double();
1816
                    pointAux = new Point2D.Double(points[j].getX() - bPointX,
1817
                                                  points[j].getY() - bPointY);
1818

    
1819
                    double laX = entity.pt.getX() +
1820
                                 (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1821
                                 ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1822
                    double laY = entity.pt.getY() +
1823
                                 (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1824
                                 ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1825
                    pointss[j].setLocation(laX, laY);
1826

    
1827
                    //pointss[j].setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
1828
                }
1829

    
1830
                DxfCircle dxfCirclee = new DxfCircle(proj, layer, pointss);
1831

    
1832
                // 050315, jmorell: Para que no se pierdan las propiedades en el
1833
                //                                        caso de objetos dentro de bloques.
1834
                pointAux = new Point2D.Double(dxfCircle.getCenter().getX() -
1835
                                              bPointX,
1836
                                              dxfCircle.getCenter().getY() -
1837
                                              bPointY);
1838

    
1839
                double laX = entity.pt.getX() +
1840
                             (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1841
                             ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1842
                double laY = entity.pt.getY() +
1843
                             (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1844
                             ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1845
                pointAux.setLocation(laX, laY);
1846
                dxfCirclee.setCenter(pointAux);
1847

    
1848
                // Escala en X = escala en Y ...
1849
                dxfCirclee.setRadius(dxfCircle.getRadius() * sFactorX);
1850

    
1851
                if (addingToBlock == false) {
1852
                    entities.add(dxfCirclee);
1853
                }
1854
            } else if (dxfEntity instanceof DxfLwPolyline) {
1855
                dxfLwPolyline = (DxfLwPolyline) dxfEntity;
1856

    
1857
                DxfLwPolyline dxfLwPolylinee = new DxfLwPolyline(proj, layer);
1858
                Point2D[] points = new Point2D[dxfLwPolyline.pts.size()];
1859
                Point2D[] pointss = new Point2D[dxfLwPolyline.pts.size()];
1860

    
1861
                for (int j = 0; j < dxfLwPolyline.pts.size(); j++) {
1862
                    points[j] = (Point2D) dxfLwPolyline.pts.get(j);
1863
                    pointss[j] = new Point2D.Double();
1864
                    pointAux = new Point2D.Double(points[j].getX() - bPointX,
1865
                                                  points[j].getY() - bPointY);
1866

    
1867
                    double laX = entity.pt.getX() +
1868
                                 (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1869
                                 ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1870
                    double laY = entity.pt.getY() +
1871
                                 (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1872
                                 ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1873
                    pointss[j].setLocation(laX, laY);
1874

    
1875
                    //pointss[j].setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
1876
                    dxfLwPolylinee.add(pointss[j]);
1877

    
1878
                    // jmorell, 050405: Bulges en Dxfpolyline para el piloto
1879
                    dxfLwPolylinee.addBulge((Double) dxfPolyline.getBulges()
1880
                                                                .get(j));
1881
                }
1882

    
1883
                if (addingToBlock == false) {
1884
                    entities.add(dxfLwPolylinee);
1885
                }
1886
            } else if (dxfEntity instanceof DxfPoint) {
1887
                dxfPoint = (DxfPoint) dxfEntity;
1888
                point1 = dxfPoint.getPt();
1889
                pointAux = new Point2D.Double(point1.getX() - bPointX,
1890
                                              point1.getY() - bPointY);
1891

    
1892
                double laX = entity.pt.getX() +
1893
                             (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1894
                             ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1895
                double laY = entity.pt.getY() +
1896
                             (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1897
                             ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1898
                point11.setLocation(laX, laY);
1899

    
1900
                //point11.setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((point1.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point1.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
1901
                DxfPoint dxfPointt = new DxfPoint(proj, layer);
1902

    
1903
                //dxfPointt.pt = point11;
1904
                dxfPointt.setPt(point11);
1905

    
1906
                if (addingToBlock == false) {
1907
                    entities.add(dxfPointt);
1908
                }
1909
            } else if (dxfEntity instanceof DxfText) {
1910
                dxfText = (DxfText) dxfEntity;
1911

    
1912
                if (dxfText.getTwoPointsFlag()) {
1913
                    point1 = dxfText.pts[0];
1914
                    pointAux = new Point2D.Double(point1.getX() - bPointX,
1915
                                                  point1.getY() - bPointY);
1916

    
1917
                    double laX = entity.pt.getX() +
1918
                                 (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1919
                                 ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1920
                    double laY = entity.pt.getY() +
1921
                                 (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1922
                                 ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1923
                    point11.setLocation(laX, laY);
1924

    
1925
                    //point11.setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((point1.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point1.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
1926
                    point2 = dxfText.pts[1];
1927
                    pointAux = new Point2D.Double(point2.getX() - bPointX,
1928
                                                  point2.getY() - bPointY);
1929
                    laX = entity.pt.getX() +
1930
                          (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1931
                          ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1932
                    laY = entity.pt.getY() +
1933
                          (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1934
                          ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1935
                    point22.setLocation(laX, laY);
1936

    
1937
                    //point22.setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((point2.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point2.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((point2.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point2.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
1938
                    DxfText dxfTextt = new DxfText(proj, layer,
1939
                                                   dxfText.getText());
1940
                    dxfTextt.pts[0] = point11;
1941
                    dxfTextt.pts[1] = point22;
1942

    
1943
                    if (addingToBlock == false) {
1944
                        entities.add(dxfTextt);
1945
                    }
1946
                } else {
1947
                    point1 = dxfText.getPt();
1948
                    pointAux = new Point2D.Double(point1.getX() - bPointX,
1949
                                                  point1.getY() - bPointY);
1950

    
1951
                    double laX = entity.pt.getX() +
1952
                                 (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1953
                                 ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1954
                    double laY = entity.pt.getY() +
1955
                                 (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1956
                                 ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1957
                    point11.setLocation(laX, laY);
1958

    
1959
                    //point11.setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((point1.getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + point1.getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((point1.getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + point1.getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
1960
                    DxfText dxfTextt = new DxfText(proj, layer,
1961
                                                   dxfText.getText());
1962
                    dxfTextt.setPt(point11);
1963

    
1964
                    if (addingToBlock == false) {
1965
                        entities.add(dxfTextt);
1966
                    }
1967
                }
1968
            } else if (dxfEntity instanceof DxfSolid) {
1969
                dxfSolid = (DxfSolid) dxfEntity;
1970

    
1971
                Point2D[] points = new Point2D[dxfSolid.pts.length];
1972
                Point2D[] pointss = new Point2D[dxfSolid.pts.length];
1973

    
1974
                for (int j = 0; j < dxfSolid.pts.length; j++) {
1975
                    points[j] = (Point2D) dxfSolid.pts[j];
1976
                    pointss[j] = new Point2D.Double();
1977
                    pointAux = new Point2D.Double(points[j].getX() - bPointX,
1978
                                                  points[j].getY() - bPointY);
1979

    
1980
                    double laX = entity.pt.getX() +
1981
                                 (((pointAux.getX() * sFactorX) * Math.cos(rAngleRad)) +
1982
                                 ((pointAux.getY() * sFactorY) * (-1) * Math.sin(rAngleRad)));
1983
                    double laY = entity.pt.getY() +
1984
                                 (((pointAux.getX() * sFactorX) * Math.sin(rAngleRad)) +
1985
                                 ((pointAux.getY() * sFactorY) * Math.cos(rAngleRad)));
1986
                    pointss[j].setLocation(laX, laY);
1987

    
1988
                    //pointss[j].setLocation(entity.pt.getX() - (entity.block.bPoint.getX() * entity.getScaleFactor().getX()) + ((points[j].getX()*Math.cos((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*(-1)*Math.sin((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getX()), entity.pt.getY() - (entity.block.bPoint.getY() * entity.getScaleFactor().getY()) + ((points[j].getX()*Math.sin((entity.rotAngle*Math.PI)/180.0) + points[j].getY()*Math.cos((entity.rotAngle*Math.PI)/180.0)) * entity.scaleFactor.getY()));
1989
                }
1990

    
1991
                DxfSolid dxfSolidd = new DxfSolid(proj, layer, pointss);
1992
                Point2D aux = dxfSolidd.pts[2];
1993
                dxfSolidd.pts[2] = dxfSolidd.pts[3];
1994
                dxfSolidd.pts[3] = aux;
1995

    
1996
                if (addingToBlock == false) {
1997
                    entities.add(dxfSolidd);
1998
                }
1999
            } else {
2000
                    DxfFile.logger.debug("gestionaInserts: Encontrado elemento desconocido");
2001
            }
2002
        }
2003
    }
2004
    
2005
    /* (non-Javadoc)
2006
     * @see org.cresques.io.DxfFile.EntityFactory#createAttdef(org.cresques.io.DxfGroupVector)
2007
     */
2008
    public void createAttdef(DxfGroupVector grp) throws Exception {
2009
        DxfGroup g = null;
2010

    
2011
        String defaultValue = "";
2012
        String tagString = "";
2013
        String textStyleName = "";
2014
        String[] attribute = new String[2];
2015
        boolean tagDefined = false;
2016
        boolean defValDefined = false;
2017

    
2018
        if (grp.hasCode(1)) {
2019
            defaultValue = grp.getDataAsString(1);
2020
            attribute[1] = DxfConvTexts.ConvertText(defaultValue);
2021
            defValDefined = true;
2022

    
2023
            if (tagDefined) {
2024
                attributes.add(attribute);
2025
            }
2026
        }
2027

    
2028
        if (grp.hasCode(2)) {
2029
            tagString = grp.getDataAsString(2);
2030
            attribute[0] = DxfConvTexts.ConvertText(tagString);
2031
            tagDefined = true;
2032

    
2033
            if (defValDefined) {
2034
                attributes.add(attribute);
2035
            }
2036
        }
2037

    
2038
        if (grp.hasCode(7)) {
2039
            textStyleName = grp.getDataAsString(7);
2040
            textStyleName = DxfConvTexts.ConvertText(textStyleName);
2041
        }
2042

    
2043
        // TODO setNewAttributes();
2044
    }
2045
    
2046
    /* (non-Javadoc)
2047
     * @see org.cresques.io.DxfFile.EntityFactory#createAttrib(org.cresques.io.DxfGroupVector)
2048
     */
2049
    public void createAttrib(DxfGroupVector grp) throws Exception {
2050
        double x = 0.0;
2051
        double y = 0.0;
2052
        double z = 0.0;
2053
        double h = 0.0;
2054
        double rot = 0.0;
2055
        DxfGroup g = null;
2056
        Point2D pt = null;
2057

    
2058
        String defaultValue = "";
2059
        String tagString = "";
2060
        String textStyleName = "";
2061
        String[] att = new String[2];
2062
        boolean tagDefined = false;
2063
        boolean defValDefined = false;
2064
        int attributeFlags = 0;
2065
        double extx = 0.0;
2066
        double exty = 0.0;
2067
        double extz = 1.0;
2068

    
2069
        DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
2070
        DxfAttrib entity = new DxfAttrib(proj, layer);
2071

    
2072
        if (grp.hasCode(1)) {
2073
            String strAux1 = grp.getDataAsString(1);
2074
            strAux1 = DxfConvTexts.ConvertText(strAux1);
2075
            defaultValue = strAux1;
2076
            att[1] = DxfConvTexts.ConvertText(defaultValue);
2077
            defValDefined = true;
2078

    
2079
            /*if (tagDefined) {
2080
                    insFea.setProp(att[0], att[1]);
2081
                    ptFea.setProp(att[0], att[1]);
2082
            }
2083
            feature.setProp("text", strAux1);*/
2084
        }
2085

    
2086
        if (grp.hasCode(2)) {
2087
            String strAux2 = grp.getDataAsString(2);
2088
            strAux2 = DxfConvTexts.ConvertText(strAux2);
2089
            tagString = strAux2;
2090
            att[0] = DxfConvTexts.ConvertText(tagString);
2091
            tagDefined = true;
2092

    
2093
            /*if (defValDefined) {
2094
                    insFea.setProp(att[0], att[1]);
2095
                    ptFea.setProp(att[0], att[1]);
2096
            }*/
2097
        }
2098

    
2099
        if (grp.hasCode(7)) {
2100
            textStyleName = grp.getDataAsString(7);
2101
            textStyleName = DxfConvTexts.ConvertText(textStyleName);
2102
        }
2103

    
2104
        x = grp.getDataAsDouble(10);
2105
        y = grp.getDataAsDouble(20);
2106
        z = grp.getDataAsDouble(30);
2107

    
2108
        if (grp.hasCode(210)) {
2109
            extx = grp.getDataAsDouble(210);
2110
        }
2111

    
2112
        if (grp.hasCode(220)) {
2113
            exty = grp.getDataAsDouble(220);
2114
        }
2115

    
2116
        if (grp.hasCode(230)) {
2117
            extz = grp.getDataAsDouble(230);
2118
        }
2119

    
2120
        Point3D point_in = new Point3D(x, y, z);
2121
        Point3D xtru = new Point3D(extx, exty, extz);
2122
        Point3D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
2123
        x = point_out.getX();
2124
        y = point_out.getY();
2125
        z = point_out.getZ();
2126
        entity.setPt(proj.createPoint(x, y));
2127

    
2128
        if (grp.hasCode(40)) {
2129
            Double heightD = new Double(grp.getDataAsDouble(40));
2130
            String heightS = heightD.toString();
2131

    
2132
            //feature.setProp("textHeight", heightS);
2133
        } else {
2134
            //feature.setProp("textHeight", "20.0");
2135
        }
2136

    
2137
        if (grp.hasCode(50)) {
2138
            Double rotD = new Double(grp.getDataAsDouble(50));
2139
            String rotS = rotD.toString();
2140

    
2141
            //feature.setProp("textRotation", rotS);
2142
        } else {
2143
            //feature.setProp("textRotation", "0.0");
2144
        }
2145

    
2146
        if (grp.hasCode(62)) {
2147
            entity.dxfColor = grp.getDataAsInt(62);
2148
        } else {
2149
            //entity.dxfColor = 0;
2150
        }
2151

    
2152
        if (grp.hasCode(70)) {
2153
            attributeFlags = grp.getDataAsInt(70);
2154
        }
2155

    
2156
        if (attributeFlags == 8) {
2157
            if (addingToBlock == false) {
2158
                entities.add(entity);
2159
            } else {
2160
                blk.add(entity);
2161
            }
2162
        }
2163
    }
2164
    
2165
    /* (non-Javadoc)
2166
     * @see org.cresques.io.DxfFile.EntityFactory#getAttributes()
2167
     */
2168
    public Vector getAttributes() {
2169
        return attributes;
2170
    }
2171

    
2172
    /* (non-Javadoc)
2173
     * @see org.cresques.io.DxfFile.EntityFactory#depureAttributes()
2174
     */
2175
    public void depureAttributes() {
2176
        // TODO Auto-generated method stub
2177
    }
2178

    
2179
    /* (non-Javadoc)
2180
     * @see org.cresques.io.DxfFile.EntityFactory#isDxf3DFile()
2181
     */
2182
    public boolean isDxf3DFile() {
2183
        // TODO Auto-generated method stub
2184
        return false;
2185
    }
2186
}