Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / FMap.java @ 325

History | View | Annotate | Download (8.4 KB)

1 213 fernando
/* Generated by Together */
2
package com.iver.cit.gvsig.fmap;
3
4
import java.awt.Graphics2D;
5 214 fernando
import java.awt.Toolkit;
6 213 fernando
import java.awt.geom.Point2D;
7
import java.awt.geom.Rectangle2D;
8
import java.awt.image.BufferedImage;
9
10
import org.cresques.cts.ICoordTrans;
11
import org.cresques.cts.IProjection;
12
import org.cresques.geo.Projected;
13
14 305 fjp
import com.iver.cit.gvsig.fmap.core.IGeometry;
15 214 fernando
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
16
import com.iver.cit.gvsig.fmap.layers.ChildrenNotAllowedException;
17
import com.iver.cit.gvsig.fmap.layers.FLayer;
18
import com.iver.cit.gvsig.fmap.layers.FLayers;
19
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
20
import com.iver.cit.gvsig.fmap.layers.LayerPath;
21
import com.iver.cit.gvsig.fmap.layers.ProjectionMismatchException;
22
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter;
23 244 fernando
import com.iver.cit.gvsig.fmap.operations.Cancellable;
24 214 fernando
import com.iver.cit.gvsig.fmap.operations.selection.Record;
25
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor;
26 325 fernando
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D;
27 213 fernando
28
29
/**
30
 * DOCUMENT ME!
31
 *
32
 * @author Fernando Gonz?lez Cort?s
33
 */
