Statistics
| Revision:

root / trunk / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfFeatureMaker.java @ 154

History | View | Annotate | Download (48.9 KB)

1 44 jmorell
package org.cresques.px.dxf;
2
3 94 luisw
import org.cresques.cts.ICoordTrans;
4
import org.cresques.cts.IProjection;
5 44 jmorell
import org.cresques.geo.Point3D;
6
import org.cresques.geo.Projected;
7 91 luisw
import org.cresques.geo.ViewPortData;
8 44 jmorell
import org.cresques.io.DxfFile;
9
import org.cresques.io.DxfGroup;
10
import org.cresques.io.DxfGroupVector;
11
import org.cresques.px.Extent;
12 96 luisw
import org.cresques.px.IObjList;
13 44 jmorell
import org.cresques.px.gml.Feature;
14 73 jmorell
import org.cresques.px.gml.FeatureCollection;
15 107 jmorell
import org.cresques.px.gml.Geometry;
16 73 jmorell
import org.cresques.px.gml.InsPoint;
17 44 jmorell
import org.cresques.px.gml.LineString;
18
import org.cresques.px.gml.Point;
19
import org.cresques.px.gml.Polygon;
20
import java.util.Iterator;
21
import java.util.Vector;
22
import java.awt.Graphics2D;
23
import java.awt.geom.Point2D;
24
25
public class DxfFeatureMaker implements DxfFile.EntityFactory, Projected {
26 94 luisw
        IProjection proj = null;
27 139 jmorell
        //Feature lastFeature = null;
28 131 jmorell
        Feature lastFeaBordes = null;
29
        Feature lastFeaFondos = null;
30 136 jmorell
        boolean isDoubleFeatured = false;
31 96 luisw
        FeatureCollection features = null;
32 44 jmorell
        double bulge = 0.0;
33
    double xtruX=0.0, xtruY=0.0, xtruZ=1.0;
34
    int polylineFlag = 0;
35
    Point2D firstPt = new Point2D.Double();
36 57 jmorell
37
    boolean addingToBlock = false;
38 73 jmorell
    int iterator = 0;
39
        FeatureCollection blk = null;
40
        Vector blkList = null;
41 128 jmorell
        DxfTable layers = null;
42 57 jmorell
43 125 luisw
        public DxfFeatureMaker(IProjection proj) {
44 44 jmorell
                this.proj = proj;
45 128 jmorell
                layers = new DxfTable();
46 96 luisw
                features = new FeatureCollection(proj);
47 73 jmorell
                blkList = new Vector();
48 44 jmorell
        }
49
50 57 jmorell
        public void setAddingToBlock(boolean a) { addingToBlock = a; }
51
52 44 jmorell
        public void createLayer(DxfGroupVector v) throws Exception {
53 128 jmorell
                int color = v.getDataAsInt(62);
54
                DxfLayer layer = new DxfLayer(v.getDataAsString(2), Math.abs(v.getDataAsInt(62)));
55
                if (color < 0) {
56
                        layer.isOff = true;
57
                }
58
                layer.lType = v.getDataAsString(6);
59
                layer.setFlags(v.getDataAsInt(70));
60
                // compruebo flags
61
                if ((layer.flags & 0x01) == 0x01) {
62
                        layer.frozen = true;
63
                }
64
                if ((layer.flags & 0x02) == 0x02) {
65
                        layer.frozen = true;
66
                }
67
                System.out.println("LAYER color="+layer.getColor());
68
69
                layers.add(layer);
70 44 jmorell
        }
71
72
        public void createPolyline(DxfGroupVector grp) throws Exception {
73
                LineString lineString = new LineString();
74
                Polygon polygon = new Polygon();
75 139 jmorell
                //Feature feature= new Feature();
76 131 jmorell
                Feature feaBordes= new Feature();
77
                Feature feaFondos= new Feature();
78 44 jmorell
                double x = 0.0, y = 0.0, z = 0.0;
79
                int flags = 0;
80 54 jmorell
81 139 jmorell
                //feature.setProp("dxfEntity", "Polyline");
82 133 jmorell
                feaBordes.setProp("dxfEntity", "Polyline");
83
                feaFondos.setProp("dxfEntity", "Polyline");
84 131 jmorell
                if (grp.hasCode(8)) {
85 139 jmorell
                        //feature.setProp("layer", grp.getDataAsString(8));
86 132 jmorell
                        feaBordes.setProp("layer", grp.getDataAsString(8));
87
                        feaFondos.setProp("layer", grp.getDataAsString(8));
88 131 jmorell
                }
89 124 jmorell
                if (grp.hasCode(39)) {
90
                        Double doub = new Double(grp.getDataAsDouble(39));
91
                        String string = doub.toString();
92 139 jmorell
                        //feature.setProp("thickness", string);
93 132 jmorell
                        feaBordes.setProp("thickness", string);
94
                        feaFondos.setProp("thickness", string);
95 124 jmorell
                } else {
96
                        Double doub = new Double(0.0);
97 139 jmorell
                        //feature.setProp("thickness", doub.toString());
98 132 jmorell
                        feaBordes.setProp("thickness", doub.toString());
99
                        feaFondos.setProp("thickness", doub.toString());
100 124 jmorell
                }
101 55 jmorell
                if (grp.hasCode(62)) {
102
                        Integer integer = new Integer(grp.getDataAsInt(62));
103
                        String string = integer.toString();
104 139 jmorell
                        //feature.setProp("color", string);
105 132 jmorell
                        feaBordes.setProp("color", string);
106
                        feaFondos.setProp("color", string);
107 55 jmorell
                } else {
108 128 jmorell
                        DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
109
                        int clr = layer.colorNumber;
110
                        Integer integer = new Integer(clr);
111
                        String string = integer.toString();
112 139 jmorell
                        //feature.setProp("color", string);
113 132 jmorell
                        feaBordes.setProp("color", string);
114
                        feaFondos.setProp("color", string);
115 54 jmorell
                }
116 44 jmorell
                if (grp.hasCode(10))
117
                        x = grp.getDataAsDouble(10);
118
                if (grp.hasCode(20))
119
                        y = grp.getDataAsDouble(20);
120 124 jmorell
                if (grp.hasCode(30)) {
121 44 jmorell
                        z = grp.getDataAsDouble(30);
122 124 jmorell
                        Double doub = new Double(z);
123
                        String string = doub.toString();
124 139 jmorell
                        //feature.setProp("elevation", string);
125 132 jmorell
                        feaBordes.setProp("elevation", string);
126
                        feaFondos.setProp("elevation", string);
127 124 jmorell
                }
128 44 jmorell
                if (grp.hasCode(70))
129
                        flags = grp.getDataAsInt(70);
130
                if (grp.hasCode(210))
131
                        xtruX = grp.getDataAsDouble(210);
132
                if (grp.hasCode(220))
133
                        xtruY = grp.getDataAsDouble(220);
134
                if (grp.hasCode(230))
135
                        xtruZ = grp.getDataAsDouble(230);
136 77 jmorell
                if ((flags & 0x01) == 0x00) {
137 139 jmorell
                        feaBordes.setGeometry(lineString);
138
                        lastFeaBordes = feaBordes;
139 136 jmorell
                        isDoubleFeatured = false;
140 77 jmorell
                } else if ((flags & 0x01) == 0x01) {
141 131 jmorell
                        feaBordes.setGeometry(lineString);
142
                        feaFondos.setGeometry(polygon);
143
                        lastFeaBordes = feaBordes;
144
                        lastFeaFondos = feaFondos;
145 136 jmorell
                        isDoubleFeatured = true;
146 44 jmorell
                } else {
147 77 jmorell
                        System.out.println("Detectada una Polyline Flag que no corresponde");
148
                        System.out.println("a una Polyline corriente, ni a una Closed Polyline");
149 44 jmorell
                }
150
        }
151
152
        public void endSeq() throws Exception {
153 136 jmorell
                if (isDoubleFeatured) {
154 131 jmorell
                        Feature feaBordes = lastFeaBordes;
155
                        Feature feaFondos = lastFeaFondos;
156
                        LineString lineString = (LineString)feaBordes.getGeometry();
157 136 jmorell
                        Polygon polygon = (Polygon)feaFondos.getGeometry();
158 137 jmorell
                        lineString.add(firstPt);
159 136 jmorell
                        polygon.add(firstPt);
160 131 jmorell
                        if (!(bulge==0)) {
161
                                int cnt = lineString.pointNr();
162
                                Vector arc = createArc((Point2D)(lineString.get(cnt-2)), (Point2D)(lineString.get(cnt-1)), bulge);
163
                                lineString.remove(cnt-1);
164 136 jmorell
                                polygon.remove(cnt-1);
165 131 jmorell
                                for (int i=0; i<arc.size(); i++) {
166
                                        Point2D pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY());
167
                                        lineString.add(pt);
168 136 jmorell
                                        polygon.add(pt);
169 131 jmorell
                                        if (lineString.pointNr() == 1) firstPt = pt;
170
                                }
171
                                bulge = 0.0;
172
                        }
173
                        lastFeaBordes.setGeometry(lineString);
174 136 jmorell
                        lastFeaFondos.setGeometry(polygon);
175 131 jmorell
                        if (addingToBlock == false) {
176
                                features.add(lastFeaBordes);
177
                                features.add(lastFeaFondos);
178
                        } else {
179
                                blk.add(lastFeaBordes);
180
                                blk.add(lastFeaFondos);
181
                        }
182
                        lastFeaBordes = null;
183
                        lastFeaFondos = null;
184
                } else {
185 139 jmorell
                        Feature feaBordes = lastFeaBordes;
186
                        LineString lineString = (LineString)feaBordes.getGeometry();
187 131 jmorell
                        if (!(bulge==0)) {
188
                                int cnt = lineString.pointNr();
189
                                Vector arc = createArc((Point2D)(lineString.get(cnt-2)), (Point2D)(lineString.get(cnt-1)), bulge);
190
                                lineString.remove(cnt-1);
191
                                for (int i=0; i<arc.size(); i++) {
192
                                        Point2D pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY());
193
                                        lineString.add(pt);
194
                                        if (lineString.pointNr() == 1) firstPt = pt;
195
                                }
196
                                bulge = 0.0;
197
                        }
198 139 jmorell
                        lastFeaBordes.setGeometry(lineString);
199 131 jmorell
                        if (addingToBlock == false) {
200 139 jmorell
                                features.add(lastFeaBordes);
201 131 jmorell
                        } else {
202 139 jmorell
                                blk.add(lastFeaBordes);
203 131 jmorell
                        }
204 139 jmorell
                        lastFeaBordes = null;
205 131 jmorell
                }
