Statistics
| Revision:

svn-gvsig-desktop / tags / v1_1_Build_1002 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLayer.java @ 12070

History | View | Annotate | Download (11.8 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.layers;
42

    
43
import java.awt.Graphics2D;
44
import java.awt.Image;
45
import java.awt.geom.Rectangle2D;
46
import java.awt.image.BufferedImage;
47
import java.io.File;
48
import java.util.List;
49
import java.util.Map;
50

    
51
import javax.print.attribute.PrintRequestAttributeSet;
52
import javax.swing.ImageIcon;
53

    
54
import org.cresques.cts.ICoordTrans;
55
import org.cresques.cts.IProjection;
56
import org.cresques.geo.Projected;
57

    
58
import com.iver.cit.gvsig.fmap.DriverException;
59
import com.iver.cit.gvsig.fmap.MapContext;
60
import com.iver.cit.gvsig.fmap.MapControl;
61
import com.iver.cit.gvsig.fmap.ViewPort;
62
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
63
import com.iver.cit.gvsig.fmap.edition.EditionException;
64
import com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer;
65
import com.iver.utiles.XMLEntity;
66
import com.iver.utiles.swing.threads.Cancellable;
67

    
68

    
69
/**
70
 * Interfaz que tienen que implementar todas las capas.
71
 */
72
public interface FLayer extends Projected {
73
        /**
74
         * Obtiene una representaci?n de la colecci?n de capas de forma recursiva
75
         *
76
         * @return XMLEntity.
77
         * @throws XMLException
78
         */
79
        XMLEntity getXMLEntity() throws XMLException;
80

    
81
        /**
82
         * Inserta las propiedades del XMLEntity al objeto actual.
83
         *
84
         * @param xml XMLEntity
85
         *
86
         * @throws XMLException
87
         */
88
        void setXMLEntity(XMLEntity xml) throws XMLException;
89

    
90
        /**
91
         * Inserta las propiedades del XMLEntity al objeto actual.
92
         *
93
         * @param xml XMLEntity
94
         *
95
         * @throws XMLException
96
         */
97
        void setXMLEntity03(XMLEntity xml) throws XMLException;
98

    
99
        /**
100
         * Pone la capa actual a activa o inactiva seg?n el boolean que se pasa
101
         * como par?metro.
102
         *
103
         * @param selected activa.
104
         */
105
        void setActive(boolean selected);
106

    
107
        /**
108
         * Devuelve true si la capa esta activa.
109
         *
110
         * @return activa.
111
         */
112
        boolean isActive();
113

    
114
        /**
115
         * Inserta un nombre a la capa.
116
         *
117
         * @param name nombre.
118
         */
119
        void setName(String name);
120

    
121
        /**
122
         * Devuelve el nombre de la capa.
123
         *
124
         * @return nombre de la capa.
125
         */
126
        String getName();
127

    
128
        /**
129
         * Realiza las operaciones de inicializaci?n de la capa. El m?todo es
130
         * invocado una ?nica vez durante la vida de la capa y justo antes de
131
         * visualizar la capa
132
         *
133
         * @throws DriverIOException
134
         */
135
        void load() throws DriverIOException;
136

    
137
        /**
138
         * Pone la capa en modo visible o no visible.
139
         *
140
         * @param visibility visibilidad.
141
         */
142
        void setVisible(boolean visibility);
143

    
144
        /**
145
         * Devuelve true si la capa es visible.
146
         * Es dependiente isAvialable @link isAvialable 
147
         *
148
         * @return visibilidad.
149
         * 
150
         * @see isAvialable()
151
         * @see setAvialable()
152
         * @see visibleRequired()
153
         */
154
        boolean isVisible();
155

    
156
        /**
157
         * Devuelve el FLayers padre de la capa.
158
         *
159
         * @return FLayers padre de la capa.
160
         */
161
        public FLayers getParentLayer();
162

    
163
        /**
164
         * Devuelve el FMap al que est? a?adida la capa o null si la capa no ha
165
         * sido a?adida a ning?n FMap
166
         *
167
         * @return FMap
168
         */
169
        public MapContext getMapContext();
170

    
171
        /**
172
         * Inserta el FLayers padre de la capa.
173
         *
174
         * @param root capa padre.
175
         */
176
        public void setParentLayer(FLayers root);
177

    
178
        /**
179
         * Obtiene la extensi?n completa de la capa
180
         *
181
         * @return FullExtent.
182
         *
183
         * @throws DriverException
184
         */
185
        Rectangle2D getFullExtent() throws DriverException;
186

    
187
        /**
188
         * Dibuja la capa
189
         *
190
         * @param image Imagen utilizada para acelerar el dibujado en pantalla.
191
         * @param g Graphics2D sobre el que dibujar.
192
         * @param viewPort Propiedades de la vista.
193
         * @param cancel PAra poder cancelar el dibujado.
194
         *
195
         * @throws DriverException
196
         */
197
        void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
198
                Cancellable cancel,double scale) throws DriverException;
199

    
200
        /**
201
         * Dibuja la capa
202
         *
203
         * @param g Graphics2D de la impresora sobre el que dibujar.
204
         * @param viewPort Propiedades de la vista.
205
         * @param cancel
206
         *
207
         * @throws DriverException
208
         */
209
        void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties)
