root / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfPoint.java @ 2249
History | View | Annotate | Download (3.56 KB)
1 |
/*
|
---|---|
2 |
* Created on 21-jun-2005
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*
|
25 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
package org.cresques.px.dxf; |
48 |
|
49 |
import java.awt.Graphics2D; |
50 |
import java.awt.geom.Point2D; |
51 |
|
52 |
import org.cresques.cts.ICoordTrans; |
53 |
import org.cresques.cts.IProjection; |
54 |
import org.cresques.geo.ViewPortData; |
55 |
import org.cresques.io.DxfGroup; |
56 |
import org.cresques.px.Extent; |
57 |
|
58 |
/**
|
59 |
* Entidad TEXT de AutoCAD
|
60 |
* jmorell: Actualizaci?n de la escritura al formato DXF2000.
|
61 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador
|
62 |
*/
|
63 |
public class DxfPoint extends DxfEntity { |
64 |
|
65 |
private Point2D pt; |
66 |
|
67 |
public DxfPoint(IProjection proj, DxfLayer layer) {
|
68 |
super(proj, layer);
|
69 |
extent = new Extent();
|
70 |
pt = new Point2D.Double(); |
71 |
} |
72 |
|
73 |
public void setPt(Point2D pt) { |
74 |
this.pt = pt;
|
75 |
extent.add(pt); |
76 |
} |
77 |
|
78 |
public void reProject(ICoordTrans rp) { |
79 |
Point2D savePt = pt;
|
80 |
|
81 |
pt = new Point2D.Double(); |
82 |
extent = new Extent();
|
83 |
Point2D ptDest = rp.getPDest().createPoint(0.0,0.0); |
84 |
if (savePt == null) |
85 |
ptDest = null;
|
86 |
else {
|
87 |
ptDest = rp.convert((Point2D) savePt, ptDest);
|
88 |
extent.add(ptDest); |
89 |
} |
90 |
pt = ptDest; |
91 |
setProjection(rp.getPDest()); |
92 |
} |
93 |
|
94 |
public void draw(Graphics2D g, ViewPortData vp) { |
95 |
//AffineTransform msave=g.getTransform();
|
96 |
//g.setTransform(vp.mat);
|
97 |
if (dxfColor == AcadColor.BYLAYER)
|
98 |
g.setColor(layer.getColor()); |
99 |
else
|
100 |
g.setColor(AcadColor.getColor(dxfColor)); |
101 |
Point2D ptT = new Point2D.Double(0, 0); |
102 |
vp.mat.transform(ptT, ptT); |
103 |
ptT.setLocation(pt.getX(), pt.getY()); |
104 |
vp.mat.transform(ptT, ptT); |
105 |
g.drawLine((int) ptT.getX(), (int)ptT.getY(), (int) ptT.getX(), (int)ptT.getY()); |
106 |
//g.setTransform(msave);
|
107 |
} |
108 |
|
109 |
/**
|
110 |
* 050221, jmorell: Escritura de puntos en un DXF2000.
|
111 |
*/
|
112 |
public String toDxfString() { |
113 |
StringBuffer sb = null; |
114 |
sb = new StringBuffer( DxfGroup.toString(0, "POINT") ); |
115 |
sb.append( DxfGroup.toString(5, getHandle()) );
|
116 |
sb.append( DxfGroup.toString(100, "AcDbEntity") ); |
117 |
sb.append( DxfGroup.toString(8, layer.getName()) );
|
118 |
sb.append( DxfGroup.toString(62, dxfColor) );
|
119 |
sb.append( DxfGroup.toString(100, "AcDbPoint") ); |
120 |
sb.append( DxfGroup.toString(10, pt.getX(), 6) ); |
121 |
sb.append( DxfGroup.toString(20, pt.getY(), 6) ); |
122 |
sb.append( DxfGroup.toString(30, 0.0, 6) ); |
123 |
return sb.toString();
|
124 |
} |
125 |
/**
|
126 |
* @return Returns the pt.
|
127 |
*/
|
128 |
public Point2D getPt() { |
129 |
return pt;
|
130 |
} |
131 |
} |