Revision 37
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/DxfFile.java | ||
---|---|---|
57 | 57 |
public void createText(DxfGroupVector v) throws Exception ; |
58 | 58 |
public void createPoint(DxfGroupVector v) throws Exception ; |
59 | 59 |
public void createCircle(DxfGroupVector v) throws Exception ; |
60 |
//public void createArc(DxfGroupVector v) throws Exception ; |
|
60 | 61 |
public void createSolid(DxfGroupVector v) throws Exception ; |
61 | 62 |
public Extent getExtent(); |
62 | 63 |
public void reProject(ReProjection rp); |
... | ... | |
225 | 226 |
entityMaker.createPoint(v); |
226 | 227 |
} else if (lastEntity.compareTo("CIRCLE") == 0) { |
227 | 228 |
entityMaker.createCircle(v); |
229 |
/*} else if (lastEntity.compareTo("ARC") == 0) { |
|
230 |
entityMaker.createArc(v);*/ |
|
228 | 231 |
} else if (lastEntity.compareTo("SOLID") == 0) { |
229 | 232 |
entityMaker.createSolid(v); |
230 | 233 |
} else |
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfArc.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 09-may-2004 |
|
3 |
* |
|
4 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es> |
|
5 |
*/ |
|
6 |
package org.cresques.px.dxf; |
|
7 |
|
|
8 |
import java.awt.Color; |
|
9 |
import java.awt.Graphics2D; |
|
10 |
import java.awt.geom.GeneralPath; |
|
11 |
import java.awt.geom.Point2D; |
|
12 |
import java.util.Iterator; |
|
13 |
import java.util.Vector; |
|
14 |
|
|
15 |
import org.cresques.geo.Projection; |
|
16 |
import org.cresques.geo.ReProjection; |
|
17 |
import org.cresques.geo.ViewPort; |
|
18 |
import org.cresques.io.DxfGroup; |
|
19 |
import org.cresques.px.Extent; |
|
20 |
|
|
21 |
/** |
|
22 |
* Entidad TEXT de AutoCAD |
|
23 |
* |
|
24 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador |
|
25 |
*/ |
|
26 |
public class DxfArc extends DxfEntity { |
|
27 |
final static Color baseColor = new Color(69, 106, 121); |
|
28 |
//Vector points = null; |
|
29 |
Point2D [] pts; |
|
30 |
GeneralPath gp = null; |
|
31 |
boolean closed = false; |
|
32 |
|
|
33 |
public DxfArc(Projection proj, DxfLayer layer, Point2D[] pts) { |
|
34 |
super(proj, layer); |
|
35 |
extent = new Extent(); |
|
36 |
this.pts = pts; |
|
37 |
} |
|
38 |
|
|
39 |
private Color color = baseColor; //Color(255,214,132,255); |
|
40 |
|
|
41 |
public Color c() {return color;} |
|
42 |
public Color c(Color color) {this.color = color; return color;} |
|
43 |
|
|
44 |
public void reProject(ReProjection rp) { |
|
45 |
Point2D [] savePts = pts; |
|
46 |
|
|
47 |
pts = new Point2D[savePts.length]; |
|
48 |
extent = new Extent(); |
|
49 |
Point2D ptDest = null; |
|
50 |
for (int i=0; i<savePts.length; i++) { |
|
51 |
ptDest = rp.getPDest().createPoint(0.0,0.0); |
|
52 |
rp.convert((Point2D) savePts[i], ptDest); |
|
53 |
this.pts[i] = ptDest; |
|
54 |
extent.add(ptDest); |
|
55 |
} |
|
56 |
setProjection(rp.getPDest()); |
|
57 |
} |
|
58 |
|
|
59 |
public void draw(Graphics2D g, ViewPort vp) { |
|
60 |
System.out.println("Va a pintar un arc"); |
|
61 |
if (dxfColor == AcadColor.BYLAYER) |
|
62 |
g.setColor(layer.getColor()); |
|
63 |
else |
|
64 |
g.setColor(AcadColor.getColor(dxfColor)); |
|
65 |
newGP(vp); |
|
66 |
if (closed) { |
|
67 |
g.setColor(new Color(color.getRed(), color.getBlue(), color.getGreen(), 0x80)); |
|
68 |
g.fill(gp); |
|
69 |
} |
|
70 |
g.setColor(color); |
|
71 |
g.draw(gp); |
|
72 |
} |
|
73 |
|
|
74 |
private void newGP(ViewPort vp) { |
|
75 |
//if (gp != null) return; |
|
76 |
gp = new GeneralPath(); |
|
77 |
Point2D pt0 = null, pt=null, pt1=null; |
|
78 |
Point2D.Double ptTmp = new Point2D.Double(0.0, 0.0); |
|
79 |
System.out.println("pts.length = " + pts.length); |
|
80 |
for (int i=0; i<pts.length; i++) { |
|
81 |
pt1 = (Point2D)pts[i]; |
|
82 |
vp.mat.transform(pt1, ptTmp); |
|
83 |
if (pt0 == null) { |
|
84 |
pt0 = ptTmp; |
|
85 |
gp.moveTo((float)ptTmp.getX(), (float)ptTmp.getY()); |
|
86 |
} else { |
|
87 |
gp.lineTo((float)ptTmp.getX(), (float)ptTmp.getY()); |
|
88 |
} |
|
89 |
} |
|
90 |
if (closed) { |
|
91 |
gp.closePath(); |
|
92 |
} |
|
93 |
} |
|
94 |
/* (non-Javadoc) |
|
95 |
* @see org.cresques.px.dxf.DxfEntity#toDxfFileString() |
|
96 |
*/ |
|
97 |
public String toDxfString() { |
|
98 |
// TODO Auto-generated method stub |
|
99 |
return ""; |
|
100 |
} |
|
101 |
/** |
|
102 |
* @return |
|
103 |
*/ |
|
104 |
public Point2D[] getPts() { |
|
105 |
return pts; |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* @return |
|
110 |
*/ |
|
111 |
/*public GeneralPath getGeneralPath(ViewPort vp) { |
|
112 |
newGP(vp); |
|
113 |
return (GeneralPath) gp.clone(); |
|
114 |
}*/ |
|
115 |
|
|
116 |
} |
|
0 | 117 |
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfEntityMaker.java | ||
---|---|---|
242 | 242 |
public void createCircle(DxfGroupVector grp) throws Exception { |
243 | 243 |
double x = 0.0, y = 0.0, z = 0.0; //, h= 0.0, rot= 0.0; |
244 | 244 |
double r = 0.0; |
245 |
//Point2D[] pts = new Point2D; |
|
245 | 246 |
DxfGroup g = null; |
246 |
Point2D pt = null; |
|
247 |
//Point2D pt1 = new Point2D.Double(); |
|
248 |
//Point2D pt2 = new Point2D.Double(); |
|
247 | 249 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8)); |
248 | 250 |
|
249 |
DxfPoint entity = new DxfPoint(proj, layer); |
|
250 |
|
|
251 | 251 |
x = grp.getDataAsDouble(10); |
252 | 252 |
y = grp.getDataAsDouble(20); |
253 | 253 |
if (grp.hasCode(30)) z = grp.getDataAsDouble(30); |
254 |
if (grp.hasCode(40)) r = grp.getDataAsDouble(40); |
|
255 |
if (grp.hasCode(210)) |
|
256 |
xtruX = grp.getDataAsDouble(210); |
|
257 |
if (grp.hasCode(220)) |
|
258 |
xtruY = grp.getDataAsInt(220); |
|
259 |
if (grp.hasCode(230)) |
|
260 |
xtruZ = grp.getDataAsInt(230); |
|
261 |
Point3D point_in = new Point3D(x, y, z); |
|
262 |
Point3D xtru = new Point3D(xtruX, xtruY, xtruZ); |
|
263 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
|
264 |
x = point_out.getX(); |
|
265 |
y = point_out.getY(); |
|
266 |
|
|
267 |
Point2D center = proj.createPoint( x, y); |
|
268 |
Point2D[] pts = new Point2D[360]; |
|
269 |
int angulo = 0; |
|
270 |
//Point2D pt1 = new Point2D.Double(center.getX() + r * Math.sin(angulo*Math.PI/(double)180.0), center.getY() + r * Math.cos(angulo*Math.PI/(double)180.0)); |
|
271 |
for (angulo=0; angulo<360; angulo++) { |
|
272 |
//System.out.println("pt1 = " + pt1); |
|
273 |
//pts[angulo] = new Point2D.Double(pt1.getX(), pt1.getY()); |
|
274 |
pts[angulo] = new Point2D.Double(center.getX(), center.getY()); |
|
275 |
pts[angulo].setLocation(pts[angulo].getX() + r * Math.sin(angulo*Math.PI/(double)180.0), pts[angulo].getY() + r * Math.cos(angulo*Math.PI/(double)180.0)); |
|
276 |
if (pts.length == 1) { |
|
277 |
firstPt = pts[angulo]; |
|
278 |
} |
|
279 |
} |
|
280 |
DxfCircle entity = new DxfCircle(proj, layer, pts); |
|
254 | 281 |
if (grp.hasCode(62)) |
255 | 282 |
entity.dxfColor = grp.getDataAsInt(62); |
283 |
System.out.println("A?ade un circulo a la lista de entidades"); |
|
284 |
entities.add(entity); |
|
285 |
} |
|
286 |
/*public void createArc(DxfGroupVector grp) throws Exception { |
|
287 |
double x = 0.0, y = 0.0, z = 0.0; //, h= 0.0, rot= 0.0; |
|
288 |
double r = 0.0, empieza = 0.0, acaba = 0.0; |
|
289 |
//Point2D[] pts = new Point2D; |
|
290 |
DxfGroup g = null; |
|
291 |
//Point2D pt1 = new Point2D.Double(); |
|
292 |
//Point2D pt2 = new Point2D.Double(); |
|
293 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8)); |
|
294 |
|
|
295 |
x = grp.getDataAsDouble(10); |
|
296 |
y = grp.getDataAsDouble(20); |
|
297 |
if (grp.hasCode(30)) z = grp.getDataAsDouble(30); |
|
298 |
if (grp.hasCode(40)) r = grp.getDataAsDouble(40); |
|
299 |
if (grp.hasCode(50)) empieza = grp.getDataAsDouble(50); |
|
300 |
if (grp.hasCode(51)) acaba = grp.getDataAsDouble(51); |
|
256 | 301 |
if (grp.hasCode(210)) |
257 | 302 |
xtruX = grp.getDataAsDouble(210); |
258 | 303 |
if (grp.hasCode(220)) |
... | ... | |
264 | 309 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
265 | 310 |
x = point_out.getX(); |
266 | 311 |
y = point_out.getY(); |
267 |
entity.setPt(proj.createPoint(x, y)); |
|
312 |
|
|
313 |
Point2D center = proj.createPoint( x, y); |
|
314 |
Point2D[] pts = new Point2D[360]; |
|
315 |
double angulo = 0; |
|
316 |
|
|
317 |
int iempieza = (int)empieza; |
|
318 |
int iacaba = (int)acaba; |
|
319 |
|
|
320 |
if (empieza <= acaba) { |
|
321 |
angulo = empieza; |
|
322 |
pts[0].setLocation(center.getX() + r * Math.sin(angulo*Math.PI/(double)180.0), center.getY() + r * Math.cos(angulo*Math.PI/(double)180.0)); |
|
323 |
for (int i=iempieza+1; i<=iacaba; i++) { |
|
324 |
angulo = (double)i; |
|
325 |
pts[i].setLocation(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
|
326 |
} |
|
327 |
angulo = acaba; |
|
328 |
pts[360].setLocation(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
|
329 |
} |
|
330 |
else { |
|
331 |
angulo = empieza; |
|
332 |
pts[0].setLocation(center.getX() + r * Math.sin(angulo*Math.PI/(double)180.0), center.getY() + r * Math.cos(angulo*Math.PI/(double)180.0)); |
|
333 |
for (int i=iempieza+1; i<=360; i++) { |
|
334 |
angulo = (double)i; |
|
335 |
pts[i].setLocation(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
|
336 |
} |
|
337 |
for (int i=1; i<=iacaba; i++) { |
|
338 |
angulo = (double)i; |
|
339 |
pts[i].setLocation(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
|
340 |
} |
|
341 |
angulo = acaba; |
|
342 |
pts[360].setLocation(center.getX() + r * Math.cos(angulo*Math.PI/(double)180.0), center.getY() + r * Math.sin(angulo*Math.PI/(double)180.0)); |
|
343 |
} |
|
344 |
DxfCircle entity = new DxfCircle(proj, layer, pts); |
|
345 |
if (grp.hasCode(62)) |
|
346 |
entity.dxfColor = grp.getDataAsInt(62); |
|
347 |
System.out.println("A?ade un arco a la lista de entidades"); |
|
268 | 348 |
entities.add(entity); |
269 |
} |
|
349 |
}*/
|
|
270 | 350 |
public void createSolid(DxfGroupVector grp) throws Exception { |
271 | 351 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8)); |
272 | 352 |
} |
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfCircle.java | ||
---|---|---|
5 | 5 |
*/ |
6 | 6 |
package org.cresques.px.dxf; |
7 | 7 |
|
8 |
import java.awt.Color; |
|
8 | 9 |
import java.awt.Graphics2D; |
10 |
import java.awt.geom.GeneralPath; |
|
9 | 11 |
import java.awt.geom.Point2D; |
12 |
import java.util.Iterator; |
|
13 |
import java.util.Vector; |
|
10 | 14 |
|
11 | 15 |
import org.cresques.geo.Projection; |
12 | 16 |
import org.cresques.geo.ReProjection; |
13 | 17 |
import org.cresques.geo.ViewPort; |
18 |
import org.cresques.io.DxfGroup; |
|
14 | 19 |
import org.cresques.px.Extent; |
15 | 20 |
|
16 | 21 |
/** |
... | ... | |
19 | 24 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador |
20 | 25 |
*/ |
21 | 26 |
public class DxfCircle extends DxfEntity { |
27 |
final static Color baseColor = new Color(69, 106, 121); |
|
28 |
//Vector points = null; |
|
29 |
Point2D [] pts; |
|
30 |
GeneralPath gp = null; |
|
31 |
boolean closed = true; |
|
22 | 32 |
|
23 |
Point2D pt; |
|
24 |
|
|
25 |
public DxfCircle(Projection proj, DxfLayer layer) { |
|
33 |
public DxfCircle(Projection proj, DxfLayer layer, Point2D[] pts) { |
|
26 | 34 |
super(proj, layer); |
35 |
this.pts = pts; |
|
27 | 36 |
extent = new Extent(); |
28 |
pt = new Point2D.Double(); |
|
37 |
for (int i=0; i<pts.length; i++) { |
|
38 |
extent.add(pts[i]); |
|
39 |
} |
|
29 | 40 |
} |
30 | 41 |
|
31 |
public void setPt(Point2D pt) { |
|
32 |
this.pt = pt; |
|
33 |
extent.add(pt); |
|
34 |
} |
|
42 |
private Color color = baseColor; //Color(255,214,132,255); |
|
35 | 43 |
|
44 |
public Color c() {return color;} |
|
45 |
public Color c(Color color) {this.color = color; return color;} |
|
46 |
|
|
36 | 47 |
public void reProject(ReProjection rp) { |
37 |
Point2D savePt = pt;
|
|
48 |
Point2D [] savePts = pts;
|
|
38 | 49 |
|
39 |
pt = new Point2D.Double();
|
|
50 |
pts = new Point2D[savePts.length];
|
|
40 | 51 |
extent = new Extent(); |
41 | 52 |
Point2D ptDest = null; |
53 |
for (int i=0; i<savePts.length; i++) { |
|
42 | 54 |
ptDest = rp.getPDest().createPoint(0.0,0.0); |
43 |
if (savePt == null) |
|
44 |
ptDest = null; |
|
45 |
else { |
|
46 |
rp.convert((Point2D) savePt, ptDest); |
|
47 |
extent.add(ptDest); |
|
48 |
} |
|
49 |
pt = ptDest; |
|
55 |
rp.convert((Point2D) savePts[i], ptDest); |
|
56 |
this.pts[i] = ptDest; |
|
57 |
extent.add(ptDest); |
|
58 |
} |
|
50 | 59 |
setProjection(rp.getPDest()); |
51 | 60 |
} |
52 | 61 |
|
53 | 62 |
public void draw(Graphics2D g, ViewPort vp) { |
54 |
//AffineTransform msave=g.getTransform(); |
|
55 |
//g.setTransform(vp.mat); |
|
63 |
System.out.println("Va a pintar un circle"); |
|
56 | 64 |
if (dxfColor == AcadColor.BYLAYER) |
57 | 65 |
g.setColor(layer.getColor()); |
58 | 66 |
else |
59 | 67 |
g.setColor(AcadColor.getColor(dxfColor)); |
60 |
Point2D ptT = new Point2D.Double(0, 0); |
|
61 |
vp.mat.transform(ptT, ptT); |
|
62 |
ptT.setLocation(pt.getX(), pt.getY()); |
|
63 |
vp.mat.transform(ptT, ptT); |
|
64 |
g.drawLine((int) ptT.getX(), (int)ptT.getY(), (int) ptT.getX(), (int)ptT.getY()); |
|
65 |
//g.setTransform(msave); |
|
68 |
newGP(vp); |
|
69 |
if (closed) { |
|
70 |
g.setColor(new Color(color.getRed(), color.getBlue(), color.getGreen(), 0x80)); |
|
71 |
g.fill(gp); |
|
72 |
} |
|
73 |
g.setColor(color); |
|
74 |
g.draw(gp); |
|
66 | 75 |
} |
67 |
|
|
76 |
|
|
77 |
private void newGP(ViewPort vp) { |
|
78 |
//if (gp != null) return; |
|
79 |
gp = new GeneralPath(); |
|
80 |
Point2D pt0 = null, pt=null, pt1=null; |
|
81 |
Point2D.Double ptTmp = new Point2D.Double(0.0, 0.0); |
|
82 |
System.out.println("pts.length = " + pts.length); |
|
83 |
for (int i=0; i<pts.length; i++) { |
|
84 |
pt1 = (Point2D)pts[i]; |
|
85 |
vp.mat.transform(pt1, ptTmp); |
|
86 |
if (pt0 == null) { |
|
87 |
pt0 = ptTmp; |
|
88 |
gp.moveTo((float)ptTmp.getX(), (float)ptTmp.getY()); |
|
89 |
} else { |
|
90 |
gp.lineTo((float)ptTmp.getX(), (float)ptTmp.getY()); |
|
91 |
} |
|
92 |
} |
|
93 |
if (closed) { |
|
94 |
gp.closePath(); |
|
95 |
} |
|
96 |
} |
|
68 | 97 |
/* (non-Javadoc) |
69 | 98 |
* @see org.cresques.px.dxf.DxfEntity#toDxfFileString() |
70 | 99 |
*/ |
... | ... | |
72 | 101 |
// TODO Auto-generated method stub |
73 | 102 |
return ""; |
74 | 103 |
} |
104 |
/** |
|
105 |
* @return |
|
106 |
*/ |
|
107 |
public Point2D[] getPts() { |
|
108 |
return pts; |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* @return |
|
113 |
*/ |
|
114 |
/*public GeneralPath getGeneralPath(ViewPort vp) { |
|
115 |
newGP(vp); |
|
116 |
return (GeneralPath) gp.clone(); |
|
117 |
}*/ |
|
118 |
|
|
75 | 119 |
} |
Also available in: Unified diff