210
                throws DriverException;
211

    
212
        /**
213
         * Inserta las coordenadas de transformaci?n.
214
         *
215
         * @param ct Coordenadas de transformaci?n.
216
         */
217
        void setCoordTrans(ICoordTrans ct);
218

    
219
        /**
220
         * Devuelve las coordenadas de transformaci?n.
221
         *
222
         * @return Coordenadas de transformaci?n.
223
         */
224
        ICoordTrans getCoordTrans();
225

    
226
        /**
227
         * A?ade un listener LayerListener a la lista de listeners.
228
         *
229
         * @param o Listener.
230
         *
231
         * @return True si es correcta la inserci?n del listener.
232
         */
233
        public boolean addLayerListener(LayerListener o);
234
        public LayerListener[] getLayerListeners();
235
        /**
236
         * Borra de la lista el LayerListener que se pasa como par?metro.
237
         *
238
         * @param o Listener.
239
         *
240
         * @return True si es correcto el borrado del listener.
241
         */
242
        public boolean removeLayerListener(LayerListener o);
243

    
244
        public boolean isWithinScale(double scale);
245

    
246

    
247
        /**
248
         * La capa no se visualiza si est? por debajo de esa escala
249
         * @return la escala minima de visualizaci?n
250
         */
251
        public double getMinScale();
252

    
253
        /**
254
         * La capa no se visualiza si est? por encima de esa escala
255
         * @return la escala m?xima de visualizaci?n
256
         */
257
        public double getMaxScale();
258

    
259
        public void setMinScale(double minScale);
260
        public void setMaxScale(double maxScale);
261
        public void setEditing(boolean b) throws EditionException;
262
        public boolean isEditing();
263
        
264
        public boolean isCachingDrawnLayers();
265
        /**
266
         * Set true if you want this layer to store an image of previous layers
267
         * Then, if you perform and "FLayers.invalidateLayer(lyr)", the system will
268
         * redraw only the layers you are requesting.
269
         * Otra opci?n ser?a guardar una imagen de cada capa dibujada, y poner una
270
         * llamada en cada una de ellas, algo como "invalidate()". Al renderizar, 
271
         * se puede ver si est? invalidada, y si no lo est?, pegar la imagen cacheada.
272
         * ERROR!: Luis tiene raz?n en esto: No puedes cachear esa imagen porque 
273
         * si el fondo ha cambiado, el antialiasing afectar? al dibujado de esa capa.
274
         * Sin embargo, s? ser?a ?til si lo que se hace es dibujar la imagen cacheada
275
         * de cada una de las capas que no est?n invalidadas, y a partir de que aparezca
276
         * una de ellas invalidada, el resto ya se tienen que dibujar.
277
         * La pega de que consumes m?s memoria sigue estando presente. 
278
         * @param bCacheDrawnLayers
279
         */
280
        public void setCachingDrawnLayers(boolean bCacheDrawnLayers);
281
        
282
        /**
283
         * Icono a mostrar en el TOC junto a la capa
284
         * @return el icono
285
         */
286
        public ImageIcon getTocImageIcon();
287

    
288
        /**
289
         * If the layer appears in the TOC then <b>true</b> is returned,
290
         * if <b>false</b> the layer will not be displayed at the TOC
291
         * although it remains in the view and in the project
292
         */
293
        boolean isInTOC();
294
        
295
        /**
296
         * @return true if this layer need a repaint.
297
         */
298
        public boolean isDirty();
299

    
300
        /**
301
         * true if this layer need a repaint. By default, all layers will be
302
         * set to dirty when the extent changes. But for events like changing
303
         * its legend, or editing a layer, we can perform some optimization
304
         * in the method prepareDrawing from FMap.
305
         * @param dirty
306
         */
307
        public void setDirty(boolean dirty);
308
        
309
        public BufferedImage getCacheImageDrawnLayers();
310

    
311
        public void setCacheImageDrawnLayers(BufferedImage cacheImageDrawnLayers);
