Statistics
| Revision:

svn-gvsig-desktop / branches / Mobile_Compatible_Hito_1 / libDXF / src / org / cresques / px / dxf / DxfLwPolyline.java @ 21930

History | View | Annotate | Download (3.19 KB)

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

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

    
29
import org.gvsig.projection.cts.IProjection;
30
import org.cresques.io.DxfGroup;
31

    
32

    
33
/**
34
 * Entidad LWPOLYLINE de un fichero DXF.
35
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
36
 * @author jmorell
37
 */
38
public class DxfLwPolyline extends DxfPolyline {
39
    
40
    /**
41
     * Constructor de DxfLwPolyline.
42
     * @param proj, proyecci?n cartogr?fica en la que se encuentra la DxfLwPolyline.
43
     * @param layer, capa del DXF en la que se encuentra la DxfLwPolyline.
44
     */
45
    public DxfLwPolyline(IProjection proj, DxfLayer layer) {
46
        super(proj, layer);
47
    }
48

    
49
    /**
50
     * Permite la escritura de entidades DxfLwPolyline en un fichero DXF2000.
51
     * @return String, la cadena que se escribir? en el fichero con la informaci?n
52
     * de la DxfLwPolyline.
53
     */
54
    /**
55
     * 050302, jmorell: Si el 90 no est? antes que el 70, Autocad 2004 no cierra
56
     * las polil?neas.
57
     */
58
    public String toDxfString() {
59
        StringBuffer sb = null;
60
        sb = new StringBuffer(DxfGroup.toString(0, "LWPOLYLINE"));
61
        sb.append(DxfGroup.toString(5, getHandle()));
62
        sb.append(DxfGroup.toString(100, "AcDbEntity"));
63
        sb.append(DxfGroup.toString(8, layer.getName()));
64
        sb.append(DxfGroup.toString(62, dxfColor));
65
        sb.append(DxfGroup.toString(100, "AcDbPolyline"));
66
        sb.append(DxfGroup.toString(90, pts.size()));
67
        sb.append(DxfGroup.toString(70, flags));
68
        sb.append(DxfGroup.toString(38, new Double(getElevation())));
69

    
70
        Point2D pt = null;
71
        double bulge;
72
        Vector bulges = getBulges();
73

    
74
        /*Iterator iter = pts.iterator();
75
        while (iter.hasNext()) {
76
                pt = (Point2D) iter.next();
77
                sb.append( DxfGroup.toString(10, pt.getX(), 6) );
78
                sb.append( DxfGroup.toString(20, pt.getY(), 6) );
79
        }*/
80
        for (int i = 0; i < pts.size(); i++) {
81
            pt = (Point2D) pts.get(i);
82
            bulge = ((Double) bulges.get(i)).doubleValue();
83
            sb.append(DxfGroup.toString(10, pt.getX(), 6));
84
            sb.append(DxfGroup.toString(20, pt.getY(), 6));
85
            sb.append(DxfGroup.toString(42, bulge, 6));
86
        }
87

    
88
        return sb.toString();
89
    }
90
}