Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / FGeometryCollection.java @ 3051

History | View | Annotate | Download (5.37 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.fmap.core;
42

    
43
import com.iver.cit.gvsig.fmap.ViewPort;
44
import com.iver.cit.gvsig.fmap.core.v02.FLabel;
45
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
46
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D;
47

    
48
import com.vividsolutions.jts.geom.Geometry;
49

    
50
import org.cresques.cts.ICoordTrans;
51
import org.geotools.data.postgis.attributeio.WKBEncoder;
52

    
53
import java.awt.Graphics2D;
54
import java.awt.geom.Rectangle2D;
55
import java.io.IOException;
56

    
57

    
58
/**
59
 * Colecci?n de Geometr?as.
60
 *
61
 * @author Vicente Caballero Navarro
62
 */
63
public class FGeometryCollection implements IGeometry {
64
        private IGeometry[] geometries;
65

    
66
        /**
67
         * Crea un nuevo FGeometryCollection.
68
         *
69
         * @param geoms vector de geometr?as.
70
         */
71
        public FGeometryCollection(IGeometry[] geoms) {
72
                geometries = geoms;
73
        }
74

    
75
        /**
76
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D,
77
         *                 com.iver.cit.gvsig.fmap.ViewPort, FStyle2D)
78
         */
79
        public void draw(Graphics2D g, ViewPort vp, FStyle2D symbol) {
80
                for (int i = 0; i < geometries.length; i++)
81
                        geometries[i].draw(g, vp, symbol);
82
        }
83

    
84
        /**
85
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#createLabels(int, boolean)
86
         */
87
        public FLabel[] createLabels(int position, boolean duplicates) {
88
                return null;
89
        }
90

    
91
        /**
92
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#intersects(java.awt.geom.Rectangle2D)
93
         */
94
        public boolean intersects(Rectangle2D r) {
95
            boolean resul = false;
96
                for (int i = 0; i < geometries.length; i++)
97
                {
98
                        resul = geometries[i].intersects(r);
99
                        if (resul) break;
100
                }
101
                
102
                return resul;
103
        }
104

    
105
        /**
106
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#getBounds2D()
107
         */
108
        public Rectangle2D getBounds2D() {
109
                Rectangle2D rAux = null;
110

    
111
                for (int i = 0; i < geometries.length; i++)
112
                        rAux.createUnion(geometries[i].getBounds2D());
113

    
114
                return rAux;
115
        }
116

    
117
        /**
118
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeometryType()
119
         */
120
        public int getGeometryType() {
121
                int ret = 0;
122

    
123
                for (int i = 0; i < geometries.length; i++) {
124
                        ret = ret & geometries[i].getGeometryType();
125
                }
126

    
127
                return ret;
128
        }
129

    
130
        /* (non-Javadoc)
131
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#draw(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.core.v02.FSymbol)
132
         */
133
        public void draw(Graphics2D g, ViewPort vp, FSymbol symbol) {
134
                for (int i = 0; i < geometries.length; i++)
135
                        geometries[i].draw(g, vp, symbol);
136
        }
137

    
138
        /* (non-Javadoc)
139
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#cloneGeometry()
140
         */
141
        public IGeometry cloneGeometry() {
142
                IGeometry[] newGeometries = new IGeometry[geometries.length];
143

    
144
                for (int i = 0; i < geometries.length; i++)
145
                        newGeometries[i] = geometries[i].cloneGeometry();
146

    
147
                return new FGeometryCollection(newGeometries);
148
        }
149

    
150
        /* (non-Javadoc)
151
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#toJTSGeometry()
152
         */
153
        public Geometry toJTSGeometry() {
154
                // TODO Auto-generated method stub
155
                return null;
156
        }
157

    
158
        /* (non-Javadoc)
159
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#reProject(org.cresques.cts.ICoordTrans)
160
         */
161
        public void reProject(ICoordTrans ct) {
162
                for (int i = 0; i < geometries.length; i++)
163
                        geometries[i].reProject(ct);
164
        }
165

    
166
        /**
167
         * @see com.iver.cit.gvsig.fmap.core.IGeometry#getGeneralPathXIterator()
168
         */
169
        public GeneralPathXIterator getGeneralPathXIterator() {
170
                //TODO no esta implementado.
171
                return null;
172
        }
173

    
174
    /* (non-Javadoc)
175
     * @see com.iver.cit.gvsig.fmap.core.IGeometry#fastIntersects(double, double, double, double)
176
     */
177
    public boolean fastIntersects(double x, double y, double w, double h) {
178
            boolean resul = false;
179
                for (int i = 0; i < geometries.length; i++)
180
                {
181
                        resul = geometries[i].fastIntersects(x,y,w,h);
182
                        if (resul) break;
183
                }                
184
                return resul;
185
    }
186

    
187
    /**
188
     * @see com.iver.cit.gvsig.fmap.core.IGeometry#toWKB()
189
     */
190
    public byte[] toWKB() throws IOException {
191
        return WKBEncoder.encodeGeometry(toJTSGeometry());
192
    }
193

    
194
    /* (non-Javadoc)
195
     * @see com.iver.cit.gvsig.fmap.core.IGeometry#drawInts(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.core.v02.FSymbol)
196
     */
197
    public void drawInts(Graphics2D g, ViewPort vp, FSymbol symbol) {
198
        for (int i = 0; i < geometries.length; i++)
199
            geometries[i].drawInts(g, vp, symbol);        
200
        
201
    }
202
}