34 214 fernando
public class FMap implements Projected {
35 230 fernando
    public static final double[] CHANGEM = {
36 214 fernando
            1000, 1, 0.01, 0.001, 1609.344, 0.9144, 0.3048, 0.0254
37
        };
38
39
        /** DOCUMENT ME! */
40
        public static final double[] CHANGE = {
41
            100000, 100, 1, 0.1, 160934.4, 91.44, 30.48, 2.54
42
        };
43
44 213 fernando
        public static final int EQUALS = 0;
45
        public static final int DISJOINT = 1;
46
        public static final int INTERSECTS = 2;
47
        public static final int TOUCHES = 3;
48
        public static final int CROSSES = 4;
49
        public static final int WITHIN = 5;
50
        public static final int CONTAINS = 6;
51
        public static final int OVERLAPS = 7;
52
        private FLayers layers = new FLayers();
53
        private ViewPort viewPort;
54
55 214 fernando
        public FMap(ViewPort vp){
56
                this.viewPort = vp;
57
        }
58
59 213 fernando
        /**
60
         * DOCUMENT ME!
61
         *
62
         * @return DOCUMENT ME!
63
         */
64
        public FLayers getLayers() {
65
                return layers;
66
        }
67
68
        /**
69
         * Dibuja en la imagen que se pasa como par?metro el contenido de las capas
70
         * visibles del mapa y teniendo en cuenta los datos del ViewPort contenido
71
         * en este FMap
72
         *
73
         * @param b DOCUMENT ME!
74
         */
75
        public void drawLabels(BufferedImage b) {
76
        }
77
78
        /**
79
         * DOCUMENT ME!
80
         *
81
         * @param g DOCUMENT ME!
82
         */
83
        public void print(Graphics2D g) {
84
        }
85
86
        /**
87
         * Crea un nuevo FMap con la informaci?n del ViewPort que se pasa como
88
         * par?metro.
89
         *
90
         * @param vp DOCUMENT ME!
91
         *
92
         * @return DOCUMENT ME!
93
         */
94
        public FMap createNewFMap(ViewPort vp) {
95 214 fernando
                FMap ret = new FMap(vp);
96 213 fernando
                ret.layers = this.layers;
97
98
                return ret;
99
        }
100
101
        /**
102
         * Crea un nuevo FMap totalmente desligado, se replican las capas y el
103
         * ViewPort
104
         *
105
         * @return DOCUMENT ME!
106
         */
107
        public FMap cloneFMap() {
108
                return createXMLEntity(getXMLEntity());
109
        }
110
111
        /**
112
         * DOCUMENT ME!
113
         *
114
         * @return DOCUMENT ME!
115
         */
116
        public XMLEntity getXMLEntity() {
117
                return new XMLEntity();
118
        }
119
120
        /**
121
         * DOCUMENT ME!
122
         *
123
         * @param xe DOCUMENT ME!
124
         *
125
         * @return DOCUMENT ME!
126
         */
127
        public FMap createXMLEntity(XMLEntity xe) {
128
                // TODO Implementar bien
129 214 fernando
                return new FMap(null);
130 213 fernando
        }
131 245 vcaballero
132 213 fernando
        /**
133
         * A?ade la capa que se pasa como par?metro al nodo que se pasa como
134
         * parametro y lanza ProjectionMismatchException si no est?n todas las
135
         * capas de este FMap en la misma proyecci?n. Lanza un
136
         * ChildNotAllowedException si la capa no es un FLayers y no permite hijos
137
         *
138
         * @param parent DOCUMENT ME!
139
         * @param layer DOCUMENT ME!
140
         *
141
         * @throws ProjectionMismatchException DOCUMENT ME!
142
         * @throws ChildrenNotAllowedException DOCUMENT ME!
143
         */
144 245 vcaballero
/*        public void addLayer(LayerPath parent, FLayer layer)
145 213 fernando
                throws ProjectionMismatchException, ChildrenNotAllowedException {
146
                layers.addLayer(parent, layer);
147
        }
148 241 vcaballero
        public void removeLayer(LayerPath parent)throws ChildrenNotAllowedException{
149
                layers.removeLayer(parent);
150
        }
151 245 vcaballero
        */
152 213 fernando
        /**
153
         * A?ade una capa al grupo de capas que se sit?a por encima de todas las
154
         * otras capas
155
         *
156
         * @param vectorial DOCUMENT ME!
157
         */
158
        public void addToTrackLayer(FLyrVect vectorial) {
159
        }
160 214 fernando
161
    public long getScaleView() {
162
        Toolkit kit = Toolkit.getDefaultToolkit();
163
        double dpi = kit.getScreenResolution();
164
        IProjection proj = layers.getProjection();
165 213 fernando
166 214 fernando
        double w = ((viewPort.getImageSize().getWidth() / dpi) * 2.54);
167
168
        if (viewPort.getAdjustedExtent() == null) {
169
            return 0;
170
        }
171
172
173
        if (proj == null)
174
                return (long) (viewPort.getAdjustedExtent().getWidth() / w * CHANGE[getViewPort()
175
                                                               .getMapUnits()]);
176
        return (long) proj.getScale(viewPort.getAdjustedExtent().getMinX(), viewPort.getAdjustedExtent().getMaxX(), viewPort.getImageSize().getWidth(), dpi);
177
    }
178
179 213 fernando
        /**
180 214 fernando
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#setVectorial(com.iver.cit.gvsig.fmap.VectorialAdapter)
181 213 fernando
         */
182
        public void setVectorial(VectorialAdapter v) {
183
        }
184
185
        /**
186 217 fernando
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#process(com.iver.cit.gvsig.fmap.FeatureSelectorVisitor, VectorialSubSet)
187 213 fernando
         */
188 229 vcaballero
        public void process(FeatureVisitor visitor) {
189 213 fernando
        }
190
191
        /**
192 214 fernando
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#processSelected(com.iver.cit.gvsig.fmap.FeatureVisitor)
193 213 fernando
         */
194
        public void processSelected(FeatureVisitor visitor) {
195
        }
196
197
        /**
198 217 fernando
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#select(com.iver.cit.gvsig.fmap.FeatureSelectorVisitor, VectorialSubSet)
199 213 fernando
         */
200 229 vcaballero
        public void select(FeatureVisitor visitor) {
201 213 fernando
        }
202
203
        /**
204 214 fernando
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectFromSelection()
205 213 fernando
         */
206
        public void selectFromSelection() {
207
        }
208
209
        /**
210 214 fernando
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#createIndex()
211 213 fernando
         */
212
        public void createIndex() {
213
        }
214
215
        /**
216
         * @see org.cresques.geo.Projected#getProjection()
217
         */
218
        public IProjection getProjection() {
219
                return null;
220
        }
221
222
        /**
223
         * @see org.cresques.geo.Projected#reProject(org.cresques.cts.ICoordTrans)
224
         */
225
        public void reProject(ICoordTrans arg0) {
226
        }
227
228
        /**
229 214 fernando
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectByPoint(java.awt.geom.Point2D,
230 213 fernando
         *                 double)
231
         */
232
        public void selectByPoint(Point2D p, double tolerance) {
233
        }
234
235
        /**
236 214 fernando
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectByRect(java.awt.geom.Rectangle2D)
237 213 fernando
         */
238
        public void selectByRect(Rectangle2D rect) {
239
        }
240
241
        /**
242 305 fjp
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectByShape(com.iver.cit.gvsig.fmap.fshape.IGeometry,
243 213 fernando
         *                 int)
244
         */
245 305 fjp
        public void selectByShape(IGeometry g, int relationship) {
246 213 fernando
        }
247
248
        /**
249 214 fernando
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByPoint(java.awt.geom.Point2D,
250 213 fernando
         *                 double)
251
         */
252
        public Record[] queryByPoint(Point2D p, double tolerance) {
253
                return null;
254
        }
255
256
        /**
257 214 fernando
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByRect(java.awt.geom.Rectangle2D)
258 213 fernando
         */
259
        public Record[] queryByRect(Rectangle2D rect) {
260
                return null;
261
        }
262
263
        /**
264 305 fjp
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByShape(com.iver.cit.gvsig.fmap.fshape.IGeometry,
265 213 fernando
         *                 int)
266
         */
267 305 fjp
        public Record[] queryByShape(IGeometry g, int relationship) {
268 213 fernando
                return null;
269
        }
270
271
        /**
272 214 fernando
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#getSelectionBounds()
273 213 fernando
         */
274
        public Rectangle2D getSelectionBounds() {
275
                return null;
276
        }
277
278
        /**
279
         * DOCUMENT ME!
280
         *
281
         * @param image DOCUMENT ME!
282
         * @param g DOCUMENT ME!
283
         * @param viewPort DOCUMENT ME!
284
         *
285
         * @throws DriverIOException
286
         *
287 228 fernando
         * @see com.iver.cit.gvsig.fmap.operations.LayerOperations#draw(java.awt.image.BufferedImage,
288 325 fernando
         *                 java.awt.Graphics2D, FStyle2D)
289 213 fernando
         */
290 244 fernando
        public void draw(BufferedImage image, Graphics2D g, Cancellable cancel)
291
                throws DriverIOException {
292
                layers.draw(image, g, viewPort, cancel);
293
        }
294
295
        /**
296
         * DOCUMENT ME!
297
         *
298
         * @param image DOCUMENT ME!
299
         * @param g DOCUMENT ME!
300
         * @param viewPort DOCUMENT ME!
301
         *
302
         * @throws DriverIOException
303
         *
304
         * @see com.iver.cit.gvsig.fmap.operations.LayerOperations#draw(java.awt.image.BufferedImage,
305 325 fernando
         *                 java.awt.Graphics2D, FStyle2D)
306 244 fernando
         */
307 214 fernando
        public void draw(BufferedImage image, Graphics2D g)
308 213 fernando
                throws DriverIOException {
309 244 fernando
                layers.draw(image, g, viewPort, new Cancellable() {
310
                        /**
311
                         * @see com.iver.cit.gvsig.fmap.operations.Cancellable#isCanceled()
312
                         */
313
                        public boolean isCanceled() {
314
                                return false;
315
                        }
316
                });
317 213 fernando
        }
318 244 fernando
319 213 fernando
        /**
320
         * @return Returns the viewPort.
321
         */
322
        public ViewPort getViewPort() {
323
                return viewPort;
324
        }
325
        /**
326
         * @param viewPort The viewPort to set.
327
         */
328
        public void setViewPort(ViewPort viewPort) {
329
                this.viewPort = viewPort;
330
        }
331
}