206 44 jmorell
                xtruX = 0.0;
207
                xtruY = 0.0;
208
                xtruZ = 1.0;
209
                bulge = 0.0;
210 136 jmorell
                isDoubleFeatured = false;
211 44 jmorell
        }
212
213
        public void addVertex(DxfGroupVector grp) throws Exception {
214
                double x = 0.0, y = 0.0, z = 0.0;
215 136 jmorell
                if (isDoubleFeatured) {
216 131 jmorell
                        Feature feaBordes = lastFeaBordes;
217
                        Feature feaFondos = lastFeaFondos;
218
                        LineString lineString = (LineString)feaBordes.getGeometry();
219 135 jmorell
                        Polygon polygon = (Polygon)feaFondos.getGeometry();
220 131 jmorell
                        if (grp.hasCode(8))
221
                                feaBordes.setProp("layer", grp.getDataAsString(8));
222 135 jmorell
                                feaFondos.setProp("layer", grp.getDataAsString(8));
223 131 jmorell
                        if (grp.hasCode(62)) {
224
                                Integer integer = new Integer(grp.getDataAsInt(62));
225
                                String string = integer.toString();
226
                                feaBordes.setProp("color", string);
227 135 jmorell
                                feaFondos.setProp("color", string);
228 131 jmorell
                        } else {
229
                                DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
230
                                int clr = layer.colorNumber;
231
                                Integer integer = new Integer(clr);
232
                                String string = integer.toString();
233
                                feaBordes.setProp("color", string);
234 135 jmorell
                                feaFondos.setProp("color", string);
235 131 jmorell
                        }
236
                        x  = grp.getDataAsDouble(10);
237
                        y  = grp.getDataAsDouble(20);
238
                        if (grp.hasCode(30)) {
239
                                z = grp.getDataAsDouble(30);
240
                        }
241
                        Point3D point_in = new Point3D(x, y, z);
242
                        Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
243
                        Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
244
                        x = point_out.getX();
245
                        y = point_out.getY();
246
                        Point2D pt = proj.createPoint( x, y);
247
                        lineString.add(pt);
248 135 jmorell
                        polygon.add(pt);
249 131 jmorell
                        if (lineString.pointNr() == 1) {
250
                                firstPt = pt;
251
                        }
252
                        if (bulge == 0.0) {
253
                                if (grp.hasCode(42)) {
254
                                        bulge = grp.getDataAsDouble(42);
255
                                } else { bulge = 0.0; }
256
                        } else {
257
                                double bulge_aux = 0.0;
258
                                if (grp.hasCode(42)) {
259
                                        bulge_aux = grp.getDataAsDouble(42);
260
                                } else { bulge_aux = 0.0; }
261
                                int cnt = lineString.pointNr();
262
                                Vector arc = createArc((Point2D)(lineString.get(cnt-2)), (Point2D)(lineString.get(cnt-1)), bulge);
263
                                lineString.remove(cnt-1);
264 135 jmorell
                                polygon.remove(cnt-1);
265 131 jmorell
                                for (int i=0; i<arc.size(); i++) {
266
                                        pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY());
267
                                        lineString.add(pt);
268 135 jmorell
                                        polygon.add(pt);
269 131 jmorell
                                        if (lineString.pointNr() == 1) firstPt = pt;
270
                                }
271
                                bulge = bulge_aux;
272
                        }
273
                } else {
274 139 jmorell
                        Feature feaBordes = lastFeaBordes;
275
                        LineString lineString = (LineString)feaBordes.getGeometry();
276 131 jmorell
                        if (grp.hasCode(8))
277 139 jmorell
                                feaBordes.setProp("layer", grp.getDataAsString(8));
278 131 jmorell
                        if (grp.hasCode(62)) {
279
                                Integer integer = new Integer(grp.getDataAsInt(62));
280
                                String string = integer.toString();
281 139 jmorell
                                feaBordes.setProp("color", string);
282 131 jmorell
                        } else {
283
                                DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
284
                                int clr = layer.colorNumber;
285
                                Integer integer = new Integer(clr);
286
                                String string = integer.toString();
287 139 jmorell
                                feaBordes.setProp("color", string);
288 131 jmorell
                        }
289
                        x  = grp.getDataAsDouble(10);
290
                        y  = grp.getDataAsDouble(20);
291
                        if (grp.hasCode(30)) {
292
                                z = grp.getDataAsDouble(30);
293
                        }
294
                        Point3D point_in = new Point3D(x, y, z);
295
                        Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
296
                        Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
297
                        x = point_out.getX();
298
                        y = point_out.getY();
299
                        Point2D pt = proj.createPoint( x, y);
300
                        lineString.add(pt);
301
                        if (lineString.pointNr() == 1) {
302
                                firstPt = pt;
303
                        }
304 44 jmorell
                        if (bulge == 0.0) {
305 131 jmorell
                                if (grp.hasCode(42)) {
306
                                        bulge = grp.getDataAsDouble(42);
307
                                } else { bulge = 0.0; }
308
                        } else {
309
                                double bulge_aux = 0.0;
310
                                if (grp.hasCode(42)) {
311
                                        bulge_aux = grp.getDataAsDouble(42);
312
                                } else { bulge_aux = 0.0; }
313
                                int cnt = lineString.pointNr();
314
                                Vector arc = createArc((Point2D)(lineString.get(cnt-2)), (Point2D)(lineString.get(cnt-1)), bulge);
315
                                lineString.remove(cnt-1);
316
                                for (int i=0; i<arc.size(); i++) {
317
                                        pt = proj.createPoint(((Point2D)arc.get(i)).getX(), ((Point2D)arc.get(i)).getY());
318
                                        lineString.add(pt);
319
                                        if (lineString.pointNr() == 1) firstPt = pt;
320
                                }
321
                                bulge = bulge_aux;
322
                        }
323
                }
324 44 jmorell
        }
