Revision 35252

View differences:

tags/v2_0_0_Build_2026/libDXF/src/org/gvsig/dxf/geo/.cvsignore
1
*.dfPackage
2
*.wmf
0 3

  
tags/v2_0_0_Build_2026/libDXF/src/org/gvsig/dxf/geo/Polygon2D.java
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.geo;
25

  
26
import java.awt.Graphics2D;
27
import java.awt.geom.GeneralPath;
28
import java.awt.geom.Point2D;
29

  
30
import java.util.Iterator;
31
import java.util.Vector;
32

  
33
import org.cresques.geo.ViewPortData;
34

  
35

  
36
/**
37
 * Clase que representa un pol?gono 2D
38
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
39
 */
40
public class Polygon2D extends Vector {
41
    GeneralPath gp = null;
42

  
43
    public Polygon2D() {
44
        super();
45
        gp = null;
46
    }
47

  
48
    /**
49
     * A?ade un vertice al po??gono
50
     * @param pt        punto 2D que representa el vertice a?adido
51
     */
52
    public void addPoint(Point2D pt) {
53
        super.add(pt);
54
    }
55

  
56
    /**
57
     * Dibuja el pol?gono
58
     * @param g        Graphics sobre el que dibuja
59
     * @param vp        ViewPort con la vista
60
     */
61
    public void draw(Graphics2D g, ViewPortData vp) {
62
        newGP(vp);
63
        g.draw(gp);
64

  
65
        //g.draw(new Line2D.Double(pt,pt0));
66
    }
67

  
68
    /**
69
     *
70
     * @param g
71
     * @param vp
72
     */
73
    public void fill(Graphics2D g, ViewPortData vp) {
74
        newGP(vp);
75
        g.fill(gp);
76
    }
77

  
78
    /**
79
     *
80
     * @param vp
81
     */
82
    private void newGP(ViewPortData vp) {
83
        //if (gp != null) return;
84
        gp = new GeneralPath();
85

  
86
        Point2D pt0 = null;
87
        Point2D pt = null;
88
        Point2D pt1 = null;
89
        Point2D.Double ptTmp = new Point2D.Double(0.0, 0.0);
90
        Iterator iter = iterator();
91

  
92
        while (iter.hasNext()) {
93
            pt1 = (Point2D) iter.next();
94
            vp.mat.transform(pt1, ptTmp);
95

  
96
            if (pt0 == null) {
97
                pt0 = ptTmp;
98
                gp.moveTo((float) ptTmp.getX(), (float) ptTmp.getY());
99
            } else {
100
                gp.lineTo((float) ptTmp.getX(), (float) ptTmp.getY());
101
            }
102
        }
103

  
104
        gp.closePath();
105
    }
106
}
0 107

  
tags/v2_0_0_Build_2026/libDXF/src/org/gvsig/dxf/geo/cover/package.html
1
<html>
2
	<body>Clases relacionadas con coverturas espaciales.
3
</body>
4
</html>
0 5

  
tags/v2_0_0_Build_2026/libDXF/src/org/gvsig/dxf/geo/cover/Hoja.java
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.geo.cover;
25

  
26
import org.cresques.cts.ICoordTrans;
27
import org.cresques.cts.IProjection;
28

  
29
import org.cresques.geo.Projected;
30
import org.cresques.px.Extent;
31

  
32

  
33
import java.awt.geom.Point2D;
34

  
35
import java.io.InputStream;
36
import java.io.OutputStream;
37

  
38
import java.util.Vector;
39

  
40

  
41
/**
42
 * @author Luis W. Sevilla <sevilla_lui@gva.es>
43
 */
44
public class Hoja implements Projected {
45
    IProjection proj;
46
    String code = null;
47
    String name = null;
48
    Extent extent = null;
49
    Point2D tl;
50
    Point2D tr;
51
    Point2D bl;
52
    Point2D br;
53

  
54
    public Hoja(IProjection proj, String code, String name) {
55
        this.proj = proj;
56
        this.code = code;
57
        this.name = name;
58
        tl = tr = bl = br = null;
59
    }
60

  
61
    public Hoja(String cod, Point2D p1, Point2D p2, Point2D p3, Point2D p4,
62
                String name) {
63
        code = cod;
64
        tl = p1;
65
        tr = p2;
66
        bl = p3;
67
        br = p4;
68

  
69
        if (name != null) {
70
            this.name = name;
71
        }
72

  
73
        setExtent();
74
    }
75

  
76
    public Hoja(String cod, Point2D[] pt, String name) {
77
        code = cod;
78
        tl = pt[0];
79
        tr = pt[1];
80
        br = pt[2];
81
        bl = pt[3];
82

  
83
        if (name != null) {
84
            this.name = name;
85
        }
86

  
87
        setExtent();
88
    }
89

  
90
    public Hoja(String cod, Vector pt, String name) {
91
        code = cod;
92
        tl = (Point2D) pt.get(0);
93
        tr = (Point2D) pt.get(1);
94
        br = (Point2D) pt.get(2);
95
        bl = (Point2D) pt.get(3);
96

  
97
        if (name != null) {
98
            this.name = name;
99
        }
100

  
101
        setExtent();
102
    }
103

  
104
    public Hoja(String cod, Hoja h, String name) {
105
        code = cod;
106
        tl = h.tl;
107
        tr = h.tr;
108
        br = h.br;
109
        bl = h.bl;
110

  
111
        if (name != null) {
112
            this.name = name;
113
        }
114

  
115
        setExtent();
116
    }
117

  
118
    public IProjection getProjection() {
119
        return proj;
120
    }
121

  
122
    public void setProjection(IProjection p) {
123
        proj = p;
124
    }
125

  
126
    public void reProject(ICoordTrans rp) {
127
        // TODO metodo reProject pendiente de implementar
128
    }
129

  
130
    public Point2D getTL() {
131
        return tl;
132
    }
133

  
134
    public void setTL(Point2D pt) {
135
        tl = pt;
136
        extent.add(pt);
137
    }
138

  
139
    public Point2D getTR() {
140
        return tr;
141
    }
142

  
143
    public void setTR(Point2D pt) {
144
        tr = pt;
145
        extent.add(pt);
146
    }
147

  
148
    public Point2D getBL() {
149
        return bl;
150
    }
151

  
152
    public void setBL(Point2D pt) {
153
        bl = pt;
154
        extent.add(pt);
155
    }
156

  
157
    public Point2D getBR() {
158
        return br;
159
    }
160

  
161
    public void setBR(Point2D pt) {
162
        br = pt;
163
        extent.add(pt);
164
    }
165

  
166
    public Extent getExtent() {
167
        return extent;
168
    }
169

  
170
    private void setExtent() {
171
        extent = new Extent(tl, br);
172
        extent.add(tr);
173
        extent.add(bl);
174
    }
175

  
176
    public String getCode() {
177
        return code;
178
    }
179

  
180
    public String getName() {
181
        return name;
182
    }
183

  
184
    public Point2D[] getVertex() {
185
        Point2D[] v = { tl, tr, br, bl };
186

  
187
        return v;
188
    }
189

  
190
    public void toXml(OutputStream os) {
191
    }
192

  
193
    public void fromXml(InputStream is) {
194
    }
195
}
0 196

  
tags/v2_0_0_Build_2026/libDXF/src/org/gvsig/dxf/geo/Point3D.java
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.geo;
25

  
26
import java.awt.geom.Point2D;
27

  
28

  
29
/**
30
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
31
 */
