Statistics
| Revision:

svn-gvsig-desktop / branches / CqCMSDvp / libraries / libCq CMS for java.old / src / org / cresques / px / gml / FeatureCollection.java @ 2312

History | View | Annotate | Download (3.33 KB)

1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 * 
4
 * Copyright (C) 2004-5. 
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 * 
22
 * cresques@gmail.com
23
 */
24
package org.cresques.px.gml;
25

    
26
import java.awt.Graphics2D;
27
import java.awt.geom.Point2D;
28
import java.util.Hashtable;
29
import java.util.Iterator;
30
import java.util.Vector;
31

    
32
import org.cresques.cts.ICoordTrans;
33
import org.cresques.cts.IProjection;
34
import org.cresques.geo.ViewPortData;
35
import org.cresques.px.Extent;
36
import org.cresques.px.IObjList;
37
import org.cresques.px.PxObj;
38
import org.cresques.px.dxf.DxfEntityList;
39

    
40
/**
41
 * FeatureCollection de .gml y .shp
42
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
43
 */
44

    
45
// 040704 --> Acabo de a?adir a FeatureCollection las capacidades de almacenamiento
46
//                          propias de Feature, con el fin de utilizar las Featurecollections
47
//            para construir los bloques.
48

    
49
public class FeatureCollection extends PxObj implements IObjList.vector {
50
        IProjection proj = null;
51
        public Vector data = null;
52
        
53
        Hashtable property = null;
54
        Geometry geometry = null;
55
        
56
        public FeatureCollection(IProjection proj) {
57
                extent = new Extent();
58
                data = new Vector();
59
                property = new Hashtable();
60
        }
61
        
62
        public void setProp(String prop, String value) {
63
                property.put(prop, value);
64
        }
65
        
66
        public String getProp(String prop) {
67
                return (String) property.get(prop);
68
        }
69
        
70
        public void add(Extent.Has feature) {
71
                Extent ext = feature.getExtent();
72
                if (extent != null) {
73
                        extent.add(ext);
74
                        data.add(feature);
75
                }
76
        }
77
        
78
        public IObjList getAt(Point2D pt) {
79
                IObjList oList = new DxfEntityList(proj);
80
                Iterator iter = iterator();
81
                while (iter.hasNext()) {
82
                        Extent.Has o = (Extent.Has) iter.next();
83
                        if (o.getExtent().isAt(pt)) oList.add(o);
84
                }
85
                return oList;
86
        }
87
        
88
        public Iterator iterator() { return data.iterator(); }
89
        public int size() { return data.size(); }
90
        
91
        public void remove(Object obj) { data.remove(obj); }
92

    
93
        public void clear() {
94
                extent = new Extent();
95
                data.clear();
96
        }
97
        public Extent.Has get(int i) { return (Extent.Has) data.get(i); }
98

    
99
        public IProjection getProjection() { return proj; }
100
        public void setProjection(IProjection p) { proj = p; }
101
        public void reProject(ICoordTrans rp) {
102
                extent = new Extent();
103
                Feature f;
104
                Geometry g;
105
                Iterator iter = iterator();
106
                while (iter.hasNext()) {
107
                        f = (Feature) iter.next();
108
                        g = f.getGeometry();
109
                        g.reProject(rp);
110
                        extent.add(g.getExtent());
111
                }
112
                setProjection(rp.getPDest());
113
        }
114
        
115
        public void draw(Graphics2D g, ViewPortData vp) {
116
                Iterator iter = iterator();
117
                while (iter.hasNext()) {
118
                        Feature f = (Feature) iter.next();
119
                        f.draw(g, vp);
120
                }
121
        }
122
        
123
        public Extent getExtent() { return extent; }
124
}
125