Revision 43
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfEntityMaker.java | ||
---|---|---|
61 | 61 |
} |
62 | 62 |
|
63 | 63 |
public void createPolyline(DxfGroupVector grp) throws Exception { |
64 |
System.out.println("Creando la polylinea"); |
|
64 |
//System.out.println("Creando la polylinea");
|
|
65 | 65 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8)); |
66 | 66 |
DxfPolyline entity = new DxfPolyline(proj, layer); |
67 | 67 |
double x = 0.0, y = 0.0, z = 0.0; |
... | ... | |
385 | 385 |
String blockName = ""; |
386 | 386 |
Point3D scaleFactor = null; |
387 | 387 |
double rotAngle = 0.0; |
388 |
|
|
389 |
DxfEntityList blocks = new DxfEntityList(proj); |
|
390 |
|
|
388 | 391 |
DxfLayer layer = (DxfLayer) layers.getByName(grp.getDataAsString(8)); |
389 | 392 |
|
390 |
DxfInsert entity = new DxfInsert(proj, layer); |
|
393 |
DxfInsert entity = new DxfInsert(proj, layer, blocks);
|
|
391 | 394 |
|
392 | 395 |
if (grp.hasCode(2)) |
393 | 396 |
blockName = grp.getDataAsString(2); |
... | ... | |
414 | 417 |
Point2D point_out = DxfCalXtru.CalculateXtru(point_in, xtru); |
415 | 418 |
x = point_out.getX(); |
416 | 419 |
y = point_out.getY(); |
420 |
|
|
421 |
/*boolean found = false; |
|
422 |
Iterator iter = blocks.entities.iterator(); |
|
423 |
DxfEntityList b = null; |
|
424 |
|
|
425 |
int numBlocks = blocks.entities.size(); |
|
426 |
System.out.println(numBlocks); |
|
427 |
|
|
428 |
while (iter.hasNext()) { |
|
429 |
b = (DxfEntityList)iter.next(); |
|
430 |
|
|
431 |
System.out.println("NBLOCK = " + b.getAttribute("NBLOCK") + ", bname = " + blockName); |
|
432 |
if (b.getAttribute("NBLOCK").equals(blockName)) { |
|
433 |
Point2D c = new Point2D.Double(x,y); |
|
434 |
DxfEntityList gc = b; |
|
435 |
System.err.print("Rotacion = " + rotAngle); |
|
436 |
b = DxfInsert.moveGeometryCollection( gc, c, scaleFactor, rotAngle); |
|
437 |
entities.add(b); |
|
438 |
|
|
439 |
found = true; |
|
440 |
System.out.println("ENCONTRADO"); |
|
441 |
break; |
|
442 |
} |
|
443 |
} |
|
444 |
if (! found) { |
|
445 |
System.out.println("NO ENCONTRADO"+ blockName); |
|
446 |
|
|
447 |
//b.setGeometry(new GeometryFactory(DPM,0).createPoint(new Coordinate(x,y,z))); |
|
448 |
entity.setPt(proj.createPoint(x, y)); |
|
449 |
|
|
450 |
//int aux = feature.getID(); |
|
451 |
//if (debug) System.out.println("AUXXXXXXXXXXXXXXX = " + aux); |
|
452 |
//DxfEntity block = null; |
|
453 |
//block = feature.getGeometry(); |
|
454 |
String marca = (String) blockName; |
|
455 |
Double xx = new Double(x); |
|
456 |
Double yy = new Double(y); |
|
457 |
//Double zz = new Double(z); |
|
458 |
Double xxscale = new Double(scaleFactor.getX()); |
|
459 |
Double yyscale = new Double(scaleFactor.getY()); |
|
460 |
Double zzscale = new Double(scaleFactor.getZ()); |
|
461 |
Double aangle = new Double(rotAngle); |
|
462 |
Object datos[] = new Object[8]; |
|
463 |
datos[0] = marca; |
|
464 |
datos[1] = xx; |
|
465 |
datos[2] = yy; |
|
466 |
//datos[3] = zz; |
|
467 |
datos[4] = xxscale; |
|
468 |
datos[5] = yyscale; |
|
469 |
datos[6] = zzscale; |
|
470 |
datos[7] = aangle; |
|
471 |
block.setUserData(datos); |
|
472 |
entities.add(b); |
|
473 |
}*/ |
|
474 |
|
|
475 |
|
|
417 | 476 |
entity.setPt(proj.createPoint(x, y)); |
418 | 477 |
entities.add(entity); |
419 | 478 |
} |
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfInsert.java | ||
---|---|---|
8 | 8 |
import java.awt.Graphics2D; |
9 | 9 |
import java.awt.geom.Point2D; |
10 | 10 |
|
11 |
import org.cresques.geo.Point3D; |
|
11 | 12 |
import org.cresques.geo.Projection; |
12 | 13 |
import org.cresques.geo.ReProjection; |
13 | 14 |
import org.cresques.geo.ViewPort; |
... | ... | |
21 | 22 |
public class DxfInsert extends DxfEntity { |
22 | 23 |
|
23 | 24 |
Point2D pt; |
25 |
DxfEntityList blocks = new DxfEntityList(proj); |
|
24 | 26 |
|
25 |
public DxfInsert(Projection proj, DxfLayer layer) { |
|
27 |
public DxfInsert(Projection proj, DxfLayer layer, DxfEntityList blocks) {
|
|
26 | 28 |
super(proj, layer); |
27 | 29 |
extent = new Extent(); |
28 | 30 |
pt = new Point2D.Double(); |
31 |
this.blocks = blocks; |
|
29 | 32 |
} |
30 | 33 |
|
31 | 34 |
public void setPt(Point2D pt) { |
... | ... | |
72 | 75 |
// TODO Auto-generated method stub |
73 | 76 |
return ""; |
74 | 77 |
} |
78 |
|
|
79 |
/*public static DxfEntity[] moveGeometryCollection(DxfEntityList gc, Point2D pt, Point3D scale, double rotation) { |
|
80 |
DxfEntity g; |
|
81 |
DxfEntity geos[] = new DxfEntity[gc.entities.size()]; |
|
82 |
String typeGeo; |
|
83 |
|
|
84 |
for (int i=0; i<gc.entities.size(); i++) { |
|
85 |
g = (DxfEntity) gc.entities.get(i); |
|
86 |
//typeGeo = g.getGeometryType(); |
|
87 |
if (g instanceof DxfPoint) { |
|
88 |
geos[i] = moveDxfPoint((DxfPoint)g, pt, scale, rotation); |
|
89 |
} |
|
90 |
if (g instanceof DxfLine) { |
|
91 |
geos[i] = moveDxfLine((DxfLine)g, pt, scale, rotation); |
|
92 |
} |
|
93 |
if (g instanceof DxfPolyline) { |
|
94 |
geos[i] = moveDxfPolyline((DxfPolyline)g, pt, scale, rotation); |
|
95 |
} |
|
96 |
//else if (g instanceof DxfEntityList) { |
|
97 |
// geos[i] = moveGeometryCollection((DxfEntityList)g, pt, scale, rotation); |
|
98 |
//} |
|
99 |
else { |
|
100 |
System.out.println("NO CONTEMPLA " + typeGeo + " en "+ i ); |
|
101 |
} |
|
102 |
} |
|
103 |
return geos; |
|
104 |
} |
|
105 |
|
|
106 |
public static DxfPoint moveDxfPoint(DxfPoint g, Point2D pt, Point3D scale, double rotation) { |
|
107 |
Point2D c, c2; |
|
108 |
double x,y,z; |
|
109 |
double alfa = rotation*Math.PI/180.0; |
|
110 |
c2 = g.pt; |
|
111 |
|
|
112 |
x = (c2.getX()*Math.cos(alfa) + c2.getY()*(-1)*Math.sin(alfa)) * scale.getX(); |
|
113 |
y = (c2.getX()*Math.sin(alfa) + c2.getY()*Math.cos(alfa)) * scale.getY(); |
|
114 |
//z = c2.z * scale.z; |
|
115 |
|
|
116 |
c = new Point2D.Double(pt.getX() + x, pt.getY() + y); |
|
117 |
DxfPoint p_out = g; |
|
118 |
p_out.pt.setLocation(c); |
|
119 |
return p_out; |
|
120 |
} |
|
121 |
|
|
122 |
public static DxfPolyline moveDxfPolyline(DxfPolyline g, Point2D pt, Point3D scale, double rotation) { |
|
123 |
Point2D c[] = new Point2D[ g.pts.size()], c2; |
|
124 |
double x,y,z; |
|
125 |
|
|
126 |
double alfa = rotation*Math.PI/180.0; |
|
127 |
|
|
128 |
for (int i=0; i<c.length; i++) { |
|
129 |
c2 = (Point2D)g.pts.get(i); |
|
130 |
|
|
131 |
x = ((c2.getX()*scale.getX())*Math.cos(alfa) + (c2.getY()*scale.getY())*(-1)*Math.sin(alfa)); |
|
132 |
y = ((c2.getX()*scale.getX())*Math.sin(alfa) + (c2.getY()*scale.getY())*Math.cos(alfa)); |
|
133 |
//z = c2.z*scale.z; |
|
134 |
|
|
135 |
double X = pt.getX() + x; //+ins.x; |
|
136 |
double Y = pt.getY() + y; // +ins.y; |
|
137 |
//double Z = pt.z + z; // +ins.z; |
|
138 |
|
|
139 |
c[i] = new Point2D.Double(X, Y); |
|
140 |
} |
|
141 |
DxfPolyline pol_out = g; |
|
142 |
//pol_out. |
|
143 |
return pol_out; |
|
144 |
}*/ |
|
145 |
|
|
75 | 146 |
} |
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfArc.java | ||
---|---|---|
32 | 32 |
|
33 | 33 |
public DxfArc(Projection proj, DxfLayer layer, Point2D[] pts) { |
34 | 34 |
super(proj, layer); |
35 |
this.pts = pts; |
|
35 | 36 |
extent = new Extent(); |
36 |
this.pts = pts; |
|
37 |
for (int i=0; i<pts.length; i++) { |
|
38 |
extent.add(pts[i]); |
|
39 |
} |
|
37 | 40 |
} |
38 | 41 |
|
39 | 42 |
private Color color = baseColor; //Color(255,214,132,255); |
trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfSolid.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.Graphics2D; |
|
9 |
import java.awt.geom.Point2D; |
|
10 |
|
|
11 |
import org.cresques.geo.Projection; |
|
12 |
import org.cresques.geo.ReProjection; |
|
13 |
import org.cresques.geo.ViewPort; |
|
14 |
import org.cresques.px.Extent; |
|
15 |
|
|
16 |
/** |
|
17 |
* Entidad TEXT de AutoCAD |
|
18 |
* |
|
19 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>* @author administrador |
|
20 |
*/ |
|
21 |
public class DxfSolid extends DxfEntity { |
|
22 |
|
|
23 |
Point2D pt; |
|
24 |
|
|
25 |
public DxfSolid(Projection proj, DxfLayer layer) { |
|
26 |
super(proj, layer); |
|
27 |
extent = new Extent(); |
|
28 |
pt = new Point2D.Double(); |
|
29 |
} |
|
30 |
|
|
31 |
public void setPt(Point2D pt) { |
|
32 |
this.pt = pt; |
|
33 |
extent.add(pt); |
|
34 |
} |
|
35 |
|
|
36 |
public void reProject(ReProjection rp) { |
|
37 |
Point2D savePt = pt; |
|
38 |
|
|
39 |
pt = new Point2D.Double(); |
|
40 |
extent = new Extent(); |
|
41 |
Point2D ptDest = null; |
|
42 |
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; |
|
50 |
setProjection(rp.getPDest()); |
|
51 |
} |
|
52 |
|
|
53 |
public void draw(Graphics2D g, ViewPort vp) { |
|
54 |
//AffineTransform msave=g.getTransform(); |
|
55 |
//g.setTransform(vp.mat); |
|
56 |
if (dxfColor == AcadColor.BYLAYER) |
|
57 |
g.setColor(layer.getColor()); |
|
58 |
else |
|
59 |
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); |
|
66 |
} |
|
67 |
|
|
68 |
/* (non-Javadoc) |
|
69 |
* @see org.cresques.px.dxf.DxfEntity#toDxfFileString() |
|
70 |
*/ |
|
71 |
public String toDxfString() { |
|
72 |
// TODO Auto-generated method stub |
|
73 |
return ""; |
|
74 |
} |
|
75 |
} |
|
0 | 76 |
Also available in: Unified diff