325
326
        public void createLwPolyline(DxfGroupVector grp) throws Exception {
327 124 jmorell
                double x = 0.0, y = 0.0;
328
                double elev = 0.0;
329 44 jmorell
                DxfGroup g = null;
330 142 jmorell
                LineString lineString = new LineString();
331
                Polygon polygon = new Polygon();
332
                //Geometry geometria;
333
                //Feature feature= new Feature();
334
                Feature feaBordes= new Feature();
335
                Feature feaFondos= new Feature();
336 44 jmorell
                int flags = 0;
337
338 142 jmorell
                //feature.setProp("dxfEntity", "LwPolyline");
339
                feaBordes.setProp("dxfEntity", "LwPolyline");
340
                feaFondos.setProp("dxfEntity", "LwPolyline");
341 55 jmorell
                if (grp.hasCode(8))
342 142 jmorell
                        //feature.setProp("layer", grp.getDataAsString(8));
343
                        feaBordes.setProp("layer", grp.getDataAsString(8));
344
                        feaFondos.setProp("layer", grp.getDataAsString(8));
345 124 jmorell
                if (grp.hasCode(38)) {
346
                        elev = grp.getDataAsDouble(38);
347
                        Double doub = new Double(elev);
348
                        String string = doub.toString();
349 142 jmorell
                        //feature.setProp("elevation", string);
350
                        feaBordes.setProp("elevation", string);
351
                        feaFondos.setProp("elevation", string);
352 124 jmorell
                } else {
353
                        Double doub = new Double(0.0);
354 142 jmorell
                        //feature.setProp("elevation", doub.toString());
355
                        feaBordes.setProp("elevation", doub.toString());
356
                        feaFondos.setProp("elevation", doub.toString());
357 124 jmorell
                }
358
                if (grp.hasCode(39)) {
359
                        Double doub = new Double(grp.getDataAsDouble(39));
360
                        String string = doub.toString();
361 142 jmorell
                        //feature.setProp("thickness", string);
362
                        feaBordes.setProp("thickness", string);
363
                        feaFondos.setProp("thickness", string);
364 124 jmorell
                } else {
365
                        Double doub = new Double(0.0);
366 142 jmorell
                        //feature.setProp("thickness", doub.toString());
367
                        feaBordes.setProp("thickness", doub.toString());
368
                        feaFondos.setProp("thickness", doub.toString());
369 124 jmorell
                }
370 55 jmorell
                if (grp.hasCode(62)) {
371
                        Integer integer = new Integer(grp.getDataAsInt(62));
372
                        String string = integer.toString();
373 142 jmorell
                        //feature.setProp("color", string);
374
                        feaBordes.setProp("color", string);
375
                        feaFondos.setProp("color", string);
376 55 jmorell
                } else {
377 128 jmorell
                        DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
378
                        int clr = layer.colorNumber;
379
                        Integer integer = new Integer(clr);
380
                        String string = integer.toString();
381 142 jmorell
                        //feature.setProp("color", string);
382
                        feaBordes.setProp("color", string);
383
                        feaFondos.setProp("color", string);
384 54 jmorell
                }
385 107 jmorell
                if (grp.hasCode(70))
386
                        flags = grp.getDataAsInt(70);
387
                if ((flags & 0x01) == 0x01) {
388 142 jmorell
                        //geometria = new Polygon();
389
                        feaBordes.setGeometry(lineString);
390
                        feaFondos.setGeometry(polygon);
391
                        isDoubleFeatured = true;
392 107 jmorell
                } else {
393 142 jmorell
                        //geometria = new LineString();
394
                        feaBordes.setGeometry(lineString);
395
                        isDoubleFeatured = false;
396 107 jmorell
                }
397 106 jmorell
398 107 jmorell
                int j = 0;
399
                double firstX = 0.0;
400
                double firstY = 0.0;
401 44 jmorell
                for (int i=0; i<grp.size(); i++) {
402
                        g = (DxfGroup) grp.get(i);
403 106 jmorell
                        if (g.getCode() == 10) {
404 107 jmorell
                                j++;
405 82 jmorell
                                x = ((Double) g.getData()).doubleValue();
406 106 jmorell
                        } else if (g.getCode() == 20) {
407 82 jmorell
                                y = ((Double) g.getData()).doubleValue();
408 107 jmorell
                                //if (y <= 1.0) throw new Exception("Y == "+y);
409
                                //lineString.add( proj.createPoint( x, y ) );
410
                                //polygon.add( proj.createPoint( x, y ) );
411 142 jmorell
                                //geometria.add( proj.createPoint( x, y ) );
412
                                lineString.add( proj.createPoint( x, y ) );
413
                                if (isDoubleFeatured) polygon.add( proj.createPoint( x, y ) );
414 107 jmorell
                                if (j == 1) {
415
                                        firstX = x;
416 106 jmorell
                                        firstY = y;
417 107 jmorell
                                }
418 44 jmorell
                                x = 0.0; y = 0.0;
419
                        }
420
                }
421 142 jmorell
                if (isDoubleFeatured) {
422
                        //geometria.add(proj.createPoint(firstX, firstY));
423
                        lineString.add(proj.createPoint(firstX, firstY));
424
                        polygon.add(proj.createPoint(firstX, firstY));
425 44 jmorell
                }
426 107 jmorell
427 142 jmorell
                lastFeaBordes = feaBordes;
428
                if (isDoubleFeatured) lastFeaFondos = feaFondos;
429 74 jmorell
                //features.add(feature);
430
                if (addingToBlock == false) {
431 142 jmorell
                        features.add(feaBordes);
432
                        if (isDoubleFeatured) features.add(feaFondos);
433 74 jmorell
                } else {
434 102 jmorell
                        //System.out.println("createLwPolyline(): A?adimos una lwpolilinea al bloque " + iterator);
435 142 jmorell
                        blk.add(feaBordes);
436
                        if (isDoubleFeatured) blk.add(feaFondos);
437 74 jmorell
                }
438 142 jmorell
                isDoubleFeatured = false;
439 44 jmorell
        }
440
441
        public void createLine(DxfGroupVector grp) throws Exception {
442
                double x = 0.0, y = 0.0, z1 = 0.0, z2 = 0.0;
443 124 jmorell
                double elev = 0.0;
444 44 jmorell
                DxfGroup g = null;
445
                Point2D pt1 = null, pt2 = null;
446
                LineString lineString = new LineString();
447
                Feature feature = new Feature();
448
449 124 jmorell
                feature.setProp("dxfEntity", "Line");
450 55 jmorell
                if (grp.hasCode(8))
451 54 jmorell
                        feature.setProp("layer", grp.getDataAsString(8));
452 124 jmorell
                if (grp.hasCode(39)) {
453
                        Double doub = new Double(grp.getDataAsDouble(39));
454
                        String string = doub.toString();
455
                        feature.setProp("thickness", string);
456
                } else {
457
                        Double doub = new Double(0.0);
458
                        feature.setProp("thickness", doub.toString());
459
                }
460 55 jmorell
                if (grp.hasCode(62)) {
461
                        Integer integer = new Integer(grp.getDataAsInt(62));
462
                        String string = integer.toString();
463
                        feature.setProp("color", string);
464
                } else {
465 128 jmorell
                        DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
466
                        int clr = layer.colorNumber;
467
                        Integer integer = new Integer(clr);
468
                        String string = integer.toString();
469
                        feature.setProp("color", string);
470 54 jmorell
                }
471 44 jmorell
                x = grp.getDataAsDouble(10);
472
                y = grp.getDataAsDouble(20);
473 124 jmorell
                if (grp.hasCode(30)) {
474
                        z1 = grp.getDataAsDouble(30);
475
                        elev = z1;
476
                        Double doub = new Double(elev);
477
                        String string = doub.toString();
478
                        feature.setProp("elevation", string);
479
                }
480 44 jmorell
                pt1 = proj.createPoint(x, y);
481
                x = grp.getDataAsDouble(11);
482
                y = grp.getDataAsDouble(21);
483 124 jmorell
                if (grp.hasCode(31)) {
484
                        z2 = grp.getDataAsDouble(31);
485
                }
486 44 jmorell
                pt2 = proj.createPoint(x, y);
487
                if (grp.hasCode(210))
488
                        xtruX = grp.getDataAsDouble(210);
489
                if (grp.hasCode(220))
490 73 jmorell
                        xtruY = grp.getDataAsDouble(220);
491 44 jmorell
                if (grp.hasCode(230))
492 73 jmorell
                        xtruZ = grp.getDataAsDouble(230);
493 44 jmorell
                Point3D point_in1 = new Point3D(pt1.getX(), pt1.getY(), z1);
494
                Point3D point_in2 = new Point3D(pt2.getX(), pt2.getY(), z2);
495
                Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
496
                Point2D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru);
497
                Point2D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru);
498
                pt1.setLocation(point_out1);
499
                pt2.setLocation(point_out2);
500
                lineString.add(pt1);
501
                lineString.add(pt2);
502 57 jmorell
503 44 jmorell
                feature.setGeometry(lineString);
504 74 jmorell
                //features.add(feature);
505
                if (addingToBlock == false) {
506 102 jmorell
                        //System.out.println("createLine(): A?adimos una linea a la lista de entidades");
507 74 jmorell
                        features.add(feature);
508
                } else {
509 102 jmorell
                        //System.out.println("createLine(): A?adimos una linea al bloque " + iterator);
510 74 jmorell
                        blk.add(feature);
511
                }
512 44 jmorell
        }
513
514
        /* (non-Javadoc)
515
         * @see org.cresques.io.DxfFile.EntityFactory#createText(org.cresques.io.DxfGroupVector)
516
         */
517
        public void createText(DxfGroupVector grp) throws Exception {
518
                double x = 0.0, y = 0.0, z = 0.0, h= 0.0, rot= 0.0;
519
                DxfGroup g = null;
520
                Point2D pt1 = null, pt2 = null;
521
                Point2D pt = null;
522
                Point point = new Point();
523 122 jmorell
524
                point.isText = true;
525
526 44 jmorell
                Feature feature = new Feature();
527
528 124 jmorell
                feature.setProp("dxfEntity", "Text");
529 55 jmorell
                if (grp.hasCode(8))
530 54 jmorell
                        feature.setProp("layer", grp.getDataAsString(8));
531 124 jmorell
                if (grp.hasCode(39)) {
532
                        Double doub = new Double(grp.getDataAsDouble(39));
533
                        String string = doub.toString();
534
                        feature.setProp("thickness", string);
535
                } else {
536
                        Double doub = new Double(0.0);
537
                        feature.setProp("thickness", doub.toString());
538
                }
539 55 jmorell
                if (grp.hasCode(62)) {
540
                        Integer integer = new Integer(grp.getDataAsInt(62));
541
                        String string = integer.toString();
542
                        feature.setProp("color", string);
543
                        //entity.dxfColor = grp.getDataAsInt(62);
544
                } else {
545 128 jmorell
                        DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
546
                        int clr = layer.colorNumber;
547
                        Integer integer = new Integer(clr);
548
                        String string = integer.toString();
549
                        feature.setProp("color", string);
550 54 jmorell
                }
551 55 jmorell
                if (grp.hasCode(1)) {
552 116 jmorell
                        String strAux1 = grp.getDataAsString(1);
553
                        strAux1 = DxfConvTexts.ConvertText(strAux1);
554
                        feature.setProp("text", strAux1);
555 55 jmorell
                        //txt = grp.getDataAsString(1);
556
                } else {
557 122 jmorell
                        feature.setProp("text", "No Text Code");
558 55 jmorell
                }
559 108 jmorell
                if (grp.hasCode(40)) {
560
                        Double heightD = new Double(grp.getDataAsDouble(40));
561
                        String heightS = heightD.toString();
562
                        feature.setProp("textHeight", heightS);
563
                } else {
564
                        feature.setProp("textHeight", "20.0");
565
                }
566
                if (grp.hasCode(50)) {
567
                        Double rotD = new Double(grp.getDataAsDouble(50));
568
                        String rotS = rotD.toString();
569
                        feature.setProp("textRotation", rotS);
570
                } else {
571
                        feature.setProp("textRotation", "0.0");
572
                }
573 44 jmorell
                x = grp.getDataAsDouble(10);
574
                y = grp.getDataAsDouble(20);
575 124 jmorell
                if (grp.hasCode(30)){
576
                        z = grp.getDataAsDouble(30);
577
                        Double doub = new Double(z);
578
                        String string = doub.toString();
579
                        feature.setProp("elevation", string);
580
                }
581 44 jmorell
                if (grp.hasCode(210))
582
                        xtruX = grp.getDataAsDouble(210);
583
                if (grp.hasCode(220))
584
                        xtruY = grp.getDataAsDouble(220);
585
                if (grp.hasCode(230))
586
                        xtruZ = grp.getDataAsDouble(230);
587
                Point3D point_in = new Point3D(x, y, z);
588
                Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
589
                Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
590
                x = point_out.getX();
591
                y = point_out.getY();
592
                //entity.setPt1(proj.createPoint(x, y));
593
                //point.add(proj.createPoint(x, y));
594
                //lineText.add(proj.createPoint(x, y));
595
                /*if (grp.hasCode(11)) {
596
                        x = grp.getDataAsDouble(11);
597
                        y = grp.getDataAsDouble(21);
598
                        //entity.setPt2(proj.createPoint(x, y));
599
                        lineText.add(proj.createPoint(x, y));
600
                }
601
                entity.h = grp.getDataAsDouble(40);
602
                if (grp.hasCode(50))
603
                        entity.rot = grp.getDataAsDouble(50);
604
                if (grp.hasCode(62))
605
                        entity.dxfColor = grp.getDataAsInt(62);
606
                if (grp.hasCode(72))
607
                        entity.align = grp.getDataAsInt(72);*/
608
                point.add(new Point2D.Double(x, y));
609
                feature.setGeometry(point);
610
                //entities.add(entity);
611 74 jmorell
                //features.add(feature);
612
                if (addingToBlock == false) {
613
                        features.add(feature);
614
                } else {
615 102 jmorell
                        //System.out.println("createText(): A?adimos un text al bloque " + iterator);
616 74 jmorell
                        blk.add(feature);
617
                }
618 44 jmorell
        }
619
620
        public void createPoint(DxfGroupVector grp) throws Exception {
621
                double x = 0.0, y = 0.0, z = 0.0;
622
                DxfGroup g = null;
623
                Point2D pt = null;
624
                Point point = new Point();
625
                Feature feature = new Feature();
626
627 124 jmorell
                feature.setProp("dxfEntity", "Point");
628 55 jmorell
                if (grp.hasCode(8))
629 54 jmorell
                        feature.setProp("layer", grp.getDataAsString(8));
630 124 jmorell
                if (grp.hasCode(39)) {
631
                        Double doub = new Double(grp.getDataAsDouble(39));
632
                        String string = doub.toString();
633
                        feature.setProp("thickness", string);
634
                } else {
635
                        Double doub = new Double(0.0);
636
                        feature.setProp("thickness", doub.toString());
637
                }
638 55 jmorell
                if (grp.hasCode(62)) {
639
                        Integer integer = new Integer(grp.getDataAsInt(62));
640
                        String string = integer.toString();
641
                        feature.setProp("color", string);
642
                } else {
643 128 jmorell
                        DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
644
                        int clr = layer.colorNumber;
645
                        Integer integer = new Integer(clr);
646
                        String string = integer.toString();
647
                        feature.setProp("color", string);
648 54 jmorell
                }
649 44 jmorell
                x = grp.getDataAsDouble(10);
650
                y = grp.getDataAsDouble(20);
651 124 jmorell
                if (grp.hasCode(30)) {
652
                        z = grp.getDataAsDouble(30);
653
                        Double doub = new Double(z);
654
                        String string = doub.toString();
655
                        feature.setProp("elevation", string);
656
                }
657 44 jmorell
                if (grp.hasCode(210))
658
                        xtruX = grp.getDataAsDouble(210);
659
                if (grp.hasCode(220))
660
                        xtruY = grp.getDataAsDouble(220);
661
                if (grp.hasCode(230))
662
                        xtruZ = grp.getDataAsDouble(230);
663
                Point3D point_in = new Point3D(x, y, z);
664
                Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
665
                Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
666
                x = point_out.getX();
667
                y = point_out.getY();
668
                point.add(new Point2D.Double(x, y));
669 57 jmorell
670 44 jmorell
                feature.setGeometry(point);
671 74 jmorell
                //features.add(feature);
672
                if (addingToBlock == false) {
673
                        features.add(feature);
674
                } else {
675 102 jmorell
                        //System.out.println("createPoint(): A?adimos un punto al bloque " + iterator);
676 74 jmorell
                        blk.add(feature);
677
                }
678 44 jmorell
        }
679
680
        public void createCircle(DxfGroupVector grp) throws Exception {
681
                double x = 0.0, y = 0.0, z = 0.0;
682
                double r = 0.0;
683
                DxfGroup g = null;
684 142 jmorell
                LineString lineString = new LineString();
685 44 jmorell
                Polygon polygon = new Polygon();
686 142 jmorell
                Feature feaBordes = new Feature();
687
                Feature feaFondos = new Feature();
688 44 jmorell
689 142 jmorell
                feaBordes.setProp("dxfEntity", "Circle");
690
                feaFondos.setProp("dxfEntity", "Circle");
691 55 jmorell
                if (grp.hasCode(8))
692 142 jmorell
                        feaBordes.setProp("layer", grp.getDataAsString(8));
693
                        feaFondos.setProp("layer", grp.getDataAsString(8));
694 124 jmorell
                if (grp.hasCode(39)) {
695
                        Double doub = new Double(grp.getDataAsDouble(39));
696
                        String string = doub.toString();
697 142 jmorell
                        feaBordes.setProp("thickness", string);
698
                        feaFondos.setProp("thickness", string);
699 124 jmorell
                } else {
700
                        Double doub = new Double(0.0);
701 142 jmorell
                        feaBordes.setProp("thickness", doub.toString());
702
                        feaFondos.setProp("thickness", doub.toString());
703 124 jmorell
                }
704 55 jmorell
                if (grp.hasCode(62)) {
705
                        Integer integer = new Integer(grp.getDataAsInt(62));
706
                        String string = integer.toString();
707 142 jmorell
                        feaBordes.setProp("color", string);
708
                        feaFondos.setProp("color", string);
709 55 jmorell
                } else {
710 128 jmorell
                        DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
711
                        int clr = layer.colorNumber;
712
                        Integer integer = new Integer(clr);
713
                        String string = integer.toString();
714 142 jmorell
                        feaBordes.setProp("color", string);
715
                        feaFondos.setProp("color", string);
716 54 jmorell
                }
717 44 jmorell
                x = grp.getDataAsDouble(10);
718
                y = grp.getDataAsDouble(20);
719 124 jmorell
                if (grp.hasCode(30)) {
720
                        z = grp.getDataAsDouble(30);
721
                        Double doub = new Double(z);
722
                        String string = doub.toString();
723 142 jmorell
                        feaBordes.setProp("elevation", string);
724
                        feaFondos.setProp("elevation", string);
725 124 jmorell
                }
726 44 jmorell
                if (grp.hasCode(40)) r = grp.getDataAsDouble(40);
727
                if (grp.hasCode(210))
728
                        xtruX = grp.getDataAsDouble(210);
729
                if (grp.hasCode(220))
730 73 jmorell
                        xtruY = grp.getDataAsDouble(220);
731 44 jmorell
                if (grp.hasCode(230))
732 73 jmorell
                        xtruZ = grp.getDataAsDouble(230);
733 44 jmorell
                Point3D point_in = new Point3D(x, y, z);
734
                Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
735
                Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
736
                x = point_out.getX();
737
                y = point_out.getY();
738
739
                Point2D center = proj.createPoint( x, y);
740
                Point2D[] pts = new Point2D[360];
741
                int angulo = 0;
742
                for (angulo=0; angulo<360; angulo++) {
743
                        pts[angulo] = new Point2D.Double(center.getX(), center.getY());
744
                        pts[angulo].setLocation(pts[angulo].getX() + r * Math.sin(angulo*Math.PI/(double)180.0), pts[angulo].getY() + r * Math.cos(angulo*Math.PI/(double)180.0));
745
                        if (pts.length == 1) {
746
                                firstPt = pts[angulo];
747
                        }
748
                }
749
                for (int i=0; i<pts.length; i++) {
750 142 jmorell
                        lineString.add(pts[i]);
751 44 jmorell
                        polygon.add(pts[i]);
752
                }
753 57 jmorell
754 142 jmorell
                feaBordes.setGeometry(lineString);
755
                feaFondos.setGeometry(polygon);
756 74 jmorell
                //features.add(feature);
757
                if (addingToBlock == false) {
758 102 jmorell
                        //System.out.println("createCircle(): A?ade un circulo a la lista de entidades");
759 142 jmorell
                        features.add(feaBordes);
760
                        features.add(feaFondos);
761 74 jmorell
                } else {
762 102 jmorell
                        //System.out.println("createCircle(): A?adimos un circulo al bloque " + iterator);
763 142 jmorell
                        blk.add(feaBordes);
764
                        blk.add(feaFondos);
765 74 jmorell
                }
766 44 jmorell
        }
