svn-gvsig-desktop / tags / Root_CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / px / dxf / DxfEntityList.java @ 1732
History | View | Annotate | Download (2.5 KB)
1 |
/*
|
---|---|
2 |
* Created on 04-may-2004
|
3 |
*/
|
4 |
package org.cresques.px.dxf; |
5 |
|
6 |
|
7 |
import java.util.Vector; |
8 |
import java.util.Iterator; |
9 |
|
10 |
import java.awt.Graphics2D; |
11 |
import java.awt.geom.Point2D; |
12 |
|
13 |
import org.cresques.cts.ICoordTrans; |
14 |
import org.cresques.cts.IProjection; |
15 |
import org.cresques.geo.Projected; |
16 |
import org.cresques.geo.ViewPortData; |
17 |
import org.cresques.px.Extent; |
18 |
import org.cresques.px.IObjList; |
19 |
import org.cresques.px.PxObj; |
20 |
import org.cresques.px.PxObjList; |
21 |
|
22 |
/**
|
23 |
* FeatureCollection de .gml y .shp
|
24 |
* @author "Luis W. Sevilla" <sevilla_lui@gva.es>
|
25 |
*/
|
26 |
|
27 |
public class DxfEntityList extends PxObj implements IObjList.vector { |
28 |
IProjection proj = null;
|
29 |
private Vector data = null; |
30 |
|
31 |
public DxfEntityList(IProjection proj) {
|
32 |
extent = new Extent();
|
33 |
data = new Vector(); |
34 |
} |
35 |
|
36 |
public void add(Extent.Has obj) { |
37 |
if (obj != null) { |
38 |
extent.add(obj.getExtent()); |
39 |
data.add(obj); |
40 |
} |
41 |
} |
42 |
|
43 |
public Extent.Has get(int cnt) { |
44 |
return (Extent.Has) data.get(cnt);
|
45 |
} |
46 |
|
47 |
public IObjList getAt(Point2D pt) { |
48 |
IObjList oList = new DxfEntityList(proj);
|
49 |
Iterator iter = iterator();
|
50 |
while (iter.hasNext()) {
|
51 |
Extent.Has o = (Extent.Has) iter.next(); |
52 |
if (o.getExtent().isAt(pt)) oList.add(o);
|
53 |
} |
54 |
return oList;
|
55 |
} |
56 |
|
57 |
public Iterator iterator() { return data.iterator(); } |
58 |
public int size() { return data.size(); } |
59 |
|
60 |
public void remove(Object obj) { data.remove(obj); } |
61 |
|
62 |
public void clear() { |
63 |
extent = new Extent();
|
64 |
data.clear(); |
65 |
} |
66 |
|
67 |
public IProjection getProjection() { return proj; } |
68 |
public void setProjection(IProjection p) { proj = p; } |
69 |
public void reProject(ICoordTrans rp) { |
70 |
extent = new Extent();
|
71 |
PxObj o; |
72 |
Iterator iter = iterator();
|
73 |
while (iter.hasNext()) {
|
74 |
o = (PxObj) iter.next(); |
75 |
((Projected) o).reProject(rp); |
76 |
extent.add(o.getExtent()); |
77 |
} |
78 |
setProjection(rp.getPDest()); |
79 |
} |
80 |
|
81 |
public void draw(Graphics2D g, ViewPortData vp) { |
82 |
Iterator iter = iterator();
|
83 |
Extent extent; |
84 |
while (iter.hasNext()) {
|
85 |
DxfEntity entity = (DxfEntity) iter.next(); |
86 |
extent = entity.getExtent(); |
87 |
if (vp.getExtent().minX()> extent.maxX()) continue; |
88 |
if (vp.getExtent().minY()> extent.maxY()) continue; |
89 |
if (vp.getExtent().maxX()< extent.minX()) continue; |
90 |
if (vp.getExtent().maxY()< extent.minY()) continue; |
91 |
if (!entity.layer.frozen && ! entity.layer.isOff)
|
92 |
entity.draw(g, vp); |
93 |
} |
94 |
} |
95 |
|
96 |
public String toDxfString() { |
97 |
StringBuffer sb = new StringBuffer(""); |
98 |
|
99 |
Iterator iter = iterator();
|
100 |
Extent extent; |
101 |
while (iter.hasNext()) {
|
102 |
sb.append(((DxfEntity) iter.next()).toDxfString()); |
103 |
} |
104 |
return sb.toString();
|
105 |
} |
106 |
} |
107 |
|