Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / FMap.java @ 214

History | View | Annotate | Download (7.66 KB)

1
/* Generated by Together */
2
package com.iver.cit.gvsig.fmap;
3

    
4
import java.awt.Graphics2D;
5
import java.awt.Toolkit;
6
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
import com.iver.cit.gvsig.fmap.core.FGeometry;
15
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
import com.iver.cit.gvsig.fmap.operations.selection.Record;
24
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureSelectorVisitor;
25
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor;
26

    
27

    
28
/**
29
 * DOCUMENT ME!
30
 *
31
 * @author Fernando Gonz?lez Cort?s
32
 */
33
public class FMap implements Projected {
34
    private static final double[] CHANGEM = {
35
            1000, 1, 0.01, 0.001, 1609.344, 0.9144, 0.3048, 0.0254
36
        };
37

    
38
        /** DOCUMENT ME! */
39
        public static final double[] CHANGE = {
40
            100000, 100, 1, 0.1, 160934.4, 91.44, 30.48, 2.54
41
        };
42
        
43
        public static final int EQUALS = 0;
44
        public static final int DISJOINT = 1;
45
        public static final int INTERSECTS = 2;
46
        public static final int TOUCHES = 3;
47
        public static final int CROSSES = 4;
48
        public static final int WITHIN = 5;
49
        public static final int CONTAINS = 6;
50
        public static final int OVERLAPS = 7;
51
        private FLayers layers = new FLayers();
52
        private ViewPort viewPort;
53

    
54
        public FMap(ViewPort vp){
55
                this.viewPort = vp;
56
        }
57
        
58
        /**
59
         * DOCUMENT ME!
60
         *
61
         * @return DOCUMENT ME!
62
         */
63
        public FLayers getLayers() {
64
                return layers;
65
        }
66

    
67
        /**
68
         * Dibuja en la imagen que se pasa como par?metro el contenido de las capas
69
         * visibles del mapa y teniendo en cuenta los datos del ViewPort contenido
70
         * en este FMap
71
         *
72
         * @param b DOCUMENT ME!
73
         */
74
        public void drawLabels(BufferedImage b) {
75
        }
76

    
77
        /**
78
         * DOCUMENT ME!
79
         *
80
         * @param g DOCUMENT ME!
81
         */
82
        public void print(Graphics2D g) {
83
        }
84

    
85
        /**
86
         * Crea un nuevo FMap con la informaci?n del ViewPort que se pasa como
87
         * par?metro.
88
         *
89
         * @param vp DOCUMENT ME!
90
         *
91
         * @return DOCUMENT ME!
92
         */
93
        public FMap createNewFMap(ViewPort vp) {
94
                FMap ret = new FMap(vp);
95
                ret.layers = this.layers;
96

    
97
                return ret;
98
        }
99

    
100
        /**
101
         * Crea un nuevo FMap totalmente desligado, se replican las capas y el
102
         * ViewPort
103
         *
104
         * @return DOCUMENT ME!
105
         */
106
        public FMap cloneFMap() {
107
                return createXMLEntity(getXMLEntity());
108
        }
109

    
110
        /**
111
         * DOCUMENT ME!
112
         *
113
         * @return DOCUMENT ME!
114
         */
115
        public XMLEntity getXMLEntity() {
116
                return new XMLEntity();
117
        }
118

    
119
        /**
120
         * DOCUMENT ME!
121
         *
122
         * @param xe DOCUMENT ME!
123
         *
124
         * @return DOCUMENT ME!
125
         */
126
        public FMap createXMLEntity(XMLEntity xe) {
127
                // TODO Implementar bien
128
                return new FMap(null);
129
        }
130

    
131
        /**
132
         * A?ade la capa que se pasa como par?metro al nodo que se pasa como
133
         * parametro y lanza ProjectionMismatchException si no est?n todas las
134
         * capas de este FMap en la misma proyecci?n. Lanza un
135
         * ChildNotAllowedException si la capa no es un FLayers y no permite hijos
136
         *
137
         * @param parent DOCUMENT ME!
138
         * @param layer DOCUMENT ME!
139
         *
140
         * @throws ProjectionMismatchException DOCUMENT ME!
141
         * @throws ChildrenNotAllowedException DOCUMENT ME!
142
         */
143
        public void addLayer(LayerPath parent, FLayer layer)
144
                throws ProjectionMismatchException, ChildrenNotAllowedException {
145
                layers.addLayer(parent, layer);
146
        }
147

    
148
        /**
149
         * A?ade una capa al grupo de capas que se sit?a por encima de todas las
150
         * otras capas
151
         *
152
         * @param vectorial DOCUMENT ME!
153
         */
154
        public void addToTrackLayer(FLyrVect vectorial) {
155
        }
156
        
157
    public long getScaleView() {
158
        Toolkit kit = Toolkit.getDefaultToolkit();
159
        double dpi = kit.getScreenResolution();
160
        IProjection proj = layers.getProjection();
161

    
162
        double w = ((viewPort.getImageSize().getWidth() / dpi) * 2.54);
163

    
164
        if (viewPort.getAdjustedExtent() == null) {
165
            return 0;
166
        }
167

    
168
        
169
        if (proj == null)
170
                return (long) (viewPort.getAdjustedExtent().getWidth() / w * CHANGE[getViewPort()
171
                                                               .getMapUnits()]);
172
        return (long) proj.getScale(viewPort.getAdjustedExtent().getMinX(), viewPort.getAdjustedExtent().getMaxX(), viewPort.getImageSize().getWidth(), dpi);
173
    }
174

    
175
        /**
176
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#setVectorial(com.iver.cit.gvsig.fmap.VectorialAdapter)
177
         */
178
        public void setVectorial(VectorialAdapter v) {
179
        }
180

    
181
        /**
182
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#process(com.iver.cit.gvsig.fmap.FeatureSelectorVisitor)
183
         */
184
        public void process(FeatureSelectorVisitor visitor) {
185
        }
186

    
187
        /**
188
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#processSelected(com.iver.cit.gvsig.fmap.FeatureVisitor)
189
         */
190
        public void processSelected(FeatureVisitor visitor) {
191
        }
192

    
193
        /**
194
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#select(com.iver.cit.gvsig.fmap.FeatureSelectorVisitor)
195
         */
196
        public void select(FeatureSelectorVisitor visitor) {
197
        }
198

    
199
        /**
200
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectFromSelection()
201
         */
202
        public void selectFromSelection() {
203
        }
204

    
205
        /**
206
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#createIndex()
207
         */
208
        public void createIndex() {
209
        }
210

    
211
        /**
212
         * @see org.cresques.geo.Projected#getProjection()
213
         */
214
        public IProjection getProjection() {
215
                return null;
216
        }
217

    
218
        /**
219
         * @see org.cresques.geo.Projected#reProject(org.cresques.cts.ICoordTrans)
220
         */
221
        public void reProject(ICoordTrans arg0) {
222
        }
223

    
224
        /**
225
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectByPoint(java.awt.geom.Point2D,
226
         *                 double)
227
         */
228
        public void selectByPoint(Point2D p, double tolerance) {
229
        }
230

    
231
        /**
232
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectByRect(java.awt.geom.Rectangle2D)
233
         */
234
        public void selectByRect(Rectangle2D rect) {
235
        }
236

    
237
        /**
238
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#selectByShape(com.iver.cit.gvsig.fmap.fshape.FGeometry,
239
         *                 int)
240
         */
241
        public void selectByShape(FGeometry g, int relationship) {
242
        }
243

    
244
        /**
245
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByPoint(java.awt.geom.Point2D,
246
         *                 double)
247
         */
248
        public Record[] queryByPoint(Point2D p, double tolerance) {
249
                return null;
250
        }
251

    
252
        /**
253
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByRect(java.awt.geom.Rectangle2D)
254
         */
255
        public Record[] queryByRect(Rectangle2D rect) {
256
                return null;
257
        }
258

    
259
        /**
260
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#queryByShape(com.iver.cit.gvsig.fmap.fshape.FGeometry,
261
         *                 int)
262
         */
263
        public Record[] queryByShape(FGeometry g, int relationship) {
264
                return null;
265
        }
266

    
267
        /**
268
         * @see com.iver.cit.gvsig.fmap.operations.strategies.Strategy#getSelectionBounds()
269
         */
270
        public Rectangle2D getSelectionBounds() {
271
                return null;
272
        }
273

    
274
        /**
275
         * DOCUMENT ME!
276
         *
277
         * @param image DOCUMENT ME!
278
         * @param g DOCUMENT ME!
279
         * @param viewPort DOCUMENT ME!
280
         *
281
         * @throws DriverIOException
282
         *
283
         * @see com.iver.cit.gvsig.fmap.operations.Operations#draw(java.awt.image.BufferedImage,
284
         *                 java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort)
285
         */
286
        public void draw(BufferedImage image, Graphics2D g)
287
                throws DriverIOException {
288
                layers.draw(image, g, viewPort);
289
        }
290
        /**
291
         * @return Returns the viewPort.
292
         */
293
        public ViewPort getViewPort() {
294
                return viewPort;
295
        }
296
        /**
297
         * @param viewPort The viewPort to set.
298
         */
299
        public void setViewPort(ViewPort viewPort) {
300
                this.viewPort = viewPort;
301
        }
302
}