32
public class Point3D extends Point2D {
33
    public double X;
34
    public double Y;
35
    public double Z;
36

  
37
    public Point3D() {
38
        setLocation(0.0, 0.0);
39
    }
40

  
41
    public Point3D(double x, double y) {
42
        setLocation(x, y);
43
    }
44

  
45
    public Point3D(double x, double y, double z) {
46
        setLocation(x, y, z);
47
    }
48

  
49
    public Point3D(Point2D pt) {
50
        setLocation(pt.getX(), pt.getY());
51
    }
52

  
53
    public Point3D(Point3D pt) {
54
        setLocation(pt.getX(), pt.getY(), pt.getZ());
55
    }
56

  
57
    public double getX() {
58
        return X;
59
    }
60

  
61
    public double getY() {
62
        return Y;
63
    }
64

  
65
    public double getZ() {
66
        return Z;
67
    }
68

  
69
    public void setLocation(double x, double y) {
70
        X = x;
71
        Y = y;
72
        Z = 0D;
73
    }
74

  
75
    public void setLocation(double x, double y, double z) {
76
        X = x;
77
        Y = y;
78
        Z = z;
79
    }
80

  
81
    public String toString() {
82
        return "(" + getX() + "," + getY() + ")";
83
    }
84
}
0 85

  
tags/v2_0_0_Build_2026/libDXF/src/org/gvsig/dxf/io/DxfFile.java
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.io;
25

  
26
import java.io.BufferedReader;
27
import java.io.FileReader;
28
import java.io.FileWriter;
29
import java.io.IOException;
30
import java.io.InputStream;
31
import java.io.InputStreamReader;
32
import java.io.Reader;
33
import java.util.Date;
34
import java.util.Hashtable;
35
import java.util.Vector;
36

  
37
import org.cresques.cts.ICoordTrans;
38
import org.cresques.cts.IProjection;
39
import org.cresques.geo.Projected;
40
import org.cresques.px.Extent;
41
import org.gvsig.dxf.px.IObjList;
42
import org.gvsig.dxf.px.dxf.DxfEntityMaker;
43
import org.gvsig.dxf.px.dxf.DxfHeaderManager;
44
import org.gvsig.dxf.px.dxf.DxfHeaderVariables;
45

  
46
/**
47
 * Clase que representa un fichero en formato DXF. Contiene los interfaces y m?todos
48
 * necesarios para acceder a la informaci?n almacenada en su interior.
49
 *
50
 * @author jmorell
51
 */