767
768
        public void createArc(DxfGroupVector grp) throws Exception {
769
                double x = 0.0, y = 0.0, z = 0.0;
770
                double r = 0.0, empieza = 0.0, acaba = 0.0;
771
                DxfGroup g = null;
772
                LineString lineString = new LineString();
773
                Feature feature = new Feature();
774
775 124 jmorell
                feature.setProp("dxfEntity", "Arc");
776 55 jmorell
                if (grp.hasCode(8))
777 54 jmorell
                        feature.setProp("layer", grp.getDataAsString(8));
778 124 jmorell
                if (grp.hasCode(39)) {
779
                        Double doub = new Double(grp.getDataAsDouble(39));
780
                        String string = doub.toString();
781
                        feature.setProp("thickness", string);
782
                } else {
783
                        Double doub = new Double(0.0);
784
                        feature.setProp("thickness", doub.toString());
785
                }
786 55 jmorell
                if (grp.hasCode(62)) {
787
                        Integer integer = new Integer(grp.getDataAsInt(62));
788
                        String string = integer.toString();
789
                        feature.setProp("color", string);
790
                } else {
791 128 jmorell
                        DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
792
                        int clr = layer.colorNumber;
793
                        Integer integer = new Integer(clr);
794
                        String string = integer.toString();
795
                        feature.setProp("color", string);
796 54 jmorell
                }
797 44 jmorell
                x = grp.getDataAsDouble(10);
798
                y = grp.getDataAsDouble(20);
799 124 jmorell
                if (grp.hasCode(30)) {
800
                        z = grp.getDataAsDouble(30);
801
                        Double doub = new Double(z);
802
                        String string = doub.toString();
803
                        feature.setProp("elevation", string);
804
                }
805 44 jmorell
                if (grp.hasCode(40)) r = grp.getDataAsDouble(40);
806
                if (grp.hasCode(50)) empieza = grp.getDataAsDouble(50);
807
                if (grp.hasCode(51)) acaba = grp.getDataAsDouble(51);
808
                if (grp.hasCode(210))
809
                        xtruX = grp.getDataAsDouble(210);
810
                if (grp.hasCode(220))
811 73 jmorell
                        xtruY = grp.getDataAsDouble(220);
812 44 jmorell
                if (grp.hasCode(230))
813 73 jmorell
                        xtruZ = grp.getDataAsDouble(230);
814 44 jmorell
                Point3D point_in = new Point3D(x, y, z);
815
                Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
816
                Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
817
                x = point_out.getX();
818
                y = point_out.getY();
819
820
                Point2D center = proj.createPoint( x, y);
821 102 jmorell
                //System.out.println("empieza = " + empieza + ", acaba = " + acaba);
822 44 jmorell
                int iempieza = (int)empieza;
823
                int iacaba = (int)acaba;
824 102 jmorell
                //System.out.println("iempieza = " + iempieza + ", iacaba = " + iacaba);
825 44 jmorell
                double angulo = 0;
826
                Point2D[] pts = null;
827
                if (empieza <= acaba) {
828
                        pts = new Point2D[(iacaba-iempieza)+2];
829
                        angulo = empieza;
830
                        pts[0] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0));
831
                        for (int i=1; i<=(iacaba-iempieza)+1; i++) {
832
                                angulo = (double)(iempieza+i);
833
                                pts[i] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0));
834
                        }
835
                        angulo = acaba;
836
                        pts[(iacaba-iempieza)+1] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0));
837
                } else {
838
                        pts = new Point2D[(360-iempieza)+iacaba+2];
839
                        angulo = empieza;
840 102 jmorell
                        //System.out.println("pts[0] = " + pts[0] + ", center = " + center + ", angulo = " + angulo);
841 44 jmorell
                        pts[0] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0));
842
                        for (int i=1; i<=(360-iempieza); i++) {
843
                                angulo = (double)(iempieza+i);
844
                                pts[i] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0));
845
                        }
846
                        for (int i=(360-iempieza)+1; i<=(360-iempieza)+iacaba; i++) {
847
                                angulo = (double)(i-(360-iempieza));
848
                                pts[i] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0));
849
                        }
850
                        angulo = acaba;
851
                        pts[(360-iempieza)+iacaba+1] = new Point2D.Double(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0));
852
                }
853
                for (int i=0; i<pts.length; i++) {
854
                        lineString.add(pts[i]);
855
                }
856 57 jmorell
857 44 jmorell
                feature.setGeometry(lineString);
858 74 jmorell
                //features.add(feature);
859
                if (addingToBlock == false) {
860
                        features.add(feature);
861
                } else {
862 102 jmorell
                        //System.out.println("createArc(): A?adimos un arco al bloque " + iterator);
863 74 jmorell
                        blk.add(feature);
864
                }
865 44 jmorell
        }
866
867
        public void createInsert(DxfGroupVector grp) throws Exception {
868
                double x = 0.0, y = 0.0, z = 0.0;
869
                DxfGroup g = null;
870 73 jmorell
                Point2D pt = new Point2D.Double(0.0, 0.0);
871
                Point2D scaleFactor = new Point2D.Double(1.0, 1.0);
872
                double rotAngle = 0.0;
873 44 jmorell
                String blockName = "";
874
875 73 jmorell
                InsPoint insert = new InsPoint();
876 44 jmorell
                Feature feature = new Feature();
877 74 jmorell
                Point secondGeom = new Point();
878
                Feature secondFeat = new Feature();
879 44 jmorell
880 124 jmorell
                feature.setProp("dxfEntity", "Insert");
881 128 jmorell
                secondFeat.setProp("dxfEntity", "Insert");
882 73 jmorell
                if (grp.hasCode(2)) {
883 44 jmorell
                        blockName = grp.getDataAsString(2);
884 74 jmorell
                        //feature.setProp("blockName", blockName);
885
                        insert.setBlockName(blockName);
886 73 jmorell
                }
887 74 jmorell
                if (grp.hasCode(8)) {
888 54 jmorell
                        feature.setProp("layer", grp.getDataAsString(8));
889 74 jmorell
                        secondFeat.setProp("layer", grp.getDataAsString(8));
890
                }
891 127 jmorell
892
                Double doub = new Double(0.0);
893
                secondFeat.setProp("thickness", doub.toString());
894
895 55 jmorell
                if (grp.hasCode(62)) {
896
                        Integer integer = new Integer(grp.getDataAsInt(62));
897
                        String string = integer.toString();
898
                        feature.setProp("color", string);
899 74 jmorell
                        secondFeat.setProp("color", string);
900 55 jmorell
                } else {
901 128 jmorell
                        DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
902
                        int clr = layer.colorNumber;
903
                        Integer integer = new Integer(clr);
904
                        String string = integer.toString();
905
                        feature.setProp("color", string);
906
                        secondFeat.setProp("color", string);
907 54 jmorell
                }
908 73 jmorell
                if (grp.hasCode(10)) x = grp.getDataAsDouble(10);
909
                if (grp.hasCode(20)) y = grp.getDataAsDouble(20);
910 124 jmorell
                if (grp.hasCode(30)) {
911
                        z = grp.getDataAsDouble(30);
912 127 jmorell
                        Double doubz = new Double(z);
913
                        String string = doubz.toString();
914 124 jmorell
                        feature.setProp("elevation", string);
915 127 jmorell
                        secondFeat.setProp("elevation", string);
916 124 jmorell
                }
917 73 jmorell
                if (grp.hasCode(41)) {
918
                        scaleFactor.setLocation(grp.getDataAsDouble(41), scaleFactor.getY());
919 74 jmorell
                        //Double scaleFactorX = new Double(scaleFactor.getX());
920
                        //feature.setProp("scaleFactorX", scaleFactorX.toString());
921
                        insert.setScaleFactor(scaleFactor);
922 73 jmorell
                } else {
923 74 jmorell
                        //Double scaleFactorX = new Double(scaleFactor.getX());
924
                        //feature.setProp("scaleFactorX", scaleFactorX.toString());
925
                        insert.setScaleFactor(scaleFactor);
926 73 jmorell
                }
927
                if (grp.hasCode(42)) {
928
                        scaleFactor.setLocation(scaleFactor.getX(), grp.getDataAsDouble(42));
929 74 jmorell
                        //Double scaleFactorY = new Double(scaleFactor.getY());
930
                        //feature.setProp("scaleFactorY", scaleFactorY.toString());
931
                        insert.setScaleFactor(scaleFactor);
932 73 jmorell
                } else {
933 74 jmorell
                        //Double scaleFactorY = new Double(scaleFactor.getY());
934
                        //feature.setProp("scaleFactorY", scaleFactorY.toString());
935
                        insert.setScaleFactor(scaleFactor);
936 73 jmorell
                }
937 75 jmorell
                if (grp.hasCode(43)) {
938 73 jmorell
                        // TODO La coordenada z
939 75 jmorell
                }
940
                if (grp.hasCode(50)) {
941 73 jmorell
                        rotAngle = grp.getDataAsDouble(50);
942 74 jmorell
                        //Double objRotAngle = new Double(rotAngle);
943
                        //feature.setProp("rotAngle", objRotAngle.toString());
944
                        insert.setRotAngle(rotAngle);
945 73 jmorell
                }
946 44 jmorell
                if (grp.hasCode(210))
947
                        xtruX = grp.getDataAsDouble(210);
948
                if (grp.hasCode(220))
949
                        xtruY = grp.getDataAsDouble(220);
950
                if (grp.hasCode(230))
951
                        xtruZ = grp.getDataAsDouble(230);
952
                Point3D point_in = new Point3D(x, y, z);
953
                Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
954
                Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru);