312

    
313
        
314
        /**
315
         * Returns the status of the layer
316
         */
317
        public FLayerStatus getFLayerStatus();
318
        /**
319
         * Sets the status of the layer
320
         * @param status
321
         */
322
        public void setFLayerStatus(FLayerStatus status);
323
        
324
        
325
        /*
326
         * This stuff is to save error's info that causes
327
         * unavailable status.
328
         * */
329
        /**
330
         * Return if the layer is in OK status
331
         * (it hasnt got errors)
332
         */
333
        public boolean isOk();
334
        /**
335
         * returns the number of errors that causes layer
336
         * unavailable status
337
         * @return
338
         */
339
        public int getNumErrors();
340
        
341
        /**
342
         * return the specified error
343
         * @param i
344
         * @return
345
         */
346
        public DriverException getError(int i);
347
        
348
        /**
349
         * add an error cause to describe the layer's wrong status
350
         * @param error
351
         */
352
        public void addError(DriverException error);
353
        
354
        /**
355
         * Returns a list with all layer errors
356
         * @return
357
         */
358
        public List getErrors();
359
        
360

    
361
        /**
362
         * @return set layer aviable or not.
363
         */
364
        public void setAvailable(boolean available);
365
        
366
        /**
367
         * @return true if this layer is aviable.
368
         * 
369
         * Default value is true.
370
         */        
371
        public boolean isAvailable();
372
        
373
        /**
374
         * Intenta recuperar una capa ante un posible error.
375
         * Si tiene algun problema en la carga, marca
376
         * el avialable a false y lanza una excepcion.
377
         *
378
         * @throws DriverIOException
379
         */
380
        public void reload() throws DriverIOException;
381
        
382
        
383
        /**
384
         * Devuelve true si la capa esta establecida como visible.
385
         *
386
         * @return visibilidad.
387
         */
388
        boolean visibleRequired();
389

    
390
        /**
391
         * Devuelve una cadena con informacion sobre la capa.
392
         *
393
         * @return visibilidad.
394
         */
395
        public String getInfoString();
396
        
397
        /**
398
         * @return true if this layer can be put in edition mode and save the
399
         * edits in itself.
400
         */
401
        public boolean isWritable();
402
        
403
        /**
404
         * Useful to associate any object to a layer. For example, you
405
         * can attach a network definition to key "network" and
406
         * check if a layer has a network loaded if getAssociatedObject("network")
407
         * is not null
408
         * 
409
         * @param key
410
         * @return null if key is not found
411
         */
412
        public Object getProperty(Object key);
413
        
414
        /**
415
         * @param key
416
         * @param obj
417
         */
418
        public void setProperty(Object key, Object obj);
419

    
420
        /**
421
         * This method can be used to have a fast cloned layer. The implementations should take care of
422
         * NOT recreate the layer. Instead of this, is better to use the same source (driver) and deepclone
423
         * the legend. Exception=> the labels aren't deepcloned to avoid memory consumption. 
424
         * Note: Labels are memory consuming to speed up layers like PostGIS and so on.
425
         * @return clonedLayer
426
         * @throws Exception 
427
         */
428
        public FLayer cloneLayer() throws Exception;
429
        
430
        public Map getExtendedProperties();
431

    
432
        /**
433
         * Return a new instance of ComposedLayer. 
434
         * This allow make a single draw for a group
435
         * of layers with the same source.
436
         * 
437
         * If this operation is not aplicable for this 
438
         * kind of layer this method returns null.
439
         * 
440
         * @see com.iver.cit.gvsig.fmap.layers.layerOperations.ComposedLayer
441
         * @return ComposedLayer instance or null
442
         */
443
        public ComposedLayer  newComposedLayer();
444
        
445
        /**
446
         * @return
447
         */
448
        Image getTocStatusImage();
449
        
450
        /**
451
         * Devuelve true en el caso de que la capa sea de un tipo reproyectable.
452
         * @return
453
         */
454
        public boolean isReprojectable();
455
        
456
        /**
457
         * M?todo que se encarga de reproyectar la capa. En cada tipo de capa se sobrecargar?
458
         * este m?todo para que se realicen las operaciones necesarias.
459
         * @return Devuelve true en el caso de que sea AddLayer la clase que se tenga que encargar de crear
460
         * la capa. Devolver? false si se pasa el control de la carga de la capa al m?todo de reproyecci?n
461
         */
462
        public boolean reProject(MapControl mapC);
463
        
464
        /**
465
         * Inserta una proyecci?n.
466
         * @param proj, proyecci?n.
467
         */
468
        public void setProjection(IProjection proj);
469

    
470
}