Statistics
| Revision:

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

History | View | Annotate | Download (10.6 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.util.List;
48
import java.util.Map;
49

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

    
53
import org.cresques.cts.ICoordTrans;
54
import org.cresques.geo.Projected;
55

    
56
import com.iver.cit.gvsig.fmap.DriverException;
57
import com.iver.cit.gvsig.fmap.MapContext;
58
import com.iver.cit.gvsig.fmap.ViewPort;
59
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
60
import com.iver.cit.gvsig.fmap.edition.EditionException;
61
import com.iver.utiles.XMLEntity;
62
import com.iver.utiles.swing.threads.Cancellable;
63

    
64

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

    
77
        /**
78
         * Inserta las propiedades del XMLEntity al objeto actual.
79
         *
80
         * @param xml XMLEntity
81
         *
82
         * @throws XMLException
83
         */
84
        void setXMLEntity(XMLEntity xml) throws XMLException;
85

    
86
        /**
87
         * Inserta las propiedades del XMLEntity al objeto actual.
88
         *
89
         * @param xml XMLEntity
90
         *
91
         * @throws XMLException
92
         */
93
        void setXMLEntity03(XMLEntity xml) throws XMLException;
94

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

    
103
        /**
104
         * Devuelve true si la capa esta activa.
105
         *
106
         * @return activa.
107
         */
108
        boolean isActive();
109

    
110
        /**
111
         * Inserta un nombre a la capa.
112
         *
113
         * @param name nombre.
114
         */
115
        void setName(String name);
116

    
117
        /**
118
         * Devuelve el nombre de la capa.
119
         *
120
         * @return nombre de la capa.
121
         */
122
        String getName();
123

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

    
133
        /**
134
         * Pone la capa en modo visible o no visible.
135
         *
136
         * @param visibility visibilidad.
137
         */
138
        void setVisible(boolean visibility);
139

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

    
152
        /**
153
         * Devuelve el FLayers padre de la capa.
154
         *
155
         * @return FLayers padre de la capa.
156
         */
157
        public FLayers getParentLayer();
158

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

    
167
        /**
168
         * Inserta el FLayers padre de la capa.
169
         *
170
         * @param root capa padre.
171
         */
172
        public void setParentLayer(FLayers root);
173

    
174
        /**
175
         * Obtiene la extensi?n completa de la capa
176
         *
177
         * @return FullExtent.
178
         *
179
         * @throws DriverException
180
         */
181
        Rectangle2D getFullExtent() throws DriverException;
182

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

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

    
208
        /**
209
         * Inserta las coordenadas de transformaci?n.
210
         *
211
         * @param ct Coordenadas de transformaci?n.
212
         */
213
        void setCoordTrans(ICoordTrans ct);
214

    
215
        /**
216
         * Devuelve las coordenadas de transformaci?n.
217
         *
218
         * @return Coordenadas de transformaci?n.
219
         */
220
        ICoordTrans getCoordTrans();
221

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

    
240
        public boolean isWithinScale(double scale);
241

    
242

    
243
        /**
244
         * La capa no se visualiza si est? por debajo de esa escala
245
         * @return la escala minima de visualizaci?n
246
         */
247
        public double getMinScale();
248

    
249
        /**
250
         * La capa no se visualiza si est? por encima de esa escala
251
         * @return la escala m?xima de visualizaci?n
252
         */
253
        public double getMaxScale();
254

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

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

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

    
307
        public void setCacheImageDrawnLayers(BufferedImage cacheImageDrawnLayers);
308

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

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

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

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

    
428
        /**
429
         * @return
430
         */
431
        Image getTocStatusImage();
432
        
433

    
434
}