955
                x = point_out.getX();
956
                y = point_out.getY();
957
958 73 jmorell
                insert.setBlkList(blkList);
959 44 jmorell
960 73 jmorell
                insert.encuentraBloque(blockName);
961 44 jmorell
962 74 jmorell
                insert.add(new Point2D.Double(x, y));
963
                secondGeom.add(new Point2D.Double(x, y));
964 73 jmorell
965 74 jmorell
                feature.setGeometry(insert);
966
                secondFeat.setGeometry(secondGeom);
967
968 73 jmorell
                gestionaInsert(feature);
969
970
                if (addingToBlock == false) {
971 74 jmorell
                        features.add(secondFeat);
972 44 jmorell
                }
973 74 jmorell
                //if (addingToBlock == true && feature.getProp("blockFound").equals("true")) {
974
                if (addingToBlock == true && insert.getBlockFound() == true) {
975 102 jmorell
                        //System.out.println("createInsert(): A?adimos un insert al bloque " + iterator);
976 73 jmorell
                        blk.add(feature);
977
                }
978 44 jmorell
        }
979
980 82 jmorell
        public void createSolid(DxfGroupVector grp) throws Exception {
981
                double x = 0.0, y = 0.0, z1 = 0.0, z2 = 0.0, z3 = 0.0, z4 = 0.0;
982
                DxfGroup g = null;
983
                //Point2D pt1 = null, pt2 = null, pt3 = null, pt4 = null;
984
                Point2D[] pts = new Point2D[4];
985
                //DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
986 44 jmorell
987 142 jmorell
                LineString lineString = new LineString();
988 82 jmorell
                Polygon polygon = new Polygon();
989 142 jmorell
                Feature feaBordes = new Feature();
990
                Feature feaFondos = new Feature();
991 124 jmorell
                double elev = 0;
992 82 jmorell
993 142 jmorell
                feaBordes.setProp("dxfEntity", "Solid");
994
                feaFondos.setProp("dxfEntity", "Solid");
995 128 jmorell
                if (grp.hasCode(8))
996 142 jmorell
                        feaBordes.setProp("layer", grp.getDataAsString(8));
997
                        feaFondos.setProp("layer", grp.getDataAsString(8));
998 82 jmorell
                x = grp.getDataAsDouble(10);
999
                y = grp.getDataAsDouble(20);
1000 124 jmorell
                if (grp.hasCode(30)) {
1001
                        z1 = grp.getDataAsDouble(30);
1002
                        elev = z1;
1003
                        Double doub = new Double(elev);
1004
                        String string = doub.toString();
1005 142 jmorell
                        feaBordes.setProp("elevation", string);
1006
                        feaFondos.setProp("elevation", string);
1007 124 jmorell
                }
1008 82 jmorell
                pts[0] = proj.createPoint(x, y);
1009
                x = grp.getDataAsDouble(11);
1010
                y = grp.getDataAsDouble(21);
1011
                if (grp.hasCode(31)) z2 = grp.getDataAsDouble(31);
1012
                pts[1] = proj.createPoint(x, y);
1013
                x = grp.getDataAsDouble(12);
1014
                y = grp.getDataAsDouble(22);
1015
                if (grp.hasCode(32)) z3 = grp.getDataAsDouble(32);
1016
                pts[2] = proj.createPoint(x, y);
1017
                x = grp.getDataAsDouble(13);
1018
                y = grp.getDataAsDouble(23);
1019
                if (grp.hasCode(33)) z2 = grp.getDataAsDouble(33);
1020
                pts[3] = proj.createPoint(x, y);
1021 124 jmorell
                if (grp.hasCode(39)) {
1022
                        Double doub = new Double(grp.getDataAsDouble(39));
1023
                        String string = doub.toString();
1024 142 jmorell
                        feaBordes.setProp("thickness", string);
1025
                        feaFondos.setProp("thickness", string);
1026 124 jmorell
                } else {
1027
                        Double doub = new Double(0.0);
1028 142 jmorell
                        feaBordes.setProp("thickness", doub.toString());
1029
                        feaFondos.setProp("thickness", doub.toString());
1030 124 jmorell
                }
1031 82 jmorell
                if (grp.hasCode(62)) {
1032
                        Integer integer = new Integer(grp.getDataAsInt(62));
1033
                        String string = integer.toString();
1034 142 jmorell
                        feaBordes.setProp("color", string);
1035
                        feaFondos.setProp("color", string);
1036 82 jmorell
                } else {
1037 128 jmorell
                        DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
1038
                        int clr = layer.colorNumber;
1039
                        Integer integer = new Integer(clr);
1040
                        String string = integer.toString();
1041 142 jmorell
                        feaBordes.setProp("color", string);
1042
                        feaFondos.setProp("color", string);
1043 82 jmorell
                }
1044
                if (grp.hasCode(210))
1045
                        xtruX = grp.getDataAsDouble(210);
1046
                if (grp.hasCode(220))
1047
                        xtruY = grp.getDataAsInt(220);
1048
                if (grp.hasCode(230))
1049
                        xtruZ = grp.getDataAsInt(230);
1050
                Point3D point_in1 = new Point3D(pts[0].getX(), pts[0].getY(), z1);
1051
                Point3D point_in2 = new Point3D(pts[1].getX(), pts[1].getY(), z2);
1052
                Point3D point_in3 = new Point3D(pts[2].getX(), pts[2].getY(), z3);
1053
                Point3D point_in4 = new Point3D(pts[3].getX(), pts[3].getY(), z4);
1054
                Point3D xtru = new Point3D(xtruX, xtruY, xtruZ);
1055
                Point2D point_out1 = DxfCalXtru.CalculateXtru(point_in1, xtru);
1056
                Point2D point_out2 = DxfCalXtru.CalculateXtru(point_in2, xtru);
1057
                Point2D point_out3 = DxfCalXtru.CalculateXtru(point_in3, xtru);
1058
                Point2D point_out4 = DxfCalXtru.CalculateXtru(point_in4, xtru);
1059
                pts[0].setLocation(point_out1);
1060
                pts[1].setLocation(point_out2);
1061
                pts[2].setLocation(point_out3);
1062
                pts[3].setLocation(point_out4);
1063
1064 106 jmorell
                Point2D aux = pts[2];
1065
                pts[2] = pts[3];
1066
                pts[3] = aux;
1067
1068 82 jmorell
                for (int i=0; i<pts.length; i++) {
1069 142 jmorell
                        lineString.add(pts[i]);
1070 82 jmorell
                        polygon.add(pts[i]);
1071
                }
1072
1073 106 jmorell
                // Para cerrarlos.
1074 142 jmorell
                lineString.add(pts[0]);
1075 106 jmorell
                polygon.add(pts[0]);
1076
1077 142 jmorell
                feaBordes.setGeometry(lineString);
1078
                feaFondos.setGeometry(polygon);
1079 82 jmorell
                //features.add(feature);
1080
                if (addingToBlock == false) {
1081 102 jmorell
                        //System.out.println("createSolid(): A?ade un solid a la lista de entidades");
1082 142 jmorell
                        features.add(feaBordes);
1083
                        features.add(feaFondos);
1084 82 jmorell
                } else {
1085 102 jmorell
                        //System.out.println("createSolid(): A?adimos un circulo al bloque " + iterator);
1086 142 jmorell
                        blk.add(feaBordes);
1087
                        blk.add(feaFondos);
1088 82 jmorell
                }
1089 44 jmorell
        }
1090
1091 73 jmorell
        public void createBlock(DxfGroupVector grp) throws Exception {
1092
                //DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
1093
                blk = new FeatureCollection(proj);
1094 44 jmorell
1095 73 jmorell
                Point2D basePoint = new Point2D.Double();
1096
                String blockName = "";
1097 102 jmorell
                //System.out.println("createBlock(): Creamos nuevo bloque, el bloque " + iterator);
1098 73 jmorell
1099
                addingToBlock = true;
1100 102 jmorell
                //System.out.println("createBlock(): A?adimos el bloque " + iterator + " a la lista de bloques");
1101 73 jmorell
                blkList.add(iterator, blk);
1102
1103 102 jmorell
                //System.out.println("createBlock(): Rellenamos la informacion del bloque " + iterator);
1104 73 jmorell
1105 74 jmorell
                if (grp.hasCode(8))
1106
                        blk.setProp("layer", grp.getDataAsString(8));
1107
                if (grp.hasCode(62)) {
1108
                        Integer integer = new Integer(grp.getDataAsInt(62));
1109
                        String string = integer.toString();
1110
                        blk.setProp("color", string);
1111
                } else {
1112 128 jmorell
                        DxfLayer layer = (DxfLayer)layers.getByName(grp.getDataAsString(8));
1113
                        int clr = layer.colorNumber;
1114
                        Integer integer = new Integer(clr);
1115
                        String string = integer.toString();
1116
                        blk.setProp("color", string);
1117 74 jmorell
                }
1118
1119 73 jmorell
                if (grp.hasCode(1)) {
1120
                        blockName = grp.getDataAsString(1);
1121
                        //blk.setBlkName(blockName);
1122
                        blk.setProp("blockName", blockName);
1123
                }
1124
                if (grp.hasCode(2)) {
1125
                        blockName = grp.getDataAsString(2);
1126
                        //blk.setBlkName(blockName);
1127
                        blk.setProp("blockName", blockName);
1128
                }
1129
                if (grp.hasCode(3)) {
1130
                        blockName = grp.getDataAsString(3);
1131
                        //blk.setBlkName(blockName);
1132
                        blk.setProp("blockName", blockName);
1133
                }
1134
                if (grp.hasCode(10)) {
1135
                        //basePoint.setLocation(grp.getDataAsDouble(10), basePoint.getY());
1136
                        //blk.setBPoint(basePoint);
1137
                        Double basePointX = new Double(grp.getDataAsDouble(10));
1138
                        blk.setProp("basePointX", basePointX.toString());
1139
                }
1140
                if (grp.hasCode(20)) {
1141
                        //basePoint.setLocation(basePoint.getX(), grp.getDataAsDouble(20));
1142
                        //blk.setBPoint(basePoint);
1143
                        Double basePointY = new Double(grp.getDataAsDouble(20));
1144
                        blk.setProp("basePointY", basePointY.toString());
1145
                }
1146
                if (grp.hasCode(30)) {
1147 124 jmorell
                        //basePoint.setLocation(basePoint.getZ(), grp.getDataAsDouble(30));
1148
                        //blk.setBPoint(basePoint);
1149
                        Double basePointZ = new Double(grp.getDataAsDouble(30));
1150
                        blk.setProp("basePointZ", basePointZ.toString());
1151 73 jmorell
                }
1152
                if (grp.hasCode(70)) {
1153
                        //blk.flags = grp.getDataAsInt(70);
1154
                        Integer blockFlags = new Integer(grp.getDataAsInt(70));
1155
                        blk.setProp("blockFlags", blockFlags.toString());
1156
                }
1157 44 jmorell
        }
1158
1159
        public void endBlk(DxfGroupVector grp) throws Exception {
1160 73 jmorell
                //DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8));
1161
                setAddingToBlock(false);
1162
                iterator = iterator + 1;
1163
        }
1164
1165 78 luisw
        public void testBlocks() {
1166
                System.out.println("getBlkList() = " + getBlkList());
1167
                Vector blkList = getBlkList();
1168
                FeatureCollection block = null;
1169
                Feature feature = null;
1170
                InsPoint insert = null;
1171
                Point2D point1 = new Point2D.Double();
1172
                Point2D point2 = new Point2D.Double();
1173
                System.out.println("blkList = " + blkList);
1174
                System.out.println("blkList.size() = " + blkList.size());
1175
                for (int i=0; i<blkList.size(); i++) {
1176
                        System.out.println("compruebaBloques(): Bloque " + i +" de " + blkList.size());
1177
                        block = (FeatureCollection) blkList.get(i);
1178 96 luisw
                        int aux = block.size();
1179 78 luisw
                        for (int j=0; j<aux; j++) {
1180 96 luisw
                                feature = (Feature)block.get(j);
1181 78 luisw
                                //if (feature.getGeometry() instanceof InsPoint && feature.getProp("isAnInsert") == "true") {
1182
                                if (feature.getGeometry() instanceof InsPoint) {
1183
                                        insert = (InsPoint)feature.getGeometry();
1184
                                        String nomBlock = insert.getBlockName();
1185
                                        System.out.println("compruebaBloques(): Bloque = " + i + ", elemento = " + j + ", inserta el bloque = " + nomBlock);
1186
                                        System.out.println("compruebaBloques(): insert.get(0) = " + insert.get(0));
1187
                                        System.out.println("compruebaBloques(): feature.getProp(rotAngle) = " + insert.getRotAngle());
1188
                                        System.out.println("compruebaBloques(): insert.getScaleFactor() = " + insert.getScaleFactor());
1189
                                        //if (feature.getProp("blockFound") == "false") {
1190
                                        if (insert.getBlockFound() == false) {
1191
                                                System.out.println("compruebaBloques(): Ahora se ocupa del DxfInsert " + nomBlock);
1192
                                                boolean aux_bool = insert.encuentraBloque(nomBlock);
1193
                                                gestionaInsert(feature);
1194 96 luisw
                                                block.add(feature);
1195 78 luisw
                                        }
1196
1197
                                }
1198
                        }
1199
                }
1200
        }
