Statistics
| Revision:

svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfPoint.java @ 2312

History | View | Annotate | Download (3.09 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.Graphics2D;
27
import java.awt.geom.Point2D;
28

    
29
import org.cresques.cts.ICoordTrans;
30
import org.cresques.cts.IProjection;
31
import org.cresques.geo.ViewPortData;
32
import org.cresques.io.DxfGroup;
33
import org.cresques.px.Extent;
34

    
35
/**
36
 * Entidad TEXT de AutoCAD
37
 * jmorell: Actualizaci?n de la escritura al formato DXF2000.
38
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
39
 */
40
public class DxfPoint extends DxfEntity {
41
        
42
        private Point2D pt;
43
        
44
        public DxfPoint(IProjection proj, DxfLayer layer) {
45
                super(proj, layer);
46
                extent = new Extent();
47
                pt = new Point2D.Double();
48
        }
49
        
50
        public void setPt(Point2D pt) { 
51
                this.pt = pt;
52
                extent.add(pt);
53
        }
54
        
55
        public void reProject(ICoordTrans rp) {
56
                Point2D savePt = pt;
57

    
58
                pt = new Point2D.Double();
59
                extent = new Extent();
60
                Point2D ptDest = rp.getPDest().createPoint(0.0,0.0);
61
                if (savePt == null)
62
                        ptDest = null;
63
                else {
64
                        ptDest = rp.convert((Point2D) savePt, ptDest);
65
                        extent.add(ptDest);
66
                }
67
                pt = ptDest;
68
                setProjection(rp.getPDest());
69
        }
70
        
71
        public void draw(Graphics2D g, ViewPortData vp) {
72
                //AffineTransform msave=g.getTransform();
73
                //g.setTransform(vp.mat);
74
                if (dxfColor == AcadColor.BYLAYER)
75
                        g.setColor(layer.getColor());
76
                else
77
                        g.setColor(AcadColor.getColor(dxfColor));
78
                Point2D ptT = new Point2D.Double(0, 0);
79
                vp.mat.transform(ptT, ptT);
80
                ptT.setLocation(pt.getX(), pt.getY());
81
                vp.mat.transform(ptT, ptT);
82
                g.drawLine((int) ptT.getX(), (int)ptT.getY(), (int) ptT.getX(), (int)ptT.getY());
83
                //g.setTransform(msave);
84
        }
85

    
86
        /**
87
         * 050221, jmorell: Escritura de puntos en un DXF2000.
88
         */
89
        public String toDxfString() {
90
                StringBuffer sb = null;
91
                sb = new StringBuffer( DxfGroup.toString(0, "POINT") );
92
                sb.append( DxfGroup.toString(5, getHandle()) );
93
                sb.append( DxfGroup.toString(100, "AcDbEntity") );
94
                sb.append( DxfGroup.toString(8, layer.getName()) );
95
                sb.append( DxfGroup.toString(62, dxfColor) );
96
                sb.append( DxfGroup.toString(100, "AcDbPoint") );
97
                sb.append( DxfGroup.toString(10, pt.getX(), 6) );
98
                sb.append( DxfGroup.toString(20, pt.getY(), 6) );
99
                sb.append( DxfGroup.toString(30, 0.0, 6) );
100
                return sb.toString();
101
        }
102
        /**
103
         * @return Returns the pt.
104
         */
105
        public Point2D getPt() {
106
                return pt;
107
        }
108
}