svn-gvsig-desktop / tags / Root_CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfBlock.java @ 1732
History | View | Annotate | Download (3.08 KB)
1 |
package org.cresques.px.dxf; |
---|---|
2 |
|
3 |
import java.util.Vector; |
4 |
import java.util.Iterator; |
5 |
import java.awt.Graphics2D; |
6 |
import java.awt.geom.Point2D; |
7 |
|
8 |
import org.cresques.cts.ICoordTrans; |
9 |
import org.cresques.cts.IProjection; |
10 |
import org.cresques.geo.Point3D; |
11 |
import org.cresques.geo.Projected; |
12 |
import org.cresques.geo.Projection; |
13 |
import org.cresques.geo.ReProjection; |
14 |
import org.cresques.geo.ViewPortData; |
15 |
import org.cresques.px.Extent; |
16 |
import org.cresques.px.IObjList; |
17 |
import org.cresques.px.PxObj; |
18 |
|
19 |
public class DxfBlock extends PxObj implements IObjList { |
20 |
IProjection proj = null;
|
21 |
Vector data = null; |
22 |
int flags = 0; |
23 |
String blkName = ""; |
24 |
Point2D bPoint = new Point2D.Double(); |
25 |
|
26 |
public DxfBlock(IProjection proj) {
|
27 |
extent = new Extent();
|
28 |
data = new Vector(); |
29 |
} |
30 |
|
31 |
public IObjList getAt(Point2D pt) { |
32 |
IObjList oList = new DxfEntityList(proj);
|
33 |
Iterator iter = iterator();
|
34 |
while (iter.hasNext()) {
|
35 |
Extent.Has o = (Extent.Has) iter.next(); |
36 |
if (o.getExtent().isAt(pt)) oList.add(o);
|
37 |
} |
38 |
return oList;
|
39 |
} |
40 |
|
41 |
public Iterator iterator() { return data.iterator(); } |
42 |
public int size() { return data.size(); } |
43 |
|
44 |
public void add(Extent.Has obj) { |
45 |
if (obj != null) { |
46 |
extent.add(obj.getExtent()); |
47 |
data.add(obj); |
48 |
} |
49 |
} |
50 |
|
51 |
public void remove(Object obj) { data.remove(obj); } |
52 |
|
53 |
public void clear() { |
54 |
extent = new Extent();
|
55 |
data.clear(); |
56 |
} |
57 |
|
58 |
public Extent.Has get(int i) { return (Extent.Has) data.get(i); } |
59 |
|
60 |
public IProjection getProjection() { return proj; } |
61 |
public void setProjection(IProjection p) { proj = p; } |
62 |
public void reProject(ICoordTrans rp) { |
63 |
extent = new Extent();
|
64 |
PxObj o; |
65 |
Iterator iter = iterator();
|
66 |
while (iter.hasNext()) {
|
67 |
o = (PxObj) iter.next(); |
68 |
((Projected) o).reProject(rp); |
69 |
extent.add(o.getExtent()); |
70 |
} |
71 |
setProjection(rp.getPDest()); |
72 |
} |
73 |
|
74 |
public void draw(Graphics2D g, ViewPortData vp) { |
75 |
Iterator iter = iterator();
|
76 |
Extent extent; |
77 |
while (iter.hasNext()) {
|
78 |
DxfEntity entity = (DxfEntity) iter.next(); |
79 |
extent = entity.getExtent(); |
80 |
if (vp.getExtent().minX()> extent.maxX()) continue; |
81 |
if (vp.getExtent().minY()> extent.maxY()) continue; |
82 |
if (vp.getExtent().maxX()< extent.minX()) continue; |
83 |
if (vp.getExtent().maxY()< extent.minY()) continue; |
84 |
if (!entity.layer.frozen)
|
85 |
entity.draw(g, vp); |
86 |
} |
87 |
} |
88 |
|
89 |
public String toDxfString() { |
90 |
StringBuffer sb = new StringBuffer(""); |
91 |
|
92 |
Iterator iter = iterator();
|
93 |
Extent extent; |
94 |
while (iter.hasNext()) {
|
95 |
sb.append(((DxfEntity) iter.next()).toDxfString()); |
96 |
} |
97 |
return sb.toString();
|
98 |
} |
99 |
|
100 |
public int getFlags() {return flags; } |
101 |
|
102 |
public String getBlkName() { return blkName; } |
103 |
|
104 |
public Vector getBlkElements() { return data; } |
105 |
|
106 |
public void setBlkElements(Vector blkElements) { |
107 |
data = blkElements; |
108 |
} |
109 |
|
110 |
public void setBlkName(String blkName) { |
111 |
this.blkName = blkName;
|
112 |
System.out.println("setBlkName: this.blkName = " + this.blkName); |
113 |
} |
114 |
|
115 |
public void setBPoint(Point2D basePoint) { |
116 |
this.bPoint = basePoint;
|
117 |
System.out.println("setBPoint: this.bPoint = " + this.bPoint); |
118 |
} |
119 |
|
120 |
public void setFlags(int flags) { |
121 |
this.flags = flags;
|
122 |
System.out.println("setFlags: this.flags = " + this.flags); |
123 |
} |
124 |
|
125 |
} |