Statistics
| Revision:

root / trunk / libraries / libCq_CMS_praster / src / org / cresques / px / dxf / DxfLwPolyline.java @ 8026

History | View | Annotate | Download (3.1 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 org.cresques.cts.IProjection;
27

    
28
import org.cresques.io.DxfGroup;
29

    
30
import java.awt.geom.Point2D;
31

    
32
import java.util.Vector;
33

    
34

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

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

    
72
        Point2D pt = null;
73
        double bulge;
74
        Vector bulges = getBulges();
75

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

    
90
        return sb.toString();
91
    }
92
}