52
public class DxfFile extends GeoFile {
53

  
54
	private boolean cadFlag = true;
55

  
56
	long lineNr = 0;
57

  
58
	String buf = null;
59

  
60
	BufferedReader fi;
61
	long l = 0;
62
	int count = 0;
63
	DxfGroup grp = null;
64

  
65
	EntityFactory entityMaker = null;
66
	VarSettings headerManager;
67
    private boolean dxf3DFlag;
68

  
69
	/**
70
	 * Crea los objetos en el Modelo correspondiente.
71
	 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
72
	 */
73
	public interface EntityFactory extends Projected {
74

  
75
		/**
76
         * Permite saber si se est?n a?adiendo elementos a un bloque
77
         * @param booleano que indica si se est?n a?adiendo elementos a un bloque
78
		 */
79
        public void setAddingToBlock(boolean a);
80

  
81
        /**
82
         * Crea una nueva capa partiendo de la informaci?n almacenada en el DXF
83
         * @param DxfGroupVector con informaci?n para la construcci?n de la nueva capa
84
         * @throws Exception
85
         */
86
		public void createLayer(DxfGroupVector v) throws Exception ;
87

  
88
        /**
89
         * Crea una nueva polil?nea partiendo de la informaci?n almacenada en el DXF
90
         * @param DxfGroupVector con informaci?n para la construcci?n de la nueva polil?nea
91
         * @throws Exception
92
         */
93
		public void createPolyline(DxfGroupVector v) throws Exception ;
94

  
95
        /**
96
         * A?ade un v?rtice a la polil?nea que se est? creando
97
         * @param DxfGroupVector con la informaci?n necesaria para la adici?n del v?rtice
98
         * @throws Exception
99
         */
100
		public void addVertex(DxfGroupVector v) throws Exception ;
101

  
102
        /**
103
         * Fin de secuencia
104
         * @throws Exception
105
         */
106
        public void endSeq() throws Exception ;
107

  
108
        /**
109
         * Crea una nueva LwPolyline partiendo de la informaci?n almacenada en el DXF
110
         * @param DxfGroupVector con informaci?n para la construcci?n de la nueva polil?nea
111
         * @throws Exception
112
         */
113
		public void createLwPolyline(DxfGroupVector v) throws Exception ;
114

  
115
        /**
116
         * Crea una nueva l?nea partiendo de la informaci?n almacenada en el DXF
117
         * @param DxfGroupVector con informaci?n para la construcci?n de la nueva l?nea
118
         * @throws Exception
119
         */
120
        public void createLine(DxfGroupVector v) throws Exception ;
121

  
122
        /**
123
         * Crea un nuevo texto partiendo de la informaci?n almacenada en el DXF
124
         * @param DxfGroupVector con informaci?n para la construcci?n del nuevo texto
125
         * @throws Exception
126
         */
127
        public void createText(DxfGroupVector v) throws Exception ;
128

  
129
        /**
130
         * Crea un nuevo MText partiendo de la informaci?n almacenada en el DXF
131
         * @param DxfGroupVector con informaci?n para la construcci?n del nuevo MText
132
         * @throws Exception
133
         */
134
        public void createMText(DxfGroupVector v) throws Exception ;
135

  
136
        /**
137
         * Crea un nuevo punto partiendo de la informaci?n almacenada en el DXF
138
         * @param DxfGroupVector con informaci?n para la construcci?n del nuevo punto
139
         * @throws Exception
140
         */
141
        public void createPoint(DxfGroupVector v) throws Exception ;
142

  
143
        /**
144
         * Crea un nuevo c?rculo partiendo de la informaci?n almacenada en el DXF
145
         * @param DxfGroupVector con informaci?n para la construcci?n del nuevo c?rculo
146
         * @throws Exception
147
         */
148
        public void createCircle(DxfGroupVector v) throws Exception ;
149

  
150
        /**
151
         * Crea una nueva elipse partiendo de la informaci?n almacenada en el DXF
152
         * @param DxfGroupVector con informaci?n para la construcci?n de la nueva elipse
153
         * @throws Exception
154
         */
155
        public void createEllipse(DxfGroupVector v) throws Exception ;
156

  
157
        /**
158
         * Crea un nuevo arco partiendo de la informaci?n almacenada en el DXF
159
         * @param DxfGroupVector con informaci?n para la construcci?n del nuevo arco
160
         * @throws Exception
161
         */
162
        public void createArc(DxfGroupVector v) throws Exception ;
163

  
164
        /**
165
         * Crea un nuevo punto de inserci?n partiendo de la informaci?n almacenada en el DXF
166
         * @param DxfGroupVector con informaci?n para la construcci?n del nuevo punto de inserci?n
167
         * @throws Exception
168
         */
169
        public void createInsert(DxfGroupVector v) throws Exception ;
170

  
171
        /**
172
         * Crea un nuevo s?lido 2D partiendo de la informaci?n almacenada en el DXF
173
         * @param DxfGroupVector con informaci?n para la construcci?n del nuevo s?lido
174
         * @throws Exception
175
         */
176
        public void createSolid(DxfGroupVector v) throws Exception ;
177

  
178
        /**
179
         * Crea un nuevo Spline partiendo de la informaci?n almacenada en el DXF
180
         * @param DxfGroupVector con informaci?n para la construcci?n del nuevo Spline
181
         * @throws Exception
182
         */
183
        public void createSpline(DxfGroupVector v) throws Exception ;
184

  
185
        /**
186
         * Construye la definici?n de un nuevo atributo partiendo de la informaci?n almacenada en el DXF
187
         * @param DxfGroupVector con informaci?n para la construcci?n de la definici?n del nuevo atributo
188
         * @throws Exception
189
         */
190
        public void createAttdef(DxfGroupVector v) throws Exception ;
191

  
192
        /**
193
         * Crea un nuevo atributo partiendo de la informaci?n almacenada en el DXF
194
         * @param DxfGroupVector con informaci?n para la creaci?n del nuevo atributo
195
         * @throws Exception
196
         */
197
        public void createAttrib(DxfGroupVector v) throws Exception ;
198

  
199
        /**
200
         * Crea un bloque
201
         * @param DxfGroupVector con informaci?n para la creaci?n del nuevo elemento
202
         * @throws Exception
203
         */
204
        public void createBlock(DxfGroupVector v) throws Exception ;
205

  
206
        /**
207
         * Fin de la definici?n de un bloqe
208
         * @param DxfGroupVector con informaci?n referente al final de un bloque
209
         * @throws Exception
210
         */
211
        public void endBlk(DxfGroupVector v) throws Exception ;
212

  
213
        /**
214
         * Gestiona los bloques que no se han tratado en la primera vuelta
215
         */
216
        void testBlocks();
217

  
218
        /**
219
         * Devuelve el extent
220
         * @return el extent
221
         */
222
        public Extent getExtent();
223

  
224
        /**
225
         * Devuelve la lista de bloques
226
         * @return la lista de bloques
227
         */
228
        public Vector getBlkList();
229

  
230
		/**
231
         * Permite la gesti?n de los atributos almacenados en unn DXF
232
         * @return un Vector con la lista de atributos
233
		 */
234
        public Vector getAttributes();
235

  
236
        /**
237
         * Borra los atributos repetidos
238
         */
239
        public void depureAttributes();
240

  
241
        /**
242
         * Devuelve los objetos almacenados en el DXF
243
         * @return IObjList con los objetos procedentes del DXF
244
         */
245
        public IObjList getObjects();
246

  
247
        /**
248
         * Permite saber si se trata de un fichero DXF en 2D o en 3D
249
         * @return booleano que indica si se trata de un fichero DXF 3D
250
         */
251
        public boolean isDxf3DFile();
252
	};
253

  
254
	/**
255
	 * Establece el estado de las variables propias de un DXF que est?n definidas
256
	 * en la secci?n HEADER. Por ejemplo, la versi?n del DXF.
257
	 * @author jmorell (jose.morell@gmail.com)
258
	 * @version 15-dic-2004
259
	 */
260
	public interface VarSettings {
261

  
262
		/**
263
		 * Establece la versi?n de Autocad en la que fue generado el DXF.
264
		 * @param informaci?n de base
265
		 * @throws Exception
266
		 */
267
		public void setAcadVersion(DxfGroupVector v) throws Exception ;
268

  
269
		/**
270
		 * Devuelve la versi?n de Autocad en la que fue generado el DXF.
271
		 * @return
272
		 */
273
		public String getAcadVersion();
274

  
275
		/**
276
		 * Devuelve el estado de las variables propias de un DXF
277
		 * @return
278
		 */
279
		public DxfHeaderVariables getDxfHeaderVars();
280
        public boolean isWritedDxf3D();
281
        public void loadMinZFromHeader(double d);
282
        public void loadMaxZFromHeader(double d);
283
	};
284

  
285
    /**
286
     * Constructor de la clase
287
     * @param proj, la proyecci?n cartogr?fica
288
     * @param name, el path absoluto hasta el fichero DXF
289
     * @param maker, el interface que permite la construcci?n de las entidades procedentes del DXF
290
     */
291
	public DxfFile(IProjection proj, String name, EntityFactory maker) {
292
		super(proj, name);
293
		entityMaker = maker;
294
		headerManager = new DxfHeaderManager();
295
	}
296

  
297
    /**
298
     * Constructor de la clase que adem?s incorpora la capacidad de leer una porci?n del HEADER
299
     * @param proj, la proyecci?n cartogr?fica
300
     * @param name, el path absoluto hasta el fichero DXF
301
     * @param maker, el interface que permite la construcci?n de las entidades procedentes del DXF
302
     * @param dxfVars, el interface que permite la lectura del HEADER de un DXF
303
     */
304
    public DxfFile(IProjection proj, String name, EntityFactory maker, VarSettings dxfVars) {
305
		super(proj, name);
306
		entityMaker = maker;
307
		headerManager = dxfVars;
308
	}
309

  
310
	/**
311
	 * Carga un fichero en formato DXF
312
	 * @throws Exception
313
	 */
314
	public GeoFile load() throws Exception {
315
		System.out.println("Dxf: Cargando " + name + " ...");
316
		if (ZipFileFolder.isUrl(name)) {
317
			ZipFileFolder zFolder = new ZipFileFolder(name);
318
			InputStream is = zFolder.getInputStream(name);
319
			return load(new InputStreamReader(is));
320
		} else
321
			return load(new FileReader(name));
322

  
323
	}
324

  
325
    /**
326
     * Carga un fichero en formato DXF tomando un Reader como par?metro
327
     * @param fr, Reader que se le pasa como par?metro
328
     * @return devuelve un objeto GeoFile, padre de DxfFile
329
     * @throws Exception
330
     * @throws Exception
331
     */
332
	public GeoFile load(Reader fr) throws Exception {
333
		System.out.println("Dxf: Cargando '"+name+"' ...");
334
		fi = new BufferedReader(fr);
335
		while ((grp = readGrp()) != null) {
336
			l+=2;
337

  
338
			if (grp.equals(0, "EOF"))		break;
339
			if (grp.equals(0, "SECTION"))
340
				readSection();
341
		}
342
		fi.close();
343
		extent.add(entityMaker.getExtent());
344
		System.out.println("Dxf: '"+name+"' cargado. ("+l+" l?neas).");
345
		this.lineNr = l;
346
		return this;
347
	}
348

  
349
    /**
350
     * El fichero DXF se divide en grupos. Este m?todo permite leer cada grupo individualmente
351
     * @return devuelve la informaci?n del DXF en forma de objetos de la clase DxfGroup
352
     * @throws NumberFormatException
353
     * @throws IOException
354
     */
355
	private DxfGroup readGrp() throws NumberFormatException, IOException {
356
		DxfGroup g = DxfGroup.read(fi);
357
		if (g != null) l += 2;
358
		/*if (g.code == 8)
359
			if (((String) g.data).length() < 1) {
360
				System.err.println("a que un layer no puede ser ''?");
361
				System.exit(1);
362
			}*/
363
		return g;
364
	}
365

  
366
    /**
367
     * El fichero DXF se divide en varias secciones. Este m?todo se encarga de leer cada
368
     * una de ellas
369
     * @throws NumberFormatException
370
     * @throws Exception
371
     */
372
	private void readSection() throws NumberFormatException, Exception {
373
		while (true) {
374
			grp = readGrp(); System.out.print("-1:"+grp);
375
			if (grp.code == 2)
376
				if (((String) grp.data).compareTo("HEADER") == 0)
377
					readHeader();
378
				else if (((String) grp.data).compareTo("CLASSES") == 0)
379
					readAnySection();
380
				else if (((String) grp.data).compareTo("TABLES") == 0)
381
					readTables();
382
				else if (((String) grp.data).compareTo("BLOCKS") == 0)
383
					readBlocks();
384
				else if (((String) grp.data).compareTo("ENTITIES") == 0)
385
					readEntities();
386
				else if (((String) grp.data).compareTo("OBJECTS") == 0)
387
					readAnySection();
388
				else {
389
					System.out.println("DxfRead: Seccion "+grp.data);
390
					readAnySection();
391
				}
392
			else
393
				System.err.println("Dxf: Codigo/Seccion desconocidos" + grp);
394
			if (grp.equals(0, "EOF")) break;
395
			if (grp.equals(0, "ENDSEC")) break;
396
		}
397
	}
398

  
399
    /**
400
     * Habilita la lectura de la secci?n de TABLES
401
     * @throws NumberFormatException
402
     * @throws Exception
403
     */
404
	private void readTables() throws NumberFormatException, Exception {
405
		System.out.println("Dxf: Seccion TABLAS, linea "+ l+ "grp ="+ grp);
406
		int layerCnt = 0;
407
		String tableAct = "NONAME";
408

  
409
		Hashtable tables = new Hashtable();
410
		Vector table = new Vector();
411
		DxfGroupVector v = new DxfGroupVector();
412

  
413
		grp = readGrp();// System.out.print("0:"+grp);
414
		while (true) {
415
			if (grp.code == 0) {
416
				String data = (String) grp.getData();
417
				if (data.compareTo("ENDSEC") == 0 || data.compareTo("EOF") == 0)
418
					break;
419
				else if (data.compareTo("ENDTAB") == 0) {
420
					tables.put(tableAct, table);
421
					table = new Vector();
422
					grp = readGrp();// System.out.print("1:"+grp);
423

  
424
					/**/if (tableAct.compareTo("LAYER") == 0 && v.size()>0) {
425
						entityMaker.createLayer(v);
426
						System.out.println("Dxf: Layer "+v.getDataAsString(2));
427
						layerCnt++;
428
						v.clear();
429
					}/**/
430
					continue;
431
				} else {
432
					if (table.size()==1) {
433
						tableAct = v.getDataAsString(2);
434
						System.out.println("Dxf: Tabla "+tableAct);
435
					} else
436
						if (tableAct.compareTo("LAYER") == 0 && v.size()>0) {
437
							entityMaker.createLayer(v);
438
							System.out.println("Dxf: Layer "+v.getDataAsString(2));
439
							layerCnt++;
440
						}
441

  
442
					v.clear();
443
					v.add(grp);
444
				}
445
				while (true) {
446
					grp = readGrp();// System.out.print("2:"+grp);
447
					if (grp.code == 0)	break;
448
					v.add(grp);
449
				}
450
				table.add(v);
451
			} else {
452
				System.err.println("Dxf: Error de secuencia");
453
				grp = readGrp(); //System.out.print("3:"+grp);
454
			}
455
		}
456
		System.out.println("Dxf: Seccion TABLAS: " + layerCnt + " Capas. ");
457
	}
458

  
459
    /**
460
     * M?todo de lectura de secci?n por defecto. Se utiliza mientras se realiza la
461
     * implementaci?n correspondiente
462
     * @throws NumberFormatException
463
     * @throws IOException
464
     */
465
	private void readAnySection() throws NumberFormatException, IOException {
466
		System.out.println("Dxf: Seccion '"+((String) grp.getData())+"', linea "+ l);
467
		while (true) {
468
			grp = readGrp();
469
			if (grp.equals(0, "ENDSEC")) break;
470
			else if (grp.equals(0, "EOF")) break;
471
		}
472
	}
473

  
474
	/**
475
	 * Primera aproximaci?n a la implementaci?n de la lectura del HEADER. En principio
476
	 * interesa que se lea la versi?n del DXF.
477
	 * Para implementar esta parte del lector se ha optado por incluir el m?todo
478
	 * setAcadVersion en el interface EntityFactory. A lo mejor conviene implementar
479
	 * un nuevo interface VarSettings.
480
	 * @throws NumberFormatException
481
	 * @throws Exception
482
	 */
483
	private void readHeader() throws NumberFormatException, Exception {
484
		System.out.println("Dxf: Seccion HEADER, linea "+ l);
485
		int variableCnt = 0;
486
		int cntVeces = 0;
487
		DxfGroupVector v = new DxfGroupVector();
488
		grp = readGrp();
489
		while (true) {
490
			if (grp.equals(0, "EOF")) {
491
				break;
492
			}
493
			else if (grp.code==9 || grp.code==0) {
494
				if (v.size() > 0) {
495
					String lastVariable = (String) ((DxfGroup) v.get(0)).data;
496
					//System.out.println(lastVariable);
497
					if (lastVariable.compareTo("$ACADVER") == 0) {
498
						//System.out.println("Aqui llega.");
499
						headerManager.setAcadVersion(v);
500
					} else if (lastVariable.compareTo("$EXTMIN") == 0) {
501
						if(v.hasCode(3))
502
							headerManager.loadMinZFromHeader(((Double)((DxfGroup) v.get(3)).data).doubleValue());
503
                    } else if (lastVariable.compareTo("$EXTMAX") == 0) {
504
                    	if(v.hasCode(3))
505
                    		headerManager.loadMaxZFromHeader(((Double)((DxfGroup) v.get(3)).data).doubleValue());
506
                    } else if (lastVariable.compareTo("ENDSEC") == 0) {
507
                        //System.out.println("Llega al ENDSEC.");
508
                        break;
509
					} /*else
510
						System.err.println("Dxf: Variable "+lastVariable+" desconocida.");*/
511
				}
512
				v.clear();
513
				v.add(grp);
514
				while (true) {
515
					grp = readGrp();
516
					if (grp.code == 9 || grp.code==0)	break;
517
					v.add(grp);
518
				}
519
				variableCnt++;
520
			}
521
			cntVeces++;
522
		}
523
		System.out.println("Dxf: Seccion HEADER, " + variableCnt + " variables, "+ cntVeces + " veces.");
524
		//System.out.println("Seccion HEADER, linea "+ l+ " (SALGO)");
525
		System.out.println("readHeader: ACAD Version: " + headerManager.getDxfHeaderVars().getAcadVersion());
526
	}
527

  
528
    /**
529
     * Permite leer la secci?n ENTITIES del DXF, donde se encuentran las entidades
530
     * geom?tricas del DXF que no aparecen dentro de ning?n bloque
531
     * @throws NumberFormatException
532
     * @throws Exception
533
     */
534
	private void readEntities() throws NumberFormatException, Exception {
535
		System.out.println("Dxf: Seccion ENTITIES, linea "+ l);
536
		int entityCnt = 0;
537
		int cntVeces = 0;
538
		DxfGroupVector v = new DxfGroupVector();
539
		grp = readGrp();
540
		while (true) {
541
			if (grp.equals(0, "EOF")) break;
542
			else if (grp.code == 0) {
543
				if (v.size() > 0) {
544
					String lastEntity = (String) ((DxfGroup) v.get(0)).data;
545
					if (lastEntity.compareTo("POLYLINE") == 0) {
546
						entityMaker.createPolyline(v);
547
					} else if (lastEntity.compareTo("VERTEX") == 0) {
548
						entityMaker.addVertex(v);
549
					} else if (lastEntity.compareTo("SEQEND") == 0) {
550
						entityMaker.endSeq();
551
					} else if (lastEntity.compareTo("LWPOLYLINE") == 0) {
552
						entityMaker.createLwPolyline(v);
553
					} else if (lastEntity.compareTo("LINE") == 0) {
554
						entityMaker.createLine(v);
555
					} else if (lastEntity.compareTo("TEXT") == 0) {
556
						entityMaker.createText(v);
557
					} else if (lastEntity.compareTo("MTEXT") == 0) {
558
						entityMaker.createMText(v);
559
					} else if (lastEntity.compareTo("POINT") == 0) {
560
						entityMaker.createPoint(v);
561
					} else if (lastEntity.compareTo("CIRCLE") == 0) {
562
						entityMaker.createCircle(v);
563
					} else if (lastEntity.compareTo("ELLIPSE") == 0) {
564
						entityMaker.createEllipse(v);
565
					} else if (lastEntity.compareTo("ARC") == 0) {
566
						entityMaker.createArc(v);
567
					} else if (lastEntity.compareTo("INSERT") == 0) {
568
						entityMaker.createInsert(v);
569
					} else if (lastEntity.compareTo("SOLID") == 0) {
570
						entityMaker.createSolid(v);
571
					} else if (lastEntity.compareTo("SPLINE") == 0) {
572
						entityMaker.createSpline(v);
573
					} else if (lastEntity.compareTo("ATTRIB") == 0) {
574
						entityMaker.createAttrib(v);
575
					} else if (lastEntity.compareTo("ENDSEC") == 0) {
576
						break;
577
					} else
578
						System.err.println("Dxf: Entidad "+lastEntity+" desconocida.");
579
				}
580
				v.clear();
581
				v.add(grp);
582
				while (true) {
583
					grp = readGrp();
584
					if (grp.code == 0)	break;
585
					v.add(grp);
586
				}
587
				entityCnt++;
588
			}
589
			cntVeces++;
590
		}
591
		System.out.println("Dxf: Seccion ENTITIES, " + entityCnt + " entidades, "+ cntVeces + " veces.");
592
		//System.out.println("Seccion ENTITIES, linea "+ l+ " (SALGO)");
593
	}
594

  
595
    /**
596
     * Permite la secci?n BLOCKS del DXF, donde se encuentran las definiciones de los
597
     * bloques que componen el DXF
598
     * @throws NumberFormatException
599
     * @throws Exception
600
     */
601
	private void readBlocks() throws NumberFormatException, Exception {
602
		System.out.println("Dxf: Seccion BLOCKS, linea "+ l);
603
		int blkCnt = 0;
604
		int cntVeces = 0;
605
		DxfGroupVector v = new DxfGroupVector();
606
		grp = readGrp();
607
		while (true) {
608
			if (grp.equals(0, "EOF")) break;
609
			else if (grp.code == 0) {
610
				if (v.size() > 0) {
611
					String lastEntity = (String) ((DxfGroup) v.get(0)).data;
612
					if (lastEntity.compareTo("BLOCK") == 0) {
613
						//System.out.println("readBlocks(): Empezamos a leer un bloque");
614
						entityMaker.createBlock(v);
615
					} else if (lastEntity.compareTo("POLYLINE") == 0) {
616
						//System.out.println("readBlocks(): A?adimos una polilinea al bloque");
617
						entityMaker.createPolyline(v);
618
					} else if (lastEntity.compareTo("VERTEX") == 0) {
619
						//System.out.println("readBlocks(): A?adimos un vertice a la polilinea");
620
						entityMaker.addVertex(v);
621
					} else if (lastEntity.compareTo("SEQEND") == 0) {
622
						//System.out.println("readBlocks(): Cerramos una polilinea");
623
						entityMaker.endSeq();
624
					} else if (lastEntity.compareTo("LWPOLYLINE") == 0) {
625
						//System.out.println("readBlocks(): A?adimos una lwpolilinea al bloque");
626
						entityMaker.createLwPolyline(v);
627
					} else if (lastEntity.compareTo("LINE") == 0) {
628
						//System.out.println("readBlocks(): A?adimos una linea al bloque");
629
						entityMaker.createLine(v);
630
					} else if (lastEntity.compareTo("TEXT") == 0) {
631
						//System.out.println("readBlocks(): A?adimos un texto al bloque");
632
						entityMaker.createText(v);
633
					} else if (lastEntity.compareTo("MTEXT") == 0) {
634
						//System.out.println("readBlocks(): A?adimos un m-texto al bloque");
635
						entityMaker.createMText(v);
636
					} else if (lastEntity.compareTo("POINT") == 0) {
637
						//System.out.println("readBlocks(): A?adimos un punto al bloque");
638
						entityMaker.createPoint(v);
639
					} else if (lastEntity.compareTo("CIRCLE") == 0) {
640
						//System.out.println("readBlocks(): A?adimos un circulo al bloque");
641
						entityMaker.createCircle(v);
642
					} else if (lastEntity.compareTo("ARC") == 0) {
643
						//System.out.println("readBlocks(): A?adimos un arco al bloque");
644
						entityMaker.createArc(v);
645
					} else if (lastEntity.compareTo("INSERT") == 0) {
646
						//System.out.println("readBlocks(): A?adimos un insert al bloque");
647
						entityMaker.createInsert(v);
648
					} else if (lastEntity.compareTo("SOLID") == 0) {
649
						//System.out.println("readBlocks(): A?adimos un solido al bloque");
650
						entityMaker.createSolid(v);
651
					} else if (lastEntity.compareTo("SPLINE") == 0) {
652
						entityMaker.createSpline(v);
653
					} else if (lastEntity.compareTo("ATTDEF") == 0) {
654
						entityMaker.createAttdef(v);
655
					} else if (lastEntity.compareTo("ENDBLK") == 0) {
656
						//System.out.println("readBlocks(): Cerramos un bloque"+v);
657
						entityMaker.endBlk(v);
658
					} else if (lastEntity.compareTo("ENDSEC") == 0) {
659
						break;
660
					} else
661
						System.err.println("Dxf: Entidad de bloque "+lastEntity+" desconocida.");
662
				}
663
				v.clear();
664
				v.add(grp);
665
				while (true) {
666
					grp = readGrp();
667
					if (grp.code == 0)	break;
668
					v.add(grp);
669
				}
670
				blkCnt++;
671
			}
672
			cntVeces++;
673
		}
674

  
675
		entityMaker.testBlocks();
676
		// Cuando termina de leer la secci?n de bloques se asegura de que todos los campos
677
		// son distintos.
678
		//System.out.println("readBlocks(): entityMaker.getAttributes().size() = " + entityMaker.getAttributes().size());
679
		entityMaker.depureAttributes();
680
		//System.out.println("readBlocks(): entityMaker.getAttributes().size() = " + entityMaker.getAttributes().size());
681
		System.out.println("Dxf: Seccion BLOCKS, " + blkCnt + " elementos de bloque. "+ cntVeces + " veces.");
682
	}
683

  
684
    /**
685
     * Devuelve los objetos geom?tricos obtenidos de un DXF
686
     */
687
	public IObjList getObjects() {
688
		return this.entityMaker.getObjects();
689
	}
690

  
691
	/**
692
	 * jmorell: M?todo que permite salvar capas al formato DXF2000.
693
	 * Este m?todo ha sido actualizado en el proceso de implementaci?n del piloto
694
	 * de CAD. En este piloto deb?a existir soporte para elipses, y este es uno de
695
	 * los motivos que nos llevan a implementar ahora para DXF2000, puesto que el
696
	 * DXF R12 no soporta elipses.
697
	 * @param fName
698
	 * @throws IOException
699
	 */
700
	public void save(String fName) throws IOException {
701
		System.out.println("save: fName = " + fName);
702
		long t2, t1;
703
		t1 = getTime();
704
		fName = DataSource.normalize(fName);
705
		FileWriter fw = new FileWriter(fName);
706
		// COMMENTAIRES DU TRADUCTEUR
707
//		fw.write(DxfGroup.toString(999, Integer.toString(features.size()) + " features"));
708
		fw.write(DxfGroup.toString(999, "TRANSLATION BY geo.cresques.io.DxfFile"));
709
		fw.write(DxfGroup.toString(999, "DATE : " + (new Date()).toString()));
710
		writeHeader(fw);
711
		writeTables(fw);
712
		writeBlocks(fw);
713
		writeEntities(fw);
714
		writeObjects(fw);
715
		fw.write(DxfGroup.toString(0, "EOF"));
716
		fw.flush();
717
		fw.close();
718
		t2 = getTime();
719
		System.out.println("DxfFile.save(): Tiempo salvando: " + (t2-t1)/1000 + " seg.");
720
	}
721

  
722
	/**
723
	 * Escritor de la cabecera de un DXF.
724
	 * jmorell: Actualizaci?n del escritor de DXF de R12 a 2000.
725
	 * @param fw, un FileWriter para escribir ficheros
726
	 * @throws IOException
727
	 */
728
	public void writeHeader(FileWriter fw) throws IOException {
729
		fw.write(DxfGroup.toString(0, "SECTION"));
730
		fw.write(DxfGroup.toString(2, "HEADER"));
731
		fw.write(DxfGroup.toString(9, "$ACADVER"));
732
			//fw.write(DxfGroup.toString(1, "AC1009"));			// DXF R12
733
			fw.write(DxfGroup.toString(1, "AC1015"));			// DXF 2000
734
		fw.write(DxfGroup.toString(9, "$INSBASE"));
735
			fw.write(DxfGroup.toString(10, 0.0, 1));
736
			fw.write(DxfGroup.toString(20, 0.0, 1));
737
			fw.write(DxfGroup.toString(30, 0.0, 1));
738
		fw.write(DxfGroup.toString(9, "$EXTMIN"));
739
			fw.write(DxfGroup.toString(10, extent.minX(), 6));
740
			fw.write(DxfGroup.toString(20, extent.minY(), 6));
741
			if (dxf3DFlag) fw.write(DxfGroup.toString(30, extent.minX(), 6));
742
            else fw.write(DxfGroup.toString(30, 0.0, 6));
743
		fw.write(DxfGroup.toString(9, "$EXTMAX"));
744
			fw.write(DxfGroup.toString(10, extent.maxX(), 6));
745
			fw.write(DxfGroup.toString(20, extent.maxY(), 6));
746
            if (dxf3DFlag) fw.write(DxfGroup.toString(30, extent.maxX(), 6));
747
            else fw.write(DxfGroup.toString(30, 0.0, 6));
748
		fw.write(DxfGroup.toString(9, "$LIMMIN"));
749
			fw.write(DxfGroup.toString(10, extent.minX(), 6));
750
			fw.write(DxfGroup.toString(20, extent.minY(), 6));
751
		fw.write(DxfGroup.toString(9, "$LIMMAX"));
752
			fw.write(DxfGroup.toString(10, extent.maxX(), 6));
753
			fw.write(DxfGroup.toString(20, extent.maxY(), 6));
754
		fw.write(DxfGroup.toString(9, "$ORTHOMODE")+DxfGroup.toString(70, 0));
755
		fw.write(DxfGroup.toString(9, "$REGENMODE")+DxfGroup.toString(70, 1));
756
		fw.write(DxfGroup.toString(9, "$FILLMODE")+	DxfGroup.toString(70, 1));
757
		fw.write(DxfGroup.toString(9, "$QTEXTMODE")+DxfGroup.toString(70, 0));
758
		fw.write(DxfGroup.toString(9, "$MIRRTEXT")+	DxfGroup.toString(70, 1));
759
		fw.write(DxfGroup.toString(9, "$DRAGMODE")+	DxfGroup.toString(70, 2));
760
		fw.write(DxfGroup.toString(9, "$LTSCALE")+	DxfGroup.toString(40, 1.0, 1));
761
		fw.write(DxfGroup.toString(9, "$OSMODE")+	DxfGroup.toString(70, 0));
762
		fw.write(DxfGroup.toString(9, "$ATTMODE")+	DxfGroup.toString(70, 1));
763
		fw.write(DxfGroup.toString(9, "$TEXTSIZE")+	DxfGroup.toString(40, 0.2, 1));
764
		fw.write(DxfGroup.toString(9, "$TRACEWID")+	DxfGroup.toString(40, 0.05, 2));
765
		fw.write(DxfGroup.toString(9, "$TEXTSTYLE")+	DxfGroup.toString(7, "STANDARD"));
766
		fw.write(DxfGroup.toString(9, "$CLAYER")+	DxfGroup.toString(8, "0"));
767
		fw.write(DxfGroup.toString(9, "$CELTYPE")+	DxfGroup.toString(6, "CONTINUOUS"));
768
		fw.write(DxfGroup.toString(9, "$CECOLOR")+	DxfGroup.toString(62, 256));
769
		fw.write(DxfGroup.toString(9, "$DIMSCALE")+	DxfGroup.toString(40, 1.0, 1));
770
		fw.write(DxfGroup.toString(9, "$DIMASZ")+	DxfGroup.toString(40, 0.18, 2));
771
		fw.write(DxfGroup.toString(9, "$DIMEXO")+	DxfGroup.toString(40, 0.0625, 4));
772
		fw.write(DxfGroup.toString(9, "$DIMDLI")+	DxfGroup.toString(40, 0.38, 2));
773
		fw.write(DxfGroup.toString(9, "$DIMRND")+	DxfGroup.toString(40, 0.0, 1));
774
		fw.write(DxfGroup.toString(9, "$DIMDLE")+	DxfGroup.toString(40, 0.0, 1));
775
		fw.write(DxfGroup.toString(9, "$DIMEXE")+	DxfGroup.toString(40, 0.18, 2));
776
		fw.write(DxfGroup.toString(9, "$DIMTP")+	DxfGroup.toString(40, 0.0, 1));
777
		fw.write(DxfGroup.toString(9, "$DIMTM")+	DxfGroup.toString(40, 0.0, 1));
778
		fw.write(DxfGroup.toString(9, "$DIMTXT")+	DxfGroup.toString(40, 0.18, 2));
779
		fw.write(DxfGroup.toString(9, "$DIMCEN")+	DxfGroup.toString(40, 0.09, 2));
780
		fw.write(DxfGroup.toString(9, "$DIMTSZ")+	DxfGroup.toString(40, 0.0, 1));
781
		fw.write(DxfGroup.toString(9,"$DIMTOL")+	DxfGroup.toString(70,0));
782
		fw.write(DxfGroup.toString(9,"$DIMLIM")+	DxfGroup.toString(70,0));
783
		fw.write(DxfGroup.toString(9,"$DIMTIH")+	DxfGroup.toString(70,1));
784
		fw.write(DxfGroup.toString(9,"$DIMTOH")+	DxfGroup.toString(70,1));
785
		fw.write(DxfGroup.toString(9,"$DIMSE1")+	DxfGroup.toString(70,0));
786
		fw.write(DxfGroup.toString(9,"$DIMSE2")+	DxfGroup.toString(70,0));
787
		fw.write(DxfGroup.toString(9,"$DIMTAD")+	DxfGroup.toString(70,0));
788
		fw.write(DxfGroup.toString(9,"$DIMZIN")+	DxfGroup.toString(70,0));
789
		fw.write(DxfGroup.toString(9,"$DIMBLK")+	DxfGroup.toString(1,""));
790
		fw.write(DxfGroup.toString(9,"$DIMASO")+	DxfGroup.toString(70,1));
791
		fw.write(DxfGroup.toString(9,"$DIMSHO")+	DxfGroup.toString(70,1));
792
		fw.write(DxfGroup.toString(9,"$DIMPOST")+	DxfGroup.toString(1,""));
793
		fw.write(DxfGroup.toString(9,"$DIMAPOST")+	DxfGroup.toString(1,""));
794
		fw.write(DxfGroup.toString(9,"$DIMALT")+	DxfGroup.toString(70,0));
795
		fw.write(DxfGroup.toString(9,"$DIMALTD")+	DxfGroup.toString(70,2));
796
		fw.write(DxfGroup.toString(9,"$DIMALTF")+	DxfGroup.toString(40,25.4,1));
797
		fw.write(DxfGroup.toString(9,"$DIMLFAC")+	DxfGroup.toString(40,1.0,1));
798
		fw.write(DxfGroup.toString(9,"$DIMTOFL")+	DxfGroup.toString(70,0));
799
		fw.write(DxfGroup.toString(9,"$DIMTVP")+	DxfGroup.toString(40,0.0,1));
800
		fw.write(DxfGroup.toString(9,"$DIMTIX")+	DxfGroup.toString(70,0));
801
		fw.write(DxfGroup.toString(9,"$DIMSOXD")+	DxfGroup.toString(70,0));
802
		fw.write(DxfGroup.toString(9,"$DIMSAH")+	DxfGroup.toString(70,0));
803
		fw.write(DxfGroup.toString(9,"$DIMBLK1")+	DxfGroup.toString(1,""));
804
		fw.write(DxfGroup.toString(9,"$DIMBLK2")+	DxfGroup.toString(1,""));
805
		fw.write(DxfGroup.toString(9,"$DIMSTYLE")+	DxfGroup.toString(2,"STANDARD"));
806
		fw.write(DxfGroup.toString(9,"$DIMCLRD")+	DxfGroup.toString(70,0));
807
		fw.write(DxfGroup.toString(9,"$DIMCLRE")+	DxfGroup.toString(70,0));
808
		fw.write(DxfGroup.toString(9,"$DIMCLRT")+	DxfGroup.toString(70,0));
809
		fw.write(DxfGroup.toString(9,"$DIMTFAC")+	DxfGroup.toString(40,1.0,1));
810
		fw.write(DxfGroup.toString(9,"$DIMGAP")+	DxfGroup.toString(40,0.09,2));
811
		fw.write(DxfGroup.toString(9,"$LUNITS")+	DxfGroup.toString(70,2));
812
		fw.write(DxfGroup.toString(9,"$LUPREC")+	DxfGroup.toString(70,4));
813
		fw.write(DxfGroup.toString(9,"$AXISMODE")+	DxfGroup.toString(70,0));
814
		fw.write(DxfGroup.toString(9,"$AXISUNIT"));
815
		fw.write(DxfGroup.toString(10,0.0,1));
816
		fw.write(DxfGroup.toString(20,0.0,1));
817
		fw.write(DxfGroup.toString(9,"$SKETCHINC")+	DxfGroup.toString(40,0.1,1));
818
		fw.write(DxfGroup.toString(9,"$FILLETRAD")+	DxfGroup.toString(40,0.0,1));
819
		fw.write(DxfGroup.toString(9,"$AUNITS")+	DxfGroup.toString(70,0));
820
		fw.write(DxfGroup.toString(9,"$AUPREC")+	DxfGroup.toString(70,0));
821
		fw.write(DxfGroup.toString(9,"$MENU")+		DxfGroup.toString(1,"acad"));
822
		fw.write(DxfGroup.toString(9,"$ELEVATION")+	DxfGroup.toString(40,0.0,1));
823
		fw.write(DxfGroup.toString(9,"$PELEVATION")+DxfGroup.toString(40,0.0,1));
824
		fw.write(DxfGroup.toString(9,"$THICKNESS")+	DxfGroup.toString(40,0.0,1));
825
		fw.write(DxfGroup.toString(9,"$LIMCHECK")+	DxfGroup.toString(70,0));
826
		fw.write(DxfGroup.toString(9,"$BLIPMODE")+	DxfGroup.toString(70,1));
827
		fw.write(DxfGroup.toString(9,"$CHAMFERA")+	DxfGroup.toString(40,0.0,1));
828
		fw.write(DxfGroup.toString(9,"$CHAMFERB")+	DxfGroup.toString(40,0.0,1));
829
		fw.write(DxfGroup.toString(9,"$SKPOLY")+	DxfGroup.toString(70,0));
830
		fw.write(DxfGroup.toString(9,"$TDCREATE")+	DxfGroup.toString(40,2453116.436828704,9));
831
		fw.write(DxfGroup.toString(9,"$TDUPDATE")+	DxfGroup.toString(40,2453116.436828704,9));
832
		fw.write(DxfGroup.toString(9,"$TDINDWG")+	DxfGroup.toString(40,0.0000000000,10));
833
		fw.write(DxfGroup.toString(9,"$TDUSRTIMER")+DxfGroup.toString(40,0.0000000000,10));
834
		fw.write(DxfGroup.toString(9,"$USRTIMER")+	DxfGroup.toString(70,1));
835
		fw.write(DxfGroup.toString(9,"$ANGBASE")+	DxfGroup.toString(50,0.0,1));
836
		fw.write(DxfGroup.toString(9,"$ANGDIR")+	DxfGroup.toString(70,0));
837
		fw.write(DxfGroup.toString(9,"$PDMODE")+	DxfGroup.toString(70,0));
838
		fw.write(DxfGroup.toString(9,"$PDSIZE")+	DxfGroup.toString(40,0.0,1));
839
		fw.write(DxfGroup.toString(9,"$PLINEWID")+	DxfGroup.toString(40,0.0,1));
840
		fw.write(DxfGroup.toString(9,"$COORDS")+	DxfGroup.toString(70,0));
841
		fw.write(DxfGroup.toString(9,"$SPLFRAME")+	DxfGroup.toString(70,0));
842
		fw.write(DxfGroup.toString(9,"$SPLINETYPE")+DxfGroup.toString(70,6));
843
		fw.write(DxfGroup.toString(9,"$SPLINESEGS")+DxfGroup.toString(70,10));
844
		fw.write(DxfGroup.toString(9,"$ATTDIA")+	DxfGroup.toString(70,0));
845
		fw.write(DxfGroup.toString(9,"$ATTREQ")+	DxfGroup.toString(70,1));
846
		fw.write(DxfGroup.toString(9,"$HANDLING")+	DxfGroup.toString(70,1));
847
		fw.write(DxfGroup.toString(9,"$HANDSEED")+	DxfGroup.toString(5,"394B"));
848
		fw.write(DxfGroup.toString(9,"$SURFTAB1")+	DxfGroup.toString(70,6));
849
		fw.write(DxfGroup.toString(9,"$SURFTAB2")+	DxfGroup.toString(70,6));
850
		fw.write(DxfGroup.toString(9,"$SURFTYPE")+	DxfGroup.toString(70,6));
851
		fw.write(DxfGroup.toString(9,"$SURFU")+		DxfGroup.toString(70,6));
852
		fw.write(DxfGroup.toString(9,"$SURFV")+		DxfGroup.toString(70,6));
853
		fw.write(DxfGroup.toString(9,"$UCSNAME")+	DxfGroup.toString(2,""));
854
		fw.write(DxfGroup.toString(9,"$UCSORG"));
855
		fw.write(DxfGroup.toString(10,0.0,1));
856
		fw.write(DxfGroup.toString(20,0.0,1));
857
		fw.write(DxfGroup.toString(30,0.0,1));
858
		fw.write(DxfGroup.toString(9,"$UCSXDIR"));
859
		fw.write(DxfGroup.toString(10,1.0,1));
860
		fw.write(DxfGroup.toString(20,0.0,1));
861
		fw.write(DxfGroup.toString(30,0.0,1));
862
		fw.write(DxfGroup.toString(9,"$UCSYDIR"));
863
		fw.write(DxfGroup.toString(10,0.0,1));
864
		fw.write(DxfGroup.toString(20,1.0,1));
865
		fw.write(DxfGroup.toString(30,0.0,1));
866
		fw.write(DxfGroup.toString(9,"$PUCSNAME")+	DxfGroup.toString(2,""));
867
		fw.write(DxfGroup.toString(9,"$PUCSORG"));
868
		fw.write(DxfGroup.toString(10,0.0,1));
869
		fw.write(DxfGroup.toString(20,0.0,1));
870
		fw.write(DxfGroup.toString(30,0.0,1));
871
		fw.write(DxfGroup.toString(9,"$PUCSXDIR"));
872
		fw.write(DxfGroup.toString(10,1.0,1));
873
		fw.write(DxfGroup.toString(20,0.0,1));
874
		fw.write(DxfGroup.toString(30,0.0,1));
875
		fw.write(DxfGroup.toString(9,"$PUCSYDIR"));
876
		fw.write(DxfGroup.toString(10,0.0,1));
877
		fw.write(DxfGroup.toString(20,1.0,1));
878
		fw.write(DxfGroup.toString(30,0.0,1));
879
		fw.write(DxfGroup.toString(9,"$USERI1")+	DxfGroup.toString(70,0));
880
		fw.write(DxfGroup.toString(9,"$USERI2")+	DxfGroup.toString(70,0));
881
		fw.write(DxfGroup.toString(9,"$USERI3")+	DxfGroup.toString(70,0));
882
		fw.write(DxfGroup.toString(9,"$USERI4")+	DxfGroup.toString(70,0));
883
		fw.write(DxfGroup.toString(9,"$USERI5")+	DxfGroup.toString(70,0));
884
		fw.write(DxfGroup.toString(9,"$USERR1")+	DxfGroup.toString(40,0.0,1));
885
		fw.write(DxfGroup.toString(9,"$USERR2")+	DxfGroup.toString(40,0.0,1));
886
		fw.write(DxfGroup.toString(9,"$USERR3")+	DxfGroup.toString(40,0.0,1));
887
		fw.write(DxfGroup.toString(9,"$USERR4")+	DxfGroup.toString(40,0.0,1));
888
		fw.write(DxfGroup.toString(9,"$USERR5")+	DxfGroup.toString(40,0.0,1));
889
		fw.write(DxfGroup.toString(9,"$WORLDVIEW")+	DxfGroup.toString(70,1));
890
		fw.write(DxfGroup.toString(9,"$SHADEDGE")+	DxfGroup.toString(70,3));
891
		fw.write(DxfGroup.toString(9,"$SHADEDIF")+	DxfGroup.toString(70,70));
892
		fw.write(DxfGroup.toString(9,"$TILEMODE")+	DxfGroup.toString(70,1));
893
		fw.write(DxfGroup.toString(9,"$MAXACTVP")+	DxfGroup.toString(70,16));
894
		fw.write(DxfGroup.toString(9,"$PINSBASE"));
895
		fw.write(DxfGroup.toString(10,0.0,1));
896
		fw.write(DxfGroup.toString(20,0.0,1));
897
		fw.write(DxfGroup.toString(30,0.0,1));
898
		fw.write(DxfGroup.toString(9,"$PLIMCHECK")+	DxfGroup.toString(70,0));
899
		fw.write(DxfGroup.toString(9,"$PEXTMIN"));
900
		fw.write(DxfGroup.toString(10,"-1.000000E+20"));
901
		fw.write(DxfGroup.toString(20,"-1.000000E+20"));
902
		fw.write(DxfGroup.toString(30,"-1.000000E+20"));
903
		fw.write(DxfGroup.toString(9,"$PEXTMAX"));
904
		fw.write(DxfGroup.toString(10,"-1.000000E+20"));
905
		fw.write(DxfGroup.toString(20,"-1.000000E+20"));
906
		fw.write(DxfGroup.toString(30,"-1.000000E+20"));
907
		fw.write(DxfGroup.toString(9,"$PLIMMIN"));
908
		fw.write(DxfGroup.toString(10,0.0,1));
909
		fw.write(DxfGroup.toString(20,0.0,1));
910
		fw.write(DxfGroup.toString(9,"$PLIMMAX"));
911
		fw.write(DxfGroup.toString(10,12.0,1));
912
		fw.write(DxfGroup.toString(20,9.0,1));
913
		fw.write(DxfGroup.toString(9,"$UNITMODE")+	DxfGroup.toString(70,0));
914
		fw.write(DxfGroup.toString(9,"$VISRETAIN")+	DxfGroup.toString(70,0));
915
		fw.write(DxfGroup.toString(9,"$PLINEGEN")+	DxfGroup.toString(70,1));
916
		fw.write(DxfGroup.toString(9,"$PSLTSCALE")+	DxfGroup.toString(70,0));
917
		fw.write(DxfGroup.toString(9,"$TREEDEPTH")+	DxfGroup.toString(70,3020));
918
		fw.write(DxfGroup.toString(9,"$DWGCODEPAGE")+DxfGroup.toString(3,"ansi_1252"));
919
/*
920
		fw.write(DxfGroup.toString(9, "$ELEVATION"));
921
			fw.write(DxfGroup.toString(40, 0.0, 3));
922
		fw.write(DxfGroup.toString(9, "$LIMCHECK"));
923
			fw.write(DxfGroup.toString(70, 1));
924
		fw.write(DxfGroup.toString(9, "$LUNITS"));
925
			fw.write(DxfGroup.toString(70, 2));
926
		fw.write(DxfGroup.toString(9, "$LUPREC"));
927
			fw.write(DxfGroup.toString(70, 2));*/
928
		fw.write(DxfGroup.toString(0, "ENDSEC"));
929
	}
930

  
931
	/**
932
	 * Escritor de la secci?n TABLES de un DXF.
933
	 * @param fw, FileWriter
934
	 * @throws IOException
935
	 */
936
	public void writeTables(FileWriter fw) throws IOException {
937
		fw.write(DxfGroup.toString(0, "SECTION"));
938
		fw.write(DxfGroup.toString(2, "TABLES"));
939
		// esta tampoco.
940
		writeVPortTable(fw);
941
		writeLTypeTable(fw);
942
		writeLayerTable(fw);
943
		writeStyleTable(fw);
944
		// estas no son las provocan el pete.
945
		writeViewTable(fw);
946
		writeUCSTable(fw);
947
		// esta provoca el pete. Y si no se pone las tablas aparecen
948
		// incompletas y acad no abre el fichero ...
949
		writeAppidTable(fw);
950
		writeDimStyleTable(fw);
951
		// esta no provoca pete.
952
		writeBlockRecordTable(fw);
953
		fw.write(DxfGroup.toString(0, "ENDSEC"));
954
	}
955

  
956
	/**
957
	 * Escritor de la tabla VPORT.
958
	 * @param fw
959
	 * @throws IOException
960
	 */
961
	public void writeVPortTable(FileWriter fw) throws IOException {
962
		fw.write(DxfGroup.toString(0, "TABLE"));
963
		fw.write(DxfGroup.toString(2, "VPORT"));
964
		fw.write(DxfGroup.toString(5, 8));
965
		fw.write(DxfGroup.toString(100, "AcDbSymbolTable"));
966
		fw.write(DxfGroup.toString(70, 0));
967
		/*fw.write(DxfGroup.toString(70, 1));
968
		fw.write(DxfGroup.toString(0, "VPORT"));
969
		fw.write(DxfGroup.toString(5, 30));
970
		fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord"));
971
		fw.write(DxfGroup.toString(100, "AcDbViewportTableRecord"));
972
		fw.write(DxfGroup.toString(2, "*Active"));
973
		fw.write(DxfGroup.toString(70, 0));
974
		fw.write(DxfGroup.toString(10, 0.0, 4));
975
		fw.write(DxfGroup.toString(20, 0.0, 4));
976
		fw.write(DxfGroup.toString(11, 1.0, 4));
977
		fw.write(DxfGroup.toString(21, 1.0, 4));
978
		fw.write(DxfGroup.toString(12, 286.30555555555549, 10));
979
		fw.write(DxfGroup.toString(22, 148.5, 4));
980
		fw.write(DxfGroup.toString(13, 0.0, 4));
981
		fw.write(DxfGroup.toString(23, 0.0, 4));
982
		fw.write(DxfGroup.toString(14, 10.0, 4));
983
		fw.write(DxfGroup.toString(24, 10.0, 4));
984
		fw.write(DxfGroup.toString(15, 10.0, 4));
985
		fw.write(DxfGroup.toString(25, 10.0, 4));
986
		fw.write(DxfGroup.toString(16, 0.0, 4));
987
		fw.write(DxfGroup.toString(26, 0.0, 4));
988
		fw.write(DxfGroup.toString(36, 1.0, 4));
989
		fw.write(DxfGroup.toString(17, 0.0, 4));
990
		fw.write(DxfGroup.toString(27, 0.0, 4));
991
		fw.write(DxfGroup.toString(37, 0.0, 4));
992
		fw.write(DxfGroup.toString(40, 297.0, 4));
993
		fw.write(DxfGroup.toString(41, 1.92798353909465, 10));
994
		fw.write(DxfGroup.toString(42, 50.0, 4));
995
		fw.write(DxfGroup.toString(43, 0.0, 4));
996
		fw.write(DxfGroup.toString(44, 0.0, 4));
997
		fw.write(DxfGroup.toString(50, 0.0, 4));
998
		fw.write(DxfGroup.toString(51, 0.0, 4));
999
		fw.write(DxfGroup.toString(71, 0));
1000
		fw.write(DxfGroup.toString(72, 100));
1001
		fw.write(DxfGroup.toString(73, 1));
1002
		fw.write(DxfGroup.toString(74, 3));
1003
		fw.write(DxfGroup.toString(75, 1));
1004
		fw.write(DxfGroup.toString(76, 1));
1005
		fw.write(DxfGroup.toString(77, 0));
1006
		fw.write(DxfGroup.toString(78, 0));
1007
		fw.write(DxfGroup.toString(281, 0));
1008
		fw.write(DxfGroup.toString(65, 1));
1009
		fw.write(DxfGroup.toString(110, 0.0, 4));
1010
		fw.write(DxfGroup.toString(120, 0.0, 4));
1011
		fw.write(DxfGroup.toString(130, 0.0, 4));
1012
		fw.write(DxfGroup.toString(111, 1.0, 4));
1013
		fw.write(DxfGroup.toString(121, 0.0, 4));
1014
		fw.write(DxfGroup.toString(131, 0.0, 4));
1015
		fw.write(DxfGroup.toString(112, 0.0, 4));
1016
		fw.write(DxfGroup.toString(122, 1.0, 4));
1017
		fw.write(DxfGroup.toString(132, 0.0, 4));
1018
		fw.write(DxfGroup.toString(79, 0));
1019
		fw.write(DxfGroup.toString(146, 0.0, 4));*/
1020
		fw.write(DxfGroup.toString(0, "ENDTAB"));
1021
	}
1022

  
1023
	/**
1024
	 * Escritor de la tabla LTYPE.
1025
	 * @param fw
1026
	 * @throws IOException
1027
	 */
1028
	public void writeLTypeTable(FileWriter fw) throws IOException {
1029
		fw.write(DxfGroup.toString(0, "TABLE"));
1030
		fw.write(DxfGroup.toString(2, "LTYPE"));
1031
		fw.write(DxfGroup.toString(5, 5));
1032
		fw.write(DxfGroup.toString(100, "AcDbSymbolTable"));
1033
		fw.write(DxfGroup.toString(70, 1));
1034
		// Aqui hay que crear un objeto DxfLType como el DxfLayer tambi?n basado en
1035
		// el lector de DXF de Mich.
1036
		/*DxfTABLE_LTYPE_ITEM ltype =
1037
			new DxfTABLE_LTYPE_ITEM("CONTINUE", 0, "", 65, 0f, new float[0]);
1038
		fw.write(ltype.toString());*/
1039
		fw.write(DxfGroup.toString(0, "LTYPE"));
1040
		fw.write(DxfGroup.toString(5, 14));
1041
		fw.write(DxfGroup.toString(100, "AcDbSymbolTableRecord"));
1042
		fw.write(DxfGroup.toString(100, "AcDbLinetypeTableRecord"));
1043
		fw.write(DxfGroup.toString(2, "ByBlock"));
1044
		fw.write(DxfGroup.toString(70, 0));
1045
		fw.write(DxfGroup.toString(3, ""));
1046
		fw.write(DxfGroup.toString(72, 65));
1047
		fw.write(DxfGroup.toString(73, 0));
1048
		fw.write(DxfGroup.toString(40, 0.0, 4));
1049
		fw.write(DxfGroup.toString(0, "LTYPE"));
1050
		fw.write(DxfGroup.toString(5, 15));
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff