Revision 43 trunk/libraries/libCq CMS for java.old/src/org/cresques/px/dxf/DxfInsert.java

View differences:

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
}

Also available in: Unified diff