1201
1202 73 jmorell
        public void gestionaInsert(Feature feature) {
1203
                Feature feature2 = null;
1204
                Point point = null;
1205
                LineString lineString = null;
1206
                Polygon polygon = null;
1207 74 jmorell
                InsPoint insert = new InsPoint();
1208
                insert = (InsPoint)feature.getGeometry();
1209 77 jmorell
                double bPointX = 0.0;
1210
                double bPointY = 0.0;
1211
                if (insert.getBlockFound() == true) {
1212
                        bPointX = Double.parseDouble(insert.getBlock().getProp("basePointX"));
1213
                        bPointY = Double.parseDouble(insert.getBlock().getProp("basePointY"));
1214
                }
1215 74 jmorell
                double sFactorX = insert.getScaleFactor().getX();
1216
                double sFactorY = insert.getScaleFactor().getY();
1217 104 jmorell
                double rAngleGra = insert.getRotAngle();
1218
                double rAngleRad = rAngleGra*Math.PI/180.0;
1219 73 jmorell
                InsPoint insert2 = null;
1220 44 jmorell
1221 96 luisw
                for (int i=0; i<insert.getBlock().size(); i++) {
1222 102 jmorell
                        //System.out.println("gestionaInserts: insert.getBlock().features.size() = " + insert.getBlock().size());
1223 119 jmorell
                        feature2 = (Feature)insert.getBlock().get(i);
1224 100 jmorell
1225 122 jmorell
                        // Para que los elementos dentro del bloque tengan la misma layer
1226 145 jmorell
                        // y color que el insert al que corresponden.
1227 154 jmorell
                        //feature2.setProp("layer", feature.getProp("layer"));
1228
                        //feature2.setProp("color", feature.getProp("color"));
1229 122 jmorell
                        //feature2.setProp("text", feature.getProp("text"));
1230 100 jmorell
1231 73 jmorell
                        Point2D point1 = new Point2D.Double();
1232
                        Point2D point11 = new Point2D.Double();
1233 119 jmorell
                        Point2D pointAux = null;
1234 103 jmorell
1235 73 jmorell
                        if (feature2.getGeometry() instanceof InsPoint){
1236 148 jmorell
1237
                                System.out.println("Encuentra bloques dentro de bloques");
1238
1239 74 jmorell
                                insert2 = (InsPoint)feature2.getGeometry();
1240 73 jmorell
                                point1 = insert2.get(0);
1241 117 jmorell
1242 119 jmorell
                                pointAux = new Point2D.Double(point1.getX() - bPointX, point1.getY() - bPointY);
1243
                                double laX = insert.get(0).getX() + ((pointAux.getX()*sFactorX)*Math.cos(rAngleRad) + (pointAux.getY()*sFactorY)*(-1)*Math.sin(rAngleRad));
1244
                                double laY = insert.get(0).getY() + ((pointAux.getX()*sFactorX)*Math.sin(rAngleRad) + (pointAux.getY()*sFactorY)*Math.cos(rAngleRad));
1245 103 jmorell
                                point11.setLocation(laX, laY);
1246 73 jmorell
                                InsPoint insert3 = new InsPoint();
1247
1248 74 jmorell
                                insert3.add(point11);
1249 73 jmorell
1250 74 jmorell
                                insert3.setBlkList(insert2.getBlkList());
1251
                                insert3.setBlock(insert2.getBlock());
1252
                                insert3.setBlockName(insert2.getBlockName());
1253
                                insert3.setRotAngle(insert2.getRotAngle());
1254 119 jmorell
                                Point2D newScale = new Point2D.Double(insert2.getScaleFactor().getX() * sFactorX, insert2.getScaleFactor().getY() * sFactorY);
1255
                                insert3.setScaleFactor(newScale);
1256 73 jmorell
1257 74 jmorell
                                Feature feature3 = new Feature();
1258
                                feature3.setProp("layer", feature2.getProp("layer"));
1259
                                feature3.setProp("color", feature2.getProp("color"));
1260 124 jmorell
                                feature3.setProp("dxfEntity", feature2.getProp("dxfEntity"));
1261
                                feature3.setProp("elevation", feature2.getProp("elevation"));
1262 74 jmorell
                                feature3.setGeometry(insert3);
1263 73 jmorell
1264 74 jmorell
                                gestionaInsert(feature3);
1265 73 jmorell
                        } else if (feature2.getGeometry() instanceof LineString) {
1266 74 jmorell
                                lineString = (LineString)feature2.getGeometry();
1267 73 jmorell
                                LineString lineString2 = new LineString();
1268
                                Point2D[] points = new Point2D[lineString.pointNr()];
1269
                                Point2D[] pointss = new Point2D[lineString.pointNr()];
1270
                                for (int j=0; j<lineString.pointNr(); j++) {
1271
                                        points[j] = (Point2D)lineString.get(j);
1272 74 jmorell
                                        pointss[j] = new Point2D.Double();
1273 117 jmorell
1274 119 jmorell
                                        pointAux = new Point2D.Double(points[j].getX() - bPointX, points[j].getY() - bPointY);
1275
                                        double laX = insert.get(0).getX() + ((pointAux.getX()*sFactorX)*Math.cos(rAngleRad) + (pointAux.getY()*sFactorY)*(-1)*Math.sin(rAngleRad));
1276
                                        double laY = insert.get(0).getY() + ((pointAux.getX()*sFactorX)*Math.sin(rAngleRad) + (pointAux.getY()*sFactorY)*Math.cos(rAngleRad));
1277 103 jmorell
                                        pointss[j].setLocation(laX, laY);
1278 73 jmorell
                                        lineString2.add(pointss[j]);
1279
                                }
1280 74 jmorell
1281
                                Feature feature3 = new Feature();
1282
                                feature3.setProp("layer", feature2.getProp("layer"));
1283
                                feature3.setProp("color", feature2.getProp("color"));
1284 124 jmorell
                                feature3.setProp("dxfEntity", feature2.getProp("dxfEntity"));
1285
                                feature3.setProp("elevation", feature2.getProp("elevation"));
1286
                                feature3.setProp("thickness", feature2.getProp("thickness"));
1287 74 jmorell
                                feature3.setGeometry(lineString2);
1288
1289
                                if (addingToBlock == false) {
1290
                                        features.add(feature3);
1291 73 jmorell
                                }
1292 74 jmorell
                        } else if (feature2.getGeometry() instanceof Polygon) {
1293
                                polygon = (Polygon)feature2.getGeometry();
1294
                                Polygon polygon2 = new Polygon();
1295
                                Point2D[] points = new Point2D[polygon.pointNr()];
1296
                                Point2D[] pointss = new Point2D[polygon.pointNr()];
1297
                                for (int j=0; j<polygon.pointNr(); j++) {
1298
                                        points[j] = (Point2D)polygon.get(j);
1299 103 jmorell
                                        pointss[j] = new Point2D.Double();
1300 117 jmorell
1301 119 jmorell
                                        points[j].setLocation(points[j].getX() - bPointX, points[j].getY() - bPointY);
1302
                                        double laX = insert.get(0).getX() + ((points[j].getX()*sFactorX)*Math.cos(rAngleRad) + (points[j].getY()*sFactorY)*(-1)*Math.sin(rAngleRad));
1303
                                        double laY = insert.get(0).getY() + ((points[j].getX()*sFactorX)*Math.sin(rAngleRad) + (points[j].getY()*sFactorY)*Math.cos(rAngleRad));
1304 103 jmorell
                                        pointss[j].setLocation(laX, laY);
1305 74 jmorell
                                        polygon2.add(pointss[j]);
1306 73 jmorell
                                }
1307 74 jmorell
1308
                                Feature feature3 = new Feature();
1309
                                feature3.setProp("layer", feature2.getProp("layer"));
1310
                                feature3.setProp("color", feature2.getProp("color"));
1311 124 jmorell
                                feature3.setProp("dxfEntity", feature2.getProp("dxfEntity"));
1312
                                feature3.setProp("elevation", feature2.getProp("elevation"));
1313
                                feature3.setProp("thickness", feature2.getProp("thickness"));
1314 74 jmorell
                                feature3.setGeometry(polygon2);
1315
1316
                                if (addingToBlock == false) {
1317
                                        features.add(feature3);
1318
                                }
1319
                        } else if (feature2.getGeometry() instanceof Point) {
1320
                                point = (Point)feature2.getGeometry();
1321
                                point1 = point.get(0);
1322 117 jmorell
1323 119 jmorell
                                pointAux = new Point2D.Double(point1.getX() - bPointX, point1.getY() - bPointY);
1324
                                double laX = insert.get(0).getX() + ((pointAux.getX()*sFactorX)*Math.cos(rAngleRad) + (pointAux.getY()*sFactorY)*(-1)*Math.sin(rAngleRad));
1325
                                double laY = insert.get(0).getY() + ((pointAux.getX()*sFactorX)*Math.sin(rAngleRad) + (pointAux.getY()*sFactorY)*Math.cos(rAngleRad));
1326 103 jmorell
                                point11.setLocation(laX, laY);
1327 74 jmorell
                                Point pointt = new Point();
1328
                                pointt.add(point11);
1329
1330
                                Feature feature3 = new Feature();
1331
                                feature3.setProp("layer", feature2.getProp("layer"));
1332
                                feature3.setProp("color", feature2.getProp("color"));
1333 124 jmorell
                                feature3.setProp("dxfEntity", feature2.getProp("dxfEntity"));
1334
                                feature3.setProp("elevation", feature2.getProp("elevation"));
1335
                                feature3.setProp("thickness", feature2.getProp("thickness"));
1336 122 jmorell
                                if (point.isText) {
1337
                                        feature3.setProp("text", feature2.getProp("text"));
1338
                                }
1339 74 jmorell
                                feature3.setGeometry(pointt);
1340
1341
                                if (addingToBlock == false) {
1342
                                        features.add(feature3);
1343
                                }
1344 73 jmorell
                        } else {
1345 119 jmorell
                                System.out.println("gestionaInserts: Encontrado elemento desconocido");
1346 73 jmorell
                        }
1347
                }
1348 44 jmorell
        }
1349
1350
        /* (non-Javadoc)
1351
         * @see org.cresques.io.DxfFile.EntityFactory#getExtent()
1352
         */
1353
        public Extent getExtent() {
1354
                Feature feature = new Feature();
1355
                Extent extent = new Extent();
1356
                Iterator iter = features.iterator();
1357
                while (iter.hasNext()) {
1358
                        feature = (Feature)iter.next();
1359
                        extent.add(feature.getExtent());
1360
                }
1361
                return extent;
1362
        }
1363
1364 94 luisw
        public void setProjection(IProjection p) {
1365 44 jmorell
                proj = p;
1366
        }
1367
1368
        /* (non-Javadoc)
1369
         * @see org.cresques.io.DxfFile.EntityFactory#reProject(org.cresques.geo.ReProjection)
1370
         */
1371 94 luisw
        public void reProject(ICoordTrans rp) {
1372 44 jmorell
                Feature feature = new Feature();
1373
                Extent extent = new Extent();
1374
                Iterator iter = features.iterator();
1375
                while (iter.hasNext()) {
1376
                        feature = (Feature)iter.next();
1377
                        ((Projected) feature).reProject(rp);
1378
                        extent.add(feature.getExtent());
1379
                }
1380
                setProjection(rp.getPDest());
1381
        }
1382
1383
        /* (non-Javadoc)
1384
         * @see org.cresques.geo.Projected#getProjection()
1385
         */
1386 94 luisw
        public IProjection getProjection() {
1387 44 jmorell
                return proj;
1388
        }
1389
1390 96 luisw
        public IObjList getObjects() { return features;}
1391 44 jmorell
1392 91 luisw
        public void draw(Graphics2D g, ViewPortData vp) {
1393 44 jmorell
                Iterator iter = features.iterator();
1394
                Extent extent;
1395
                while (iter.hasNext()) {
1396
                        Feature feature = new Feature();
1397
                        feature = (Feature)iter.next();
1398
                        extent = feature.getExtent();
1399
                        if (vp.getExtent().minX()> extent.maxX()) continue;
1400
                        if (vp.getExtent().minY()> extent.maxY()) continue;
1401
                        if (vp.getExtent().maxX()< extent.minX()) continue;
1402
                        if (vp.getExtent().maxY()< extent.minY()) continue;
1403
                        //if (!feature.layer.frozen)
1404
                                feature.draw(g, vp);
1405
                }
1406
        }
1407
1408
        public static Vector createArc(Point2D coord1, Point2D coord2, double bulge) {
1409
                return new DxfCalArcs(coord1, coord2, bulge).getPoints(1);
1410
        }
1411 62 jmorell
1412
        /* (non-Javadoc)
1413
         * @see org.cresques.io.DxfFile.EntityFactory#getBlkList()
1414
         */
1415
        public Vector getBlkList() {
1416 76 jmorell
                return blkList;
1417 62 jmorell
        }
1418 66 jmorell
1419
        /* (non-Javadoc)
1420
         * @see org.cresques.io.DxfFile.EntityFactory#getDxfEntityList()
1421
         */
1422
        public DxfEntityList getDxfEntityList() {
1423
                // TODO Auto-generated method stub
1424
                return null;
1425
        }
1426 69 jmorell
1427
        /* (non-Javadoc)
1428
         * @see org.cresques.io.DxfFile.EntityFactory#getBlk()
1429
         */
1430
        public DxfBlock getBlk() {
1431
                // TODO Auto-generated method stub
1432
                return null;
1433
        }
1434 90 jmorell
1435
        /* (non-Javadoc)
1436
         * @see org.cresques.io.DxfFile.EntityFactory#createSpline(org.cresques.io.DxfGroupVector)
1437
         */
1438
        public void createSpline(DxfGroupVector v) throws Exception {
1439
                // TODO Auto-generated method stub
1440
1441
        }
1442 44 jmorell
1443
}